evui 2.1.0 → 2.1.3

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.
Files changed (189) hide show
  1. package/dist/{adac9fa4f723f9d2cb5b6640517114a9.png → 0b8d1200e71cae8d747dce4e69c4efb6.png} +0 -0
  2. package/dist/1.css +4 -0
  3. package/dist/1.css.map +1 -0
  4. package/dist/1.evui.min.js +2 -0
  5. package/dist/1.evui.min.js.map +1 -0
  6. package/dist/1ba679c05036b34bf359aa2e6c450faa.ttf +0 -0
  7. package/dist/2.css +4 -0
  8. package/dist/2.css.map +1 -0
  9. package/dist/2.evui.min.js +2 -0
  10. package/dist/2.evui.min.js.map +1 -0
  11. package/dist/{e8c322de9658cbeb8a774b6624167c2c.woff2 → 278156e41e0ad908cf7f841b17130502.woff2} +0 -0
  12. package/dist/3.evui.min.js +2 -0
  13. package/dist/3.evui.min.js.map +1 -0
  14. package/dist/32be89b11725274cd3e801192ba88361.ttf +0 -0
  15. package/dist/{0ab54153eeeca0ce03978cc463b257f7.woff2 → 38c6d8bab26db77d8c806813e1497763.woff2} +0 -0
  16. package/dist/4.evui.min.js +2 -0
  17. package/dist/4.evui.min.js.map +1 -0
  18. package/dist/{faff92145777a3cbaf8e7367b4807987.woff → 425399f81e4ce7cbd967685402ba0260.woff} +0 -0
  19. package/dist/4730076470a665bbc7b783c56d29a72e.svg +261 -0
  20. package/dist/52e9a7f6ff3af5ad261e5292d07ebdca.eot +0 -0
  21. package/dist/{ad97afd3337e8cda302d10ff5a4026b8.ttf → 5367103510b27b78482794590e1ce3b0.ttf} +0 -0
  22. package/dist/{65363c4d55617bbeb57d8ce6dcd46099.svg → 57e963e3d6dd0a9cf05150b40eebf69b.svg} +0 -0
  23. package/dist/{c5ebe0b32dc1b5cc449a76c4204d13bb.ttf → 65a2fb6d9aaa164b41a039302093995b.ttf} +0 -0
  24. package/dist/{cd6c777f1945164224dee082abaea03a.woff2 → 687a4990ea22bb1a49d469a5d9319790.woff2} +0 -0
  25. package/dist/{7583da5c07275cd5eb364507616f998f.ttf → 6c1d906bf5ba48676f65b2d65e935e1a.ttf} +0 -0
  26. package/dist/6dafca5a4f1e31f2bdf11939b24ff422.ttf +0 -0
  27. package/dist/{701ae6abd4719e9c2ada3535a497b341.eot → 752905fa5edf21fc52a10a0c1ca9c7a4.eot} +0 -0
  28. package/dist/76c05d80dda67cdc5d03f345b7bd063f.ttf +0 -0
  29. package/dist/{b551b554a67e86a840bc80cbb8066c30.svg → 7d62eb50e7bb05eedb2a4656f7fe8f3b.svg} +0 -0
  30. package/dist/{8e3c7f5520f5ae906c6cf6d7f3ddcd19.eot → a01e3f2d6c83dc3aee175e2482b3f777.eot} +0 -0
  31. package/dist/{448f2aaa315fa9dce7b2cf6ce31caed6.svg → b30fd8419d7e6d5918856c7531d33482.svg} +0 -0
  32. package/dist/c57dd55fa982e8940f69ca1d69a8a999.woff +0 -0
  33. package/dist/{b87b9ba532ace76ae9f6edfe9f72ded2.ttf → c656b8caa454ed19b9a2ef7f4f5b8fea.ttf} +0 -0
  34. package/dist/{a046592bac8f2fd96e994733faf3858c.woff → cac87dc00c87a5d74711d0276713808a.woff} +0 -0
  35. package/dist/{13db00b7a34fee4d819ab7f9838cc428.eot → d68fa3e67dbb653a13cec44b1bcabcfe.eot} +0 -0
  36. package/dist/{ef60a4f6c25ef7f39f2d25a748dbecfe.woff → ddae9b1ba9b0b42f58809904b0b21349.woff} +0 -0
  37. package/dist/evui.min.js +6 -86054
  38. package/dist/evui.min.js.gz +0 -0
  39. package/dist/evui.min.js.map +1 -1
  40. package/dist/main.css +43 -5541
  41. package/dist/main.css.gz +0 -0
  42. package/dist/main.css.map +1 -1
  43. package/package.json +56 -76
  44. package/src/common/emitter.js +20 -0
  45. package/src/common/utils.debounce.js +223 -0
  46. package/src/common/utils.js +51 -17
  47. package/src/common/utils.throttle.js +83 -0
  48. package/src/common/utils.tree.js +18 -0
  49. package/src/components/button/button.vue +317 -241
  50. package/src/components/chart/chart.core.js +378 -85
  51. package/src/components/chart/chart.vue +133 -115
  52. package/src/components/chart/element/element.bar.js +219 -25
  53. package/src/components/chart/element/element.bar.time.js +115 -0
  54. package/src/components/chart/element/element.line.js +172 -21
  55. package/src/components/chart/element/element.pie.js +86 -0
  56. package/src/components/chart/element/element.scatter.js +9 -2
  57. package/src/components/chart/element/element.tip.js +356 -0
  58. package/src/components/chart/helpers/helpers.canvas.js +94 -0
  59. package/src/components/chart/helpers/helpers.constant.js +25 -6
  60. package/src/components/chart/helpers/helpers.util.js +83 -38
  61. package/src/components/chart/index.js +0 -1
  62. package/src/components/chart/model/model.series.js +43 -14
  63. package/src/components/chart/model/model.store.js +440 -46
  64. package/src/components/chart/plugins/plugins.interaction.js +324 -0
  65. package/src/components/chart/plugins/plugins.legend.js +233 -91
  66. package/src/components/chart/plugins/plugins.pie.js +179 -0
  67. package/src/components/chart/plugins/plugins.title.js +25 -2
  68. package/src/components/chart/plugins/plugins.tooltip.js +384 -0
  69. package/src/components/chart/scale/scale.js +91 -29
  70. package/src/components/chart/scale/scale.linear.js +12 -0
  71. package/src/components/chart/scale/scale.logarithmic.js +25 -0
  72. package/src/components/chart/scale/scale.step.js +89 -52
  73. package/src/components/chart/scale/scale.time.category.js +204 -0
  74. package/src/components/chart/scale/scale.time.js +19 -1
  75. package/src/components/checkbox/checkbox-group.vue +15 -11
  76. package/src/components/checkbox/checkbox.vue +210 -138
  77. package/src/components/codeview/code.vue +42 -29
  78. package/src/components/contextmenu/contextmenu.child.vue +79 -0
  79. package/src/components/contextmenu/contextmenu.vue +276 -0
  80. package/src/components/contextmenu/contextmenu.wrap.vue +189 -0
  81. package/src/components/contextmenu/index.js +3 -0
  82. package/src/components/datepicker/calendar.core.js +588 -492
  83. package/src/components/datepicker/calendar.vue +0 -3
  84. package/src/components/datepicker/datepicker.vue +43 -15
  85. package/src/components/datepicker/index.js +5 -1
  86. package/src/components/grid/grid.filter.vue +290 -0
  87. package/src/components/grid/grid.filter.window.vue +411 -0
  88. package/src/components/grid/grid.render.vue +45 -0
  89. package/src/components/grid/grid.vue +1338 -0
  90. package/src/components/icon/icon.vue +23 -7
  91. package/src/components/input/input.number.vue +309 -277
  92. package/src/components/label/label.vue +2 -2
  93. package/src/components/loadingmask/loadingmask.vue +6 -13
  94. package/src/components/loginfield/loginfield.vue +46 -37
  95. package/src/components/markdown/index.js +3 -0
  96. package/src/components/markdown/markdown.vue +1001 -0
  97. package/src/components/menu/index.js +1 -3
  98. package/src/components/menu/menu.nav.item.vue +115 -0
  99. package/src/components/menu/menu.nav.sub.vue +42 -0
  100. package/src/components/menu/menu.nav.vue +71 -98
  101. package/src/components/message/index.js +3 -0
  102. package/src/components/message/message.js +63 -0
  103. package/src/components/message/message.vue +191 -0
  104. package/src/components/message-box/index.js +7 -0
  105. package/src/components/message-box/message-box.js +32 -0
  106. package/src/components/message-box/message-box.vue +291 -0
  107. package/src/components/notification/index.js +3 -0
  108. package/src/components/notification/notification.js +75 -0
  109. package/src/components/notification/notification.vue +242 -0
  110. package/src/components/radio/radio-group.vue +6 -2
  111. package/src/components/radio/radio.vue +156 -76
  112. package/src/components/selectbox/dropdown.vue +86 -40
  113. package/src/components/selectbox/listbox.vue +47 -18
  114. package/src/components/selectbox/option.vue +1 -1
  115. package/src/components/selectbox/selectbox.vue +304 -316
  116. package/src/components/slider/slider-tooltip.vue +7 -7
  117. package/src/components/slider/slider.vue +20 -25
  118. package/src/components/splitter/splitter.vue +104 -94
  119. package/src/components/table/table.black.css +1 -1
  120. package/src/components/table/table.filter.lite.vue +7 -7
  121. package/src/components/table/table.filter.vue +1 -1
  122. package/src/components/table/table.grey.css +5 -6
  123. package/src/components/table/table.navy.css +1 -1
  124. package/src/components/table/table.vue +55 -48
  125. package/src/components/tabs/tab-panel.vue +19 -5
  126. package/src/components/tabs/tabs.vue +182 -87
  127. package/src/components/textfield/textfield.vue +110 -87
  128. package/src/components/timepicker/index.js +2 -2
  129. package/src/components/timepicker/spinner.vue +15 -17
  130. package/src/components/timepicker/timepicker.vue +98 -53
  131. package/src/components/toggle/toggle.vue +148 -109
  132. package/src/components/tree/index.js +2 -6
  133. package/src/components/tree/render.js +17 -0
  134. package/src/components/tree/tree-node.vue +214 -0
  135. package/src/components/tree/tree.vue +296 -0
  136. package/src/components/tree-table/index.js +7 -0
  137. package/src/components/{tree → tree-table}/tree.table.black.css +0 -0
  138. package/src/components/{tree → tree-table}/tree.table.grey.css +0 -0
  139. package/src/components/{tree → tree-table}/tree.table.vue +36 -41
  140. package/src/components/{tree → tree-table}/tree.util.js +0 -0
  141. package/src/components/window/window.vue +238 -191
  142. package/src/index.js +28 -12
  143. package/src/styles/base/base.scss +50 -0
  144. package/src/styles/base/index.scss +1 -0
  145. package/src/styles/default.scss +5 -0
  146. package/src/styles/{codemirror.css → lib/codemirror.css} +0 -0
  147. package/src/styles/{all.css → lib/fontawesome.css} +1 -1
  148. package/src/styles/lib/icon.css +792 -0
  149. package/src/styles/themes/index.scss +2 -0
  150. package/src/styles/themes/mixin.scss +33 -0
  151. package/src/styles/themes/variables.scss +206 -0
  152. package/src/styles/utils/colors.scss +222 -0
  153. package/src/styles/utils/index.scss +2 -0
  154. package/src/styles/utils/mixins.scss +34 -0
  155. package/src/styles/utils/variables.scss +27 -0
  156. package/src/webfonts/EVUI.eot +0 -0
  157. package/src/webfonts/EVUI.svg +251 -173
  158. package/src/webfonts/EVUI.ttf +0 -0
  159. package/src/webfonts/EVUI.woff +0 -0
  160. package/src/webfonts/Roboto-Bold.ttf +0 -0
  161. package/src/webfonts/Roboto-Medium.ttf +0 -0
  162. package/src/webfonts/Roboto-Regular.ttf +0 -0
  163. package/dist/3c9453211570a4ede66a4b4954a32bbb.ttf +0 -0
  164. package/dist/8634884f932627fc43782e6963b64ccd.svg +0 -183
  165. package/dist/b9e64d9b5fa6b500eb5df6fa980d3e5b.eot +0 -0
  166. package/dist/f0ac0c8b3c9cd3ef9002749985ae546f.woff +0 -0
  167. package/src/components/chart/charts/chart.bar.js +0 -334
  168. package/src/components/chart/charts/chart.base.js +0 -1075
  169. package/src/components/chart/charts/chart.line.js +0 -262
  170. package/src/components/chart/charts/chart.pie.js +0 -383
  171. package/src/components/chart/charts/chart.scatter.js +0 -349
  172. package/src/components/chart/charts/chart.sunburst.js +0 -193
  173. package/src/components/chart/core/axis/axis.js +0 -217
  174. package/src/components/chart/core/axis/axis.scale.auto.js +0 -69
  175. package/src/components/chart/core/axis/axis.scale.fixed.js +0 -65
  176. package/src/components/chart/core/axis/axis.scale.steps.js +0 -149
  177. package/src/components/chart/core/core.constant.js +0 -116
  178. package/src/components/chart/core/core.legend.js +0 -473
  179. package/src/components/chart/core/core.util.js +0 -66
  180. package/src/components/chart/core/data/data.js +0 -412
  181. package/src/components/chart/core/data/data.pie.js +0 -70
  182. package/src/components/chart/core/data/data.stack.js +0 -222
  183. package/src/components/chart/core/data/data.sunburst.js +0 -172
  184. package/src/components/menu/menu.context.children.vue +0 -201
  185. package/src/components/menu/menu.context.vue +0 -144
  186. package/src/components/tabs/jun/tab.vue +0 -123
  187. package/src/components/tabs/jun/tabs.vue +0 -484
  188. package/src/styles/evui.css +0 -386
  189. package/src/styles/icon.css +0 -557
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evui",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "A EXEM Library project",
5
5
  "author": "exem <dev_client@ex-em.com>",
