vxe-table 4.18.5 → 4.18.7
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/LICENSE +20 -20
- package/README.en.md +118 -118
- package/README.ja-JP.md +117 -117
- package/README.md +268 -268
- package/README.zh-TW.md +117 -117
- package/es/style.css +1 -1
- package/es/table/src/table.js +54 -0
- package/es/table/src/util.js +3 -4
- package/es/table/style.css +48 -18
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +48 -18
- package/lib/index.common.js +1 -2
- package/lib/index.umd.js +2832 -2732
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/src/table.js +5 -4
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +4 -6
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +48 -18
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/v-x-e-table/index.js +1 -2
- package/lib/v-x-e-table/index.min.js +1 -1
- package/lib/vxe-colgroup/index.js +1 -2
- package/lib/vxe-colgroup/index.min.js +1 -1
- package/lib/vxe-column/index.js +1 -2
- package/lib/vxe-column/index.min.js +1 -1
- package/lib/vxe-grid/index.js +1 -2
- package/lib/vxe-grid/index.min.js +1 -1
- package/lib/vxe-table/index.js +1 -2
- package/lib/vxe-table/index.min.js +1 -1
- package/lib/vxe-table/style/style.css +48 -18
- package/lib/vxe-toolbar/index.js +1 -2
- package/lib/vxe-toolbar/index.min.js +1 -1
- package/lib/vxe-ui/index.js +1 -2
- package/lib/vxe-ui/index.min.js +1 -1
- package/lib/vxe-v-x-e-table/index.js +1 -2
- package/lib/vxe-v-x-e-table/index.min.js +1 -1
- package/package.json +91 -91
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +43 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +19 -19
- package/packages/grid/src/grid.ts +1768 -1768
- package/packages/grid/src/props.ts +23 -23
- package/packages/index.ts +4 -4
- package/packages/locale/lang/ar-EG.ts +832 -832
- package/packages/locale/lang/de-DE.ts +832 -832
- package/packages/locale/lang/en-US.ts +832 -832
- package/packages/locale/lang/es-ES.ts +832 -832
- package/packages/locale/lang/fr-FR.ts +832 -832
- package/packages/locale/lang/hu-HU.ts +832 -832
- package/packages/locale/lang/hy-AM.ts +832 -832
- package/packages/locale/lang/id-ID.ts +832 -832
- package/packages/locale/lang/it-IT.ts +832 -832
- package/packages/locale/lang/ja-JP.ts +832 -832
- package/packages/locale/lang/ko-KR.ts +832 -832
- package/packages/locale/lang/ms-MY.ts +832 -832
- package/packages/locale/lang/nb-NO.ts +832 -832
- package/packages/locale/lang/pt-BR.ts +832 -832
- package/packages/locale/lang/ru-RU.ts +832 -832
- package/packages/locale/lang/th-TH.ts +832 -832
- package/packages/locale/lang/ug-CN.ts +832 -832
- package/packages/locale/lang/uk-UA.ts +832 -832
- package/packages/locale/lang/uz-UZ.ts +832 -832
- package/packages/locale/lang/vi-VN.ts +832 -832
- package/packages/locale/lang/zh-CHT.ts +832 -832
- package/packages/locale/lang/zh-CN.ts +832 -832
- package/packages/locale/lang/zh-HK.ts +3 -3
- package/packages/locale/lang/zh-MO.ts +3 -3
- package/packages/locale/lang/zh-TC.ts +3 -3
- package/packages/locale/lang/zh-TW.ts +3 -3
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +359 -359
- package/packages/table/module/custom/panel.ts +1331 -1331
- package/packages/table/module/edit/hook.ts +1032 -1032
- package/packages/table/module/export/export-panel.ts +567 -567
- package/packages/table/module/export/hook.ts +1654 -1654
- package/packages/table/module/export/import-panel.ts +266 -266
- package/packages/table/module/export/util.ts +24 -24
- package/packages/table/module/filter/hook.ts +468 -468
- package/packages/table/module/filter/panel.ts +301 -301
- package/packages/table/module/keyboard/hook.ts +495 -495
- package/packages/table/module/menu/hook.ts +325 -325
- package/packages/table/module/menu/panel.ts +201 -201
- package/packages/table/module/validator/hook.ts +631 -631
- package/packages/table/render/index.ts +1440 -1440
- package/packages/table/src/body.ts +932 -932
- package/packages/table/src/cell.ts +1290 -1290
- package/packages/table/src/column.ts +190 -190
- package/packages/table/src/columnInfo.ts +225 -225
- package/packages/table/src/emits.ts +123 -123
- package/packages/table/src/footer.ts +368 -368
- package/packages/table/src/group.ts +59 -59
- package/packages/table/src/header.ts +559 -559
- package/packages/table/src/props.ts +324 -324
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +14004 -13947
- package/packages/table/src/use/cell-view.ts +44 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1064 -1064
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +701 -701
- package/packages/ui/index.ts +530 -530
- package/packages/ui/src/anime.ts +52 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +236 -236
- package/packages/ui/src/log.ts +8 -8
- package/packages/ui/src/utils.ts +56 -56
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +4 -4
- package/packages/v-x-e-table/index.ts +4 -4
- package/styles/all.scss +7 -7
- package/styles/base.scss +16 -16
- package/styles/components/grid.scss +89 -89
- package/styles/components/icon.scss +225 -225
- package/styles/components/old-icon.scss +715 -715
- package/styles/components/table-module/all.scss +6 -6
- package/styles/components/table-module/custom.scss +527 -527
- package/styles/components/table-module/export.scss +130 -130
- package/styles/components/table-module/filter.scss +130 -130
- package/styles/components/table-module/menu.scss +81 -81
- package/styles/components/table.scss +2679 -2679
- package/styles/components/toolbar.scss +119 -119
- package/styles/default.scss +2 -2
- package/styles/helpers/baseMixin.scss +95 -95
- package/styles/index.scss +4 -4
- package/styles/modules.scss +5 -5
- package/styles/theme/base.scss +93 -93
- package/styles/theme/dark.scss +49 -49
- package/styles/theme/light.scss +44 -44
- package/styles/variable.scss +43 -43
- package/types/all.d.ts +37 -37
- package/types/index.d.ts +4 -4
- /package/es/{iconfont.1773710736571.ttf → iconfont.1773991907408.ttf} +0 -0
- /package/es/{iconfont.1773710736571.woff → iconfont.1773991907408.woff} +0 -0
- /package/es/{iconfont.1773710736571.woff2 → iconfont.1773991907408.woff2} +0 -0
- /package/lib/{iconfont.1773710736571.ttf → iconfont.1773991907408.ttf} +0 -0
- /package/lib/{iconfont.1773710736571.woff → iconfont.1773991907408.woff} +0 -0
- /package/lib/{iconfont.1773710736571.woff2 → iconfont.1773991907408.woff2} +0 -0
package/packages/ui/src/anime.ts
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
import XEUtils from 'xe-utils'
|
|
3
|
-
import { addClass, removeClass } from './dom'
|
|
4
|
-
|
|
5
|
-
const rowMoveCls = 'row--drag-move'
|
|
6
|
-
const colMoveClass = 'col--drag-move'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 上下拖拽
|
|
10
|
-
*/
|
|
11
|
-
export function moveRowAnimateToTb (elemList: NodeListOf<HTMLElement> | HTMLDivElement[], offsetTop: number) {
|
|
12
|
-
XEUtils.arrayEach(elemList, trEl => {
|
|
13
|
-
trEl.style.transform = `translateY(${offsetTop}px)`
|
|
14
|
-
})
|
|
15
|
-
requestAnimationFrame(() => {
|
|
16
|
-
XEUtils.arrayEach(elemList, trEl => {
|
|
17
|
-
addClass(trEl, rowMoveCls)
|
|
18
|
-
trEl.style.transform = ''
|
|
19
|
-
})
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function clearRowAnimate (elem: HTMLElement | undefined, clss: string[]) {
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (elem) {
|
|
26
|
-
XEUtils.arrayEach(elem.querySelectorAll(clss.map(cls => `${cls}.${rowMoveCls}`).join(',')), elem => removeClass(elem, rowMoveCls))
|
|
27
|
-
}
|
|
28
|
-
}, 500)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 左右拖拽
|
|
33
|
-
*/
|
|
34
|
-
export function moveColAnimateToLr (elemList: NodeListOf<HTMLElement> | HTMLDivElement[], offsetLeft: number) {
|
|
35
|
-
XEUtils.arrayEach(elemList, trEl => {
|
|
36
|
-
trEl.style.transform = `translateX(${offsetLeft}px)`
|
|
37
|
-
})
|
|
38
|
-
requestAnimationFrame(() => {
|
|
39
|
-
XEUtils.arrayEach(elemList, trEl => {
|
|
40
|
-
addClass(trEl, colMoveClass)
|
|
41
|
-
trEl.style.transform = ''
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function clearColAnimate (elem: HTMLElement | undefined, clss: string[]) {
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
if (elem) {
|
|
49
|
-
XEUtils.arrayEach(elem.querySelectorAll(clss.map(cls => `${cls}.${rowMoveCls}`).join(',')), elem => removeClass(elem, colMoveClass))
|
|
50
|
-
}
|
|
51
|
-
}, 500)
|
|
52
|
-
}
|
|
1
|
+
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
import { addClass, removeClass } from './dom'
|
|
4
|
+
|
|
5
|
+
const rowMoveCls = 'row--drag-move'
|
|
6
|
+
const colMoveClass = 'col--drag-move'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 上下拖拽
|
|
10
|
+
*/
|
|
11
|
+
export function moveRowAnimateToTb (elemList: NodeListOf<HTMLElement> | HTMLDivElement[], offsetTop: number) {
|
|
12
|
+
XEUtils.arrayEach(elemList, trEl => {
|
|
13
|
+
trEl.style.transform = `translateY(${offsetTop}px)`
|
|
14
|
+
})
|
|
15
|
+
requestAnimationFrame(() => {
|
|
16
|
+
XEUtils.arrayEach(elemList, trEl => {
|
|
17
|
+
addClass(trEl, rowMoveCls)
|
|
18
|
+
trEl.style.transform = ''
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function clearRowAnimate (elem: HTMLElement | undefined, clss: string[]) {
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (elem) {
|
|
26
|
+
XEUtils.arrayEach(elem.querySelectorAll(clss.map(cls => `${cls}.${rowMoveCls}`).join(',')), elem => removeClass(elem, rowMoveCls))
|
|
27
|
+
}
|
|
28
|
+
}, 500)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 左右拖拽
|
|
33
|
+
*/
|
|
34
|
+
export function moveColAnimateToLr (elemList: NodeListOf<HTMLElement> | HTMLDivElement[], offsetLeft: number) {
|
|
35
|
+
XEUtils.arrayEach(elemList, trEl => {
|
|
36
|
+
trEl.style.transform = `translateX(${offsetLeft}px)`
|
|
37
|
+
})
|
|
38
|
+
requestAnimationFrame(() => {
|
|
39
|
+
XEUtils.arrayEach(elemList, trEl => {
|
|
40
|
+
addClass(trEl, colMoveClass)
|
|
41
|
+
trEl.style.transform = ''
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function clearColAnimate (elem: HTMLElement | undefined, clss: string[]) {
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
if (elem) {
|
|
49
|
+
XEUtils.arrayEach(elem.querySelectorAll(clss.map(cls => `${cls}.${rowMoveCls}`).join(',')), elem => removeClass(elem, colMoveClass))
|
|
50
|
+
}
|
|
51
|
+
}, 500)
|
|
52
|
+
}
|
package/packages/ui/src/comp.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { defineComponent } from 'vue'
|
|
2
|
-
|
|
3
|
-
export const defineVxeComponent = defineComponent
|
|
1
|
+
import { defineComponent } from 'vue'
|
|
2
|
+
|
|
3
|
+
export const defineVxeComponent = defineComponent
|
package/packages/ui/src/dom.ts
CHANGED
|
@@ -1,236 +1,236 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
|
|
3
|
-
const reClsMap: { [key: string]: any } = {}
|
|
4
|
-
|
|
5
|
-
let tpImgEl: HTMLImageElement | undefined
|
|
6
|
-
|
|
7
|
-
export function initTpImg () {
|
|
8
|
-
if (!tpImgEl) {
|
|
9
|
-
tpImgEl = new Image()
|
|
10
|
-
tpImgEl.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
|
11
|
-
}
|
|
12
|
-
return tpImgEl
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function getTpImg () {
|
|
16
|
-
if (!tpImgEl) {
|
|
17
|
-
return initTpImg()
|
|
18
|
-
}
|
|
19
|
-
return tpImgEl
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getPropClass (property: any, params: any) {
|
|
23
|
-
return property ? XEUtils.isFunction(property) ? property(params) : property : ''
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getClsRE (cls: any) {
|
|
27
|
-
if (!reClsMap[cls]) {
|
|
28
|
-
reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g')
|
|
29
|
-
}
|
|
30
|
-
return reClsMap[cls]
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getNodeOffset (elem: any, container: any, rest: any): any {
|
|
34
|
-
if (elem) {
|
|
35
|
-
const parentElem = elem.parentNode
|
|
36
|
-
rest.top += elem.offsetTop
|
|
37
|
-
rest.left += elem.offsetLeft
|
|
38
|
-
if (parentElem && parentElem !== document.documentElement && parentElem !== document.body) {
|
|
39
|
-
rest.top -= parentElem.scrollTop
|
|
40
|
-
rest.left -= parentElem.scrollLeft
|
|
41
|
-
}
|
|
42
|
-
if (container && (elem === container || elem.offsetParent === container) ? 0 : elem.offsetParent) {
|
|
43
|
-
return getNodeOffset(elem.offsetParent, container, rest)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return rest
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isPx (val: any) {
|
|
50
|
-
return val && /^\d+(\.\d+)?(px)?$/.test(val)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function isScale (val: any) {
|
|
54
|
-
return val && /^\d+(\.\d+)?%$/.test(val)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function hasClass (elem: any, cls: any) {
|
|
58
|
-
return !!(elem && elem.className && elem.className.match && elem.className.match(getClsRE(cls)))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function removeClass (elem: any, cls: any) {
|
|
62
|
-
if (elem && hasClass(elem, cls)) {
|
|
63
|
-
elem.className = elem.className.replace(getClsRE(cls), '')
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function addClass (elem: any, cls: string) {
|
|
68
|
-
if (elem && !hasClass(elem, cls)) {
|
|
69
|
-
removeClass(elem, cls)
|
|
70
|
-
elem.className = `${elem.className} ${cls}`
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function hasControlKey (evnt: KeyboardEvent | MouseEvent | DragEvent) {
|
|
75
|
-
return evnt.ctrlKey || evnt.metaKey
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function toCssUnit (val?: number | string, unit = 'px') {
|
|
79
|
-
if (XEUtils.isNumber(val) || /^\d+$/.test(`${val}`)) {
|
|
80
|
-
return `${val}${unit}`
|
|
81
|
-
}
|
|
82
|
-
return `${val || ''}`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function queryElement (elem: HTMLTableCellElement, selector: string) {
|
|
86
|
-
if (elem) {
|
|
87
|
-
return elem.querySelector<HTMLElement>(selector)
|
|
88
|
-
}
|
|
89
|
-
return null
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function getDomNode () {
|
|
93
|
-
const documentElement = document.documentElement
|
|
94
|
-
const bodyElem = document.body
|
|
95
|
-
return {
|
|
96
|
-
scrollTop: documentElement.scrollTop || bodyElem.scrollTop,
|
|
97
|
-
scrollLeft: documentElement.scrollLeft || bodyElem.scrollLeft,
|
|
98
|
-
visibleHeight: documentElement.clientHeight || bodyElem.clientHeight,
|
|
99
|
-
visibleWidth: documentElement.clientWidth || bodyElem.clientWidth
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function getOffsetHeight (elem?: HTMLElement) {
|
|
104
|
-
return elem ? elem.offsetHeight : 0
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function getPaddingTopBottomSize (elem: HTMLElement) {
|
|
108
|
-
if (elem) {
|
|
109
|
-
const computedStyle = getComputedStyle(elem)
|
|
110
|
-
const paddingTop = XEUtils.toNumber(computedStyle.paddingTop)
|
|
111
|
-
const paddingBottom = XEUtils.toNumber(computedStyle.paddingBottom)
|
|
112
|
-
return paddingTop + paddingBottom
|
|
113
|
-
}
|
|
114
|
-
return 0
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export function setScrollTop (elem: HTMLElement | null | undefined, scrollTop: number) {
|
|
118
|
-
if (elem) {
|
|
119
|
-
elem.scrollTop = scrollTop
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function setScrollLeft (elem: HTMLElement | null | undefined, scrollLeft: number) {
|
|
124
|
-
if (elem) {
|
|
125
|
-
elem.scrollLeft = scrollLeft
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// export function setScrollLeftAndTop (elem: HTMLElement | null, scrollLeft: number, scrollTop: number) {
|
|
130
|
-
// if (elem) {
|
|
131
|
-
// elem.scrollLeft = scrollLeft
|
|
132
|
-
// elem.scrollTop = scrollTop
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
|
|
136
|
-
export function updateCellTitle (overflowElem: any, column: any) {
|
|
137
|
-
const content = column.type === 'html' ? overflowElem.innerText : overflowElem.textContent
|
|
138
|
-
if (overflowElem.getAttribute('title') !== content) {
|
|
139
|
-
overflowElem.setAttribute('title', content)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export function checkTargetElement (target: HTMLElement | EventTarget | null, exEls: (HTMLElement | null)[], endEl?: HTMLElement | EventTarget | null) {
|
|
144
|
-
let targetEl = target
|
|
145
|
-
if (!exEls || !exEls.length) {
|
|
146
|
-
return false
|
|
147
|
-
}
|
|
148
|
-
const [exEl1, exEl2, exEl3] = exEls
|
|
149
|
-
while (targetEl) {
|
|
150
|
-
if (exEl1 === targetEl || (exEl2 && targetEl === exEl2) || (exEl3 && targetEl === exEl3)) {
|
|
151
|
-
return true
|
|
152
|
-
}
|
|
153
|
-
if (endEl && targetEl === endEl) {
|
|
154
|
-
return false
|
|
155
|
-
}
|
|
156
|
-
targetEl = (targetEl as HTMLElement).parentElement
|
|
157
|
-
}
|
|
158
|
-
return false
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 检查触发源是否属于目标节点
|
|
163
|
-
*/
|
|
164
|
-
export function getEventTargetNode (evnt: any, container: any, queryCls?: string, queryMethod?: (target: Element) => boolean) {
|
|
165
|
-
let targetElem
|
|
166
|
-
let target = (evnt.target.shadowRoot && evnt.composed) ? (evnt.composedPath()[0] || evnt.target) : evnt.target
|
|
167
|
-
while (target && target.nodeType && target !== document) {
|
|
168
|
-
if (queryCls && hasClass(target, queryCls) && (!queryMethod || queryMethod(target))) {
|
|
169
|
-
targetElem = target
|
|
170
|
-
} else if (target === container) {
|
|
171
|
-
return { flag: queryCls ? !!targetElem : true, container, targetElem: targetElem }
|
|
172
|
-
}
|
|
173
|
-
target = target.parentNode
|
|
174
|
-
}
|
|
175
|
-
return { flag: false }
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* 获取元素相对于 document 的位置
|
|
180
|
-
*/
|
|
181
|
-
export function getOffsetPos (elem: any, container: any) {
|
|
182
|
-
return getNodeOffset(elem, container, { left: 0, top: 0 })
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function getAbsolutePos (elem: any) {
|
|
186
|
-
const bounding = elem.getBoundingClientRect()
|
|
187
|
-
const boundingTop = bounding.top
|
|
188
|
-
const boundingLeft = bounding.left
|
|
189
|
-
const { scrollTop, scrollLeft, visibleHeight, visibleWidth } = getDomNode()
|
|
190
|
-
return { boundingTop, top: scrollTop + boundingTop, boundingLeft, left: scrollLeft + boundingLeft, visibleHeight, visibleWidth }
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
|
|
194
|
-
const scrollIntoView = 'scrollIntoView'
|
|
195
|
-
|
|
196
|
-
export function scrollToView (elem: any) {
|
|
197
|
-
if (elem) {
|
|
198
|
-
if (elem[scrollIntoViewIfNeeded]) {
|
|
199
|
-
elem[scrollIntoViewIfNeeded]()
|
|
200
|
-
} else if (elem[scrollIntoView]) {
|
|
201
|
-
elem[scrollIntoView]()
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export function triggerEvent (targetElem: Element, type: string) {
|
|
207
|
-
if (targetElem) {
|
|
208
|
-
targetElem.dispatchEvent(new Event(type))
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function isNodeElement (elem: any): elem is HTMLElement {
|
|
213
|
-
return elem && elem.nodeType === 1
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function scrollTopTo (diffNum: number, cb: (progress: number) => void) {
|
|
217
|
-
const duration = Math.abs(diffNum)
|
|
218
|
-
const startTime = performance.now()
|
|
219
|
-
let countTop = 0
|
|
220
|
-
const step = (timestamp: number) => {
|
|
221
|
-
let progress = (timestamp - startTime) / duration
|
|
222
|
-
if (progress < 0) {
|
|
223
|
-
progress = 0
|
|
224
|
-
} else if (progress > 1) {
|
|
225
|
-
progress = 1
|
|
226
|
-
}
|
|
227
|
-
const easedProgress = Math.pow(progress, 2)
|
|
228
|
-
const offsetTop = Math.floor((diffNum * easedProgress)) - countTop
|
|
229
|
-
countTop += offsetTop
|
|
230
|
-
cb(offsetTop)
|
|
231
|
-
if (progress < 1) {
|
|
232
|
-
requestAnimationFrame(step)
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
requestAnimationFrame(step)
|
|
236
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
|
|
3
|
+
const reClsMap: { [key: string]: any } = {}
|
|
4
|
+
|
|
5
|
+
let tpImgEl: HTMLImageElement | undefined
|
|
6
|
+
|
|
7
|
+
export function initTpImg () {
|
|
8
|
+
if (!tpImgEl) {
|
|
9
|
+
tpImgEl = new Image()
|
|
10
|
+
tpImgEl.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
|
11
|
+
}
|
|
12
|
+
return tpImgEl
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getTpImg () {
|
|
16
|
+
if (!tpImgEl) {
|
|
17
|
+
return initTpImg()
|
|
18
|
+
}
|
|
19
|
+
return tpImgEl
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getPropClass (property: any, params: any) {
|
|
23
|
+
return property ? XEUtils.isFunction(property) ? property(params) : property : ''
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getClsRE (cls: any) {
|
|
27
|
+
if (!reClsMap[cls]) {
|
|
28
|
+
reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g')
|
|
29
|
+
}
|
|
30
|
+
return reClsMap[cls]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getNodeOffset (elem: any, container: any, rest: any): any {
|
|
34
|
+
if (elem) {
|
|
35
|
+
const parentElem = elem.parentNode
|
|
36
|
+
rest.top += elem.offsetTop
|
|
37
|
+
rest.left += elem.offsetLeft
|
|
38
|
+
if (parentElem && parentElem !== document.documentElement && parentElem !== document.body) {
|
|
39
|
+
rest.top -= parentElem.scrollTop
|
|
40
|
+
rest.left -= parentElem.scrollLeft
|
|
41
|
+
}
|
|
42
|
+
if (container && (elem === container || elem.offsetParent === container) ? 0 : elem.offsetParent) {
|
|
43
|
+
return getNodeOffset(elem.offsetParent, container, rest)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return rest
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function isPx (val: any) {
|
|
50
|
+
return val && /^\d+(\.\d+)?(px)?$/.test(val)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function isScale (val: any) {
|
|
54
|
+
return val && /^\d+(\.\d+)?%$/.test(val)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function hasClass (elem: any, cls: any) {
|
|
58
|
+
return !!(elem && elem.className && elem.className.match && elem.className.match(getClsRE(cls)))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function removeClass (elem: any, cls: any) {
|
|
62
|
+
if (elem && hasClass(elem, cls)) {
|
|
63
|
+
elem.className = elem.className.replace(getClsRE(cls), '')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function addClass (elem: any, cls: string) {
|
|
68
|
+
if (elem && !hasClass(elem, cls)) {
|
|
69
|
+
removeClass(elem, cls)
|
|
70
|
+
elem.className = `${elem.className} ${cls}`
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function hasControlKey (evnt: KeyboardEvent | MouseEvent | DragEvent) {
|
|
75
|
+
return evnt.ctrlKey || evnt.metaKey
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function toCssUnit (val?: number | string, unit = 'px') {
|
|
79
|
+
if (XEUtils.isNumber(val) || /^\d+$/.test(`${val}`)) {
|
|
80
|
+
return `${val}${unit}`
|
|
81
|
+
}
|
|
82
|
+
return `${val || ''}`
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function queryElement (elem: HTMLTableCellElement, selector: string) {
|
|
86
|
+
if (elem) {
|
|
87
|
+
return elem.querySelector<HTMLElement>(selector)
|
|
88
|
+
}
|
|
89
|
+
return null
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function getDomNode () {
|
|
93
|
+
const documentElement = document.documentElement
|
|
94
|
+
const bodyElem = document.body
|
|
95
|
+
return {
|
|
96
|
+
scrollTop: documentElement.scrollTop || bodyElem.scrollTop,
|
|
97
|
+
scrollLeft: documentElement.scrollLeft || bodyElem.scrollLeft,
|
|
98
|
+
visibleHeight: documentElement.clientHeight || bodyElem.clientHeight,
|
|
99
|
+
visibleWidth: documentElement.clientWidth || bodyElem.clientWidth
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function getOffsetHeight (elem?: HTMLElement) {
|
|
104
|
+
return elem ? elem.offsetHeight : 0
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function getPaddingTopBottomSize (elem: HTMLElement) {
|
|
108
|
+
if (elem) {
|
|
109
|
+
const computedStyle = getComputedStyle(elem)
|
|
110
|
+
const paddingTop = XEUtils.toNumber(computedStyle.paddingTop)
|
|
111
|
+
const paddingBottom = XEUtils.toNumber(computedStyle.paddingBottom)
|
|
112
|
+
return paddingTop + paddingBottom
|
|
113
|
+
}
|
|
114
|
+
return 0
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function setScrollTop (elem: HTMLElement | null | undefined, scrollTop: number) {
|
|
118
|
+
if (elem) {
|
|
119
|
+
elem.scrollTop = scrollTop
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function setScrollLeft (elem: HTMLElement | null | undefined, scrollLeft: number) {
|
|
124
|
+
if (elem) {
|
|
125
|
+
elem.scrollLeft = scrollLeft
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// export function setScrollLeftAndTop (elem: HTMLElement | null, scrollLeft: number, scrollTop: number) {
|
|
130
|
+
// if (elem) {
|
|
131
|
+
// elem.scrollLeft = scrollLeft
|
|
132
|
+
// elem.scrollTop = scrollTop
|
|
133
|
+
// }
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
export function updateCellTitle (overflowElem: any, column: any) {
|
|
137
|
+
const content = column.type === 'html' ? overflowElem.innerText : overflowElem.textContent
|
|
138
|
+
if (overflowElem.getAttribute('title') !== content) {
|
|
139
|
+
overflowElem.setAttribute('title', content)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function checkTargetElement (target: HTMLElement | EventTarget | null, exEls: (HTMLElement | null)[], endEl?: HTMLElement | EventTarget | null) {
|
|
144
|
+
let targetEl = target
|
|
145
|
+
if (!exEls || !exEls.length) {
|
|
146
|
+
return false
|
|
147
|
+
}
|
|
148
|
+
const [exEl1, exEl2, exEl3] = exEls
|
|
149
|
+
while (targetEl) {
|
|
150
|
+
if (exEl1 === targetEl || (exEl2 && targetEl === exEl2) || (exEl3 && targetEl === exEl3)) {
|
|
151
|
+
return true
|
|
152
|
+
}
|
|
153
|
+
if (endEl && targetEl === endEl) {
|
|
154
|
+
return false
|
|
155
|
+
}
|
|
156
|
+
targetEl = (targetEl as HTMLElement).parentElement
|
|
157
|
+
}
|
|
158
|
+
return false
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* 检查触发源是否属于目标节点
|
|
163
|
+
*/
|
|
164
|
+
export function getEventTargetNode (evnt: any, container: any, queryCls?: string, queryMethod?: (target: Element) => boolean) {
|
|
165
|
+
let targetElem
|
|
166
|
+
let target = (evnt.target.shadowRoot && evnt.composed) ? (evnt.composedPath()[0] || evnt.target) : evnt.target
|
|
167
|
+
while (target && target.nodeType && target !== document) {
|
|
168
|
+
if (queryCls && hasClass(target, queryCls) && (!queryMethod || queryMethod(target))) {
|
|
169
|
+
targetElem = target
|
|
170
|
+
} else if (target === container) {
|
|
171
|
+
return { flag: queryCls ? !!targetElem : true, container, targetElem: targetElem }
|
|
172
|
+
}
|
|
173
|
+
target = target.parentNode
|
|
174
|
+
}
|
|
175
|
+
return { flag: false }
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* 获取元素相对于 document 的位置
|
|
180
|
+
*/
|
|
181
|
+
export function getOffsetPos (elem: any, container: any) {
|
|
182
|
+
return getNodeOffset(elem, container, { left: 0, top: 0 })
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export function getAbsolutePos (elem: any) {
|
|
186
|
+
const bounding = elem.getBoundingClientRect()
|
|
187
|
+
const boundingTop = bounding.top
|
|
188
|
+
const boundingLeft = bounding.left
|
|
189
|
+
const { scrollTop, scrollLeft, visibleHeight, visibleWidth } = getDomNode()
|
|
190
|
+
return { boundingTop, top: scrollTop + boundingTop, boundingLeft, left: scrollLeft + boundingLeft, visibleHeight, visibleWidth }
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
|
|
194
|
+
const scrollIntoView = 'scrollIntoView'
|
|
195
|
+
|
|
196
|
+
export function scrollToView (elem: any) {
|
|
197
|
+
if (elem) {
|
|
198
|
+
if (elem[scrollIntoViewIfNeeded]) {
|
|
199
|
+
elem[scrollIntoViewIfNeeded]()
|
|
200
|
+
} else if (elem[scrollIntoView]) {
|
|
201
|
+
elem[scrollIntoView]()
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function triggerEvent (targetElem: Element, type: string) {
|
|
207
|
+
if (targetElem) {
|
|
208
|
+
targetElem.dispatchEvent(new Event(type))
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function isNodeElement (elem: any): elem is HTMLElement {
|
|
213
|
+
return elem && elem.nodeType === 1
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function scrollTopTo (diffNum: number, cb: (progress: number) => void) {
|
|
217
|
+
const duration = Math.abs(diffNum)
|
|
218
|
+
const startTime = performance.now()
|
|
219
|
+
let countTop = 0
|
|
220
|
+
const step = (timestamp: number) => {
|
|
221
|
+
let progress = (timestamp - startTime) / duration
|
|
222
|
+
if (progress < 0) {
|
|
223
|
+
progress = 0
|
|
224
|
+
} else if (progress > 1) {
|
|
225
|
+
progress = 1
|
|
226
|
+
}
|
|
227
|
+
const easedProgress = Math.pow(progress, 2)
|
|
228
|
+
const offsetTop = Math.floor((diffNum * easedProgress)) - countTop
|
|
229
|
+
countTop += offsetTop
|
|
230
|
+
cb(offsetTop)
|
|
231
|
+
if (progress < 1) {
|
|
232
|
+
requestAnimationFrame(step)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
requestAnimationFrame(step)
|
|
236
|
+
}
|
package/packages/ui/src/log.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { VxeUI } from '@vxe-ui/core'
|
|
2
|
-
|
|
3
|
-
const { log } = VxeUI
|
|
4
|
-
|
|
5
|
-
const version = `table v${process.env.VUE_APP_VXE_VERSION}`
|
|
6
|
-
|
|
7
|
-
export const warnLog = log.create('warn', version)
|
|
8
|
-
export const errLog = log.create('error', version)
|
|
1
|
+
import { VxeUI } from '@vxe-ui/core'
|
|
2
|
+
|
|
3
|
+
const { log } = VxeUI
|
|
4
|
+
|
|
5
|
+
const version = `table v${process.env.VUE_APP_VXE_VERSION}`
|
|
6
|
+
|
|
7
|
+
export const warnLog = log.create('warn', version)
|
|
8
|
+
export const errLog = log.create('error', version)
|