├── .babelrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github └── dependabot.yml ├── .gitignore ├── .npmignore ├── .prettierrc ├── .travis.yml ├── LICENSE ├── README.md ├── dist ├── v-click-outside.umd.js └── v-click-outside.umd.js.map ├── example ├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── public │ ├── favicon.ico │ └── index.html └── src │ ├── App.vue │ ├── assets │ └── logo.png │ ├── main.js │ ├── router │ └── index.js │ └── views │ ├── About.vue │ └── Home.vue ├── package-lock.json ├── package.json ├── src ├── index.js └── v-click-outside.js └── test └── v-click-outside.test.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"] 3 | } 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | 9 | # Change these settings to your own preference 10 | indent_style = space 11 | indent_size = 2 12 | 13 | # We recommend you to keep these unchanged 14 | end_of_line = lf 15 | charset = utf-8 16 | trim_trailing_whitespace = true 17 | insert_final_newline = true 18 | 19 | [*.md] 20 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["airbnb-base", "prettier"], 3 | "plugins": ["prettier"], 4 | "rules": { 5 | "prettier/prettier": "error", 6 | "no-param-reassign": 0, 7 | "no-shadow": 0 8 | }, 9 | "parserOptions": { 10 | "ecmaVersion": 2018 11 | }, 12 | "env": { 13 | "browser": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: "10:00" 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | *.log 4 | .DS_Store 5 | jest_* 6 | yarn.lock 7 | .idea 8 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | rollup.config.js 2 | coverage 3 | test 4 | yarn.lock 5 | example 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "semi": false, 4 | "trailingComma": "all", 5 | "singleQuote": true, 6 | "arrowParens": "always" 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: '12' 4 | 5 | cache: npm 6 | 7 | before_script: 8 | - npm install coveralls 9 | 10 | script: 11 | - npm test 12 | - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Nicolas Del Valle 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 | # click-outside-vue3 2 | 3 | Vue 3 directive to react on clicks outside an element without stopping the event propagation. 4 | Great for closing dialogues and menus among other things. 5 | 6 | ## Install 7 | ```bash 8 | $ npm install --save click-outside-vue3 9 | ``` 10 | 11 | ```bash 12 | $ yarn add click-outside-vue3 13 | ``` 14 | 15 | ## Use 16 | 17 | ```js 18 | import { createApp } from "vue" 19 | import App from "./App.vue" 20 | import vClickOutside from "click-outside-vue3" 21 | 22 | const app = createApp(App) 23 | app.use(vClickOutside) 24 | ``` 25 | 26 | ```js 27 | 62 | 63 | 67 | ``` 68 | Or use it as a directive 69 | 70 | ```js 71 | import vClickOutside from 'click-outside-vue3' 72 | 73 | 85 | 86 | 89 | ``` 90 | 91 | ## Detecting Iframe Clicks 92 | 93 | To our knowledge, there isn't an idiomatic way to detect a click on a `