@vxe-ui/core 3.4.42 → 3.5.0

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 (154) hide show
  1. package/es/index.d.ts +121 -0
  2. package/es/index.esm.js +132 -122
  3. package/es/index.js +144 -0
  4. package/es/src/base-utils.d.ts +2 -0
  5. package/es/src/base-utils.js +40 -37
  6. package/es/src/clipboard.d.ts +2 -0
  7. package/es/src/clipboard.js +48 -45
  8. package/es/src/commands.d.ts +2 -0
  9. package/es/src/commands.js +47 -48
  10. package/es/src/config.d.ts +13 -0
  11. package/es/src/config.js +21 -23
  12. package/es/src/configStore.d.ts +2 -0
  13. package/es/src/configStore.js +8 -5
  14. package/es/src/core.d.ts +3 -0
  15. package/es/src/core.js +11 -7
  16. package/es/src/dataStore.d.ts +2 -0
  17. package/es/src/dataStore.js +4 -1
  18. package/es/src/dom-utils.d.ts +2 -0
  19. package/es/src/dom-utils.js +65 -68
  20. package/es/src/event.d.ts +4 -0
  21. package/es/src/event.js +133 -147
  22. package/es/src/formats.d.ts +2 -0
  23. package/es/src/formats.js +47 -48
  24. package/es/src/i18n.d.ts +6 -0
  25. package/es/src/i18n.js +54 -47
  26. package/es/src/i18nStore.d.ts +5 -0
  27. package/es/src/i18nStore.js +11 -8
  28. package/es/src/icon.d.ts +6 -0
  29. package/es/src/icon.js +27 -21
  30. package/es/src/iconStore.d.ts +2 -0
  31. package/es/src/iconStore.js +4 -1
  32. package/es/src/interceptor.d.ts +2 -0
  33. package/es/src/interceptor.js +52 -54
  34. package/es/src/log.d.ts +2 -0
  35. package/es/src/log.js +14 -11
  36. package/es/src/menus.d.ts +2 -0
  37. package/es/src/menus.js +47 -48
  38. package/es/src/mixins.d.ts +36 -0
  39. package/es/src/mixins.js +229 -236
  40. package/es/src/permission.d.ts +3 -0
  41. package/es/src/permission.js +57 -55
  42. package/es/src/popper-utils.d.ts +2 -0
  43. package/es/src/popper-utils.js +159 -179
  44. package/es/src/renderer.d.ts +5 -0
  45. package/es/src/renderer.js +37 -42
  46. package/es/src/resize.d.ts +2 -0
  47. package/es/src/resize.js +60 -70
  48. package/es/src/scrollbar-utils.d.ts +2 -0
  49. package/es/src/scrollbar-utils.js +57 -54
  50. package/es/src/store.d.ts +13 -0
  51. package/es/src/store.js +43 -45
  52. package/es/src/theme.d.ts +3 -0
  53. package/es/src/theme.js +17 -13
  54. package/es/src/themeStore.d.ts +4 -0
  55. package/es/src/themeStore.js +5 -2
  56. package/es/src/validators.d.ts +2 -0
  57. package/es/src/validators.js +6 -3
  58. package/es/src/vm.d.ts +2 -0
  59. package/es/src/vm.js +9 -6
  60. package/es/src/z-index.d.ts +2 -0
  61. package/es/src/z-index.js +29 -26
  62. package/lib/index.common.js +129 -353
  63. package/lib/index.js +175 -0
  64. package/lib/index.umd.js +560 -3304
  65. package/lib/index.umd.min.js +1 -1
  66. package/lib/src/base-utils.js +39 -13
  67. package/lib/src/clipboard.js +50 -23
  68. package/lib/src/commands.js +46 -27
  69. package/lib/src/config.js +43 -23
  70. package/lib/src/configStore.js +24 -7
  71. package/lib/src/core.js +29 -11
  72. package/lib/src/dataStore.js +22 -5
  73. package/lib/src/dom-utils.js +40 -20
  74. package/lib/src/event.js +95 -102
  75. package/lib/src/formats.js +46 -27
  76. package/lib/src/i18n.js +54 -41
  77. package/lib/src/i18nStore.js +35 -9
  78. package/lib/src/icon.js +45 -21
  79. package/lib/src/iconStore.js +22 -5
  80. package/lib/src/interceptor.js +40 -18
  81. package/lib/src/log.js +29 -12
  82. package/lib/src/menus.js +46 -27
  83. package/lib/src/mixins.js +67 -83
  84. package/lib/src/permission.js +40 -17
  85. package/lib/src/popper-utils.js +71 -71
  86. package/lib/src/renderer.js +40 -21
  87. package/lib/src/resize.js +48 -42
  88. package/lib/src/scrollbar-utils.js +23 -6
  89. package/lib/src/store.js +44 -25
  90. package/lib/src/theme.js +31 -14
  91. package/lib/src/themeStore.js +24 -7
  92. package/lib/src/validators.js +34 -10
  93. package/lib/src/vm.js +34 -8
  94. package/lib/src/z-index.js +38 -12
  95. package/package.json +17 -3
  96. package/packages/index.ts +166 -166
  97. package/packages/src/base-utils.ts +42 -43
  98. package/packages/src/clipboard.ts +56 -56
  99. package/packages/src/commands.ts +56 -56
  100. package/packages/src/config.ts +30 -30
  101. package/packages/src/configStore.ts +8 -8
  102. package/packages/src/core.ts +11 -11
  103. package/packages/src/dataStore.ts +3 -4
  104. package/packages/src/dom-utils.ts +86 -87
  105. package/packages/src/event.ts +161 -161
  106. package/packages/src/formats.ts +56 -56
  107. package/packages/src/i18n.ts +66 -66
  108. package/packages/src/i18nStore.ts +16 -16
  109. package/packages/src/icon.ts +32 -32
  110. package/packages/src/iconStore.ts +3 -3
  111. package/packages/src/interceptor.ts +64 -64
  112. package/packages/src/log.ts +19 -19
  113. package/packages/src/menus.ts +56 -56
  114. package/packages/src/mixins.ts +284 -292
  115. package/packages/src/permission.ts +61 -61
  116. package/packages/src/popper-utils.ts +197 -194
  117. package/packages/src/renderer.ts +50 -50
  118. package/packages/src/resize.ts +89 -89
  119. package/packages/src/scrollbar-utils.ts +58 -58
  120. package/packages/src/store.ts +47 -47
  121. package/packages/src/theme.ts +20 -20
  122. package/packages/src/themeStore.ts +7 -7
  123. package/packages/src/validators.ts +7 -7
  124. package/packages/src/vm.ts +10 -10
  125. package/packages/src/z-index.ts +30 -30
  126. package/lib/src/base-utils.min.js +0 -1
  127. package/lib/src/clipboard.min.js +0 -1
  128. package/lib/src/commands.min.js +0 -1
  129. package/lib/src/config.min.js +0 -1
  130. package/lib/src/configStore.min.js +0 -1
  131. package/lib/src/core.min.js +0 -1
  132. package/lib/src/dataStore.min.js +0 -1
  133. package/lib/src/dom-utils.min.js +0 -1
  134. package/lib/src/event.min.js +0 -1
  135. package/lib/src/formats.min.js +0 -1
  136. package/lib/src/i18n.min.js +0 -1
  137. package/lib/src/i18nStore.min.js +0 -1
  138. package/lib/src/icon.min.js +0 -1
  139. package/lib/src/iconStore.min.js +0 -1
  140. package/lib/src/interceptor.min.js +0 -1
  141. package/lib/src/log.min.js +0 -1
  142. package/lib/src/menus.min.js +0 -1
  143. package/lib/src/mixins.min.js +0 -1
  144. package/lib/src/permission.min.js +0 -1
  145. package/lib/src/popper-utils.min.js +0 -1
  146. package/lib/src/renderer.min.js +0 -1
  147. package/lib/src/resize.min.js +0 -1
  148. package/lib/src/scrollbar-utils.min.js +0 -1
  149. package/lib/src/store.min.js +0 -1
  150. package/lib/src/theme.min.js +0 -1
  151. package/lib/src/themeStore.min.js +0 -1
  152. package/lib/src/validators.min.js +0 -1
  153. package/lib/src/vm.min.js +0 -1
  154. package/lib/src/z-index.min.js +0 -1
