doway-coms 1.1.66 → 1.1.67

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doway-coms",
3
- "version": "1.1.66",
3
+ "version": "1.1.67",
4
4
  "description": "doway组件库",
5
5
  "author": "dowaysoft",
6
6
  "main": "packages/index.js",
package/vue.config.js ADDED
@@ -0,0 +1,60 @@
1
+ // vue.config.js 文件
2
+ const ExtractTextPlugin = require('extract-text-webpack-plugin')
3
+ const path = require('path')
4
+ function resolve(dir) {
5
+ return path.join(__dirname, dir)
6
+ }
7
+ module.exports = {
8
+ pages: {
9
+ index: {
10
+ entry: "examples/main.js",
11
+ template: "public/index.html",
12
+ filename: "index.html"
13
+ }
14
+ },
15
+ // configureWebpack: () => {
16
+ // new ExtractTextPlugin('libs/test.css')
17
+ // },
18
+ // css: {
19
+ // extract: true, // 是否使用css分离插件 ExtractTextPlugin
20
+ // sourceMap: false, // 开启 CSS source maps?
21
+ // // loaderOptions: {
22
+ // // less: {
23
+ // // javascriptEnabled: true //less 配置
24
+ // // }
25
+ // // }, // css预设器配置项
26
+ // modules: false // 启用 CSS modules for all css / pre-processor files.
27
+ // },
28
+ // 扩展 webpack 配置,使 packages 加入编译
29
+ /* chainWebpack 是一个函数,会接收一个基于 webpack-chain 的 ChainableConfig 实例。容许对内部的 webpack 配置进行更细粒度的修改。 */
30
+ chainWebpack: config => {
31
+ config.plugins.delete('preload') // TODO: need test
32
+ config.plugins.delete('prefetch') // TODO: need test
33
+ config.resolve.alias.set('../../tools/dom', resolve('packages/utils/dom.js'))
34
+ // config.module.rule('/\.less$/').use(ExtractTextPlugin.extract({
35
+ // fallback:'vue-style-loader',
36
+ // use:['css-loader',
37
+ // 'less-loader']
38
+ // })).loader('less-loader','css-loader')
39
+
40
+
41
+
42
+ config.module
43
+ .rule('js')
44
+ .include
45
+ .add(__dirname + 'packages') // 注意这里须要绝对路径,全部要拼接__dirname
46
+ .end()
47
+ .use('babel')
48
+ .loader('babel-loader')
49
+ .tap(options => {
50
+ // 修改它的选项...
51
+ return options
52
+ })
53
+
54
+
55
+ }
56
+ }
57
+
58
+
59
+
60
+
@@ -1,181 +0,0 @@
1
- import XEUtils from 'xe-utils'
2
-
3
- export const browse = XEUtils.browse()
4
- const reClsMap = {}
5
-
6
- function getClsRE (cls) {
7
- if (!reClsMap[cls]) {
8
- reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g')
9
- }
10
- return reClsMap[cls]
11
- }
12
-
13
- function getNodeOffset (elem, container, rest) {
14
- if (elem) {
15
- const parentElem = elem.parentNode
16
- rest.top += elem.offsetTop
17
- rest.left += elem.offsetLeft
18
- if (parentElem && parentElem !== document.documentElement && parentElem !== document.body) {
19
- rest.top -= parentElem.scrollTop
20
- rest.left -= parentElem.scrollLeft
21
- }
22
- if (container && (elem === container || elem.offsetParent === container) ? 0 : elem.offsetParent) {
23
- return getNodeOffset(elem.offsetParent, container, rest)
24
- }
25
- }
26
- return rest
27
- }
28
-
29
- function isScale (val) {
30
- return val && /^\d+%$/.test(val)
31
- }
32
-
33
- function hasClass (elem, cls) {
34
- return elem && elem.className && elem.className.match && elem.className.match(getClsRE(cls))
35
- }
36
-
37
- function removeClass (elem, cls) {
38
- if (elem && hasClass(elem, cls)) {
39
- elem.className = elem.className.replace(getClsRE(cls), '')
40
- }
41
- }
42
-
43
- function getDomNode () {
44
- const documentElement = document.documentElement
45
- const bodyElem = document.body
46
- return {
47
- scrollTop: documentElement.scrollTop || bodyElem.scrollTop,
48
- scrollLeft: documentElement.scrollLeft || bodyElem.scrollLeft,
49
- visibleHeight: documentElement.clientHeight || bodyElem.clientHeight,
50
- visibleWidth: documentElement.clientWidth || bodyElem.clientWidth
51
- }
52
- }
53
-
54
- export function getOffsetHeight (elem) {
55
- return elem ? elem.offsetHeight : 0
56
- }
57
-
58
- export function getPaddingTopBottomSize (elem) {
59
- if (elem) {
60
- const computedStyle = getComputedStyle(elem)
61
- const paddingTop = XEUtils.toNumber(computedStyle.paddingTop)
62
- const paddingBottom = XEUtils.toNumber(computedStyle.paddingBottom)
63
- return paddingTop + paddingBottom
64
- }
65
- return 0
66
- }
67
-
68
- export function setScrollTop (elem, scrollTop) {
69
- if (elem) {
70
- elem.scrollTop = scrollTop
71
- }
72
- }
73
-
74
- export function setScrollLeft (elem, scrollLeft) {
75
- if (elem) {
76
- elem.scrollLeft = scrollLeft
77
- }
78
- }
79
-
80
- // export function setScrollLeftAndTop (elem, scrollLeft, scrollTop) {
81
- // if (elem) {
82
- // elem.scrollLeft = scrollLeft
83
- // elem.scrollTop = scrollTop
84
- // }
85
- // }
86
-
87
- function isNodeElement (elem) {
88
- return elem && elem.nodeType === 1
89
- }
90
-
91
- export const DomTools = {
92
- browse,
93
- isPx (val) {
94
- return val && /^\d+(px)?$/.test(val)
95
- },
96
- isScale,
97
- hasClass,
98
- removeClass,
99
- addClass (elem, cls) {
100
- if (elem && !hasClass(elem, cls)) {
101
- removeClass(elem, cls)
102
- elem.className = `${elem.className} ${cls}`
103
- }
104
- },
105
- updateCellTitle (overflowElem, column) {
106
- const content = column.type === 'html' ? overflowElem.innerText : overflowElem.textContent
107
- if (overflowElem.getAttribute('title') !== content) {
108
- overflowElem.setAttribute('title', content)
109
- }
110
- },
111
- getDomNode,
112
- /**
113
- * 检查触发源是否属于目标节点
114
- */
115
- getEventTargetNode (evnt, container, queryCls, queryMethod) {
116
- let targetElem
117
- let target =
118
- evnt.target.shadowRoot && evnt.composed
119
- ? evnt.composedPath()[0] || evnt.target
120
- : evnt.target
121
- while (target && target.nodeType && target !== document) {
122
- if (queryCls && hasClass(target, queryCls) && (!queryMethod || queryMethod(target))) {
123
- targetElem = target
124
- } else if (target === container) {
125
- return { flag: queryCls ? !!targetElem : true, container, targetElem: targetElem }
126
- }
127
- target = target.parentNode
128
- }
129
- return { flag: false }
130
- },
131
- /**
132
- * 获取元素相对于 document 的位置
133
- */
134
- getOffsetPos (elem, container) {
135
- return getNodeOffset(elem, container, { left: 0, top: 0 })
136
- },
137
- getAbsolutePos (elem) {
138
- const bounding = elem.getBoundingClientRect()
139
- const boundingTop = bounding.top
140
- const boundingLeft = bounding.left
141
- const { scrollTop, scrollLeft, visibleHeight, visibleWidth } = getDomNode()
142
- return { boundingTop, top: scrollTop + boundingTop, boundingLeft, left: scrollLeft + boundingLeft, visibleHeight, visibleWidth }
143
- },
144
- scrollToView (elem) {
145
- const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
146
- const scrollIntoView = 'scrollIntoView'
147
- if (elem) {
148
- if (elem[scrollIntoViewIfNeeded]) {
149
- elem[scrollIntoViewIfNeeded]()
150
- } else if (elem[scrollIntoView]) {
151
- elem[scrollIntoView]()
152
- }
153
- }
154
- },
155
- triggerEvent (targetElem, type) {
156
- if (targetElem) {
157
- targetElem.dispatchEvent(new Event(type))
158
- }
159
- },
160
- calcHeight ($xetable, key) {
161
- const val = $xetable[key]
162
- let num = 0
163
- if (val) {
164
- if (val === 'auto') {
165
- num = $xetable.parentHeight
166
- } else {
167
- const excludeHeight = $xetable.getExcludeHeight()
168
- if (isScale(val)) {
169
- num = Math.floor((XEUtils.toInteger(val) || 1) / 100 * $xetable.parentHeight)
170
- } else {
171
- num = XEUtils.toNumber(val)
172
- }
173
- num = Math.max(40, num - excludeHeight)
174
- }
175
- }
176
- return num
177
- },
178
- isNodeElement
179
- }
180
-
181
- export default DomTools