@vxe-ui/core 3.4.42 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.d.ts +124 -0
- package/es/index.esm.js +135 -122
- package/es/index.js +147 -0
- package/es/src/base-utils.d.ts +2 -0
- package/es/src/base-utils.js +40 -37
- package/es/src/clipboard.d.ts +2 -0
- package/es/src/clipboard.js +48 -45
- package/es/src/commands.d.ts +2 -0
- package/es/src/commands.js +47 -48
- package/es/src/config.d.ts +13 -0
- package/es/src/config.js +21 -23
- package/es/src/configStore.d.ts +2 -0
- package/es/src/configStore.js +8 -5
- package/es/src/core.d.ts +3 -0
- package/es/src/core.js +11 -7
- package/es/src/dataStore.d.ts +2 -0
- package/es/src/dataStore.js +4 -1
- package/es/src/db-utils.d.ts +2 -0
- package/es/src/db-utils.js +234 -0
- package/es/src/dom-utils.d.ts +2 -0
- package/es/src/dom-utils.js +65 -68
- package/es/src/event.d.ts +4 -0
- package/es/src/event.js +133 -147
- package/es/src/formats.d.ts +2 -0
- package/es/src/formats.js +47 -48
- package/es/src/i18n.d.ts +6 -0
- package/es/src/i18n.js +54 -47
- package/es/src/i18nStore.d.ts +5 -0
- package/es/src/i18nStore.js +11 -8
- package/es/src/icon.d.ts +6 -0
- package/es/src/icon.js +27 -21
- package/es/src/iconStore.d.ts +2 -0
- package/es/src/iconStore.js +4 -1
- package/es/src/interceptor.d.ts +2 -0
- package/es/src/interceptor.js +52 -54
- package/es/src/log.d.ts +2 -0
- package/es/src/log.js +14 -11
- package/es/src/menus.d.ts +2 -0
- package/es/src/menus.js +47 -48
- package/es/src/mixins.d.ts +36 -0
- package/es/src/mixins.js +229 -236
- package/es/src/permission.d.ts +3 -0
- package/es/src/permission.js +57 -55
- package/es/src/popper-utils.d.ts +2 -0
- package/es/src/popper-utils.js +159 -179
- package/es/src/renderer.d.ts +5 -0
- package/es/src/renderer.js +37 -42
- package/es/src/resize.d.ts +2 -0
- package/es/src/resize.js +60 -70
- package/es/src/scrollbar-utils.d.ts +2 -0
- package/es/src/scrollbar-utils.js +57 -54
- package/es/src/store.d.ts +13 -0
- package/es/src/store.js +43 -45
- package/es/src/theme.d.ts +3 -0
- package/es/src/theme.js +17 -13
- package/es/src/themeStore.d.ts +4 -0
- package/es/src/themeStore.js +5 -2
- package/es/src/validators.d.ts +2 -0
- package/es/src/validators.js +6 -3
- package/es/src/vm.d.ts +2 -0
- package/es/src/vm.js +9 -6
- package/es/src/z-index.d.ts +2 -0
- package/es/src/z-index.js +29 -26
- package/lib/index.common.js +132 -353
- package/lib/index.js +178 -0
- package/lib/index.umd.js +790 -3303
- package/lib/index.umd.min.js +1 -1
- package/lib/src/base-utils.js +39 -13
- package/lib/src/clipboard.js +50 -23
- package/lib/src/commands.js +46 -27
- package/lib/src/config.js +43 -23
- package/lib/src/configStore.js +24 -7
- package/lib/src/core.js +29 -11
- package/lib/src/dataStore.js +22 -5
- package/lib/src/db-utils.js +263 -0
- package/lib/src/dom-utils.js +40 -20
- package/lib/src/event.js +95 -102
- package/lib/src/formats.js +46 -27
- package/lib/src/i18n.js +54 -41
- package/lib/src/i18nStore.js +35 -9
- package/lib/src/icon.js +45 -21
- package/lib/src/iconStore.js +22 -5
- package/lib/src/interceptor.js +40 -18
- package/lib/src/log.js +29 -12
- package/lib/src/menus.js +46 -27
- package/lib/src/mixins.js +67 -83
- package/lib/src/permission.js +40 -17
- package/lib/src/popper-utils.js +71 -71
- package/lib/src/renderer.js +40 -21
- package/lib/src/resize.js +48 -42
- package/lib/src/scrollbar-utils.js +23 -6
- package/lib/src/store.js +44 -25
- package/lib/src/theme.js +31 -14
- package/lib/src/themeStore.js +24 -7
- package/lib/src/validators.js +34 -10
- package/lib/src/vm.js +34 -8
- package/lib/src/z-index.js +38 -12
- package/package.json +17 -3
- package/packages/index.ts +169 -166
- package/packages/src/base-utils.ts +42 -43
- package/packages/src/clipboard.ts +56 -56
- package/packages/src/commands.ts +56 -56
- package/packages/src/config.ts +30 -30
- package/packages/src/configStore.ts +8 -8
- package/packages/src/core.ts +11 -11
- package/packages/src/dataStore.ts +3 -4
- package/packages/src/db-utils.ts +267 -0
- package/packages/src/dom-utils.ts +86 -87
- package/packages/src/event.ts +161 -161
- package/packages/src/formats.ts +56 -56
- package/packages/src/i18n.ts +66 -66
- package/packages/src/i18nStore.ts +16 -16
- package/packages/src/icon.ts +32 -32
- package/packages/src/iconStore.ts +3 -3
- package/packages/src/interceptor.ts +64 -64
- package/packages/src/log.ts +19 -19
- package/packages/src/menus.ts +56 -56
- package/packages/src/mixins.ts +284 -292
- package/packages/src/permission.ts +61 -61
- package/packages/src/popper-utils.ts +197 -194
- package/packages/src/renderer.ts +50 -50
- package/packages/src/resize.ts +89 -89
- package/packages/src/scrollbar-utils.ts +58 -58
- package/packages/src/store.ts +47 -47
- package/packages/src/theme.ts +20 -20
- package/packages/src/themeStore.ts +7 -7
- package/packages/src/validators.ts +7 -7
- package/packages/src/vm.ts +10 -10
- package/packages/src/z-index.ts +30 -30
- package/types/core/db-utils.d.ts +44 -0
- package/types/core/global-config.d.ts +4 -6
- package/types/core/index.d.ts +7 -0
- package/lib/src/base-utils.min.js +0 -1
- package/lib/src/clipboard.min.js +0 -1
- package/lib/src/commands.min.js +0 -1
- package/lib/src/config.min.js +0 -1
- package/lib/src/configStore.min.js +0 -1
- package/lib/src/core.min.js +0 -1
- package/lib/src/dataStore.min.js +0 -1
- package/lib/src/dom-utils.min.js +0 -1
- package/lib/src/event.min.js +0 -1
- package/lib/src/formats.min.js +0 -1
- package/lib/src/i18n.min.js +0 -1
- package/lib/src/i18nStore.min.js +0 -1
- package/lib/src/icon.min.js +0 -1
- package/lib/src/iconStore.min.js +0 -1
- package/lib/src/interceptor.min.js +0 -1
- package/lib/src/log.min.js +0 -1
- package/lib/src/menus.min.js +0 -1
- package/lib/src/mixins.min.js +0 -1
- package/lib/src/permission.min.js +0 -1
- package/lib/src/popper-utils.min.js +0 -1
- package/lib/src/renderer.min.js +0 -1
- package/lib/src/resize.min.js +0 -1
- package/lib/src/scrollbar-utils.min.js +0 -1
- package/lib/src/store.min.js +0 -1
- package/lib/src/theme.min.js +0 -1
- package/lib/src/themeStore.min.js +0 -1
- package/lib/src/validators.min.js +0 -1
- package/lib/src/vm.min.js +0 -1
- package/lib/src/z-index.min.js +0 -1
package/packages/src/resize.ts
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
import { globalConfigStore } from './configStore'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalResize } from '../../types'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 监听 resize 事件
|
|
8
|
-
* 如果项目中已使用了 resize-observer-polyfill,那么只需要将方法定义全局,该组件就会自动使用
|
|
9
|
-
*/
|
|
10
|
-
let resizeTimeout: any
|
|
11
|
-
/* eslint-disable no-use-before-define */
|
|
12
|
-
const eventStore: XEResizeObserver[] = []
|
|
13
|
-
const defaultInterval = 500
|
|
14
|
-
|
|
15
|
-
function eventHandle
|
|
16
|
-
if (eventStore.length) {
|
|
17
|
-
eventStore.forEach((item) => {
|
|
18
|
-
item.tarList.forEach((observer) => {
|
|
19
|
-
const { target, width, heighe } = observer
|
|
20
|
-
const clientWidth = target.clientWidth
|
|
21
|
-
const clientHeight = target.clientHeight
|
|
22
|
-
const rWidth = clientWidth && width !== clientWidth
|
|
23
|
-
const rHeight = clientHeight && heighe !== clientHeight
|
|
24
|
-
if (rWidth || rHeight) {
|
|
25
|
-
observer.width = clientWidth
|
|
26
|
-
observer.heighe = clientHeight
|
|
27
|
-
setTimeout(item.callback)
|
|
28
|
-
}
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
32
|
-
eventListener()
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function eventListener
|
|
37
|
-
clearTimeout(resizeTimeout)
|
|
38
|
-
resizeTimeout = setTimeout(eventHandle, globalConfigStore.resizeInterval || defaultInterval)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
class XEResizeObserver {
|
|
42
|
-
tarList: {
|
|
43
|
-
target: Element
|
|
44
|
-
width: number
|
|
45
|
-
heighe: number
|
|
46
|
-
}[] = []
|
|
47
|
-
|
|
48
|
-
callback: (...args: any[]) => void
|
|
49
|
-
|
|
50
|
-
constructor
|
|
51
|
-
this.callback = callback
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
observe
|
|
55
|
-
if (target) {
|
|
56
|
-
const { tarList } = this
|
|
57
|
-
if (!tarList.some(observer => observer.target === target)) {
|
|
58
|
-
tarList.push({
|
|
59
|
-
target,
|
|
60
|
-
width: target.clientWidth,
|
|
61
|
-
heighe: target.clientHeight
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
if (!eventStore.length) {
|
|
65
|
-
eventListener()
|
|
66
|
-
}
|
|
67
|
-
if (!eventStore.some((item) => item === this)) {
|
|
68
|
-
eventStore.push(this)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
unobserve
|
|
74
|
-
XEUtils.remove(eventStore, item => item.tarList.some(observer => observer.target === target))
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
disconnect
|
|
78
|
-
XEUtils.remove(eventStore, item => item === this)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export const globalResize: VxeGlobalResize = {
|
|
83
|
-
create
|
|
84
|
-
if (window.ResizeObserver) {
|
|
85
|
-
return new window.ResizeObserver(callback)
|
|
86
|
-
}
|
|
87
|
-
return new XEResizeObserver(callback)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
import { globalConfigStore } from './configStore'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalResize } from '../../types'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 监听 resize 事件
|
|
8
|
+
* 如果项目中已使用了 resize-observer-polyfill,那么只需要将方法定义全局,该组件就会自动使用
|
|
9
|
+
*/
|
|
10
|
+
let resizeTimeout: any
|
|
11
|
+
/* eslint-disable no-use-before-define */
|
|
12
|
+
const eventStore: XEResizeObserver[] = []
|
|
13
|
+
const defaultInterval = 500
|
|
14
|
+
|
|
15
|
+
function eventHandle() {
|
|
16
|
+
if (eventStore.length) {
|
|
17
|
+
eventStore.forEach((item) => {
|
|
18
|
+
item.tarList.forEach((observer) => {
|
|
19
|
+
const { target, width, heighe } = observer
|
|
20
|
+
const clientWidth = target.clientWidth
|
|
21
|
+
const clientHeight = target.clientHeight
|
|
22
|
+
const rWidth = clientWidth && width !== clientWidth
|
|
23
|
+
const rHeight = clientHeight && heighe !== clientHeight
|
|
24
|
+
if (rWidth || rHeight) {
|
|
25
|
+
observer.width = clientWidth
|
|
26
|
+
observer.heighe = clientHeight
|
|
27
|
+
setTimeout(item.callback)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
})
|
|
31
|
+
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
32
|
+
eventListener()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function eventListener() {
|
|
37
|
+
clearTimeout(resizeTimeout)
|
|
38
|
+
resizeTimeout = setTimeout(eventHandle, globalConfigStore.resizeInterval || defaultInterval)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class XEResizeObserver {
|
|
42
|
+
tarList: {
|
|
43
|
+
target: Element
|
|
44
|
+
width: number
|
|
45
|
+
heighe: number
|
|
46
|
+
}[] = []
|
|
47
|
+
|
|
48
|
+
callback: (...args: any[]) => void
|
|
49
|
+
|
|
50
|
+
constructor(callback: (...args: any[]) => void) {
|
|
51
|
+
this.callback = callback
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
observe(target: Element): void {
|
|
55
|
+
if (target) {
|
|
56
|
+
const { tarList } = this
|
|
57
|
+
if (!tarList.some((observer) => observer.target === target)) {
|
|
58
|
+
tarList.push({
|
|
59
|
+
target,
|
|
60
|
+
width: target.clientWidth,
|
|
61
|
+
heighe: target.clientHeight
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
if (!eventStore.length) {
|
|
65
|
+
eventListener()
|
|
66
|
+
}
|
|
67
|
+
if (!eventStore.some((item) => item === this)) {
|
|
68
|
+
eventStore.push(this)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
unobserve(target: Element): void {
|
|
74
|
+
XEUtils.remove(eventStore, (item) => item.tarList.some((observer) => observer.target === target))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
disconnect(): void {
|
|
78
|
+
XEUtils.remove(eventStore, (item) => item === this)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const globalResize: VxeGlobalResize = {
|
|
83
|
+
create(callback: (...args: any[]) => void) {
|
|
84
|
+
if (window.ResizeObserver) {
|
|
85
|
+
return new window.ResizeObserver(callback)
|
|
86
|
+
}
|
|
87
|
+
return new XEResizeObserver(callback)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { VxeScrollbarUtils } from '../../types'
|
|
2
|
-
|
|
3
|
-
export const scrollbarUtils: VxeScrollbarUtils = {
|
|
4
|
-
/**
|
|
5
|
-
* 计算滚动条滑块的长度
|
|
6
|
-
*/
|
|
7
|
-
getThumbSize
|
|
8
|
-
if (contentSize <= viewportSize) {
|
|
9
|
-
return 0
|
|
10
|
-
}
|
|
11
|
-
const ratio = viewportSize / contentSize
|
|
12
|
-
const ideal = trackSize * ratio
|
|
13
|
-
return Math.max(20, Math.min(ideal, trackSize))
|
|
14
|
-
},
|
|
15
|
-
/**
|
|
16
|
-
* 计算滚动条滑块的偏移位置
|
|
17
|
-
*/
|
|
18
|
-
getThumbOffsetSize
|
|
19
|
-
const maxScroll = contentSize - viewportSize
|
|
20
|
-
if (maxScroll <= 0) {
|
|
21
|
-
return 0
|
|
22
|
-
}
|
|
23
|
-
const maxThumbOffset = trackSize - thumbSize
|
|
24
|
-
if (maxThumbOffset <= 0) {
|
|
25
|
-
return 0
|
|
26
|
-
}
|
|
27
|
-
const clamped = Math.min(Math.max(offsetSize, 0), maxScroll)
|
|
28
|
-
const ratio = clamped / maxScroll
|
|
29
|
-
return ratio * maxThumbOffset
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* 根据点击轨道的位置,计算滑块的偏移位置
|
|
33
|
-
*/
|
|
34
|
-
getScrollFromClick
|
|
35
|
-
const maxThumbOffset = trackSize - thumbSize
|
|
36
|
-
const maxScroll = contentSize - viewportSize
|
|
37
|
-
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
38
|
-
return 0
|
|
39
|
-
}
|
|
40
|
-
let thumbOffset = clickPosition - thumbSize / 2
|
|
41
|
-
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset)
|
|
42
|
-
const scrollOffset = (thumbOffset / maxThumbOffset) * maxScroll
|
|
43
|
-
return scrollOffset
|
|
44
|
-
},
|
|
45
|
-
/**
|
|
46
|
-
* 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
|
|
47
|
-
*/
|
|
48
|
-
getScrollFromDrag
|
|
49
|
-
const maxScroll = contentSize - viewportSize
|
|
50
|
-
const maxThumbOffset = trackSize - thumbSize
|
|
51
|
-
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
52
|
-
return 0
|
|
53
|
-
}
|
|
54
|
-
let thumbOffset = pointerPosition - dragOffset
|
|
55
|
-
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset)
|
|
56
|
-
return (thumbOffset / maxThumbOffset) * maxScroll
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
import { VxeScrollbarUtils } from '../../types'
|
|
2
|
+
|
|
3
|
+
export const scrollbarUtils: VxeScrollbarUtils = {
|
|
4
|
+
/**
|
|
5
|
+
* 计算滚动条滑块的长度
|
|
6
|
+
*/
|
|
7
|
+
getThumbSize(viewportSize: number, contentSize: number, trackSize: number) {
|
|
8
|
+
if (contentSize <= viewportSize) {
|
|
9
|
+
return 0
|
|
10
|
+
}
|
|
11
|
+
const ratio = viewportSize / contentSize
|
|
12
|
+
const ideal = trackSize * ratio
|
|
13
|
+
return Math.max(20, Math.min(ideal, trackSize))
|
|
14
|
+
},
|
|
15
|
+
/**
|
|
16
|
+
* 计算滚动条滑块的偏移位置
|
|
17
|
+
*/
|
|
18
|
+
getThumbOffsetSize(offsetSize: number, viewportSize: number, contentSize: number, trackSize: number, thumbSize: number) {
|
|
19
|
+
const maxScroll = contentSize - viewportSize
|
|
20
|
+
if (maxScroll <= 0) {
|
|
21
|
+
return 0
|
|
22
|
+
}
|
|
23
|
+
const maxThumbOffset = trackSize - thumbSize
|
|
24
|
+
if (maxThumbOffset <= 0) {
|
|
25
|
+
return 0
|
|
26
|
+
}
|
|
27
|
+
const clamped = Math.min(Math.max(offsetSize, 0), maxScroll)
|
|
28
|
+
const ratio = clamped / maxScroll
|
|
29
|
+
return ratio * maxThumbOffset
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* 根据点击轨道的位置,计算滑块的偏移位置
|
|
33
|
+
*/
|
|
34
|
+
getScrollFromClick(clickPosition: number, viewportSize: number, contentSize: number, trackSize: number, thumbSize: number) {
|
|
35
|
+
const maxThumbOffset = trackSize - thumbSize
|
|
36
|
+
const maxScroll = contentSize - viewportSize
|
|
37
|
+
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
38
|
+
return 0
|
|
39
|
+
}
|
|
40
|
+
let thumbOffset = clickPosition - thumbSize / 2
|
|
41
|
+
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset)
|
|
42
|
+
const scrollOffset = (thumbOffset / maxThumbOffset) * maxScroll
|
|
43
|
+
return scrollOffset
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* 拖拽 thumb 时,根据鼠标位置计算滑块的偏移位置
|
|
47
|
+
*/
|
|
48
|
+
getScrollFromDrag(pointerPosition: number, dragOffset: number, viewportSize: number, contentSize: number, trackSize: number, thumbSize: number) {
|
|
49
|
+
const maxScroll = contentSize - viewportSize
|
|
50
|
+
const maxThumbOffset = trackSize - thumbSize
|
|
51
|
+
if (maxScroll <= 0 || maxThumbOffset <= 0) {
|
|
52
|
+
return 0
|
|
53
|
+
}
|
|
54
|
+
let thumbOffset = pointerPosition - dragOffset
|
|
55
|
+
thumbOffset = Math.min(Math.max(thumbOffset, 0), maxThumbOffset)
|
|
56
|
+
return (thumbOffset / maxThumbOffset) * maxScroll
|
|
57
|
+
}
|
|
58
|
+
}
|
package/packages/src/store.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { log } from './log'
|
|
2
|
-
import XEUtils from 'xe-utils'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 创建数据仓库
|
|
6
|
-
*/
|
|
7
|
-
export class Store {
|
|
8
|
-
private store: any = {}
|
|
9
|
-
|
|
10
|
-
mixin
|
|
11
|
-
XEUtils.each(options, (item, key) => {
|
|
12
|
-
this.add(key, item)
|
|
13
|
-
})
|
|
14
|
-
return this
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
has
|
|
18
|
-
return !!this.get(name)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
get
|
|
22
|
-
return this.store[name]
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
add
|
|
26
|
-
const conf = this.store[name]
|
|
27
|
-
// 检测是否覆盖
|
|
28
|
-
const confKeys = XEUtils.keys(conf)
|
|
29
|
-
XEUtils.each(options, (item, key) => {
|
|
30
|
-
if (confKeys.includes(key)) {
|
|
31
|
-
log.warn('vxe.error.coverProp', [name, key])
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
this.store[name] = conf ? XEUtils.merge(conf, options) : options
|
|
35
|
-
return this
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
delete
|
|
39
|
-
delete this.store[name]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
forEach
|
|
43
|
-
XEUtils.objectEach(this.store, callback)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default Store
|
|
1
|
+
import { log } from './log'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 创建数据仓库
|
|
6
|
+
*/
|
|
7
|
+
export class Store {
|
|
8
|
+
private store: any = {}
|
|
9
|
+
|
|
10
|
+
mixin(options: any): Store {
|
|
11
|
+
XEUtils.each(options, (item, key) => {
|
|
12
|
+
this.add(key, item)
|
|
13
|
+
})
|
|
14
|
+
return this
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
has(name: string): boolean {
|
|
18
|
+
return !!this.get(name)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get(name: string): any {
|
|
22
|
+
return this.store[name]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
add(name: string, options: any): Store {
|
|
26
|
+
const conf = this.store[name]
|
|
27
|
+
// 检测是否覆盖
|
|
28
|
+
const confKeys = XEUtils.keys(conf)
|
|
29
|
+
XEUtils.each(options, (item, key) => {
|
|
30
|
+
if (confKeys.includes(key)) {
|
|
31
|
+
log.warn('vxe.error.coverProp', [name, key])
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
this.store[name] = conf ? XEUtils.merge(conf, options) : options
|
|
35
|
+
return this
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
delete(name: string): void {
|
|
39
|
+
delete this.store[name]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
forEach(callback: any): void {
|
|
43
|
+
XEUtils.objectEach(this.store, callback)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Store
|
package/packages/src/theme.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { VxeCore } from './core'
|
|
2
|
-
import { themeConfigStore } from './themeStore'
|
|
3
|
-
|
|
4
|
-
import { VxeGlobalThemeName } from '../../types'
|
|
5
|
-
|
|
6
|
-
export function setTheme
|
|
7
|
-
const theme = !name || name === 'default' ? 'light' : name
|
|
8
|
-
themeConfigStore.theme = theme
|
|
9
|
-
if (typeof document !== 'undefined') {
|
|
10
|
-
const documentElement = document.documentElement
|
|
11
|
-
if (documentElement) {
|
|
12
|
-
documentElement.setAttribute('data-vxe-ui-theme', theme)
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return VxeCore
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function getTheme
|
|
19
|
-
return themeConfigStore.theme
|
|
20
|
-
}
|
|
1
|
+
import { VxeCore } from './core'
|
|
2
|
+
import { themeConfigStore } from './themeStore'
|
|
3
|
+
|
|
4
|
+
import { VxeGlobalThemeName } from '../../types'
|
|
5
|
+
|
|
6
|
+
export function setTheme(name?: VxeGlobalThemeName) {
|
|
7
|
+
const theme = !name || name === 'default' ? 'light' : name
|
|
8
|
+
themeConfigStore.theme = theme
|
|
9
|
+
if (typeof document !== 'undefined') {
|
|
10
|
+
const documentElement = document.documentElement
|
|
11
|
+
if (documentElement) {
|
|
12
|
+
documentElement.setAttribute('data-vxe-ui-theme', theme)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return VxeCore
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getTheme() {
|
|
19
|
+
return themeConfigStore.theme
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { VxeGlobalThemeName } from '../../types'
|
|
2
|
-
|
|
3
|
-
export const themeConfigStore: {
|
|
4
|
-
theme: VxeGlobalThemeName
|
|
5
|
-
} = {
|
|
6
|
-
theme: ''
|
|
7
|
-
}
|
|
1
|
+
import { VxeGlobalThemeName } from '../../types'
|
|
2
|
+
|
|
3
|
+
export const themeConfigStore: {
|
|
4
|
+
theme: VxeGlobalThemeName
|
|
5
|
+
} = {
|
|
6
|
+
theme: ''
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import VXEStore from './store'
|
|
2
|
-
|
|
3
|
-
import { VxeGlobalValidators } from '../../types'
|
|
4
|
-
|
|
5
|
-
export const validators = new VXEStore() as VxeGlobalValidators
|
|
6
|
-
|
|
7
|
-
Object.assign(validators, { _name: 'Validators' })
|
|
1
|
+
import VXEStore from './store'
|
|
2
|
+
|
|
3
|
+
import { VxeGlobalValidators } from '../../types'
|
|
4
|
+
|
|
5
|
+
export const validators = new VXEStore() as VxeGlobalValidators
|
|
6
|
+
|
|
7
|
+
Object.assign(validators, { _name: 'Validators' })
|
package/packages/src/vm.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import XEUtils from 'xe-utils'
|
|
2
|
-
|
|
3
|
-
import { VxeComponentSlotType } from '../../types'
|
|
4
|
-
|
|
5
|
-
export function getSlotVNs
|
|
6
|
-
if (XEUtils.isArray(vns)) {
|
|
7
|
-
return vns
|
|
8
|
-
}
|
|
9
|
-
return vns ? [vns] : []
|
|
10
|
-
}
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
|
|
3
|
+
import { VxeComponentSlotType } from '../../types'
|
|
4
|
+
|
|
5
|
+
export function getSlotVNs(vns: VxeComponentSlotType | VxeComponentSlotType[] | undefined) {
|
|
6
|
+
if (XEUtils.isArray(vns)) {
|
|
7
|
+
return vns
|
|
8
|
+
}
|
|
9
|
+
return vns ? [vns] : []
|
|
10
|
+
}
|
package/packages/src/z-index.ts
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import DomZIndex from 'dom-zindex'
|
|
2
|
-
|
|
3
|
-
import { VxeZIndex } from '../../types'
|
|
4
|
-
|
|
5
|
-
export const zIndex: VxeZIndex = {
|
|
6
|
-
/**
|
|
7
|
-
* 获取主层级下一个 z-index
|
|
8
|
-
*/
|
|
9
|
-
next
|
|
10
|
-
return DomZIndex.getNext()
|
|
11
|
-
},
|
|
12
|
-
/**
|
|
13
|
-
* 获取主层级最后一个 z-index
|
|
14
|
-
*/
|
|
15
|
-
getLast
|
|
16
|
-
return DomZIndex.getCurrent()
|
|
17
|
-
},
|
|
18
|
-
/**
|
|
19
|
-
* 获取子层级的下一个 z-index
|
|
20
|
-
*/
|
|
21
|
-
nextSub
|
|
22
|
-
return DomZIndex.getSubNext()
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* 获取子层级的最后一个 z-index
|
|
26
|
-
*/
|
|
27
|
-
getSubLast
|
|
28
|
-
return DomZIndex.getSubCurrent()
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import DomZIndex from 'dom-zindex'
|
|
2
|
+
|
|
3
|
+
import { VxeZIndex } from '../../types'
|
|
4
|
+
|
|
5
|
+
export const zIndex: VxeZIndex = {
|
|
6
|
+
/**
|
|
7
|
+
* 获取主层级下一个 z-index
|
|
8
|
+
*/
|
|
9
|
+
next() {
|
|
10
|
+
return DomZIndex.getNext()
|
|
11
|
+
},
|
|
12
|
+
/**
|
|
13
|
+
* 获取主层级最后一个 z-index
|
|
14
|
+
*/
|
|
15
|
+
getLast() {
|
|
16
|
+
return DomZIndex.getCurrent()
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* 获取子层级的下一个 z-index
|
|
20
|
+
*/
|
|
21
|
+
nextSub() {
|
|
22
|
+
return DomZIndex.getSubNext()
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* 获取子层级的最后一个 z-index
|
|
26
|
+
*/
|
|
27
|
+
getSubLast() {
|
|
28
|
+
return DomZIndex.getSubCurrent()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface VxeDBStore<T = any> {
|
|
2
|
+
/**
|
|
3
|
+
* 根据 ID 获取数据
|
|
4
|
+
* @param id
|
|
5
|
+
*/
|
|
6
|
+
getById(id: string): Promise<{ id: string; data: T } | undefined>
|
|
7
|
+
/**
|
|
8
|
+
* 获取所有数据
|
|
9
|
+
*/
|
|
10
|
+
getAll(): Promise<{ id: string; data: T }[]>
|
|
11
|
+
/**
|
|
12
|
+
* 根据 ID 更新数据
|
|
13
|
+
* @param id
|
|
14
|
+
*/
|
|
15
|
+
updateById(id: string, data: T): Promise<void>
|
|
16
|
+
/**
|
|
17
|
+
* 根据 ID 删除数据
|
|
18
|
+
* @param id
|
|
19
|
+
*/
|
|
20
|
+
deleteById(id: string): Promise<void>
|
|
21
|
+
/**
|
|
22
|
+
* 清空当前存储的数据
|
|
23
|
+
*/
|
|
24
|
+
clear(): Promise<void>
|
|
25
|
+
/**
|
|
26
|
+
* 清理旧版本数据
|
|
27
|
+
*/
|
|
28
|
+
cleanupOldDBs(): Promise<void>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface VxeDBOptions {
|
|
32
|
+
version?: string | number
|
|
33
|
+
driver?: 'indexedDB' | 'localStorage' | '' | null
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface VxeDBUtils {
|
|
37
|
+
/**
|
|
38
|
+
* 创建存储实例
|
|
39
|
+
* - driver = 'indexedDB' 且环境支持 => IdbStore
|
|
40
|
+
* @param key
|
|
41
|
+
* @param options
|
|
42
|
+
*/
|
|
43
|
+
createStore<T = any>(key: string, options?: VxeDBOptions): VxeDBStore<T>
|
|
44
|
+
}
|
|
@@ -33,6 +33,10 @@ export interface VxeGlobalConfig {
|
|
|
33
33
|
* 全局默认 z-index
|
|
34
34
|
*/
|
|
35
35
|
zIndex?: number
|
|
36
|
+
/**
|
|
37
|
+
* 全局版本号,对于某些带数据缓存的功能有用到,上升版本号可以用于重置组件保存的数据
|
|
38
|
+
*/
|
|
39
|
+
version?: string | number
|
|
36
40
|
/**
|
|
37
41
|
* 全局组件尺寸
|
|
38
42
|
*/
|
|
@@ -55,12 +59,6 @@ export interface VxeGlobalConfig {
|
|
|
55
59
|
* @returns string
|
|
56
60
|
*/
|
|
57
61
|
i18n?:(key: string, args?: any) => string | number
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* 已废弃,请使用 VxeUI.tableVersion
|
|
61
|
-
* @deprecated
|
|
62
|
-
*/
|
|
63
|
-
version?: string | number
|
|
64
62
|
/**
|
|
65
63
|
* 已废弃,请使用 VxeUI.setConfig({ table: { resizeInterval: 300 } })
|
|
66
64
|
* @deprecated
|
package/types/core/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import { VxeGlobalClipboard } from './clipboard'
|
|
|
17
17
|
import { VxeGlobalPermission } from './permission'
|
|
18
18
|
import { VxeZIndex } from './z-index'
|
|
19
19
|
import { VxeBaseUtils } from './base-utils'
|
|
20
|
+
import { VxeDBUtils } from './db-utils'
|
|
20
21
|
import { VxeDomUtils } from './dom-utils'
|
|
21
22
|
import { VxeScrollbarUtils } from './scrollbar-utils'
|
|
22
23
|
import { VxePopperUtils } from './popper-utils'
|
|
@@ -78,6 +79,7 @@ export const permission: VxeGlobalPermission
|
|
|
78
79
|
export const zIndex: VxeZIndex
|
|
79
80
|
|
|
80
81
|
export const baseUtils: VxeBaseUtils
|
|
82
|
+
export const dbUtils: VxeDBUtils
|
|
81
83
|
export const domUtils: VxeDomUtils
|
|
82
84
|
export const scrollbarUtils: VxeScrollbarUtils
|
|
83
85
|
export const popperUtils: VxePopperUtils
|
|
@@ -223,6 +225,10 @@ export interface VxeUIExport {
|
|
|
223
225
|
* 基础工具函数
|
|
224
226
|
*/
|
|
225
227
|
baseUtils: VxeBaseUtils
|
|
228
|
+
/**
|
|
229
|
+
* 数据储存函数
|
|
230
|
+
*/
|
|
231
|
+
dbUtils: VxeDBUtils
|
|
226
232
|
/**
|
|
227
233
|
* Document 工具函数
|
|
228
234
|
*/
|
|
@@ -312,6 +318,7 @@ export * from './permission'
|
|
|
312
318
|
export * from './z-index'
|
|
313
319
|
|
|
314
320
|
export * from './base-utils'
|
|
321
|
+
export * from './db-utils'
|
|
315
322
|
export * from './dom-utils'
|
|
316
323
|
export * from './scrollbar-utils'
|
|
317
324
|
export * from './popper-utils'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.baseUtils=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let baseUtils=exports.baseUtils={toString(e){return _xeUtils.default.eqNull(e)?"":""+e},isEmpty(e){return null==e||""===e},getDefVal(e,t){return _xeUtils.default.eqNull(e)?t:e},isEnabled(e){return!(!e||!1===e.enabled)},hasEnableConf(e,t){return!(!t||(e?!1===t.enabled:!t.enabled))}};
|
package/lib/src/clipboard.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.clipboard=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}let copyElem,clipStore={text:"",html:""};function handleText(e){var t;copyElem||((copyElem=document.createElement("textarea")).id="$VxeCopy",(t=copyElem.style).width="48px",t.height="24px",t.position="fixed",t.zIndex="0",t.left="-500px",t.top="-500px",document.body.appendChild(copyElem)),copyElem.value=e}let clipboard=exports.clipboard={getStore(){return clipStore},setStore(e){Object.assign(clipStore,e||{})},copy(e){let t=!1;try{var l=_xeUtils.default.toValueString(e);handleText(l),copyElem.select(),copyElem.setSelectionRange(0,copyElem.value.length),t=document.execCommand("copy"),copyElem.blur(),clipStore.text=l,clipStore.html=""}catch(e){}return t},getText(){return clipStore.text||""}};
|
package/lib/src/commands.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.commands=void 0;var _xeUtils=_interopRequireDefault(require("xe-utils")),_log=require("./log");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}class VXECommandsStore{constructor(){Object.defineProperty(this,"store",{enumerable:!0,configurable:!0,writable:!0,value:{}})}mixin(e){return _xeUtils.default.each(e,(e,t)=>{this.add(t,e)}),this}has(e){return!!this.get(e)}get(e){return this.store[e]}add(r,e){var t=this.store[r];_xeUtils.default.isFunction(e)&&(_log.log.warn("vxe.error.delProp",["commands -> callback","commandMethod"]),e={commandMethod:e});let o=_xeUtils.default.keys(t);return _xeUtils.default.each(e,(e,t)=>{o.includes(t)&&_log.log.warn("vxe.error.coverProp",[r,t])}),this.store[r]=t?_xeUtils.default.merge(t,e):e,this}delete(e){delete this.store[e]}forEach(e){_xeUtils.default.objectEach(this.store,e)}}let commands=exports.commands=new VXECommandsStore;Object.assign(commands,{_name:"Commands"});
|
package/lib/src/config.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.getConfig=getConfig,exports.setConfig=setConfig;var _xeUtils=_interopRequireDefault(require("xe-utils")),_domZindex=_interopRequireDefault(require("dom-zindex")),_core=require("./core"),_configStore=require("./configStore"),_theme=require("./theme");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function setConfig(e){return e&&(e.zIndex&&_domZindex.default.setCurrent(e.zIndex),e.theme&&(0,_theme.setTheme)(e.theme),_xeUtils.default.merge(_configStore.globalConfigStore,e)),_core.VxeCore}function getConfig(e,t){return arguments.length?_xeUtils.default.get(_configStore.globalConfigStore,e,t):_configStore.globalConfigStore}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.globalConfigStore=void 0;let globalConfigStore=exports.globalConfigStore={size:"",version:1,zIndex:999,resizeInterval:500};
|