@@ -1,43 +1,42 @@
1
-
2
- import XEUtils from 'xe-utils'
3
-
4
- import { VxeBaseUtils, VxeBaseEmptyValue } from '../../types'
5
-
6
- export const baseUtils: VxeBaseUtils = {
7
- /**
8
- * 转成字符串
9
- */
10
- toString (content) {
11
- if (XEUtils.eqNull(content)) {
12
- return ''
13
- }
14
- return '' + content
15
- },
16
- /**
17
- * 判断值为:'' | null | undefined 时都属于空值
18
- */
19
- isEmpty (value) : value is VxeBaseEmptyValue {
20
- return value === null || value === undefined || value === ''
21
- },
22
- /**
23
- * 获取配置值,如果存在则返回,如果不存在则使用默认值
24
- */
25
- getDefVal (value, defVal) {
26
- return XEUtils.eqNull(value) ? defVal : value
27
- },
28
- /**
29
- * 判断是否启用
30
- */
31
- isEnabled (conf: any) {
32
- return !!(conf && conf.enabled !== false)
33
- },
34
- /**
35
- * 用于开关类型的配置项
36
- * 局部启用规则:conf={}
37
- * 局部禁用规则:conf={enabled:false}
38
- * 全局默认启用规则:conf.enabled=true
39
- */
40
- hasEnableConf (conf, opts) {
41
- return !!(opts && (conf ? opts.enabled !== false : opts.enabled))
42
- }
43
- }
1
+ import XEUtils from 'xe-utils'
2
+
3
+ import { VxeBaseUtils, VxeBaseEmptyValue } from '../../types'
4
+
5
+ export const baseUtils: VxeBaseUtils = {
6
+ /**
7
+ * 转成字符串
8
+ */
9
+ toString(content) {
10
+ if (XEUtils.eqNull(content)) {
11
+ return ''
12
+ }
13
+ return '' + content
14
+ },
15
+ /**
16
+ * 判断值为:'' | null | undefined 时都属于空值
17
+ */
18
+ isEmpty(value): value is VxeBaseEmptyValue {
19
+ return value === null || value === undefined || value === ''
20
+ },
21
+ /**
22
+ * 获取配置值,如果存在则返回,如果不存在则使用默认值
23
+ */
24
+ getDefVal(value, defVal) {
25
+ return XEUtils.eqNull(value) ? defVal : value
26
+ },
27
+ /**
28
+ * 判断是否启用
29
+ */
30
+ isEnabled(conf: any) {
31
+ return !!(conf && conf.enabled !== false)
32
+ },
33
+ /**
34
+ * 用于开关类型的配置项
35
+ * 局部启用规则:conf={}
36
+ * 局部禁用规则:conf={enabled:false}
37
+ * 全局默认启用规则:conf.enabled=true
38
+ */
39
+ hasEnableConf(conf, opts) {
40
+ return !!(opts && (conf ? opts.enabled !== false : opts.enabled))
41
+ }
42
+ }
@@ -1,56 +1,56 @@
1
- import XEUtils from 'xe-utils'
2
-
3
- import { VxeGlobalClipboard } from '../../types'
4
-
5
- let copyElem: HTMLTextAreaElement
6
- const clipStore = {
7
- text: '',
8
- html: ''
9
- }
10
-
11
- function handleText (text: string) {
12
- if (!copyElem) {
13
- copyElem = document.createElement('textarea')
14
- copyElem.id = '$VxeCopy'
15
- const styles = copyElem.style
16
- styles.width = '48px'
17
- styles.height = '24px'
18
- styles.position = 'fixed'
19
- styles.zIndex = '0'
20
- styles.left = '-500px'
21
- styles.top = '-500px'
22
- document.body.appendChild(copyElem)
23
- }
24
- copyElem.value = text
25
- }
26
-
27
- export const clipboard: VxeGlobalClipboard = {
28
- getStore () {
29
- return clipStore
30
- },
31
- setStore (data) {
32
- Object.assign(clipStore, data || {})
33
- },
34
- /**
35
- * 复制内容到剪贴板
36
- *
37
- * @param {String} content Text 内容
38
- */
39
- copy (content) {
40
- let result = false
41
- try {
42
- const text = XEUtils.toValueString(content)
43
- handleText(text)
44
- copyElem.select()
45
- copyElem.setSelectionRange(0, copyElem.value.length)
46
- result = document.execCommand('copy')
47
- copyElem.blur()
48
- clipStore.text = text
49
- clipStore.html = ''
50
- } catch (e) {}
51
- return result
52
- },
53
- getText () {
54
- return clipStore.text || ''
55
- }
56
- }
1
+ import XEUtils from 'xe-utils'
2
+
3
+ import { VxeGlobalClipboard } from '../../types'
4
+
5
+ let copyElem: HTMLTextAreaElement
6
+ const clipStore = {
7
+ text: '',
8
+ html: ''
9
+ }
10
+
11
+ function handleText(text: string) {
12
+ if (!copyElem) {
13
+ copyElem = document.createElement('textarea')
14
+ copyElem.id = '$VxeCopy'
15
+ const styles = copyElem.style
16
+ styles.width = '48px'
17
+ styles.height = '24px'
18
+ styles.position = 'fixed'
19
+ styles.zIndex = '0'
20
+ styles.left = '-500px'
21
+ styles.top = '-500px'
22
+ document.body.appendChild(copyElem)
23
+ }
24
+ copyElem.value = text
25
+ }
26
+
27
+ export const clipboard: VxeGlobalClipboard = {
28
+ getStore() {
29
+ return clipStore
30
+ },
31
+ setStore(data) {
32
+ Object.assign(clipStore, data || {})
33
+ },
34
+ /**
35
+ * 复制内容到剪贴板
36
+ *
37
+ * @param {String} content Text 内容
38
+ */
39
+ copy(content) {
40
+ let result = false
41
+ try {
42
+ const text = XEUtils.toValueString(content)
43
+ handleText(text)
44
+ copyElem.select()
45
+ copyElem.setSelectionRange(0, copyElem.value.length)
46
+ result = document.execCommand('copy')
47
+ copyElem.blur()
48
+ clipStore.text = text
49
+ clipStore.html = ''
50
+ } catch (e) {}
51
+ return result
52
+ },
53
+ getText() {
54
+ return clipStore.text || ''
55
+ }
56
+ }
@@ -1,56 +1,56 @@
1
- import XEUtils from 'xe-utils'
2
- import { log } from './log'
3
-
4
- import { VxeGlobalCommands } from '../../types'
5
-
6
- class VXECommandsStore {
7
- private store: any = {}
8
-
9
- mixin (options: any): VXECommandsStore {
10
- XEUtils.each(options, (item, key) => {
11
- this.add(key, item)
12
- })
13
- return this
14
- }
15
-
16
- has (name: string): boolean {
17
- return !!this.get(name)
18
- }
19
-
20
- get (name: string): any {
21
- return this.store[name]
22
- }
23
-
24
- add (name: string, render: any): VXECommandsStore {
25
- const conf = this.store[name]
26
- // 兼容
27
- if (XEUtils.isFunction(render)) {
28
- log.warn('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
29
- render = {
30
- commandMethod: render
31
- }
32
- }
33
-
34
- // 检测是否覆盖
35
- const confKeys = XEUtils.keys(conf)
36
- XEUtils.each(render, (item, key) => {
37
- if (confKeys.includes(key)) {
38
- log.warn('vxe.error.coverProp', [name, key])
39
- }
40
- })
41
- this.store[name] = conf ? XEUtils.merge(conf, render) : render
42
- return this
43
- }
44
-
45
- delete (name: string): void {
46
- delete this.store[name]
47
- }
48
-
49
- forEach (callback: any): void {
50
- XEUtils.objectEach(this.store, callback)
51
- }
52
- }
53
-
54
- export const commands = new VXECommandsStore() as VxeGlobalCommands
55
-
56
- Object.assign(commands, { _name: 'Commands' })
1
+ import XEUtils from 'xe-utils'
2
+ import { log } from './log'
3
+
4
+ import { VxeGlobalCommands } from '../../types'
5
+
6
+ class VXECommandsStore {
7
+ private store: any = {}
8
+
9
+ mixin(options: any): VXECommandsStore {
10
+ XEUtils.each(options, (item, key) => {
11
+ this.add(key, item)
12
+ })
13
+ return this
14
+ }
15
+
16
+ has(name: string): boolean {
17
+ return !!this.get(name)
18
+ }
19
+
20
+ get(name: string): any {
21
+ return this.store[name]
22
+ }
23
+
24
+ add(name: string, render: any): VXECommandsStore {
25
+ const conf = this.store[name]
26
+ // 兼容
27
+ if (XEUtils.isFunction(render)) {
28
+ log.warn('vxe.error.delProp', ['commands -> callback', 'commandMethod'])
29
+ render = {
30
+ commandMethod: render
31
+ }
32
+ }
33
+
34
+ // 检测是否覆盖
35
+ const confKeys = XEUtils.keys(conf)
36
+ XEUtils.each(render, (item, key) => {
37
+ if (confKeys.includes(key)) {
38
+ log.warn('vxe.error.coverProp', [name, key])
39
+ }
40
+ })
41
+ this.store[name] = conf ? XEUtils.merge(conf, render) : render
42
+ return this
43
+ }
44
+
45
+ delete(name: string): void {
46
+ delete this.store[name]
47
+ }
48
+
49
+ forEach(callback: any): void {
50
+ XEUtils.objectEach(this.store, callback)
51
+ }
52
+ }
53
+
54
+ export const commands = new VXECommandsStore() as VxeGlobalCommands
55
+
56
+ Object.assign(commands, { _name: 'Commands' })
@@ -1,30 +1,30 @@
1
- import XEUtils from 'xe-utils'
2
- import DomZIndex from 'dom-zindex'
3
- import { VxeCore } from './core'
4
- import { globalConfigStore } from './configStore'
5
- import { setTheme } from './theme'
6
-
7
- import { VxeGlobalConfig } from '../../types'
8
-
9
- /**
10
- * 全局参数设置
11
- */
12
- export function setConfig (options?: VxeGlobalConfig) {
13
- if (options) {
14
- if (options.zIndex) {
15
- DomZIndex.setCurrent(options.zIndex)
16
- }
17
- if (options.theme) {
18
- setTheme(options.theme)
19
- }
20
- XEUtils.merge(globalConfigStore, options)
21
- }
22
- return VxeCore
23
- }
24
-
25
- /**
26
- * 获取全局参数
27
- */
28
- export function getConfig (key: keyof VxeGlobalConfig, defaultValue?: any) {
29
- return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
30
- }
1
+ import XEUtils from 'xe-utils'
2
+ import DomZIndex from 'dom-zindex'
3
+ import { VxeCore } from './core'
4
+ import { globalConfigStore } from './configStore'
5
+ import { setTheme } from './theme'
6
+
7
+ import { VxeGlobalConfig } from '../../types'
8
+
9
+ /**
10
+ * 全局参数设置
11
+ */
12
+ export function setConfig(options?: VxeGlobalConfig) {
13
+ if (options) {
14
+ if (options.zIndex) {
15
+ DomZIndex.setCurrent(options.zIndex)
16
+ }
17
+ if (options.theme) {
18
+ setTheme(options.theme)
19
+ }
20
+ XEUtils.merge(globalConfigStore, options)
21
+ }
22
+ return VxeCore
23
+ }
24
+
25
+ /**
26
+ * 获取全局参数
27
+ */
28
+ export function getConfig(key: keyof VxeGlobalConfig, defaultValue?: any) {
29
+ return arguments.length ? XEUtils.get(globalConfigStore, key, defaultValue) : globalConfigStore
30
+ }
@@ -1,8 +1,8 @@
1
- import { VxeGlobalConfig } from '../../types'
2
-
3
- export const globalConfigStore: VxeGlobalConfig = {
4
- size: '',
5
- version: 1,
6
- zIndex: 999,
7
- resizeInterval: 500
8
- }
1
+ import { VxeGlobalConfig } from '../../types'
2
+
3
+ export const globalConfigStore: VxeGlobalConfig = {
4
+ size: '',
5
+ version: 1,
6
+ zIndex: 999,
7
+ resizeInterval: 500
8
+ }
@@ -1,11 +1,11 @@
1
- import { VxeUIExport } from '../../types'
2
-
3
- export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
4
-
5
- export const VxeCore = {
6
- coreVersion,
7
- uiVersion: '',
8
- tableVersion: '',
9
- designVersion: '',
10
- ganttVersion: ''
11
- } as VxeUIExport
1
+ import { VxeUIExport } from '../../types'
2
+
3
+ export const coreVersion = process.env.VUE_APP_VXE_VERSION as string
4
+
5
+ export const VxeCore = {
6
+ coreVersion,
7
+ uiVersion: '',
8
+ tableVersion: '',
9
+ designVersion: '',
10
+ ganttVersion: ''
11
+ } as VxeUIExport
@@ -1,4 +1,3 @@
1
- import { VxeGlobalData } from '../../types'
2
-
3
- export const globalStore: VxeGlobalData = {
4
- }
1
+ import { VxeGlobalData } from '../../types'
2
+
3
+ export const globalStore: VxeGlobalData = {}
@@ -1,87 +1,86 @@
1
-
2
- import XEUtils from 'xe-utils'
3
-
4
- import { VxeDomUtils } from '../../types'
5
-
6
- const reClsMap: { [key: string]: any } = {}
7
-
8
- function getClsRE (cls: any) {
9
- if (!reClsMap[cls]) {
10
- reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g')
11
- }
12
- return reClsMap[cls]
13
- }
14
-
15
- /**
16
- * 判断元素是否包含 class
17
- */
18
- function hasClass (elem: any, cls: any) {
19
- if (elem) {
20
- if (elem.classList) {
21
- return elem.classList.contains(cls)
22
- }
23
- return !!(elem.className && elem.className.match && elem.className.match(getClsRE(cls)))
24
- }
25
- return false
26
- }
27
-
28
- /**
29
- * 给元素删除 class
30
- */
31
- function removeClass (elem: any, cls: any) {
32
- if (elem && hasClass(elem, cls)) {
33
- elem.className = elem.className.replace(getClsRE(cls), '')
34
- }
35
- }
36
-
37
- export const domUtils: VxeDomUtils = {
38
- /**
39
- * 判断是否像素px单位 '100px' | 100
40
- */
41
- isPx (val: any) {
42
- return val && /^\d+(\.\d+)?(px)?$/.test(val)
43
- },
44
- /**
45
- * 判断是否百分比%单位 '100%'
46
- */
47
- isScale (val: any) {
48
- return val && /^\d+(\.\d+)?%$/.test(val)
49
- },
50
- /**
51
- * 判断元素是否包含 class
52
- */
53
- hasClass,
54
- /**
55
- * 给元素删除 class
56
- */
57
- removeClass,
58
- /**
59
- * 给元素增加 class
60
- */
61
- addClass (elem: any, cls: string) {
62
- if (elem && !hasClass(elem, cls)) {
63
- removeClass(elem, cls)
64
- elem.className = elem.className + ' ' + cls
65
- }
66
- },
67
- /**
68
- * 生成 className
69
- */
70
- buildClass (staticClassNames, mapClassName) {
71
- const parts: string[] = []
72
- if (staticClassNames) {
73
- for (let i = 0; i < staticClassNames.length; i++) {
74
- const val = staticClassNames[i]
75
- if (val) {
76
- parts.push('' + val)
77
- }
78
- }
79
- }
80
- XEUtils.each(mapClassName, (val, key) => {
81
- if (val) {
82
- parts.push(key)
83
- }
84
- })
85
- return parts.join(' ')
86
- }
87
- }
1
+ import XEUtils from 'xe-utils'
2
+
3
+ import { VxeDomUtils } from '../../types'
4
+
5
+ const reClsMap: { [key: string]: any } = {}
6
+
7
+ function getClsRE(cls: any) {
8
+ if (!reClsMap[cls]) {
9
+ reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g')
10
+ }
11
+ return reClsMap[cls]
12
+ }
13
+
14
+ /**
15
+ * 判断元素是否包含 class
16
+ */
17
+ function hasClass(elem: any, cls: any) {
18
+ if (elem) {
19
+ if (elem.classList) {
20
+ return elem.classList.contains(cls)
21
+ }
22
+ return !!(elem.className && elem.className.match && elem.className.match(getClsRE(cls)))
23
+ }
24
+ return false
25
+ }
26
+
27
+ /**
28
+ * 给元素删除 class
29
+ */
30
+ function removeClass(elem: any, cls: any) {
31
+ if (elem && hasClass(elem, cls)) {
32
+ elem.className = elem.className.replace(getClsRE(cls), '')
33
+ }
34
+ }
35
+
36
+ export const domUtils: VxeDomUtils = {
37
+ /**
38
+ * 判断是否像素px单位 '100px' | 100
39
+ */
40
+ isPx(val: any) {
41
+ return val && /^\d+(\.\d+)?(px)?$/.test(val)
42
+ },
43
+ /**
44
+ * 判断是否百分比%单位 '100%'
45
+ */
46
+ isScale(val: any) {
47
+ return val && /^\d+(\.\d+)?%$/.test(val)
48
+ },
49
+ /**
50
+ * 判断元素是否包含 class
51
+ */
52
+ hasClass,
53
+ /**
54
+ * 给元素删除 class
55
+ */
56
+ removeClass,
57
+ /**
58
+ * 给元素增加 class
59
+ */
60
+ addClass(elem: any, cls: string) {
61
+ if (elem && !hasClass(elem, cls)) {
62
+ removeClass(elem, cls)
63
+ elem.className = elem.className + ' ' + cls
64
+ }
65
+ },
66
+ /**
67
+ * 生成 className
68
+ */
69
+ buildClass(staticClassNames, mapClassName) {
70
+ const parts: string[] = []
71
+ if (staticClassNames) {
72
+ for (let i = 0; i < staticClassNames.length; i++) {
73
+ const val = staticClassNames[i]
74
+ if (val) {
75
+ parts.push('' + val)
76
+ }
77
+ }
78
+ }
79
+ XEUtils.each(mapClassName, (val, key) => {
80
+ if (val) {
81
+ parts.push(key)
82
+ }
83
+ })
84
+ return parts.join(' ')
85
+ }
86
+ }