6
6
  "license": "MIT",
@@ -11,11 +11,11 @@
11
11
  "test": "npm run unit",
12
12
  "lint": "eslint --ext .js,.vue src test/unit",
13
13
  "build": "webpack --config build/webpack.prod.conf.js",
14
- "home": "webpack-dev-server --progress --config build/webpack.home.conf.js --mode=development",
15
- "home_build": "webpack --config build/webpack.home.conf.js --mode=production",
16
- "maxgauge": "webpack-dev-server --progress --config build/webpack.maxgauge.conf.js",
17
- "liteplus": "webpack-dev-server --progress --config build/webpack.liteplus.conf.js",
18
- "liteplus_build": "webpack --config build/webpack.liteplus.conf.js --mode=production"
14
+ "docs": "webpack-dev-server --progress --config build/webpack.docs.conf.js --mode=development",
15
+ "docs_build": "webpack --config build/webpack.docs.conf.js --mode=production",
16
+ "pub:patch": "npm version patch --no-git-tag-version",
17
+ "pub:minor": "npm version minor --no-git-tag-version",
18
+ "pub:major": "npm version major --no-git-tag-version"
19
19
  },
20
20
  "main": "dist/evui.min.js",
21
21
  "module": "dist/evui.min.js",
@@ -39,87 +39,67 @@
39
39
  "EVUI"
