├── .prettierignore
├── .gitattributes
├── .storybook
├── addons.js
├── public
│ ├── frodo.jpg
│ ├── aragorn.jpg
│ ├── gandalf.png
│ └── samwise.jpg
├── config.js
└── preview-head.html
├── .npmrc
├── docs
├── logo.png
├── storybook
│ ├── favicon.ico
│ ├── index.html
│ └── iframe.html
├── index.js
├── webpack.config.js
├── index.html
└── App.vue
├── .github
├── FUNDING.yml
├── workflows
│ └── test.yml
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── __tests__
├── test-compat-all.sh
├── test-compat.sh
├── autosuggest.test.js
└── __snapshots__
│ └── autosuggest.test.js.snap
├── .prettierrc.js
├── .eslintrc.js
├── other
├── USERS.md
├── manual-releases.md
├── CODE_OF_CONDUCT.md
└── MAINTAINING.md
├── src
├── utils.js
├── vue-autosuggest.js
├── parts
│ └── DefaultSection.js
├── stories
│ └── index.js
└── Autosuggest.vue
├── .babelrc
├── codecov.yml
├── LICENSE
├── CONTRIBUTING.md
├── .all-contributorsrc
├── CHANGELOG.md
├── package.json
└── README.md
/.prettierignore:
--------------------------------------------------------------------------------
1 | *.vue
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.js text eol=lf
3 |
--------------------------------------------------------------------------------
/.storybook/addons.js:
--------------------------------------------------------------------------------
1 | import "@storybook/addon-actions/register";
2 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | registry=http://registry.npmjs.org/
2 | package-lock=false
3 |
--------------------------------------------------------------------------------
/docs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darrenjennings/vue-autosuggest/HEAD/docs/logo.png
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [darrenjennings]
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | dist
4 | .opt-in
5 | .opt-out
6 | .DS_Store
7 | .eslintcache
8 | .idea
9 |
--------------------------------------------------------------------------------
/docs/storybook/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darrenjennings/vue-autosuggest/HEAD/docs/storybook/favicon.ico
--------------------------------------------------------------------------------
/.storybook/public/frodo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darrenjennings/vue-autosuggest/HEAD/.storybook/public/frodo.jpg
--------------------------------------------------------------------------------
/.storybook/public/aragorn.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darrenjennings/vue-autosuggest/HEAD/.storybook/public/aragorn.jpg
--------------------------------------------------------------------------------
/.storybook/public/gandalf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darrenjennings/vue-autosuggest/HEAD/.storybook/public/gandalf.png
--------------------------------------------------------------------------------
/.storybook/public/samwise.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/darrenjennings/vue-autosuggest/HEAD/.storybook/public/samwise.jpg
--------------------------------------------------------------------------------
/__tests__/test-compat-all.sh:
--------------------------------------------------------------------------------
1 | set -e
2 |
3 | __tests__/test-compat.sh "~2.5.0"
4 | __tests__/test-compat.sh "~2.6.0"
5 |
6 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | // .prettierrc.js
2 | module.exports = {
3 | printWidth: 100,
4 | singleQuote: false,
5 | semi: true
6 | };
7 |
--------------------------------------------------------------------------------
/__tests__/test-compat.sh:
--------------------------------------------------------------------------------
1 | set -e
2 |
3 | echo "running unit tests with Vue $1"
4 | yarn add -W -D vue@$1 vue-template-compiler@$1 vue-server-renderer@$1
5 | yarn test
6 |
--------------------------------------------------------------------------------
/docs/index.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import App from './App.vue';
3 |
4 | // Vue.config.performance = true
5 |
6 | new Vue({
7 | el: "#app",
8 | components: {
9 | App
10 | },
11 | template: ""
12 | });
13 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | browser: true
4 | },
5 | extends: ["plugin:vue/recommended"],
6 | plugins: ["vue"],
7 | rules: {
8 | "vue/valid-v-if": "error",
9 | "no-console": ["warn", { allow: ["warn", "error"] }]
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/.storybook/config.js:
--------------------------------------------------------------------------------
1 | import { configure } from '@storybook/vue';
2 |
3 | import Vue from 'vue';
4 | import VueAutosuggest from "../src/Autosuggest.vue";
5 |
6 | function loadStories() {
7 | // You can require as many stories as you need.
8 | require('../src/stories');
9 | }
10 |
11 | configure(loadStories, module);
12 |
--------------------------------------------------------------------------------
/other/USERS.md:
--------------------------------------------------------------------------------
1 | # Users
2 |
3 | If you or your company uses this project, add your name to this list! Eventually
4 | we may have a website to showcase these (wanna build it!?)
5 |
6 | > [Educents](https://www.educents.com) uses it on [Educents.com](https://www.educents.com)
7 |
8 |
13 |
--------------------------------------------------------------------------------
/src/utils.js:
--------------------------------------------------------------------------------
1 | /** DOM Utilities */
2 | function hasClass(el, className) {
3 | return !!el.className.match(new RegExp("(\\s|^)" + className + "(\\s|$)"));
4 | }
5 |
6 | function addClass(el, className) {
7 | if (!hasClass(el, className)) el.className += " " + className;
8 | }
9 |
10 | function removeClass(el, className) {
11 | if (el.classList) {
12 | el.classList.remove(className);
13 | }
14 | }
15 |
16 | export { addClass, removeClass };
17 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "env",
5 | {
6 | "targets": {
7 | "browsers": ["last 2 versions", "safari >= 7"],
8 | "uglify": true
9 | },
10 | "modules": "umd"
11 | }
12 | ]
13 | ],
14 | "plugins": [
15 | "transform-object-rest-spread",
16 | "transform-vue-jsx",
17 | [
18 | "transform-runtime",
19 | {
20 | "polyfill": true,
21 | "regenerator": true
22 | }
23 | ]
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/src/vue-autosuggest.js:
--------------------------------------------------------------------------------
1 | import VueAutosuggest from "./Autosuggest.vue";
2 | import DefaultSection from "./parts/DefaultSection.js";
3 |
4 | const VueAutosuggestPlugin = {
5 | install(Vue) {
6 | Vue.component("vue-autosuggest-default-section", DefaultSection);
7 | Vue.component("vue-autosuggest", VueAutosuggest);
8 | }
9 | };
10 |
11 | export default VueAutosuggestPlugin;
12 | export { VueAutosuggest, DefaultSection };
13 |
14 | if (typeof window !== "undefined" && window.Vue) {
15 | window.Vue.use(VueAutosuggestPlugin);
16 | }
17 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: "Test"
2 |
3 | on: push
4 |
5 | jobs:
6 | lint:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v2
10 | - name: Set up Node 14
11 | uses: actions/setup-node@v2
12 | with:
13 | node-version: 14
14 | cache: "yarn"
15 | - name: Install dependencies
16 | run: yarn install
17 | - name: Run Tests
18 | run: yarn test-compat
19 | - name: Run Coverage
20 | run: yarn test:coverage
21 | - name: Run Build
22 | run: yarn build:umd
23 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | require_ci_to_pass: yes
3 |
4 | coverage:
5 | precision: 2
6 | round: down
7 | range: "70...100"
8 | status:
9 | project:
10 | default:
11 | threshold: 0.2
12 | if_not_found: success
13 | patch:
14 | default:
15 | enabled: no
16 | if_not_found: success
17 | changes:
18 | default:
19 | enabled: no
20 | if_not_found: success
21 |
22 | parsers:
23 | gcov:
24 | branch_detection:
25 | conditional: yes
26 | loop: yes
27 | method: no
28 | macro: no
29 |
30 | comment: false
31 |
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2017 Educents
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in all
12 | copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | SOFTWARE.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
13 |
14 | - `vue-autosuggest` version:
15 | - `node` version:
16 | - `npm` (or `yarn`) version:
17 |
18 | Relevant code or config
19 |
20 | ```javascript
21 |
22 | ```
23 |
24 | What you did:
25 |
26 |
27 |
28 | What happened:
29 |
30 |
31 |
32 | Reproduction sandbox/repository:
33 |
34 |
41 |
42 | Problem description:
43 |
44 |
45 |
46 | Suggested solution:
47 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | **What**:
19 |
20 |
21 | **Why**:
22 |
23 |
24 | **How**:
25 |
26 |
27 | **Checklist**:
28 |
29 |
30 | - [ ] Documentation
31 | - [ ] Tests
32 | - [ ] Ready to be merged
33 | - [ ] Added myself to contributors table
34 |
35 |
36 |
--------------------------------------------------------------------------------
/other/manual-releases.md:
--------------------------------------------------------------------------------
1 | # manual-releases
2 |
3 | This project has an automated release set up. So things are only released when there are
4 | useful changes in the code that justify a release. But sometimes things get messed up one way or another
5 | and we need to trigger the release ourselves. When this happens, simply bump the number below and commit
6 | that with the following commit message based on your needs:
7 |
8 | **Major**
9 |
10 | ```
11 | fix(release): manually release a major version
12 |
13 | There was an issue with a major release, so this manual-releases.md
14 | change is to release a new major version.
15 |
16 | Reference: #
17 |
18 | BREAKING CHANGE:
19 | ```
20 |
21 | **Minor**
22 |
23 | ```
24 | feat(release): manually release a minor version
25 |
26 | There was an issue with a minor release, so this manual-releases.md
27 | change is to release a new minor version.
28 |
29 | Reference: #
30 | ```
31 |
32 | **Patch**
33 |
34 | ```
35 | fix(release): manually release a patch version
36 |
37 | There was an issue with a patch release, so this manual-releases.md
38 | change is to release a new patch version.
39 |
40 | Reference: #
41 | ```
42 |
43 | The number of times we've had to do a manual release is: 0
44 |
--------------------------------------------------------------------------------
/docs/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const eslintFriendlyFormatter = require("eslint-friendly-formatter");
3 |
4 | module.exports = {
5 | context: __dirname,
6 | mode: process.env.NODE_ENV || 'development',
7 | module: {
8 | rules: [
9 | {
10 | test: /\.js$/,
11 | exclude: /node_modules/,
12 | test: /\.(js|vue)$/,
13 | loader: "eslint-loader",
14 | enforce: "pre",
15 | options: {
16 | formatter: eslintFriendlyFormatter
17 | }
18 | },
19 | {
20 | test: /\.js/,
21 | loader: "babel-loader",
22 | exclude: /node_modules/,
23 | options: {
24 | babelrc: true
25 | }
26 | },
27 | {
28 | test: /\.vue$/,
29 | loaders: ["vue-loader"],
30 | exclude: /node_modules/
31 | }
32 | ]
33 | },
34 |
35 | resolve: {
36 | extensions: [".js", ".vue"],
37 | alias: {
38 | vue: "vue/dist/vue.js"
39 | }
40 | },
41 |
42 | entry: "./index.js",
43 |
44 | output: {
45 | path: path.resolve(__dirname, "build"),
46 | filename: "app.js",
47 | publicPath: "/build/"
48 | },
49 |
50 | devServer: {
51 | contentBase: __dirname,
52 | port: 2000
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/docs/storybook/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Storybook
10 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | vue-autosuggest
9 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Thanks for being willing to contribute!
4 |
5 | **Working on your first Pull Request?** You can learn how from this *free* series
6 | [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
7 |
8 | ## Project setup
9 |
10 | 1. Fork and clone the repo
11 | 2. Run `npm run setup -s` to install dependencies and run validation
12 | 3. Create a branch for your PR with `git checkout -b pr/your-branch-name`
13 |
14 | > Tip: Keep your `master` branch pointing at the original repository and make
15 | > pull requests from branches on your fork. To do this, run:
16 | >
17 | > ```
18 | > git remote add upstream https://github.com/educents/vue-autosuggest.git
19 | > git fetch upstream
20 | > git branch --set-upstream-to=upstream/master master
21 | > ```
22 | >
23 | > This will add the original repository as a "remote" called "upstream,"
24 | > Then fetch the git information from that remote, then set your local `master`
25 | > branch to use the upstream master branch whenever you run `git pull`.
26 | > Then you can make all of your pull request branches based on this `master`
27 | > branch. Whenever you want to update your version of `master`, do a regular
28 | > `git pull`.
29 |
30 | ## Add yourself as a contributor
31 |
32 | This project follows the [all contributors][all-contributors] specification.
33 | To add yourself to the table of contributors on the `README.md`, please use the
34 | automated script as part of your PR:
35 |
36 | ```console
37 | yarn add-contributor
38 | ```
39 |
40 | Follow the prompt and commit `.all-contributorsrc` and `README.md` in the PR.
41 | If you've already added yourself to the list and are making
42 | a new type of contribution, you can run it again and select the added
43 | contribution type.
44 |
45 | ## Committing and Pushing changes
46 |
47 | Please make sure to run the tests before you commit your changes. You can run
48 | `npm run test:update` which will update any snapshots that need updating.
49 | Make sure to include those changes (if they exist) in your commit.
50 |
51 | ## Help needed
52 |
53 | Please checkout [the open issues][issues]
54 |
55 | Also, please watch the repo and respond to questions/bug reports/feature
56 | requests! Thanks!
57 |
58 | [issues]: https://github.com/educents/vue-autosuggest/issues
59 | [all-contributors]: https://github.com/kentcdodds/all-contributors
60 |
--------------------------------------------------------------------------------
/.all-contributorsrc:
--------------------------------------------------------------------------------
1 | {
2 | "projectName": "vue-autosuggest",
3 | "projectOwner": "darrenjennings",
4 | "files": [
5 | "README.md"
6 | ],
7 | "imageSize": 100,
8 | "commit": false,
9 | "contributors": [
10 | {
11 | "login": "darrenjennings",
12 | "name": "Darren Jennings",
13 | "avatar_url": "https://avatars.githubusercontent.com/u/5770711?v=4",
14 | "profile": "https://darrenjennings.github.io",
15 | "contributions": [
16 | "code",
17 | "doc",
18 | "infra",
19 | "test",
20 | "design",
21 | "example"
22 | ]
23 | },
24 | {
25 | "login": "ekulish",
26 | "name": "Evgeniy Kulish",
27 | "avatar_url": "https://avatars2.githubusercontent.com/u/411772?v=4",
28 | "profile": "https://github.com/ekulish",
29 | "contributions": [
30 | "code",
31 | "design",
32 | "example",
33 | "test"
34 | ]
35 | },
36 | {
37 | "login": "scottadamsmith",
38 | "name": "Scott Smith",
39 | "avatar_url": "https://avatars3.githubusercontent.com/u/1824850?v=4",
40 | "profile": "https://github.com/scottadamsmith",
41 | "contributions": [
42 | "bug",
43 | "code",
44 | "test"
45 | ]
46 | },
47 | {
48 | "login": "chuca",
49 | "name": "Fernando Machuca",
50 | "avatar_url": "https://avatars0.githubusercontent.com/u/864496?v=4",
51 | "profile": "https://github.com/chuca",
52 | "contributions": [
53 | "design"
54 | ]
55 | },
56 | {
57 | "login": "BerniML",
58 | "name": "BerniML",
59 | "avatar_url": "https://avatars1.githubusercontent.com/u/12657810?v=4",
60 | "profile": "https://github.com/BerniML",
61 | "contributions": [
62 | "code",
63 | "test"
64 | ]
65 | },
66 | {
67 | "login": "42tte",
68 | "name": "Kristoffer Nordström",
69 | "avatar_url": "https://avatars0.githubusercontent.com/u/8436510?v=4",
70 | "profile": "https://github.com/42tte",
71 | "contributions": [
72 | "code",
73 | "test"
74 | ]
75 | },
76 | {
77 | "login": "djw",
78 | "name": "Dan Wilson",
79 | "avatar_url": "https://avatars.githubusercontent.com/u/8142?v=4",
80 | "profile": "https://www.danjwilson.co.uk",
81 | "contributions": [
82 | "code"
83 | ]
84 | }
85 | ]
86 | }
87 |
--------------------------------------------------------------------------------
/.storybook/preview-head.html:
--------------------------------------------------------------------------------
1 |
90 |
--------------------------------------------------------------------------------
/other/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at devs@educents.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/other/MAINTAINING.md:
--------------------------------------------------------------------------------
1 | # Maintaining
2 |
3 | This is documentation for maintainers of this project.
4 |
5 | ## Code of Conduct
6 |
7 | Please review, understand, and be an example of it. Violations of the code of conduct are
8 | taken seriously, even (especially) for maintainers.
9 |
10 | ## Issues
11 |
12 | We want to support and build the community. We do that best by helping people learn to solve
13 | their own problems. We have an issue template and hopefully most folks follow it. If it's
14 | not clear what the issue is, invite them to create a minimal reproduction of what they're trying
15 | to accomplish or the bug they think they've found.
16 |
17 | Once it's determined that a code change is necessary, point people to
18 | [makeapullrequest.com](http://makeapullrequest.com) and invite them to make a pull request.
19 | If they're the one who needs the feature, they're the one who can build it. If they need
20 | some hand holding and you have time to lend a hand, please do so. It's an investment into
21 | another human being, and an investment into a potential maintainer.
22 |
23 | Remember that this is open source, so the code is not yours, it's ours. If someone needs a change
24 | in the codebase, you don't have to make it happen yourself. Commit as much time to the project
25 | as you want/need to. Nobody can ask any more of you than that.
26 |
27 | ## Pull Requests
28 |
29 | As a maintainer, you're fine to make your branches on the main repo or on your own fork. Either
30 | way is fine.
31 |
32 | When we receive a pull request, an Actions build is kicked off automatically (see `.github/workflows/test.yml`
33 | for what runs in the Actions build). We avoid merging anything that breaks the Actions build.
34 |
35 | Please review PRs and focus on the code rather than the individual. You never know when this is
36 | someone's first ever PR and we want their experience to be as positive as possible, so be
37 | uplifting and constructive.
38 |
39 | When you merge the pull request, 99% of the time you should use the
40 | [Squash and merge](https://help.github.com/articles/merging-a-pull-request/) feature. This keeps
41 | our git history clean, but more importantly, this allows us to make any necessary changes to the
42 | commit message so we release what we want to release. See the next section on Releases for more
43 | about that.
44 |
45 | ## Release
46 |
47 | Our releases are automatic. They happen whenever code lands into `master`. A travis build gets
48 | kicked off and if it's successful, a tool called
49 | [`semantic-release`](https://github.com/semantic-release/semantic-release) is used to
50 | automatically publish a new release to npm as well as a changelog to GitHub. It is only able to
51 | determine the version and whether a release is necessary by the git commit messages. With this
52 | in mind, **please brush up on [the commit message convention][commit] which drives our releases.**
53 |
54 | > One important note about this: Please make sure that commit messages do NOT contain the words
55 | > "BREAKING CHANGE" in them unless we want to push a major version. I've been burned by this
56 | > more than once where someone will include "BREAKING CHANGE: None" and it will end up releasing
57 | > a new major version. Not a huge deal honestly, but kind of annoying...
58 |
59 | ## Thanks!
60 |
61 | Thank you so much for helping to maintain this project!
62 |
63 | [commit]: https://github.com/conventional-changelog-archived-repos/conventional-changelog-angular/blob/ed32559941719a130bb0327f886d6a32a8cbc2ba/convention.md
64 |
--------------------------------------------------------------------------------
/docs/storybook/iframe.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
14 | Storybook
15 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # CHANGELOG
2 |
3 | Abridged versions of releases. See [release notes](https://github.com/Educents/vue-autosuggest/releases) for more details.
4 |
5 | * [2.0.4](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v2.0.4) Bugfix
6 | * Fixes #124
7 | * [2.0.3](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v2.0.3) Bugfix
8 | * Fixes #142
9 | * [2.0.2](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v2.0.2) Bugfixes
10 | * Fixes #136, Fixes #135, Fixes #129
11 | * [2.0.1](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v2.0.1) Bugfix
12 | * Fixes #129 where in some cases, re-renders would cause the default autocomplete="off" to be unset.
13 | * [2.0.0](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v2.0.0) :sparkles: Major Release
14 | * See [full release notes](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v2.0.0)
15 | * [1.8.3](https://github.com/darrenjennings/vue-autosuggest/tree/v1.8.3) Bugfix
16 | * Bugfix to support IE/Edge since they don't support scrollTo. #40
17 | * [1.8.2](https://github.com/darrenjennings/vue-autosuggest/tree/v1.8.2) Bugfix
18 | * Fixes #102 Clicking on the scroll bar has been a rough go. This release aims to rid us of the all the frustration.
19 | * [1.8.1](https://github.com/darrenjennings/vue-autosuggest/tree/v1.8.1) Bugfix
20 | * Fix incorrect scrollbar click calculation
21 | * [1.8.0-1](https://github.com/darrenjennings/vue-autosuggest/tree/v1.8.0-1) Bugfix
22 | * Removes form-control as an always present css class on the ``
23 | * Migration from 1.x -> 1.8.0-1
24 | * If you had class set on the inputProps property, then vue-autosuggest used to always append form-control. If class is
25 | empty, the form-control class is the default, but if you have it set then now you need to specifically add form
26 | control to `inputProps.class` if you are wanting it.
27 | * [1.7.3](https://github.com/darrenjennings/vue-autosuggest/tree/v1.7.3) Bugfix, multiple instances navigation fixes
28 | * From [#78](https://github.com/darrenjennings/vue-autosuggest/pull/78)
29 | * [1.7.1-2](https://github.com/darrenjennings/vue-autosuggest/tree/v1.7.1-2) Bugfix
30 | * fix(mousedown) check for presence of results
31 | * Fixes [#66](https://github.com/darrenjennings/vue-autosuggest/issues/66)
32 | * [1.7.1-1](https://github.com/darrenjennings/vue-autosuggest/releases/tag/v1.7.1-1) bugfixes scrollbar clicking and event management
33 | * fix(scroll) don't close autosuggest when clicking on scrollbar (#64)
34 | * destroy event listeners in beforeDestroy lifecycle
35 | * Fixes [#63](https://github.com/darrenjennings/vue-autosuggest/issues/63)
36 | * The biggest benefit for this release is not only the ability to click and drag the scroll bar, but the cleanup of event listeners, which would previously hang around even after the component would be destroyed.
37 |
38 | * [1.7.0](https://github.com/darrenjennings/vue-autosuggest/tree/v1.7.0) @suggestion and minify esm bundle
39 | * feat(events) add suggestion as event @suggestion
40 | * chore(eslint) add eslint vue/recommended configuration and have
41 | * autosuggest lib conform
42 | * chore(rollup) uglify esm module for smaller lib size
43 | * Migrating from 1.6-1.7:
44 | * The on-selected event is now @selected
45 | * Fixes [#58](https://github.com/darrenjennings/vue-autosuggest/issues/58), From #62
46 |
47 | * [1.6.0](https://github.com/darrenjennings/vue-autosuggest/tree/v1.6.0) - Attribute prop customization
48 | * Added component id and class customization props:
49 | * component-attr-id-autosuggest
50 | * component-attr-class-autosuggest-results-container
51 | * component-attr-class-autosuggest-results
52 | * [1.5.0](https://github.com/Educents/vue-autosuggest/releases/tag/v1.5.0) - Slots
53 | * Slots - header, footer, and suggestion items
54 | * [1.4.3](https://github.com/Educents/vue-autosuggest/releases/tag/1.4.3) - bugfix [46](https://github.com/Educents/vue-autosuggest/pull/46)
55 | * [1.4.1](https://github.com/Educents/vue-autosuggest/releases/tag/1.4.1) - Native events using transparent wrappers, bugfixes
56 | * [1.3.1](https://github.com/Educents/vue-autosuggest/releases/tag/v1.3.1) - various improvements
57 | * Blur and Focus events added to inputProps
58 | * passing in oldText for onInputChange(val, oldVal) watcher event
59 | * Ability to set input autocomplete value. Default = off
60 | * [1.1.2](https://github.com/Educents/vue-autosuggest/releases/tag/v1.1.2) - getSuggestionValue, renderSuggestion props, scrollTo behavior
61 |
--------------------------------------------------------------------------------
/src/parts/DefaultSection.js:
--------------------------------------------------------------------------------
1 | const DefaultSection = {
2 | name: "default-section",
3 | props: {
4 | /** @type ResultSection */
5 | section: { type: Object, required: true },
6 | currentIndex: { type: [Number, String], required: false, default: Infinity },
7 | renderSuggestion: { type: Function, required: false },
8 | normalizeItemFunction: { type: Function, required: true },
9 | componentAttrPrefix: { type: String, required: true },
10 | componentAttrIdAutosuggest: { type: String, required: true }
11 | },
12 | data: function () {
13 | return {
14 | /** @type Number */
15 | _currentIndex: this.currentIndex
16 | }
17 | },
18 | computed: {
19 | /**
20 | * Suggestions from the section
21 | */
22 | list: function () {
23 | let { limit, data } = this.section;
24 | if (data.length < limit) {
25 | limit = data.length;
26 | }
27 | return data.slice(0, limit);
28 | }
29 | },
30 | methods: {
31 | getItemIndex (i) {
32 | return this.section.start_index + i;
33 | },
34 | getItemByIndex (i) {
35 | return this.section.data[i];
36 | },
37 | onMouseEnter (event) {
38 | const idx = parseInt(event.currentTarget.getAttribute("data-suggestion-index"))
39 | this._currentIndex = idx
40 | this.$emit('updateCurrentIndex', idx)
41 | },
42 | onMouseLeave () {
43 | this.$emit('updateCurrentIndex', null)
44 | }
45 | },
46 | // eslint-disable-next-line no-unused-vars
47 | render (h) {
48 | const componentAttrPrefix = this.componentAttrPrefix
49 | const slots = {
50 | beforeSection: this.$scopedSlots[`before-section-${this.section.name}`],
51 | afterSectionDefault: this.$scopedSlots[`after-section`],
52 | afterSectionNamed: this.$scopedSlots[`after-section-${this.section.name}`]
53 | }
54 |
55 | const beforeClassName = `${componentAttrPrefix}__results-before ${componentAttrPrefix}__results-before--${this.section.name}`
56 | const before = slots.beforeSection && slots.beforeSection({
57 | section: this.section,
58 | className: beforeClassName
59 | }) || []
60 |
61 | return h(
62 | "ul",
63 | {
64 | attrs: { role: "listbox", "aria-labelledby": this.section.label && `${this.componentAttrIdAutosuggest}-${this.section.label}` },
65 | class: this.section.ulClass
66 | },
67 | [
68 | before[0] && before[0] || this.section.label &&
31 | "Not idly do the leaves of Lórien fall," proclaimed Aragorn.
34 |
35 | You have choosen poorly. Humans
36 | are like... the worst.
37 |
38 | Legolas is like... so hawt.
41 |
42 | "Things that were... things that are... and some things... that have not
43 | yet come to pass." Wait... is that in the book?!
44 |
45 | And with my axe!
46 | What is the plural of Dwarf anyways?
47 |
48 | The counsel of Gandalf was not founded on foreknowledge of safety, for
49 | himself or for others," said Aragorn. "There are some things that it is
50 | better to begin than to refuse, even though the end may be dark."
51 |
52 | Sneaky little Hobbitses. Wicked. Tricksy.
53 |
244 |
245 | For more advanced usage, check out the examples below, and explore the
246 | properties you can use.
247 |
248 | ## [Slots](#slots)
249 |
250 | ### header/footer
251 | Slots for injecting content around the results/input. Useful for header/footer like slots or empty state.
252 |
253 | ```html
254 |
255 | content before the goes here
256 | content after the goes here
257 | content before the
goes here
258 | section header content for specific section goes here
259 | footer content goes here for specific section.
260 | Default footer content for all sections
261 | content after the
goes here
262 |
263 | ```
264 |
265 | ### Adding labels
266 |
267 | It is common in forms to add a label next to the `` tag for semantic html / accessibility. You can use the
268 | `before-input` slot to accomplish this in conjunction with the `inputProps.id`:
269 |
270 | ```html
271 |
272 |
273 |
274 |
275 | ...
276 |
277 | ```
278 |
279 | ### suggestion item (i.e. default slot)
280 | Used to style each suggestion inside the `
` tag. Using [scoped slots](https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots)
281 | you have access to the `suggestion` item inside the `v-for` suggestions loop. This gives you the power of Vue templating, since
282 | vue-autosuggest does not have an opinion about how you render the items in your list.
283 |
284 | ```vue
285 |
286 |
287 |
288 |
293 |
294 |
295 | ```
296 |
297 | > This slot will be overridden when the [`render-suggestion`](#renderSuggestion) prop is used.
298 |
299 |
300 |
301 | ## [Props](#props)
302 |
303 | | Prop | Type | Required | Description |
304 | | :------------------------------------------ | :------- | :------: | :-------------------------------------------------------- |
305 | | [`suggestions`](#suggestionsProp) | Array | ✓ | Array of sections, each containing suggestions to be rendered. e.g.`suggestions: [{data: ['harry','ron','hermione']}]` |
306 | | [`input-props`](#inputPropsTable) | Object | ✓ | Add props to the ``. |
307 | | [`section-configs`](#sectionConfigsProp) | Object | | Define multiple sections ``. |
308 | | [`render-suggestion`](#renderSuggestion) | Function | | Tell vue-autosuggest how to render inside the `
` tag. Overrides what is inside the default suggestion template slot. |
309 | | [`get-suggestion-value`](#getSuggestionValue) | Function | | Tells vue-autosuggest what to put in the `` value |
310 | | [`should-render-suggestions`](#shouldRenderSuggestions) | Function | | Tell vue-autosuggest if it should render the suggestions results popover |
311 | | `component-attr-id-autosuggest` | String | | `id` of entire component |
312 | | `component-attr-class-autosuggest-results-container` | String | | `class` of container of results container |
313 | | `component-attr-class-autosuggest-results` | String | | `class` of results container |
314 | | `component-attr-prefix` | String | | prefix to be used for results item classes/ids. default: `autosuggest` |
315 |
316 |
317 |
318 | ### inputProps
319 |
320 | | Prop | Type | Required | Description |
321 | | :----------------------- | :------------------ | :--------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
322 | | [`id`](#inputPropsTable) | String | ✓ | id attribute on ``. |
323 | | Any DOM Props | \* | | You can add any props to `` as the component will `v-bind` inputProps. Similar to rest spread in JSX. See more details here: https://vuejs.org/v2/api/#v-bind. The `name` attribute is set to "`q`" by default. |
324 |
325 |
326 |
327 | ### sectionConfigs
328 |
329 | Multiple sections can be defined in the `sectionConfigs` prop which defines the control behavior for
330 | each section.
331 |
332 | | Prop | Type | Required | Description |
333 | | :----------- | :------- | :------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
334 | | `on-selected` | Function | ✓ | Determine behavior for what should happen when a suggestion is selected. e.g. Submit a form, open a link, update a vue model, tweet at Ken Wheeler etc. |
335 | | `limit` | Number | | Limit each section by some value. Default: `Infinity` |
336 |
337 | Below we have defined a `default` section and a `blog` section. The `blog` section has a component
338 | `type` of `url-section` which corresponds to which component the Autosuggest loads. When type is not
339 | defined, Vue-autosuggest will use a built in `DefaultSection.vue` component.
340 |
341 | ```js
342 | sectionConfigs: {
343 | 'default': {
344 | limit: 6,
345 | onSelected: function(item, originalInput) {
346 | console.log(item, originalInput, `Selected "${item.item}"`);
347 | }
348 | },
349 | 'blog': {
350 | limit: 3,
351 | type: "url-section",
352 | onSelected: function() {
353 | console.log("url: " + item.item.url);
354 | }
355 | }
356 | }
357 | ```
358 |
359 |
360 |
361 | ### renderSuggestion
362 |
363 | This function can be used to tell vue-autosuggest how to render the html inside the `
` tag when you do not want to use the
364 | default template slot for suggestions but would rather have the power of javascript / jsx.
365 |
366 | In its most basic form it just returns an object property:
367 |
368 | ```js
369 | renderSuggestion(suggestion) {
370 | return suggestion.name;
371 | },
372 | ```
373 |
374 | But usually it returns a JSX fragment, which is transformed into a virtual node description with babel-plugin-transform-vue-jsx:
375 |
376 | ```jsx
377 | renderSuggestion(suggestion) {
378 | return