vxe-table 4.19.0-beta.2 → 4.19.0-beta.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 (121) hide show
  1. package/LICENSE +20 -20
  2. package/README.en.md +118 -118
  3. package/README.ja-JP.md +117 -117
  4. package/README.md +268 -268
  5. package/README.zh-TW.md +117 -117
  6. package/es/style.css +1 -1
  7. package/es/table/render/index.js +1 -1
  8. package/es/ui/index.js +1 -1
  9. package/es/ui/src/log.js +1 -1
  10. package/lib/index.umd.js +2767 -2851
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/style.css +1 -1
  13. package/lib/table/render/index.js +1 -1
  14. package/lib/table/render/index.min.js +1 -1
  15. package/lib/ui/index.js +1 -1
  16. package/lib/ui/index.min.js +1 -1
  17. package/lib/ui/src/log.js +1 -1
  18. package/lib/ui/src/log.min.js +1 -1
  19. package/package.json +92 -92
  20. package/packages/colgroup/index.ts +22 -22
  21. package/packages/column/index.ts +22 -22
  22. package/packages/components.ts +43 -43
  23. package/packages/grid/index.ts +18 -18
  24. package/packages/grid/src/emits.ts +19 -19
  25. package/packages/grid/src/grid.ts +1768 -1768
  26. package/packages/grid/src/props.ts +23 -23
  27. package/packages/index.ts +4 -4
  28. package/packages/locale/lang/ar-EG.ts +840 -840
  29. package/packages/locale/lang/de-DE.ts +840 -840
  30. package/packages/locale/lang/en-US.ts +840 -840
  31. package/packages/locale/lang/es-ES.ts +840 -840
  32. package/packages/locale/lang/fr-FR.ts +840 -840
  33. package/packages/locale/lang/hu-HU.ts +840 -840
  34. package/packages/locale/lang/hy-AM.ts +840 -840
  35. package/packages/locale/lang/id-ID.ts +840 -840
  36. package/packages/locale/lang/it-IT.ts +840 -840
  37. package/packages/locale/lang/ja-JP.ts +840 -840
  38. package/packages/locale/lang/ko-KR.ts +840 -840
  39. package/packages/locale/lang/ms-MY.ts +840 -840
  40. package/packages/locale/lang/nb-NO.ts +840 -840
  41. package/packages/locale/lang/pt-BR.ts +840 -840
  42. package/packages/locale/lang/ru-RU.ts +840 -840
  43. package/packages/locale/lang/th-TH.ts +840 -840
  44. package/packages/locale/lang/ug-CN.ts +840 -840
  45. package/packages/locale/lang/uk-UA.ts +840 -840
  46. package/packages/locale/lang/uz-UZ.ts +840 -840
  47. package/packages/locale/lang/vi-VN.ts +840 -840
  48. package/packages/locale/lang/zh-CHT.ts +840 -840
  49. package/packages/locale/lang/zh-CN.ts +840 -840
  50. package/packages/locale/lang/zh-HK.ts +3 -3
  51. package/packages/locale/lang/zh-MO.ts +3 -3
  52. package/packages/locale/lang/zh-TC.ts +3 -3
  53. package/packages/locale/lang/zh-TW.ts +3 -3
  54. package/packages/table/index.ts +26 -26
  55. package/packages/table/module/custom/hook.ts +422 -422
  56. package/packages/table/module/custom/panel.ts +1512 -1512
  57. package/packages/table/module/edit/hook.ts +1064 -1064
  58. package/packages/table/module/export/export-panel.ts +567 -567
  59. package/packages/table/module/export/hook.ts +1654 -1654
  60. package/packages/table/module/export/import-panel.ts +266 -266
  61. package/packages/table/module/export/util.ts +24 -24
  62. package/packages/table/module/filter/hook.ts +468 -468
  63. package/packages/table/module/filter/panel.ts +301 -301
  64. package/packages/table/module/keyboard/hook.ts +494 -494
  65. package/packages/table/module/menu/hook.ts +325 -325
  66. package/packages/table/module/menu/panel.ts +201 -201
  67. package/packages/table/module/validator/hook.ts +631 -631
  68. package/packages/table/render/index.ts +1440 -1440
  69. package/packages/table/src/body.ts +935 -935
  70. package/packages/table/src/cell.ts +1290 -1290
  71. package/packages/table/src/column.ts +190 -190
  72. package/packages/table/src/columnInfo.ts +225 -225
  73. package/packages/table/src/emits.ts +125 -125
  74. package/packages/table/src/footer.ts +368 -368
  75. package/packages/table/src/group.ts +59 -59
  76. package/packages/table/src/header.ts +561 -561
  77. package/packages/table/src/props.ts +324 -324
  78. package/packages/table/src/store.ts +14 -14
  79. package/packages/table/src/table.ts +14274 -14274
  80. package/packages/table/src/use/cell-view.ts +44 -44
  81. package/packages/table/src/use/index.ts +1 -1
  82. package/packages/table/src/util.ts +1086 -1086
  83. package/packages/toolbar/index.ts +18 -18
  84. package/packages/toolbar/src/toolbar.ts +701 -701
  85. package/packages/ui/index.ts +532 -532
  86. package/packages/ui/src/anime.ts +52 -52
  87. package/packages/ui/src/comp.ts +3 -3
  88. package/packages/ui/src/dom.ts +264 -264
  89. package/packages/ui/src/log.ts +8 -8
  90. package/packages/ui/src/utils.ts +56 -56
  91. package/packages/ui/src/vn.ts +55 -55
  92. package/packages/v-x-e-table/index.d.ts +4 -4
  93. package/packages/v-x-e-table/index.ts +4 -4
  94. package/styles/all.scss +7 -7
  95. package/styles/base.scss +16 -16
  96. package/styles/components/grid.scss +89 -89
  97. package/styles/components/icon.scss +225 -225
  98. package/styles/components/old-icon.scss +715 -715
  99. package/styles/components/table-module/all.scss +6 -6
  100. package/styles/components/table-module/custom.scss +550 -550
  101. package/styles/components/table-module/export.scss +130 -130
  102. package/styles/components/table-module/filter.scss +130 -130
  103. package/styles/components/table-module/menu.scss +81 -81
  104. package/styles/components/table.scss +2679 -2679
  105. package/styles/components/toolbar.scss +119 -119
  106. package/styles/default.scss +2 -2
  107. package/styles/helpers/baseMixin.scss +95 -95
  108. package/styles/index.scss +4 -4
  109. package/styles/modules.scss +5 -5
  110. package/styles/theme/base.scss +93 -93
  111. package/styles/theme/dark.scss +49 -49
  112. package/styles/theme/light.scss +44 -44
  113. package/styles/variable.scss +43 -43
  114. package/types/all.d.ts +37 -37
  115. package/types/index.d.ts +4 -4
  116. /package/es/{iconfont.1778157083004.ttf → iconfont.1778318183872.ttf} +0 -0
  117. /package/es/{iconfont.1778157083004.woff → iconfont.1778318183872.woff} +0 -0
  118. /package/es/{iconfont.1778157083004.woff2 → iconfont.1778318183872.woff2} +0 -0
  119. /package/lib/{iconfont.1778157083004.ttf → iconfont.1778318183872.ttf} +0 -0
  120. /package/lib/{iconfont.1778157083004.woff → iconfont.1778318183872.woff} +0 -0
  121. /package/lib/{iconfont.1778157083004.woff2 → iconfont.1778318183872.woff2} +0 -0
