diff --git a/.babelrc b/.babelrc index 41789ca..2c5d2dc 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,5 @@ { - "presets": ["es2015", "stage-2"], - "plugins": ["transform-runtime"], + "presets": ["@babel/preset-env"], + "plugins": ["@babel/plugin-transform-runtime"], "comments": false } diff --git a/.codeclimate.yml b/.codeclimate.yml deleted file mode 100644 index 14313fc..0000000 --- a/.codeclimate.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -engines: - csslint: - enabled: true - duplication: - enabled: true - config: - languages: - - ruby - - javascript - - python - - php - eslint: - enabled: true - fixme: - enabled: true -ratings: - paths: - - "src/components/Select.vue" -exclude_paths: -- dist/ -- test/ -- docs/ -- config/ -- build/ diff --git a/.csslintrc b/.csslintrc deleted file mode 100644 index aacba95..0000000 --- a/.csslintrc +++ /dev/null @@ -1,2 +0,0 @@ ---exclude-exts=.min.css ---ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 96212a3..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -**/*{.,-}min.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 7f2ceaf..0000000 --- a/.eslintrc +++ /dev/null @@ -1,185 +0,0 @@ -{ - "plugins": [ - "html" - ], - - "env": { - "browser": true, - "node": true - }, - - "ecmaFeatures": { - "arrowFunctions": true, - "destructuring": true, - "classes": true, - "defaultParams": true, - "blockBindings": true, - "modules": true, - "objectLiteralComputedProperties": true, - "objectLiteralShorthandMethods": true, - "objectLiteralShorthandProperties": true, - "restParams": true, - "spread": true, - "forOf": true, - "generators": true, - "templateStrings": true, - "superInFunctions": true, - "experimentalObjectRestSpread": true - }, - - "rules": { - "accessor-pairs": 2, - "array-bracket-spacing": 0, - "block-scoped-var": 0, - "brace-style": [2, "1tbs", { "allowSingleLine": true }], - "camelcase": 0, - "comma-dangle": [2, "never"], - "comma-spacing": [2, { "before": false, "after": true }], - "comma-style": [2, "last"], - "complexity": 0, - "computed-property-spacing": 0, - "consistent-return": 0, - "consistent-this": 0, - "constructor-super": 2, - "curly": [2, "multi-line"], - "default-case": 0, - "dot-location": [2, "property"], - "dot-notation": 0, - "eol-last": 2, - "eqeqeq": [2, "allow-null"], - "func-names": 0, - "func-style": 0, - "generator-star-spacing": [2, { "before": true, "after": true }], - "guard-for-in": 0, - "handle-callback-err": [2, "^(err|error)$" ], - "indent": [2, 2, { "SwitchCase": 1 }], - "key-spacing": [2, { "beforeColon": false, "afterColon": true }], - "linebreak-style": 0, - "lines-around-comment": 0, - "max-nested-callbacks": 0, - "new-cap": [2, { "newIsCap": true, "capIsNew": false }], - "new-parens": 2, - "newline-after-var": 0, - "no-alert": 0, - "no-array-constructor": 2, - "no-caller": 2, - "no-catch-shadow": 0, - "no-cond-assign": 2, - "no-console": 0, - "no-constant-condition": 0, - "no-continue": 0, - "no-control-regex": 2, - "no-debugger": 2, - "no-delete-var": 2, - "no-div-regex": 0, - "no-dupe-args": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - "no-else-return": 0, - "no-empty": 0, - "no-empty-character-class": 2, - "no-empty-label": 2, - "no-eq-null": 0, - "no-eval": 2, - "no-ex-assign": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-extra-boolean-cast": 2, - "no-extra-parens": 0, - "no-extra-semi": 0, - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-func-assign": 2, - "no-implied-eval": 2, - "no-inline-comments": 0, - "no-inner-declarations": [2, "functions"], - "no-invalid-regexp": 2, - "no-irregular-whitespace": 2, - "no-iterator": 2, - "no-label-var": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-lonely-if": 0, - "no-loop-func": 0, - "no-mixed-requires": 0, - "no-mixed-spaces-and-tabs": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-multiple-empty-lines": [2, { "max": 1 }], - "no-native-reassign": 2, - "no-negated-in-lhs": 2, - "no-nested-ternary": 0, - "no-new": 2, - "no-new-func": 0, - "no-new-object": 2, - "no-new-require": 2, - "no-new-wrappers": 2, - "no-obj-calls": 2, - "no-octal": 2, - "no-octal-escape": 2, - "no-param-reassign": 0, - "no-path-concat": 0, - "no-process-env": 0, - "no-process-exit": 0, - "no-proto": 0, - "no-redeclare": 2, - "no-regex-spaces": 2, - "no-restricted-modules": 0, - "no-return-assign": 2, - "no-script-url": 0, - "no-self-compare": 2, - "no-sequences": 2, - "no-shadow": 0, - "no-shadow-restricted-names": 2, - "no-spaced-func": 2, - "no-sparse-arrays": 2, - "no-sync": 0, - "no-ternary": 0, - "no-this-before-super": 2, - "no-throw-literal": 2, - "no-trailing-spaces": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-undefined": 0, - "no-underscore-dangle": 0, - "no-unexpected-multiline": 2, - "no-unneeded-ternary": 2, - "no-unreachable": 2, - "no-unused-expressions": 0, - "no-unused-vars": [2, { "vars": "all", "args": "none" }], - "no-use-before-define": 0, - "no-var": 0, - "no-void": 0, - "no-warning-comments": 0, - "no-with": 2, - "object-curly-spacing": 0, - "object-shorthand": 0, - "one-var": [2, { "initialized": "never" }], - "operator-assignment": 0, - "operator-linebreak": [2, "after", { "overrides": { "?": "before", ":": "before" } }], - "padded-blocks": 0, - "prefer-const": 0, - "quote-props": 0, - "quotes": [2, "single", "avoid-escape"], - "radix": 2, - "semi": [2, "never"], - "semi-spacing": 0, - "sort-vars": 0, - "space-after-keywords": [2, "always"], - "space-before-blocks": [2, "always"], - "space-before-function-paren": [2, "always"], - "space-in-parens": [2, "never"], - "space-infix-ops": 2, - "space-return-throw-case": 2, - "space-unary-ops": [2, { "words": true, "nonwords": false }], - "spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!"] }], - "strict": 0, - "use-isnan": 2, - "valid-jsdoc": 0, - "valid-typeof": 2, - "vars-on-top": 0, - "wrap-iife": [2, "any"], - "wrap-regex": 0, - "yoda": [2, "never"] - } -} diff --git a/.gitignore b/.gitignore index f153968..17372d9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,28 @@ .DS_Store node_modules -npm-debug.log + +# local env files +.env.local +.env.*.local + +# Log files +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Editor directories and files .idea -test/unit/coverage -.coveralls.yml -.flowconfig -package-lock.json -docs/gitbook/_book -docs/node_modules -site +.vscode +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw* + +# Project specific +coverage dist +test/unit/coverage +package-lock.json +dev/dist +docs/.vuepress/dist diff --git a/.travis.yml b/.travis.yml index 7621ea0..cb9fc23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: node_js +cache: npm + node_js: - node -after_success: - - codeclimate-test-reporter < ./test/unit/coverage/lcov.info + +script: + - yarn test --coverage --coverageReporters=text-lcov | coveralls diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a8e6d01..e705d1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,9 @@ ## Pull Requests -Looks like you want to help out on vue-select.. awesome! Here's a couple things to keep in mind when contributing. +Looks like you want to help out on vue-select.. awesome! Here's a few things to keep in mind when contributing. 1. If your PR contains multiple commits, try to keep those commits succinct, with descriptive messages. This makes it easier to understand your thought process. -2. Don't run the build before submitting. The build is only run and committed immediately before a new release, and submitting a PR with a build included is just more to parse. +2. **Don't run the build** before submitting. The build is only run and committed immediately before a new release. 3. If your PR fixes or references an open issue, be sure to reference it in your message. 4. If you're adding new functionality, make sure your code has good test coverage. diff --git a/README.md b/README.md index 6f06a9a..5074c93 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# vue-select [![Build Status](https://travis-ci.org/sagalbot/vue-select.svg?branch=master)](https://travis-ci.org/sagalbot/vue-select) ![MIT License](https://img.shields.io/github/license/sagalbot/vue-select.svg?style=flat-square) ![Current Release](https://img.shields.io/github/release/sagalbot/vue-select.svg?style=flat-square) +# vue-select [![Build Status](https://travis-ci.org/sagalbot/vue-select.svg?branch=master)](https://travis-ci.org/sagalbot/vue-select) [![Coverage Status](https://coveralls.io/repos/github/sagalbot/vue-select/badge.svg)](https://coveralls.io/github/sagalbot/vue-select) ![MIT License](https://img.shields.io/github/license/sagalbot/vue-select.svg?style=flat-square) ![Current Release](https://img.shields.io/github/release/sagalbot/vue-select.svg?style=flat-square) -> A native Vue.js select component that provides similar functionality to Select2 without the overhead of jQuery. +> Everything you wish the native ` element could do, wrapped up into a zero dependency, highly extensible Vue component.', + url: 'http://sagalbot.github.io/vue-select/', + icon: '/vue-logo.png', +}; + +let head = [ + [ + 'link', + { + href: '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,600|Roboto Mono', + rel: 'stylesheet', + type: 'text/css', + }], + [ + 'link', + { + href: '//fonts.googleapis.com/css?family=Dosis:300&text=Vue Select', + rel: 'stylesheet', + type: 'text/css', + }], + ['link', { rel: 'icon', href: `/vue-logo.png` }], + ['meta', { name: 'theme-color', content: '#3eaf7c' }], + ['meta', { name: 'apple-mobile-web-app-capable', content: 'yes' }], + ['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'black' }], + ['link', { rel: 'apple-touch-icon', href: `/icons/apple-touch-icon-152x152.png` }], + ['link', { rel: 'mask-icon', href: '/icons/safari-pinned-tab.svg', color: '#3eaf7c' }], + ['meta', { name: 'msapplication-TileImage', content: '/icons/msapplication-icon-144x144.png' }], + ['meta', { name: 'msapplication-TileColor', content: '#000000' }] +]; + +if (isDeployPreview) { + head.push( + ['meta', {name: 'robots', content: 'noindex'}], + ['meta', {name: 'googlebot', content: 'noindex'}], + ); +} else { + head.push( + ['meta', {name: 'title', content: meta.title}], + ['meta', {name: 'description', content: meta.description}], + ['link', {rel: 'icon', href: meta.icon, type: 'image/png'}], + ['meta', {property: 'og:image', content: meta.icon}], + ['meta', {property: 'twitter:image', content: meta.icon}], + ['meta', {name: 'description', content: meta.description}], + ['meta', {property: 'og:description', content: ''}], + ['meta', {property: 'twitter:description', content: meta.description}], + ['meta', {property: 'twitter:title', content: meta.title}], + ['meta', {property: 'og:title', content: meta.title}], + ['meta', {property: 'og:site_name', content: meta.title}], + ['meta', {property: 'og:url', content: meta.url}], + ); +} + +module.exports = { + title: 'Vue Select', + description: meta.description, + head, + serviceWorker: !isDeployPreview, + ga: isDeployPreview ? '' : 'UA-12818324-8', + themeConfig: { + repo: 'sagalbot/vue-select', + editLinks: true, + docsDir: 'docs', + nav: [ + {text: 'Home', link: '/'}, + {text: 'Sandbox', link: '/sandbox'}, + ], + sidebar: { + '/': [ + { + title: 'Getting Started', + collapsable: false, + children: [ + ['guide/install', 'Installation'], + ['guide/options', 'Dropdown Options'], + ['guide/values', 'Selecting Values'], + ['guide/localization', 'Localization'], + ], + }, + { + title: 'Digging Deeper', + collapsable: false, + children: [ + ['guide/templating', 'Templating'], + ['guide/vuex', 'Vuex'], + ['guide/ajax', 'AJAX'], + ], + }, + { + title: 'API', + collapsable: false, + children: [ + ['api/props', 'Props'], + ['api/slots', 'Slots'], + ['api/events', 'Events'], + ], + }, + ], + }, + }, +}; diff --git a/dev/data/books.js b/docs/.vuepress/data/books.js similarity index 99% rename from dev/data/books.js rename to docs/.vuepress/data/books.js index bd4606c..bc00994 100644 --- a/dev/data/books.js +++ b/docs/.vuepress/data/books.js @@ -1,3 +1,4 @@ +/* eslint-disable */ export default [ { title: "Old Man's War", @@ -160,4 +161,4 @@ export default [ lastName: "Maine" } } -] \ No newline at end of file +] diff --git a/docs/.vuepress/data/countries.js b/docs/.vuepress/data/countries.js new file mode 100644 index 0000000..cec5f3e --- /dev/null +++ b/docs/.vuepress/data/countries.js @@ -0,0 +1,246 @@ +/* eslint-disable */ +export default [ + 'Afghanistan', + 'Åland Islands', + 'Albania', + 'Algeria', + 'American Samoa', + 'Andorra', + 'Angola', + 'Anguilla', + 'Antarctica', + 'Antigua and Barbuda', + 'Argentina', + 'Armenia', + 'Aruba', + 'Australia', + 'Austria', + 'Azerbaijan', + 'Bahamas', + 'Bahrain', + 'Bangladesh', + 'Barbados', + 'Belarus', + 'Belgium', + 'Belize', + 'Benin', + 'Bermuda', + 'Bhutan', + 'Bolivia', + 'Bosnia and Herzegovina', + 'Botswana', + 'Bouvet Island', + 'Brazil', + 'British Indian Ocean Territory', + 'Brunei Darussalam', + 'Bulgaria', + 'Burkina Faso', + 'Burundi', + 'Cambodia', + 'Cameroon', + 'Canada', + 'Cape Verde', + 'Cayman Islands', + 'Central African Republic', + 'Chad', + 'Chile', + 'China', + 'Christmas Island', + 'Cocos (Keeling) Islands', + 'Colombia', + 'Comoros', + 'Congo', + 'Congo, The Democratic Republic of The', + 'Cook Islands', + 'Costa Rica', + 'Cote D\'ivoire', + 'Croatia', + 'Cuba', + 'Cyprus', + 'Czech Republic', + 'Denmark', + 'Djibouti', + 'Dominica', + 'Dominican Republic', + 'Ecuador', + 'Egypt', + 'El Salvador', + 'Equatorial Guinea', + 'Eritrea', + 'Estonia', + 'Ethiopia', + 'Falkland Islands (Malvinas)', + 'Faroe Islands', + 'Fiji', + 'Finland', + 'France', + 'French Guiana', + 'French Polynesia', + 'French Southern Territories', + 'Gabon', + 'Gambia', + 'Georgia', + 'Germany', + 'Ghana', + 'Gibraltar', + 'Greece', + 'Greenland', + 'Grenada', + 'Guadeloupe', + 'Guam', + 'Guatemala', + 'Guernsey', + 'Guinea', + 'Guinea-bissau', + 'Guyana', + 'Haiti', + 'Heard Island and Mcdonald Islands', + 'Holy See (Vatican City State)', + 'Honduras', + 'Hong Kong', + 'Hungary', + 'Iceland', + 'India', + 'Indonesia', + 'Iran, Islamic Republic of', + 'Iraq', + 'Ireland', + 'Isle of Man', + 'Israel', + 'Italy', + 'Jamaica', + 'Japan', + 'Jersey', + 'Jordan', + 'Kazakhstan', + 'Kenya', + 'Kiribati', + 'Korea, Democratic People\'s Republic of', + 'Korea, Republic of', + 'Kuwait', + 'Kyrgyzstan', + 'Lao People\'s Democratic Republic', + 'Latvia', + 'Lebanon', + 'Lesotho', + 'Liberia', + 'Libyan Arab Jamahiriya', + 'Liechtenstein', + 'Lithuania', + 'Luxembourg', + 'Macao', + 'Macedonia, The Former Yugoslav Republic of', + 'Madagascar', + 'Malawi', + 'Malaysia', + 'Maldives', + 'Mali', + 'Malta', + 'Marshall Islands', + 'Martinique', + 'Mauritania', + 'Mauritius', + 'Mayotte', + 'Mexico', + 'Micronesia, Federated States of', + 'Moldova, Republic of', + 'Monaco', + 'Mongolia', + 'Montenegro', + 'Montserrat', + 'Morocco', + 'Mozambique', + 'Myanmar', + 'Namibia', + 'Nauru', + 'Nepal', + 'Netherlands', + 'Netherlands Antilles', + 'New Caledonia', + 'New Zealand', + 'Nicaragua', + 'Niger', + 'Nigeria', + 'Niue', + 'Norfolk Island', + 'Northern Mariana Islands', + 'Norway', + 'Oman', + 'Pakistan', + 'Palau', + 'Palestinian Territory, Occupied', + 'Panama', + 'Papua New Guinea', + 'Paraguay', + 'Peru', + 'Philippines', + 'Pitcairn', + 'Poland', + 'Portugal', + 'Puerto Rico', + 'Qatar', + 'Reunion', + 'Romania', + 'Russian Federation', + 'Rwanda', + 'Saint Helena', + 'Saint Kitts and Nevis', + 'Saint Lucia', + 'Saint Pierre and Miquelon', + 'Saint Vincent and The Grenadines', + 'Samoa', + 'San Marino', + 'Sao Tome and Principe', + 'Saudi Arabia', + 'Senegal', + 'Serbia', + 'Seychelles', + 'Sierra Leone', + 'Singapore', + 'Slovakia', + 'Slovenia', + 'Solomon Islands', + 'Somalia', + 'South Africa', + 'South Georgia and The South Sandwich Islands', + 'Spain', + 'Sri Lanka', + 'Sudan', + 'Suriname', + 'Svalbard and Jan Mayen', + 'Swaziland', + 'Sweden', + 'Switzerland', + 'Syrian Arab Republic', + 'Taiwan, Province of China', + 'Tajikistan', + 'Tanzania, United Republic of', + 'Thailand', + 'Timor-leste', + 'Togo', + 'Tokelau', + 'Tonga', + 'Trinidad and Tobago', + 'Tunisia', + 'Turkey', + 'Turkmenistan', + 'Turks and Caicos Islands', + 'Tuvalu', + 'Uganda', + 'Ukraine', + 'United Arab Emirates', + 'United Kingdom', + 'United States', + 'United States Minor Outlying Islands', + 'Uruguay', + 'Uzbekistan', + 'Vanuatu', + 'Venezuela', + 'Viet Nam', + 'Virgin Islands, British', + 'Virgin Islands, U.S.', + 'Wallis and Futuna', + 'Western Sahara', + 'Yemen', + 'Zambia', + 'Zimbabwe']; diff --git a/dev/data/countryCodes.js b/docs/.vuepress/data/countryCodes.js similarity index 99% rename from dev/data/countryCodes.js rename to docs/.vuepress/data/countryCodes.js index 96dbcb8..3d835d0 100644 --- a/dev/data/countryCodes.js +++ b/docs/.vuepress/data/countryCodes.js @@ -1,3 +1,4 @@ +/* eslint-disable */ export default [ {value: "AF", label: "Afghanistan"}, {value: "AX", label: "Åland Islands"}, diff --git a/docs/.vuepress/enhanceApp.js b/docs/.vuepress/enhanceApp.js new file mode 100644 index 0000000..878431f --- /dev/null +++ b/docs/.vuepress/enhanceApp.js @@ -0,0 +1,5 @@ +import vSelect from '../../src/components/Select'; + +export default ({Vue, options, router, siteData}) => { + Vue.component('v-select', vSelect); +} diff --git a/docs/.vuepress/utils/codePen.js b/docs/.vuepress/utils/codePen.js new file mode 100644 index 0000000..b8d7a28 --- /dev/null +++ b/docs/.vuepress/utils/codePen.js @@ -0,0 +1,111 @@ +export default () => { + + document.getElementsByClassName || (document.getElementsByClassName = function (e) { + var n, t, r, a = document, o = []; + if (a.querySelectorAll) return a.querySelectorAll('.' + e); + if (a.evaluate) for (t = './/*[contains(concat(\' \', @class, \' \'), \' ' + e + ' \')]', n = a.evaluate(t, a, + null, 0, + null); r = n.iterateNext();) o.push(r); else for (n = a.getElementsByTagName('*'), t = new RegExp( + '(^|\\s)' + e + '(\\s|$)'), r = 0; r < n.length; r++) t.test(n[r].className) && o.push(n[r]); + return o; + }), function () { + function e () { + function e () { + for (var e = document.getElementsByClassName('codepen'), t = e.length - 1; t > -1; t--) { + var u = a(e[t]); + if (0 !== Object.keys(u).length && (u = o(u), u.user = n(u, e[t]), r(u))) { + var c = i(u), l = s(u, c); + f(e[t], l); + } + } + m(); + } + + function n (e, n) { + if ('string' == typeof e.user) return e.user; + for (var t = 0, r = n.children.length; t < r; t++) { + var a = n.children[t], o = a.href || '', i = o.match(/codepen\.(io|dev)\/(\w+)\/pen\//i); + if (i) return i[2]; + } + return 'anon'; + } + + function r (e) {return e['slug-hash'];} + + function a (e) { + for (var n = {}, t = e.attributes, r = 0, a = t.length; r < a; r++) { + var o = t[r].name; + 0 === o.indexOf('data-') && (n[o.replace('data-', '')] = t[r].value); + } + return n; + } + + function o (e) { + return e.href && (e['slug-hash'] = e.href), e.type && (e['default-tab'] = e.type), e.safe && + ('true' === e.safe ? e.animations = 'run' : e.animations = 'stop-after-5'), e; + } + + function i (e) { + var n = u(e), t = e.user ? e.user : 'anon', r = '?' + l(e), + a = e.preview && 'true' === e.preview ? 'embed/preview' : 'embed', + o = [n, t, a, e['slug-hash'] + r].join('/'); + return o.replace(/\/\//g, '//'); + } + + function u (e) { + return e.host ? c(e.host) : 'file:' === document.location.protocol + ? 'https://codepen.io' + : '//codepen.io'; + } + + function c (e) {return e.match(/^\/\//) || !e.match(/https?:/) ? document.location.protocol + '//' + e : e;} + + function l (e) { + var n = ''; + for (var t in e) '' !== n && (n += '&'), n += t + '=' + encodeURIComponent(e[t]); + return n; + } + + function s (e, n) { + var r; + e['pen-title'] ? r = e['pen-title'] : (r = 'CodePen Embed ' + t, t++); + var a = { + id: 'cp_embed_' + e['slug-hash'].replace('/', '_'), + src: n, + scrolling: 'no', + frameborder: '0', + height: d(e), + allowTransparency: 'true', + allowfullscreen: 'true', + allowpaymentrequest: 'true', + name: 'CodePen Embed', + title: r, + 'class': 'cp_embed_iframe ' + (e['class'] ? e['class'] : ''), + style: 'width: ' + p + '; overflow: hidden;', + }, o = '