40
40
  ],
41
41
  "dependencies": {
42
- "axios": "^0.18.0",
43
- "lodash": "^4.17.11",
44
- "lodash-es": "^4.17.11",
45
- "vue": "^2.6.9",
46
- "vue-resize-directive": "^1.2.0",
47
- "vue-router": "^3.0.2",
48
- "vuex": "^3.1.0"
42
+ "lodash": "^4.17.15",
43
+ "lodash-es": "^4.17.15",
44
+ "vue": "^2.6.11",
45
+ "vue-i18n": "^8.15.6",
46
+ "vue-observe-visibility": "^0.4.6",
47
+ "vue-resize-directive": "^1.2.0"
49
48
  },
50
49
  "devDependencies": {
51
- "acorn": "^6.1.1",
52
- "babel-core": "^6.26.3",
53
- "babel-eslint": "^8.2.6",
54
- "babel-helper-vue-jsx-merge-props": "^2.0.3",
55
- "babel-loader": "^7.1.5",
56
- "babel-plugin-istanbul": "^5.1.1",
57
- "babel-plugin-syntax-dynamic-import": "^6.18.0",
58
- "babel-plugin-syntax-jsx": "^6.18.0",
59
- "babel-plugin-transform-runtime": "^6.22.0",
60
- "babel-plugin-transform-vue-jsx": "^3.7.0",
61
- "babel-polyfill": "^6.26.0",
62
- "babel-preset-env": "^1.7.0",
63
- "babel-preset-stage-2": "^6.22.0",
64
- "chai": "^3.5.0",
65
- "clean-webpack-plugin": "^2.0.1",
66
- "compression-webpack-plugin": "^2.0.0",
67
- "copy-webpack-plugin": "^5.0.1",
68
- "cross-env": "^5.2.0",
69
- "css-loader": "^2.1.1",
70
- "eslint": "4.16.0",
71
- "eslint-config-airbnb-base": "^11.3.0",
72
- "eslint-friendly-formatter": "^3.0.0",
73
- "eslint-import-resolver-webpack": "^0.8.3",
74
- "eslint-loader": "^2.1.2",
75
- "eslint-plugin-html": "^4.0.6",
76
- "eslint-plugin-import": "^2.16.0",
77
- "eslint-plugin-vue": "^4.7.1",
78
- "file-loader": "^3.0.1",
50
+ "@babel/core": "^7.9.0",
51
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
52
+ "@babel/plugin-transform-runtime": "^7.9.0",
53
+ "@babel/preset-env": "^7.9.0",
54
+ "axios": "^0.19.2",
55
+ "babel-eslint": "^10.1.0",
56
+ "babel-loader": "^8.1.0",
57
+ "clean-webpack-plugin": "^3.0.0",
58
+ "codesandbox": "^2.1.12",
59
+ "compression-webpack-plugin": "^3.1.0",
60
+ "copy-webpack-plugin": "^5.1.1",
61
+ "css-loader": "^3.4.2",
62
+ "eslint": "^6.8.0",
63
+ "eslint-config-airbnb-base": "^14.1.0",
64
+ "eslint-formatter-friendly": "^7.0.0",
65
+ "eslint-import-resolver-webpack": "^0.12.1",
66
+ "eslint-loader": "^3.0.3",
67
+ "eslint-plugin-import": "^2.20.1",
68
+ "eslint-plugin-vue": "^6.2.2",
69
+ "file-loader": "^6.0.0",
79
70
  "friendly-errors-webpack-plugin": "^1.7.0",
80
- "html-loader": "^0.5.5",
81
- "html-webpack-plugin": "^3.2.0",
82
- "karma": "^4.0.1",
83
- "karma-coverage": "^1.1.2",
84
- "karma-mocha": "^1.3.0",
85
- "karma-phantomjs-launcher": "^1.0.2",
86
- "karma-phantomjs-shim": "^1.4.0",
87
- "karma-sinon-chai": "^1.3.4",
88
- "karma-sourcemap-loader": "^0.3.7",
89
- "karma-spec-reporter": "0.0.31",
90
- "karma-webpack": "^3.0.5",
91
- "mini-css-extract-plugin": "^0.5.0",
92
- "mocha": "^5.2.0",
71
+ "highlight.js": "^9.18.1",
72
+ "html-loader": "^1.0.0",
73
+ "html-webpack-plugin": "^4.0.1",
74
+ "marked": "^0.8.2",
75
+ "mini-css-extract-plugin": "^0.9.0",
93
76
  "moment": "^2.24.0",
94
- "ora": "^1.4.0",
95
- "postcss-import": "^11.1.0",
96
- "postcss-loader": "^2.1.6",
97
- "postcss-url": "^7.3.2",
98
- "shelljs": "^0.7.6",
99
- "sinon": "^4.5.0",
100
- "sinon-chai": "^2.9.0",
101
- "style-loader": "^0.21.0",
102
- "url-loader": "^1.1.2",
77
+ "node-sass": "^4.13.1",
78
+ "sass": "^1.26.3",
79
+ "sass-loader": "^8.0.2",
80
+ "style-loader": "^1.1.3",
81
+ "stylelint": "^13.2.1",
82
+ "stylelint-formatter-pretty": "^2.0.0",
83
+ "stylelint-webpack-plugin": "^1.2.3",
84
+ "url-loader": "^4.0.0",
103
85
  "vue-codemirror-lite": "^1.0.4",
104
- "vue-loader": "^15.7.0",
105
- "vue-style-loader": "^3.1.2",
106
- "vue-template-compiler": "^2.6.9",
107
- "vue-test-utils": "^1.0.0-beta.11",
108
- "webpack": "^4.29.6",
109
- "webpack-bundle-analyzer": "^2.13.1",
110
- "webpack-cli": "^3.3.0",
111
- "webpack-dev-server": "^3.2.1",
112
- "webpack-merge": "^4.2.1",
113
- "worker-loader": "^2.0.0"
86
+ "vue-loader": "^15.9.1",
87
+ "vue-router": "^3.1.6",
88
+ "vue-style-loader": "^4.1.2",
89
+ "vue-template-compiler": "^2.6.11",
90
+ "webpack": "^4.42.1",
91
+ "webpack-cli": "^3.3.11",
92
+ "webpack-dev-server": "^3.10.3",
93
+ "webpack-merge": "^4.2.2"
114
94
  },