@@ -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
+ }
@@ -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
@@ -1,264 +1,264 @@
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
- export function hasEventInputTarget (target: EventTarget | Element | null) {
194
- const tagName = target ? (target as Element).tagName : ''
195
- return tagName && ['input', 'textarea'].includes((tagName.toLowerCase()))
196
- }
197
-
198
- const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
199
- const scrollIntoView = 'scrollIntoView'
200
-
201
- export function scrollToView (elem: any) {
202
- if (elem) {
203
- if (elem[scrollIntoViewIfNeeded]) {
204
- elem[scrollIntoViewIfNeeded]()
205
- } else if (elem[scrollIntoView]) {
206
- elem[scrollIntoView]()
207
- }
208
- }
209
- }
210
-
211
- export function triggerEvent (targetElem: Element, type: string) {
212
- if (targetElem) {
213
- targetElem.dispatchEvent(new Event(type))
214
- }
215
- }
216
-
217
- export function isNodeElement (elem: any): elem is HTMLElement {
218
- return elem && elem.nodeType === 1
219
- }
220
-
221
- export function scrollTopTo (diffNum: number, cb: (progress: number) => void) {
222
- const duration = Math.abs(diffNum)
223
- const startTime = performance.now()
224
- let countTop = 0
225
- const step = (timestamp: number) => {
226
- let progress = (timestamp - startTime) / duration
227
- if (progress < 0) {
228
- progress = 0
229
- } else if (progress > 1) {
230
- progress = 1
231
- }
232
- const easedProgress = Math.pow(progress, 2)
233
- const offsetTop = Math.floor((diffNum * easedProgress)) - countTop
234
- countTop += offsetTop
235
- cb(offsetTop)
236
- if (progress < 1) {
237
- requestAnimationFrame(step)
238
- }
239
- }
240
- requestAnimationFrame(step)
241
- }
242
-
243
- let wtlFrame: any
244
- export function wheelScrollLeftTo (scrollLeft: number, cb: (offsetLeft: number) => void) {
245
- if (wtlFrame) {
246
- cancelAnimationFrame(wtlFrame)
247
- }
248
- wtlFrame = requestAnimationFrame(() => {
249
- cb(scrollLeft)
250
- wtlFrame = null
251
- })
252
- }
253
-
254
- let wtaFrame: any
255
- export function wheelScrollTopTo (diffNum: number, cb: (progress: number) => void) {
256
- if (wtaFrame) {
257
- cancelAnimationFrame(wtaFrame)
258
- }
259
- wtaFrame = requestAnimationFrame(() => {
260
- const offsetTop = diffNum
261
- cb(offsetTop)
262
- wtaFrame = null
263
- })
264
- }
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
+ export function hasEventInputTarget (target: EventTarget | Element | null) {
194
+ const tagName = target ? (target as Element).tagName : ''
195
+ return tagName && ['input', 'textarea'].includes((tagName.toLowerCase()))
196
+ }
197
+
198
+ const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
199
+ const scrollIntoView = 'scrollIntoView'
200
+
201
+ export function scrollToView (elem: any) {
202
+ if (elem) {
203
+ if (elem[scrollIntoViewIfNeeded]) {
204
+ elem[scrollIntoViewIfNeeded]()
205
+ } else if (elem[scrollIntoView]) {
206
+ elem[scrollIntoView]()
207
+ }
208
+ }
209
+ }
210
+
211
+ export function triggerEvent (targetElem: Element, type: string) {
212
+ if (targetElem) {
213
+ targetElem.dispatchEvent(new Event(type))
214
+ }
215
+ }
216
+
217
+ export function isNodeElement (elem: any): elem is HTMLElement {
218
+ return elem && elem.nodeType === 1
219
+ }
220
+
221
+ export function scrollTopTo (diffNum: number, cb: (progress: number) => void) {
222
+ const duration = Math.abs(diffNum)
223
+ const startTime = performance.now()
224
+ let countTop = 0
225
+ const step = (timestamp: number) => {
226
+ let progress = (timestamp - startTime) / duration
227
+ if (progress < 0) {
228
+ progress = 0
229
+ } else if (progress > 1) {
230
+ progress = 1
231
+ }
232
+ const easedProgress = Math.pow(progress, 2)
233
+ const offsetTop = Math.floor((diffNum * easedProgress)) - countTop
234
+ countTop += offsetTop
235
+ cb(offsetTop)
236
+ if (progress < 1) {
237
+ requestAnimationFrame(step)
238
+ }
239
+ }
240
+ requestAnimationFrame(step)
241
+ }
242
+
243
+ let wtlFrame: any
244
+ export function wheelScrollLeftTo (scrollLeft: number, cb: (offsetLeft: number) => void) {
245
+ if (wtlFrame) {
246
+ cancelAnimationFrame(wtlFrame)
247
+ }
248
+ wtlFrame = requestAnimationFrame(() => {
249
+ cb(scrollLeft)
250
+ wtlFrame = null
251
+ })
252
+ }
253
+
254
+ let wtaFrame: any
255
+ export function wheelScrollTopTo (diffNum: number, cb: (progress: number) => void) {
256
+ if (wtaFrame) {
257
+ cancelAnimationFrame(wtaFrame)
258
+ }
259
+ wtaFrame = requestAnimationFrame(() => {
260
+ const offsetTop = diffNum
261
+ cb(offsetTop)
262
+ wtaFrame = null
263
+ })
264
+ }
@@ -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)