├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── build └── rollup.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html ├── src ├── App.vue ├── entry.js ├── main.js └── vue-bootstrap-select.vue └── vue.config.js /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ["plugin:vue/essential", "@vue/prettier"], 7 | rules: { 8 | "no-console": process.env.NODE_ENV === "production" ? "error" : "off", 9 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" 10 | }, 11 | parserOptions: { 12 | parser: "babel-eslint" 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | dist/ 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![AUR version](https://img.shields.io/npm/v/@alfsnd/vue-bootstrap-select.svg)](https://github.com/Sandalf/vue-bootstrap-select) 3 | [![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/react.svg)](https://github.com/Sandalf/vue-bootstrap-select) 4 | 5 | # @alfsnd/vue-bootstrap-select 6 | A vue version of [bootstrap select](https://github.com/snapappointments/bootstrap-select/) 7 | 8 | # Demo 9 | 10 | [![Edit Vue Bootstrap Select Demo](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/ovq821j566) 11 | 12 | # Install 13 | 14 | ```shell 15 | npm install @alfsnd/vue-bootstrap-select --save 16 | ``` 17 | 18 | # Usage 19 | 20 | ```js 21 | import VSelect from '@alfsnd/vue-bootstrap-select' 22 | 23 | export default { 24 | name: 'app', 25 | components: { 26 | VSelect 27 | }, 28 | data() { 29 | return { 30 | selectedValue: null 31 | }; 32 | } 33 | } 34 | ``` 35 | 36 | ```html 37 | 42 | ``` 43 | 44 | ### Passing options 45 | 46 | The `options` prop accepts arrays of strings 47 | 48 | ```html 49 | 50 | ``` 51 | And arrays of objects 52 | 53 | ```html 54 | 55 | ``` 56 | 57 | ## Props 58 | 59 | | parameter | description | type | default | acceptable value | 60 | | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- | ------------ | ---------------- | 61 | | disabled | disables select | Boolean | false | | 62 | | disabledProp | allows to disable specific options. If an option has this prop set to a truthy value it will disable the option. | String | disabled | | 63 | | labelNotFound | text displayed when no option is found in the search results | String | No results matched || 64 | | labelSearchPlaceholder | placeholder text for search input | String | Search | | 65 | | options | list of options | Array | [] | | 66 | | searchable | display search input | Boolean | false | | 67 | | showDefaultOption | sets the select title is set as an option | Boolean | false | | 68 | | textProp | the option's prop that is displayed as the option's text | String | text | | 69 | | valueProp | the option's prop that is used to find the selected value | String | value | 70 | 71 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/app"] 3 | }; 4 | -------------------------------------------------------------------------------- /build/rollup.config.js: -------------------------------------------------------------------------------- 1 | // rollup.config.js 2 | import vue from 'rollup-plugin-vue'; 3 | import buble from 'rollup-plugin-buble'; 4 | import uglify from 'rollup-plugin-uglify-es'; 5 | import minimist from 'minimist'; 6 | 7 | const argv = minimist(process.argv.slice(2)); 8 | 9 | const config = { 10 | input: 'src/entry.js', 11 | output: { 12 | name: 'VueBootstrapSelect', 13 | exports: 'named', 14 | }, 15 | plugins: [ 16 | vue({ 17 | css: true, 18 | compileTemplate: true, 19 | }), 20 | buble(), 21 | ], 22 | }; 23 | 24 | // Only minify browser (iife) version 25 | if (argv.format === 'iife') { 26 | config.plugins.push(uglify()); 27 | } 28 | 29 | export default config; 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@alfsnd/vue-bootstrap-select", 3 | "version": "0.4.4", 4 | "description": "A vue version of bootstrap select", 5 | "license": "MIT", 6 | "repository": "Sandalf/vue-bootstrap-select", 7 | "keywords": [ 8 | "npm", 9 | "package", 10 | "vue", 11 | "bootstrap", 12 | "select", 13 | "alfsnd" 14 | ], 15 | "main": "dist/vue-bootstrap-select.umd.js", 16 | "module": "dist/vue-bootstrap-select.esm.js", 17 | "unpkg": "dist/vue-bootstrap-select.min.js", 18 | "browser": { 19 | "./sfc": "src/vue-bootstrap-select.vue" 20 | }, 21 | "files": [ 22 | "dist/*", 23 | "src/*" 24 | ], 25 | "scripts": { 26 | "serve": "vue-cli-service serve", 27 | "build": "npm run build:unpkg & npm run build:es & npm run build:umd", 28 | "build:umd": "rollup --config build/rollup.config.js --format umd --file dist/vue-bootstrap-select.umd.js", 29 | "build:es": "rollup --config build/rollup.config.js --format es --file dist/vue-bootstrap-select.esm.js", 30 | "build:unpkg": "rollup --config build/rollup.config.js --format iife --file dist/vue-bootstrap-select.min.js", 31 | "ship": "npm publish --access public" 32 | }, 33 | "dependencies": { 34 | "vue-clickaway": "^2.2.2" 35 | }, 36 | "devDependencies": { 37 | "@vue/cli-plugin-babel": "^3.4.0", 38 | "@vue/cli-plugin-eslint": "^3.4.0", 39 | "@vue/cli-service": "^3.4.0", 40 | "@vue/eslint-config-prettier": "^4.0.1", 41 | "babel-eslint": "^10.0.1", 42 | "eslint": "^5.8.0", 43 | "eslint-plugin-vue": "^5.0.0", 44 | "minimist": "^1.2.0", 45 | "node-sass": "^4.9.0", 46 | "sass-loader": "^7.1.0", 47 | "rollup": "^0.66.2", 48 | "rollup-plugin-buble": "^0.19.2", 49 | "rollup-plugin-uglify-es": "0.0.1", 50 | "rollup-plugin-vue": "^4.3.0", 51 | "vue": "^2.5.22", 52 | "vue-template-compiler": "^2.5.22" 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sandalf/vue-bootstrap-select/1d7ab520b7b48625dd657da65230a570e7a3730c/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Vue Bootstrap Select 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 40 | 41 | 76 | 77 | 78 | 93 | -------------------------------------------------------------------------------- /src/entry.js: -------------------------------------------------------------------------------- 1 | // Import vue component 2 | import component from './vue-bootstrap-select.vue'; 3 | 4 | // install function executed by Vue.use() 5 | function install(Vue) { 6 | if (install.installed) return; 7 | install.installed = true; 8 | Vue.component('VueBootstrapSelect', component); 9 | } 10 | 11 | // Create module definition for Vue.use() 12 | const plugin = { 13 | install, 14 | }; 15 | 16 | // To auto-install when vue is found 17 | /* global window global */ 18 | let GlobalVue = null; 19 | if (typeof window !== 'undefined') { 20 | GlobalVue = window.Vue; 21 | } else if (typeof global !== 'undefined') { 22 | GlobalVue = global.Vue; 23 | } 24 | if (GlobalVue) { 25 | GlobalVue.use(plugin); 26 | } 27 | 28 | // To allow use as module (npm/webpack/etc.) export component 29 | export default component; 30 | 31 | // It's possible to expose named exports when writing components that can 32 | // also be used as directives, etc. - eg. import { RollupDemoDirective } from 'rollup-demo'; 33 | // export const RollupDemoDirective = component; 34 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | 4 | Vue.config.productionTip = false; 5 | 6 | new Vue({ 7 | render: h => h(App) 8 | }).$mount("#app"); 9 | -------------------------------------------------------------------------------- /src/vue-bootstrap-select.vue: -------------------------------------------------------------------------------- 1 | 44 | 45 | 244 | 245 | 394 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | chainWebpack: config => { 3 | config.module 4 | .rule("eslint") 5 | .use("eslint-loader") 6 | .options({ 7 | fix: true 8 | }); 9 | } 10 | }; 11 | --------------------------------------------------------------------------------