115
95
  "engines": {
116
- "node": ">= 6.0.0",
117
- "npm": ">= 3.0.0",
96
+ "node": ">= 8.0.0",
97
+ "npm": ">= 5.0.0",
118
98
  "webpack": ">=4.0.0"
119
99
  },
120
100
  "browserslist": [
121
101
  "> 1%",
122
102
  "last 2 versions",
123
- "not ie <= 8"
103
+ "not ie <= 10"
124
104
  ]
125
105
  }
@@ -0,0 +1,20 @@
1
+ export default {
2
+ methods: {
3
+ dispatch(componentName, eventName, params) {
4
+ let parent = this.$parent || this.$root;
5
+ let name = parent.$options.name;
6
+
7
+ while (parent && (!name || name !== componentName)) {
8
+ parent = parent.$parent;
9
+
10
+ if (parent) {
11
+ name = parent.$options.name;
12
+ }
13
+ }
14
+ if (parent) {
15
+ // eslint-disable-next-line prefer-spread
16
+ parent.$emit.apply(parent, [eventName].concat(params));
17
+ }
18
+ },
19
+ },
20
+ };
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Original Code
3
+ * https://github.com/lodash/lodash/blob/es/debounce.js
4
+ * lodash/debounce.js
5
+ */
6
+
7
+ function isObject(value) {
8
+ const type = typeof value;
9
+ return value != null && (type === 'object' || type === 'function');
10
+ }
11
+
12
+ /**
13
+ * Creates a debounced function that delays invoking `func` until after `wait`
14
+ * milliseconds have elapsed since the last time the debounced function was
15
+ * invoked, or until the next browser frame is drawn. The debounced function
16
+ * comes with a `cancel` method to cancel delayed `func` invocations and a
17
+ * `flush` method to immediately invoke them. Provide `options` to indicate
18
+ * whether `func` should be invoked on the leading and/or trailing edge of the
19
+ * `wait` timeout. The `func` is invoked with the last arguments provided to the
20
+ * debounced function. Subsequent calls to the debounced function return the
21
+ * result of the last `func` invocation.
22
+ *
23
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
24
+ * invoked on the trailing edge of the timeout only if the debounced function
25
+ * is invoked more than once during the `wait` timeout.
26
+ *
27
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
28
+ * until the next tick, similar to `setTimeout` with a timeout of `0`.
29
+ *
30
+ * If `wait` is omitted in an environment with `requestAnimationFrame`, `func`
31
+ * invocation will be deferred until the next frame is drawn (typically about
32
+ * 16ms).
33
+ *
34
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
35
+ * for details over the differences between `debounce` and `throttle`.
36
+ *
37
+ * @since 0.1.0
38
+ * @category Function
39
+ * @param {Function} func The function to debounce.
40
+ * @param {number} [wait=0]
41
+ * The number of milliseconds to delay; if omitted, `requestAnimationFrame` is
42
+ * used (if available).
43
+ * @param {Object} [options={}] The options object.
44
+ * @param {boolean} [options.leading=false]
45
+ * Specify invoking on the leading edge of the timeout.
46
+ * @param {number} [options.maxWait]
47
+ * The maximum time `func` is allowed to be delayed before it's invoked.
48
+ * @param {boolean} [options.trailing=true]
49
+ * Specify invoking on the trailing edge of the timeout.
50
+ * @returns {Function} Returns the new debounced function.
51
+ * @example
52
+ *
53
+ * // Avoid costly calculations while the window size is in flux.
54
+ * jQuery(window).on('resize', debounce(calculateLayout, 150))
55
+ *
56
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
57
+ * jQuery(element).on('click', debounce(sendMail, 300, {
58
+ * 'leading': true,
59
+ * 'trailing': false
60
+ * }))
61
+ *
62
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
63
+ * const debounced = debounce(batchLog, 250, { 'maxWait': 1000 })
64
+ * const source = new EventSource('/stream')
65
+ * jQuery(source).on('message', debounced)
66
+ *
67
+ * // Cancel the trailing debounced invocation.
68
+ * jQuery(window).on('popstate', debounced.cancel)
69
+ *
70
+ * // Check for pending invocations.
71
+ * const status = debounced.pending() ? "Pending..." : "Ready"
72
+ */
73
+ /* eslint-disable */
74
+ function debounce(func, wait, options) {
75
+ let lastArgs,
76
+ lastThis,
77
+ maxWait,
78
+ result,
79
+ timerId,
80
+ lastCallTime
81
+
82
+ let lastInvokeTime = 0
83
+ let leading = false
84
+ let maxing = false
85
+ let trailing = true
86
+
87
+ // Bypass `requestAnimationFrame` by explicitly setting `wait=0`.
88
+ const useRAF = (!wait && wait !== 0 && typeof root.requestAnimationFrame === 'function')
89
+
90
+ if (typeof func !== 'function') {
91
+ throw new TypeError('Expected a function')
92
+ }
93
+ wait = +wait || 0
94
+ if (isObject(options)) {
95
+ leading = !!options.leading
96
+ maxing = 'maxWait' in options
97
+ maxWait = maxing ? Math.max(+options.maxWait || 0, wait) : maxWait
98
+ trailing = 'trailing' in options ? !!options.trailing : trailing
99
+ }
100
+
101
+ function invokeFunc(time) {
102
+ const args = lastArgs
103
+ const thisArg = lastThis
104
+
105
+ lastArgs = lastThis = undefined
106
+ lastInvokeTime = time
107
+ result = func.apply(thisArg, args)
108
+ return result
109
+ }
110
+
111
+ function startTimer(pendingFunc, wait) {
112
+ if (useRAF) {
113
+ window.cancelAnimationFrame(timerId)
114
+ return window.requestAnimationFrame(pendingFunc)
115
+ }
116
+ return setTimeout(pendingFunc, wait)
117
+ }
118
+
119
+ function cancelTimer(id) {
120
+ if (useRAF) {
121
+ return window.cancelAnimationFrame(id)
122
+ }
123
+ clearTimeout(id)
124
+ }
125
+
126
+ function leadingEdge(time) {
127
+ // Reset any `maxWait` timer.
128
+ lastInvokeTime = time
129
+ // Start the timer for the trailing edge.
130
+ timerId = startTimer(timerExpired, wait)
131
+ // Invoke the leading edge.
132
+ return leading ? invokeFunc(time) : result
133
+ }
134
+
135
+ function remainingWait(time) {
136
+ const timeSinceLastCall = time - lastCallTime
137
+ const timeSinceLastInvoke = time - lastInvokeTime
138
+ const timeWaiting = wait - timeSinceLastCall
139
+
140
+ return maxing
141
+ ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke)
142
+ : timeWaiting
143
+ }
144
+
145
+ function shouldInvoke(time) {
146
+ const timeSinceLastCall = time - lastCallTime
147
+ const timeSinceLastInvoke = time - lastInvokeTime
148
+
149
+ // Either this is the first call, activity has stopped and we're at the
150
+ // trailing edge, the system time has gone backwards and we're treating
151
+ // it as the trailing edge, or we've hit the `maxWait` limit.
152
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
153
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait))
154
+ }
155
+
156
+ function timerExpired() {
157
+ const time = Date.now()
158
+ if (shouldInvoke(time)) {
159
+ return trailingEdge(time)
160
+ }
161
+ // Restart the timer.
162
+ timerId = startTimer(timerExpired, remainingWait(time))
163
+ }
164
+
165
+ function trailingEdge(time) {
166
+ timerId = undefined
167
+
168
+ // Only invoke if we have `lastArgs` which means `func` has been
169
+ // debounced at least once.
170
+ if (trailing && lastArgs) {
171
+ return invokeFunc(time)
172
+ }
173
+ lastArgs = lastThis = undefined
174
+ return result
175
+ }
176
+
177
+ function cancel() {
178
+ if (timerId !== undefined) {
179
+ cancelTimer(timerId)
180
+ }
181
+ lastInvokeTime = 0
182
+ lastArgs = lastCallTime = lastThis = timerId = undefined
183
+ }
184
+
185
+ function flush() {
186
+ return timerId === undefined ? result : trailingEdge(Date.now())
187
+ }
188
+
189
+ function pending() {
190
+ return timerId !== undefined
191
+ }
192
+
193
+ function debounced(...args) {
194
+ const time = Date.now()
195
+ const isInvoking = shouldInvoke(time)
196
+
197
+ lastArgs = args
198
+ lastThis = this
199
+ lastCallTime = time
200
+
201
+ if (isInvoking) {
202
+ if (timerId === undefined) {
203
+ return leadingEdge(lastCallTime)
204
+ }
205
+ if (maxing) {
206
+ // Handle invocations in a tight loop.
207
+ timerId = startTimer(timerExpired, wait)
208
+ return invokeFunc(lastCallTime)
209
+ }
210
+ }
211
+ if (timerId === undefined) {
212
+ timerId = startTimer(timerExpired, wait)
213
+ }
214
+ return result
215
+ }
216
+ debounced.cancel = cancel
217
+ debounced.flush = flush
218
+ debounced.pending = pending
219
+ return debounced
220
+ }
221
+
222
+ export default debounce
223
+ /* eslint-enable */
@@ -21,24 +21,21 @@ export const Console = {
21
21
  };
