vxe-table 4.19.0-beta.3 → 4.19.0-beta.4

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 (200) 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/locale/lang/ar-EG.js +4 -0
  7. package/es/locale/lang/de-DE.js +4 -0
  8. package/es/locale/lang/en-US.js +4 -0
  9. package/es/locale/lang/es-ES.js +4 -0
  10. package/es/locale/lang/fr-FR.js +4 -0
  11. package/es/locale/lang/hu-HU.js +4 -0
  12. package/es/locale/lang/hy-AM.js +4 -0
  13. package/es/locale/lang/id-ID.js +4 -0
  14. package/es/locale/lang/it-IT.js +4 -0
  15. package/es/locale/lang/ja-JP.js +4 -0
  16. package/es/locale/lang/ko-KR.js +4 -0
  17. package/es/locale/lang/ms-MY.js +4 -0
  18. package/es/locale/lang/nb-NO.js +4 -0
  19. package/es/locale/lang/pt-BR.js +4 -0
  20. package/es/locale/lang/ru-RU.js +4 -0
  21. package/es/locale/lang/th-TH.js +4 -0
  22. package/es/locale/lang/ug-CN.js +4 -0
  23. package/es/locale/lang/uk-UA.js +4 -0
  24. package/es/locale/lang/uz-UZ.js +4 -0
  25. package/es/locale/lang/vi-VN.js +4 -0
  26. package/es/locale/lang/zh-CHT.js +4 -0
  27. package/es/locale/lang/zh-CN.js +4 -0
  28. package/es/style.css +1 -1
  29. package/lib/index.umd.js +2852 -2764
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/locale/lang/ar-EG.js +4 -0
  32. package/lib/locale/lang/ar-EG.min.js +1 -1
  33. package/lib/locale/lang/ar-EG.umd.js +4 -0
  34. package/lib/locale/lang/de-DE.js +4 -0
  35. package/lib/locale/lang/de-DE.min.js +1 -1
  36. package/lib/locale/lang/de-DE.umd.js +4 -0
  37. package/lib/locale/lang/en-US.js +4 -0
  38. package/lib/locale/lang/en-US.min.js +1 -1
  39. package/lib/locale/lang/en-US.umd.js +4 -0
  40. package/lib/locale/lang/es-ES.js +4 -0
  41. package/lib/locale/lang/es-ES.min.js +1 -1
  42. package/lib/locale/lang/es-ES.umd.js +4 -0
  43. package/lib/locale/lang/fr-FR.js +4 -0
  44. package/lib/locale/lang/fr-FR.min.js +1 -1
  45. package/lib/locale/lang/fr-FR.umd.js +4 -0
  46. package/lib/locale/lang/hu-HU.js +4 -0
  47. package/lib/locale/lang/hu-HU.min.js +1 -1
  48. package/lib/locale/lang/hu-HU.umd.js +4 -0
  49. package/lib/locale/lang/hy-AM.js +4 -0
  50. package/lib/locale/lang/hy-AM.min.js +1 -1
  51. package/lib/locale/lang/hy-AM.umd.js +4 -0
  52. package/lib/locale/lang/id-ID.js +4 -0
  53. package/lib/locale/lang/id-ID.min.js +1 -1
  54. package/lib/locale/lang/id-ID.umd.js +4 -0
  55. package/lib/locale/lang/it-IT.js +4 -0
  56. package/lib/locale/lang/it-IT.min.js +1 -1
  57. package/lib/locale/lang/it-IT.umd.js +4 -0
  58. package/lib/locale/lang/ja-JP.js +4 -0
  59. package/lib/locale/lang/ja-JP.min.js +1 -1
  60. package/lib/locale/lang/ja-JP.umd.js +4 -0
  61. package/lib/locale/lang/ko-KR.js +4 -0
  62. package/lib/locale/lang/ko-KR.min.js +1 -1
  63. package/lib/locale/lang/ko-KR.umd.js +4 -0
  64. package/lib/locale/lang/ms-MY.js +4 -0
  65. package/lib/locale/lang/ms-MY.min.js +1 -1
  66. package/lib/locale/lang/ms-MY.umd.js +4 -0
  67. package/lib/locale/lang/nb-NO.js +4 -0
  68. package/lib/locale/lang/nb-NO.min.js +1 -1
  69. package/lib/locale/lang/nb-NO.umd.js +4 -0
  70. package/lib/locale/lang/pt-BR.js +4 -0
  71. package/lib/locale/lang/pt-BR.min.js +1 -1
  72. package/lib/locale/lang/pt-BR.umd.js +4 -0
  73. package/lib/locale/lang/ru-RU.js +4 -0
  74. package/lib/locale/lang/ru-RU.min.js +1 -1
  75. package/lib/locale/lang/ru-RU.umd.js +4 -0
  76. package/lib/locale/lang/th-TH.js +4 -0
  77. package/lib/locale/lang/th-TH.min.js +1 -1
  78. package/lib/locale/lang/th-TH.umd.js +4 -0
  79. package/lib/locale/lang/ug-CN.js +4 -0
  80. package/lib/locale/lang/ug-CN.min.js +1 -1
  81. package/lib/locale/lang/ug-CN.umd.js +4 -0
  82. package/lib/locale/lang/uk-UA.js +4 -0
  83. package/lib/locale/lang/uk-UA.min.js +1 -1
  84. package/lib/locale/lang/uk-UA.umd.js +4 -0
  85. package/lib/locale/lang/uz-UZ.js +4 -0
  86. package/lib/locale/lang/uz-UZ.min.js +1 -1
  87. package/lib/locale/lang/uz-UZ.umd.js +4 -0
  88. package/lib/locale/lang/vi-VN.js +4 -0
  89. package/lib/locale/lang/vi-VN.min.js +1 -1
  90. package/lib/locale/lang/vi-VN.umd.js +4 -0
  91. package/lib/locale/lang/zh-CHT.js +4 -0
  92. package/lib/locale/lang/zh-CHT.min.js +1 -1
  93. package/lib/locale/lang/zh-CHT.umd.js +4 -0
  94. package/lib/locale/lang/zh-CN.js +4 -0
  95. package/lib/locale/lang/zh-CN.min.js +1 -1
  96. package/lib/locale/lang/zh-CN.umd.js +4 -0
  97. package/lib/style.css +1 -1
  98. package/package.json +92 -92
  99. package/packages/colgroup/index.ts +22 -22
  100. package/packages/column/index.ts +22 -22
  101. package/packages/components.ts +43 -43
  102. package/packages/grid/index.ts +18 -18
  103. package/packages/grid/src/emits.ts +19 -19
  104. package/packages/grid/src/grid.ts +1768 -1768
  105. package/packages/grid/src/props.ts +23 -23
  106. package/packages/index.ts +4 -4
  107. package/packages/locale/lang/ar-EG.ts +844 -840
  108. package/packages/locale/lang/de-DE.ts +844 -840
  109. package/packages/locale/lang/en-US.ts +844 -840
  110. package/packages/locale/lang/es-ES.ts +844 -840
  111. package/packages/locale/lang/fr-FR.ts +844 -840
  112. package/packages/locale/lang/hu-HU.ts +844 -840
  113. package/packages/locale/lang/hy-AM.ts +844 -840
  114. package/packages/locale/lang/id-ID.ts +844 -840
  115. package/packages/locale/lang/it-IT.ts +844 -840
  116. package/packages/locale/lang/ja-JP.ts +844 -840
  117. package/packages/locale/lang/ko-KR.ts +844 -840
  118. package/packages/locale/lang/ms-MY.ts +844 -840
  119. package/packages/locale/lang/nb-NO.ts +844 -840
  120. package/packages/locale/lang/pt-BR.ts +844 -840
  121. package/packages/locale/lang/ru-RU.ts +844 -840
  122. package/packages/locale/lang/th-TH.ts +844 -840
  123. package/packages/locale/lang/ug-CN.ts +844 -840
  124. package/packages/locale/lang/uk-UA.ts +844 -840
  125. package/packages/locale/lang/uz-UZ.ts +844 -840
  126. package/packages/locale/lang/vi-VN.ts +844 -840
  127. package/packages/locale/lang/zh-CHT.ts +844 -840
  128. package/packages/locale/lang/zh-CN.ts +844 -840
  129. package/packages/locale/lang/zh-HK.ts +3 -3
  130. package/packages/locale/lang/zh-MO.ts +3 -3
  131. package/packages/locale/lang/zh-TC.ts +3 -3
  132. package/packages/locale/lang/zh-TW.ts +3 -3
  133. package/packages/table/index.ts +26 -26
  134. package/packages/table/module/custom/hook.ts +422 -422
  135. package/packages/table/module/custom/panel.ts +1512 -1512
  136. package/packages/table/module/edit/hook.ts +1064 -1064
  137. package/packages/table/module/export/export-panel.ts +567 -567
  138. package/packages/table/module/export/hook.ts +1654 -1654
  139. package/packages/table/module/export/import-panel.ts +266 -266
  140. package/packages/table/module/export/util.ts +24 -24
  141. package/packages/table/module/filter/hook.ts +468 -468
  142. package/packages/table/module/filter/panel.ts +301 -301
  143. package/packages/table/module/keyboard/hook.ts +494 -494
  144. package/packages/table/module/menu/hook.ts +325 -325
  145. package/packages/table/module/menu/panel.ts +201 -201
  146. package/packages/table/module/validator/hook.ts +631 -631
  147. package/packages/table/render/index.ts +1440 -1440
  148. package/packages/table/src/body.ts +935 -935
  149. package/packages/table/src/cell.ts +1290 -1290
  150. package/packages/table/src/column.ts +190 -190
  151. package/packages/table/src/columnInfo.ts +225 -225
  152. package/packages/table/src/emits.ts +125 -125
  153. package/packages/table/src/footer.ts +368 -368
  154. package/packages/table/src/group.ts +59 -59
  155. package/packages/table/src/header.ts +561 -561
  156. package/packages/table/src/props.ts +324 -324
  157. package/packages/table/src/store.ts +14 -14
  158. package/packages/table/src/table.ts +14274 -14274
  159. package/packages/table/src/use/cell-view.ts +44 -44
  160. package/packages/table/src/use/index.ts +1 -1
  161. package/packages/table/src/util.ts +1086 -1086
  162. package/packages/toolbar/index.ts +18 -18
  163. package/packages/toolbar/src/toolbar.ts +701 -701
  164. package/packages/ui/index.ts +532 -532
  165. package/packages/ui/src/anime.ts +52 -52
  166. package/packages/ui/src/comp.ts +3 -3
  167. package/packages/ui/src/dom.ts +264 -264
  168. package/packages/ui/src/log.ts +8 -8
  169. package/packages/ui/src/utils.ts +56 -56
  170. package/packages/ui/src/vn.ts +55 -55
  171. package/packages/v-x-e-table/index.d.ts +4 -4
  172. package/packages/v-x-e-table/index.ts +4 -4
  173. package/styles/all.scss +7 -7
  174. package/styles/base.scss +16 -16
  175. package/styles/components/grid.scss +89 -89
  176. package/styles/components/icon.scss +225 -225
  177. package/styles/components/old-icon.scss +715 -715
  178. package/styles/components/table-module/all.scss +6 -6
  179. package/styles/components/table-module/custom.scss +550 -550
  180. package/styles/components/table-module/export.scss +130 -130
  181. package/styles/components/table-module/filter.scss +130 -130
  182. package/styles/components/table-module/menu.scss +81 -81
  183. package/styles/components/table.scss +2679 -2679
  184. package/styles/components/toolbar.scss +119 -119
  185. package/styles/default.scss +2 -2
  186. package/styles/helpers/baseMixin.scss +95 -95
  187. package/styles/index.scss +4 -4
  188. package/styles/modules.scss +5 -5
  189. package/styles/theme/base.scss +93 -93
  190. package/styles/theme/dark.scss +49 -49
  191. package/styles/theme/light.scss +44 -44
  192. package/styles/variable.scss +43 -43
  193. package/types/all.d.ts +37 -37
  194. package/types/index.d.ts +4 -4
  195. /package/es/{iconfont.1778318183872.ttf → iconfont.1778421994938.ttf} +0 -0
  196. /package/es/{iconfont.1778318183872.woff → iconfont.1778421994938.woff} +0 -0
  197. /package/es/{iconfont.1778318183872.woff2 → iconfont.1778421994938.woff2} +0 -0
  198. /package/lib/{iconfont.1778318183872.ttf → iconfont.1778421994938.ttf} +0 -0
  199. /package/lib/{iconfont.1778318183872.woff → iconfont.1778421994938.woff} +0 -0
  200. /package/lib/{iconfont.1778318183872.woff2 → iconfont.1778421994938.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)