vxe-table 4.18.7 → 4.18.8

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 (148) 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/src/table.js +85 -78
  8. package/es/table/src/util.js +6 -0
  9. package/es/table/style.css +18 -48
  10. package/es/ui/index.js +1 -1
  11. package/es/ui/src/dom.js +21 -0
  12. package/es/ui/src/log.js +1 -1
  13. package/es/vxe-table/style.css +18 -48
  14. package/lib/index.common.js +2 -1
  15. package/lib/index.umd.js +2762 -2833
  16. package/lib/index.umd.min.js +1 -1
  17. package/lib/style.css +1 -1
  18. package/lib/table/src/table.js +14 -11
  19. package/lib/table/src/table.min.js +1 -1
  20. package/lib/table/src/util.js +6 -0
  21. package/lib/table/src/util.min.js +1 -1
  22. package/lib/table/style/style.css +18 -48
  23. package/lib/ui/index.js +1 -1
  24. package/lib/ui/index.min.js +1 -1
  25. package/lib/ui/src/dom.js +23 -0
  26. package/lib/ui/src/dom.min.js +1 -1
  27. package/lib/ui/src/log.js +1 -1
  28. package/lib/ui/src/log.min.js +1 -1
  29. package/lib/v-x-e-table/index.js +2 -1
  30. package/lib/v-x-e-table/index.min.js +1 -1
  31. package/lib/vxe-colgroup/index.js +2 -1
  32. package/lib/vxe-colgroup/index.min.js +1 -1
  33. package/lib/vxe-column/index.js +2 -1
  34. package/lib/vxe-column/index.min.js +1 -1
  35. package/lib/vxe-grid/index.js +2 -1
  36. package/lib/vxe-grid/index.min.js +1 -1
  37. package/lib/vxe-table/index.js +2 -1
  38. package/lib/vxe-table/index.min.js +1 -1
  39. package/lib/vxe-table/style/style.css +18 -48
  40. package/lib/vxe-toolbar/index.js +2 -1
  41. package/lib/vxe-toolbar/index.min.js +1 -1
  42. package/lib/vxe-ui/index.js +2 -1
  43. package/lib/vxe-ui/index.min.js +1 -1
  44. package/lib/vxe-v-x-e-table/index.js +2 -1
  45. package/lib/vxe-v-x-e-table/index.min.js +1 -1
  46. package/package.json +91 -91
  47. package/packages/colgroup/index.ts +22 -22
  48. package/packages/column/index.ts +22 -22
  49. package/packages/components.ts +43 -43
  50. package/packages/grid/index.ts +18 -18
  51. package/packages/grid/src/emits.ts +19 -19
  52. package/packages/grid/src/grid.ts +1768 -1768
  53. package/packages/grid/src/props.ts +23 -23
  54. package/packages/index.ts +4 -4
  55. package/packages/locale/lang/ar-EG.ts +832 -832
  56. package/packages/locale/lang/de-DE.ts +832 -832
  57. package/packages/locale/lang/en-US.ts +832 -832
  58. package/packages/locale/lang/es-ES.ts +832 -832
  59. package/packages/locale/lang/fr-FR.ts +832 -832
  60. package/packages/locale/lang/hu-HU.ts +832 -832
  61. package/packages/locale/lang/hy-AM.ts +832 -832
  62. package/packages/locale/lang/id-ID.ts +832 -832
  63. package/packages/locale/lang/it-IT.ts +832 -832
  64. package/packages/locale/lang/ja-JP.ts +832 -832
  65. package/packages/locale/lang/ko-KR.ts +832 -832
  66. package/packages/locale/lang/ms-MY.ts +832 -832
  67. package/packages/locale/lang/nb-NO.ts +832 -832
  68. package/packages/locale/lang/pt-BR.ts +832 -832
  69. package/packages/locale/lang/ru-RU.ts +832 -832
  70. package/packages/locale/lang/th-TH.ts +832 -832
  71. package/packages/locale/lang/ug-CN.ts +832 -832
  72. package/packages/locale/lang/uk-UA.ts +832 -832
  73. package/packages/locale/lang/uz-UZ.ts +832 -832
  74. package/packages/locale/lang/vi-VN.ts +832 -832
  75. package/packages/locale/lang/zh-CHT.ts +832 -832
  76. package/packages/locale/lang/zh-CN.ts +832 -832
  77. package/packages/locale/lang/zh-HK.ts +3 -3
  78. package/packages/locale/lang/zh-MO.ts +3 -3
  79. package/packages/locale/lang/zh-TC.ts +3 -3
  80. package/packages/locale/lang/zh-TW.ts +3 -3
  81. package/packages/table/index.ts +26 -26
  82. package/packages/table/module/custom/hook.ts +359 -359
  83. package/packages/table/module/custom/panel.ts +1331 -1331
  84. package/packages/table/module/edit/hook.ts +1032 -1032
  85. package/packages/table/module/export/export-panel.ts +567 -567
  86. package/packages/table/module/export/hook.ts +1654 -1654
  87. package/packages/table/module/export/import-panel.ts +266 -266
  88. package/packages/table/module/export/util.ts +24 -24
  89. package/packages/table/module/filter/hook.ts +468 -468
  90. package/packages/table/module/filter/panel.ts +301 -301
  91. package/packages/table/module/keyboard/hook.ts +495 -495
  92. package/packages/table/module/menu/hook.ts +325 -325
  93. package/packages/table/module/menu/panel.ts +201 -201
  94. package/packages/table/module/validator/hook.ts +631 -631
  95. package/packages/table/render/index.ts +1440 -1440
  96. package/packages/table/src/body.ts +932 -932
  97. package/packages/table/src/cell.ts +1290 -1290
  98. package/packages/table/src/column.ts +190 -190
  99. package/packages/table/src/columnInfo.ts +225 -225
  100. package/packages/table/src/emits.ts +123 -123
  101. package/packages/table/src/footer.ts +368 -368
  102. package/packages/table/src/group.ts +59 -59
  103. package/packages/table/src/header.ts +559 -559
  104. package/packages/table/src/props.ts +324 -324
  105. package/packages/table/src/store.ts +14 -14
  106. package/packages/table/src/table.ts +14010 -14004
  107. package/packages/table/src/use/cell-view.ts +44 -44
  108. package/packages/table/src/use/index.ts +1 -1
  109. package/packages/table/src/util.ts +1070 -1064
  110. package/packages/toolbar/index.ts +18 -18
  111. package/packages/toolbar/src/toolbar.ts +701 -701
  112. package/packages/ui/index.ts +530 -530
  113. package/packages/ui/src/anime.ts +52 -52
  114. package/packages/ui/src/comp.ts +3 -3
  115. package/packages/ui/src/dom.ts +259 -236
  116. package/packages/ui/src/log.ts +8 -8
  117. package/packages/ui/src/utils.ts +56 -56
  118. package/packages/ui/src/vn.ts +55 -55
  119. package/packages/v-x-e-table/index.d.ts +4 -4
  120. package/packages/v-x-e-table/index.ts +4 -4
  121. package/styles/all.scss +7 -7
  122. package/styles/base.scss +16 -16
  123. package/styles/components/grid.scss +89 -89
  124. package/styles/components/icon.scss +225 -225
  125. package/styles/components/old-icon.scss +715 -715
  126. package/styles/components/table-module/all.scss +6 -6
  127. package/styles/components/table-module/custom.scss +527 -527
  128. package/styles/components/table-module/export.scss +130 -130
  129. package/styles/components/table-module/filter.scss +130 -130
  130. package/styles/components/table-module/menu.scss +81 -81
  131. package/styles/components/table.scss +2679 -2679
  132. package/styles/components/toolbar.scss +119 -119
  133. package/styles/default.scss +2 -2
  134. package/styles/helpers/baseMixin.scss +95 -95
  135. package/styles/index.scss +4 -4
  136. package/styles/modules.scss +5 -5
  137. package/styles/theme/base.scss +93 -93
  138. package/styles/theme/dark.scss +49 -49
  139. package/styles/theme/light.scss +44 -44
  140. package/styles/variable.scss +43 -43
  141. package/types/all.d.ts +37 -37
  142. package/types/index.d.ts +4 -4
  143. /package/es/{iconfont.1773991907408.ttf → iconfont.1774240404046.ttf} +0 -0
  144. /package/es/{iconfont.1773991907408.woff → iconfont.1774240404046.woff} +0 -0
  145. /package/es/{iconfont.1773991907408.woff2 → iconfont.1774240404046.woff2} +0 -0
  146. /package/lib/{iconfont.1773991907408.ttf → iconfont.1774240404046.ttf} +0 -0
  147. /package/lib/{iconfont.1773991907408.woff → iconfont.1774240404046.woff} +0 -0
  148. /package/lib/{iconfont.1773991907408.woff2 → iconfont.1774240404046.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,236 +1,259 @@
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
+ }
237
+
238
+ let wtlFrame: any
239
+ export function wheelScrollLeftTo (scrollLeft: number, cb: (offsetLeft: number) => void) {
240
+ if (wtlFrame) {
241
+ cancelAnimationFrame(wtlFrame)
242
+ }
243
+ wtlFrame = requestAnimationFrame(() => {
244
+ cb(scrollLeft)
245
+ wtlFrame = null
246
+ })
247
+ }
248
+
249
+ let wtaFrame: any
250
+ export function wheelScrollTopTo (diffNum: number, cb: (progress: number) => void) {
251
+ if (wtaFrame) {
252
+ cancelAnimationFrame(wtaFrame)
253
+ }
254
+ wtaFrame = requestAnimationFrame(() => {
255
+ const offsetTop = diffNum
256
+ cb(offsetTop)
257
+ wtaFrame = null
258
+ })
259
+ }
@@ -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)