22
22
 
23
23
  export function getQuantity(input) {
24
- let output;
24
+ let output = null;
25
25
  if (typeof input === 'string' || typeof input === 'number') {
26
- const match = (/^(normal|(-*\d+(?:\.\d+)?)(px|%)?)$/).exec(input);
26
+ const match = /^(normal|(-*\d+(?:\.\d+)?)(px|%)?)$/.exec(input);
27
27
  output = match ? { value: +match[2], unit: match[3] || undefined } : null;
28
- } else {
29
- output = null;
30
28
  }
29
+
31
30
  return output;
32
31
  }
33
32
 
34
33
  export function getSize(size) {
35
- let sizeValue;
36
-
34
+ let sizeValue = '100%';
37
35
  if (size) {
38
36
  sizeValue = size.unit ? size.value + size.unit : `${size.value}px`;
39
- } else {
40
- sizeValue = '100%';
41
37
  }
38
+
42
39
  return sizeValue;
43
40
  }
44
41
 
@@ -46,7 +43,7 @@ export function getMatchedComponentsDownward(context, componentName) {
46
43
  const children = context.$children;
47
44
  const result = [];
48
45
  if (!children) {
49
- return [];
46
+ return result;
50
47
  }
51
48
  for (let i = 0; i < children.length; i++) {
52
49
  const v = children[i];
@@ -74,22 +71,59 @@ export function getMatchedComponentUpward(context, componentName) {
74
71
  return parent;
75
72
  }
76
73
 
74
+ export function truthyNumber(v) {
75
+ return typeof v === 'number' && !Number.isNaN(v);
76
+ }
77
+
78
+ export function truthy(...args) {
79
+ return args.every(truthyNumber);
80
+ }
81
+
77
82
  export function convertToPercent(value, totalValue) {
78
- if (!value || !totalValue) {
83
+ const res = (value / totalValue) * 100;
84
+ if (!truthy(value, totalValue, res) || value === 0 || totalValue === 0) {
79
85
  return 0;
80
86
  }
81
87
 
82
- return +((value / totalValue) * 100).toFixed(2);
88
+ return res.toFixed(2);
83
89
  }
84
90
 
85
91
  export function convertToValue(value, totalValue) {
86
- let result = 0;
87
-
88
- if (!value || !totalValue) {
89
- return result;
92
+ const res = (value / 100) * totalValue;
93
+ if (!truthy(value, totalValue, res) || value === 0 || totalValue === 0) {
94
+ return 0;
90
95
  }
91
96
 
92
- result = (value / 100) * totalValue;
97
+ return res.toFixed(2);
98
+ }
99
+
100
+ export function millions(v) {
101
+ return truthy(v) ? 1e6 * v : 0;
102
+ }
103
+
104
+ export function billions(v) {
105
+ return truthy(v) ? 1e9 * v : 0;
106
+ }
107
+
108
+ export function trillion(v) {
109
+ return truthy(v) ? 1e12 * v : 0;
110
+ }
111
+
112
+ export function quadrillion(v) {
113
+ return truthy(v) ? 1e15 * v : 0;
114
+ }
115
+
116
+ export function numberWithComma(v) {
117
+ const reg = /\B(?=(\d{3})+(?!\d))/g;
118
+
119
+ if (truthy(v)) {
120
+ if (Number.isInteger(v)) {
121
+ return v.toString().replace(reg, ',');
122
+ }
123
+
124
+ const part = v.toString().split('.');
125
+ return part[0].replace(reg, ',') + (part[1] ? `.${part[1]}` : '');
126
+ }
93
127
 
94
- return +result.toFixed(2);
128
+ return false;
95
129
  }
@@ -0,0 +1,83 @@
1
+ import debounce from './utils.debounce';
2
+
3
+ /**
4
+ * Original Code
5
+ * https://github.com/lodash/lodash/blob/es/throttle.js
6
+ * lodash/throttle.js
7
+ */
8
+
9
+ function isObject(value) {
10
+ const type = typeof value;
11
+ return value != null && (type === 'object' || type === 'function');
12
+ }
13
+
14
+ /** Error message constants. */
15
+ const FUNC_ERROR_TEXT = 'Expected a function';
16
+
17
+ /**
18
+ * Creates a throttled function that only invokes `func` at most once per
19
+ * every `wait` milliseconds. The throttled function comes with a `cancel`
20
+ * method to cancel delayed `func` invocations and a `flush` method to
21
+ * immediately invoke them. Provide `options` to indicate whether `func`
22
+ * should be invoked on the leading and/or trailing edge of the `wait`
23
+ * timeout. The `func` is invoked with the last arguments provided to the
24
+ * throttled function. Subsequent calls to the throttled function return the
25
+ * result of the last `func` invocation.
26
+ *
27
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
28
+ * invoked on the trailing edge of the timeout only if the throttled function
29
+ * is invoked more than once during the `wait` timeout.
30
+ *
31
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
32
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
33
+ *
34
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
35
+ * for details over the differences between `_.throttle` and `_.debounce`.
36
+ *
37
+ * @static
38
+ * @memberOf _
39
+ * @since 0.1.0
40
+ * @category Function
41
+ * @param {Function} func The function to throttle.
42
+ * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
43
+ * @param {Object} [options={}] The options object.
44
+ * @param {boolean} [options.leading=true]
45
+ * Specify invoking on the leading edge of the timeout.
46
+ * @param {boolean} [options.trailing=true]
47
+ * Specify invoking on the trailing edge of the timeout.
48
+ * @returns {Function} Returns the new throttled function.
49
+ * @example
50
+ *
51
+ * // Avoid excessively updating the position while scrolling.
52
+ * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
53
+ *
54
+ * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
55
+ * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
56
+ * jQuery(element).on('click', throttled);
57
+ *
58
+ * // Cancel the trailing throttled invocation.
59
+ * jQuery(window).on('popstate', throttled.cancel);
60
+ */
61
+ /* eslint-disable */
62
+ function throttle(func, wait, options) {
63
+ let leading = true;
64
+ let trailing = true;
65
+
66
+ if (typeof func != 'function') {
67
+ throw new TypeError(FUNC_ERROR_TEXT);
68
+ }
69
+
70
+ if (isObject(options)) {
71
+ leading = 'leading' in options ? !!options.leading : leading;
72
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
73
+ }
74
+
75
+ return debounce(func, wait, {
76
+ 'leading': leading,
77
+ 'maxWait': wait,
78
+ 'trailing': trailing
79
+ });
80
+ }
81
+
82
+ export default throttle;
83
+ /* eslint-enable */
@@ -0,0 +1,18 @@
1
+ function findComponentUpward(context, componentName, componentNames) {
2
+ let componentNamesTemp = componentNames;
3
+ if (typeof componentName === 'string') {
4
+ componentNamesTemp = [componentName];
5
+ } else {
6
+ componentNamesTemp = componentName;
7
+ }
8
+
9
+ let parent = context.$parent;
10
+ let name = parent.$options.name;
11
+ while (parent && (!name || componentNamesTemp.indexOf(name) < 0)) {
12
+ parent = parent.$parent;
13
+ if (parent) name = parent.$options.name;
14
+ }
15
+ return parent;
16
+ }
17
+ // eslint-disable-next-line import/prefer-default-export
18
+ export { findComponentUpward };