@vxe-ui/core 0.0.1 → 0.1.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 (81) hide show
  1. package/es/index.esm.js +4 -6
  2. package/es/src/commands.js +3 -3
  3. package/es/src/core.js +49 -14
  4. package/es/src/event.js +11 -19
  5. package/es/src/formats.js +3 -3
  6. package/es/src/globalStore.js +1 -3
  7. package/es/src/i18n.js +3 -5
  8. package/es/src/i18nStore.js +4 -0
  9. package/es/src/iconStore.js +1 -2
  10. package/es/src/interceptor.js +2 -2
  11. package/es/src/log.js +8 -8
  12. package/es/src/menus.js +3 -3
  13. package/es/src/renderer.js +2 -2
  14. package/es/src/resize.js +9 -7
  15. package/es/src/store.js +2 -2
  16. package/es/src/themeStore.js +3 -0
  17. package/lib/index.common.js +2 -4
  18. package/lib/index.umd.js +301 -99
  19. package/lib/index.umd.min.js +1 -1
  20. package/lib/src/commands.js +2 -2
  21. package/lib/src/commands.min.js +1 -1
  22. package/lib/src/core.js +105 -22
  23. package/lib/src/core.min.js +1 -1
  24. package/lib/src/event.js +12 -23
  25. package/lib/src/event.min.js +1 -1
  26. package/lib/src/formats.js +2 -2
  27. package/lib/src/formats.min.js +1 -1
  28. package/lib/src/globalStore.js +3 -5
  29. package/lib/src/globalStore.min.js +1 -1
  30. package/lib/src/i18n.js +3 -5
  31. package/lib/src/i18n.min.js +1 -1
  32. package/lib/src/i18nStore.js +10 -0
  33. package/lib/src/i18nStore.min.js +1 -0
  34. package/lib/src/iconStore.js +2 -3
  35. package/lib/src/iconStore.min.js +1 -1
  36. package/lib/src/interceptor.js +1 -1
  37. package/lib/src/interceptor.min.js +1 -1
  38. package/lib/src/log.js +9 -11
  39. package/lib/src/log.min.js +1 -1
  40. package/lib/src/menus.js +2 -2
  41. package/lib/src/menus.min.js +1 -1
  42. package/lib/src/renderer.js +1 -1
  43. package/lib/src/renderer.min.js +1 -1
  44. package/lib/src/resize.js +10 -10
  45. package/lib/src/resize.min.js +1 -1
  46. package/lib/src/store.js +1 -1
  47. package/lib/src/store.min.js +1 -1
  48. package/lib/src/themeStore.js +9 -0
  49. package/lib/src/themeStore.min.js +1 -0
  50. package/package.json +2 -2
  51. package/packages/index.ts +4 -6
  52. package/packages/src/commands.ts +6 -6
  53. package/packages/src/core.ts +61 -18
  54. package/packages/src/event.ts +14 -23
  55. package/packages/src/formats.ts +6 -6
  56. package/packages/src/globalStore.ts +1 -4
  57. package/packages/src/i18n.ts +3 -5
  58. package/packages/src/i18nStore.ts +9 -0
  59. package/packages/src/iconStore.ts +1 -3
  60. package/packages/src/interceptor.ts +3 -3
  61. package/packages/src/log.ts +9 -8
  62. package/packages/src/menus.ts +6 -6
  63. package/packages/src/renderer.ts +5 -5
  64. package/packages/src/resize.ts +10 -6
  65. package/packages/src/store.ts +3 -3
  66. package/packages/src/themeStore.ts +7 -0
  67. package/packages/src/validators.ts +1 -1
  68. package/types/core/global-config.d.ts +0 -1
  69. package/types/core/global-event.d.ts +26 -0
  70. package/types/core/global-icon.d.ts +3 -1
  71. package/types/core/global-lang.d.ts +1 -0
  72. package/types/core/global-resize.d.ts +3 -0
  73. package/types/core/global-theme.d.ts +1 -0
  74. package/types/core/index.d.ts +62 -9
  75. package/types/core/log.d.ts +8 -0
  76. package/types/core/renderer.d.ts +5 -16
  77. package/types/index.d.ts +2 -2
  78. package/es/src/theme.js +0 -10
  79. package/lib/src/theme.js +0 -17
  80. package/lib/src/theme.min.js +0 -1
  81. package/packages/src/theme.ts +0 -13
@@ -1,12 +1,12 @@
1
1
  import XEUtils from 'xe-utils'
2
- import { warnLog } from './log'
2
+ import { log } from './log'
3
3
 
4
- import { VxeGlobalRenderer, RendererOptions } from '../../types'
4
+ import { VxeGlobalRenderer, VxeGlobalRendererOptions } from '../../types'
5
5
 
6
6
  /**
7
7
  * 内置的组件渲染
8
8
  */
9
- const renderMap: Record<string, RendererOptions> = {}
9
+ const renderMap: Record<string, VxeGlobalRendererOptions> = {}
10
10
 
11
11
  /**
12
12
  * 全局渲染器
@@ -24,10 +24,10 @@ export const renderer: VxeGlobalRenderer = {
24
24
  const renders: any = renderMap[name]
25
25
  if (renders) {
26
26
  // 检测是否覆盖
27
- if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
27
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
28
28
  XEUtils.each(options, (val, key) => {
29
29
  if (!XEUtils.eqNull(renders[key]) && renders[key] !== val) {
30
- warnLog('vxe.error.coverProp', [`Renderer.${name}`, key])
30
+ log.warn('vxe.error.coverProp', [`Renderer.${name}`, key])
31
31
  }
32
32
  })
33
33
  }
@@ -1,5 +1,7 @@
1
1
  import XEUtils from 'xe-utils'
2
- import globalConfigStore from './globalStore'
2
+ import { globalConfigStore } from './globalStore'
3
+
4
+ import { VxeGlobalResize } from '../../types'
3
5
 
4
6
  /**
5
7
  * 监听 resize 事件
@@ -36,7 +38,7 @@ function eventListener () {
36
38
  resizeTimeout = setTimeout(eventHandle, globalConfigStore.resizeInterval || defaultInterval)
37
39
  }
38
40
 
39
- export class XEResizeObserver {
41
+ class XEResizeObserver {
40
42
  tarList: {
41
43
  target: Element;
42
44
  width: number;
@@ -77,9 +79,11 @@ export class XEResizeObserver {
77
79
  }
78
80
  }
79
81
 
80
- export function createResizeEvent (callback: (...args: any[]) => void): any {
81
- if (window.ResizeObserver) {
82
- return new window.ResizeObserver(callback)
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)
83
88
  }
84
- return new XEResizeObserver(callback)
85
89
  }
@@ -1,4 +1,4 @@
1
- import { warnLog } from './log'
1
+ import { log } from './log'
2
2
  import XEUtils from 'xe-utils'
3
3
 
4
4
  /**
@@ -25,11 +25,11 @@ export class Store {
25
25
  add (name: string, options: any): Store {
26
26
  const conf = this.store[name]
27
27
  // 检测是否覆盖
28
- if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
28
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
29
29
  const confKeys = XEUtils.keys(conf)
30
30
  XEUtils.each(options, (item, key) => {
31
31
  if (confKeys.includes(key)) {
32
- warnLog('vxe.error.coverProp', [name, key])
32
+ log.warn('vxe.error.coverProp', [name, key])
33
33
  }
34
34
  })
35
35
  }
@@ -0,0 +1,7 @@
1
+ import { VxeGlobalThemeName } from '../../types'
2
+
3
+ export const themeConfigStore: {
4
+ theme: VxeGlobalThemeName
5
+ } = {
6
+ theme: ''
7
+ }
@@ -4,6 +4,6 @@ import { VxeGlobalValidators } from '../../types'
4
4
 
5
5
  export const validators = new VXEStore() as VxeGlobalValidators
6
6
 
7
- if (process.env.VUE_APP_VXE_TABLE_ENV === 'development') {
7
+ if (process.env.VUE_APP_VXE_ENV === 'development') {
8
8
  Object.assign(validators, { _name: 'Validators' })
9
9
  }
@@ -7,7 +7,6 @@ export interface VxeGlobalConfig {
7
7
  zIndex?: number
8
8
  size?: VxeComponentSize
9
9
  version?: string | number
10
- theme?: null | '' | 'default' | 'dark'
11
10
  resizeInterval?: number
12
11
 
13
12
  i18n?(key: string, args?: any): string
@@ -0,0 +1,26 @@
1
+ import { VxeComponentBase } from '../tool'
2
+
3
+ export type VxeGlobalEventType = 'copy' | 'cut' | 'paste' | 'keydown' | 'contextmenu' | 'mousedown' | 'blur' | 'resize' | 'mousewheel'
4
+
5
+ export const GLOBAL_EVENT_KEYS: {
6
+ F2: 'F2',
7
+ ESCAPE: 'Escape',
8
+ ENTER: 'Enter',
9
+ TAB: 'Tab',
10
+ DELETE: 'Delete',
11
+ BACKSPACE: 'Backspace',
12
+ SPACEBAR: ' ',
13
+ CONTEXT_MENU: 'ContextMenu',
14
+ ARROW_UP: 'ArrowUp',
15
+ ARROW_DOWN: 'ArrowDown',
16
+ ARROW_LEFT: 'ArrowLeft',
17
+ ARROW_RIGHT: 'ArrowRight',
18
+ PAGE_UP: 'PageUp',
19
+ PAGE_DOWN: 'PageDown'
20
+ }
21
+
22
+ export interface VxeGlobalEvents {
23
+ on (comp: VxeComponentBase, type: VxeGlobalEventType, cb: (evnt: any) => void): void
24
+ off (comp: VxeComponentBase, type: VxeGlobalEventType): void
25
+ hasKey(evnt: KeyboardEvent, targetKey: string): boolean
26
+ }
@@ -1,4 +1,6 @@
1
1
  /**
2
2
  * 全局图标参数
3
3
  */
4
- export interface VxeGlobalIcon {}
4
+ export interface VxeGlobalIcon {
5
+ LOGO?: string
6
+ }
@@ -0,0 +1 @@
1
+ export type VxeGlobalI18nLocale= '' | 'zh-CN' | 'zh-TC' | 'zh-HK' | 'zh-MO' | 'zh-TW' | 'en-US' | 'ja-JP' | 'es-ES' | 'pt-BR'
@@ -0,0 +1,3 @@
1
+ export interface VxeGlobalResize {
2
+ create (callback: (...args: any[]) => void): ResizeObserver
3
+ }
@@ -0,0 +1 @@
1
+ export type VxeGlobalThemeName = null | '' | 'default' | 'dark'
@@ -1,5 +1,9 @@
1
1
  import { VxeGlobalConfig } from './global-config'
2
2
  import { VxeGlobalIcon } from './global-icon'
3
+ import { VxeGlobalThemeName } from './global-theme'
4
+ import { VxeGlobalI18nLocale } from './global-lang'
5
+ import { VxeGlobalEvents } from './global-event'
6
+ import { VxeGlobalResize } from './global-resize'
3
7
  import { VxeGlobalRenderer } from './renderer'
4
8
  import { VxeGlobalValidators } from './validators'
5
9
  import { VxeGlobalMenus } from './menus'
@@ -8,17 +12,24 @@ import { VxeGlobalCommands } from './commands'
8
12
  import { VxeGlobalInterceptor } from './interceptor'
9
13
  import { VxeGlobalClipboard } from './clipboard'
10
14
  import { VxeGlobalHooks } from './hooks'
15
+ import { VxeGlobalLog } from './log'
11
16
 
12
17
  /* eslint-disable no-use-before-define */
13
18
 
14
- export function setConfig(options?: VxeGlobalConfig): VxeCoreExport
19
+ export function setTheme(name: VxeGlobalThemeName): VxeUIExport
15
20
 
16
- export function getConfig(key: string | number | null | undefined, defaultValue?: any): any
21
+ export function getTheme(): VxeGlobalThemeName
17
22
 
18
- export function setIcon(options?: VxeGlobalIcon): VxeCoreExport
23
+ export function setConfig(options?: VxeGlobalConfig): VxeUIExport
24
+ export function getConfig(): Required<VxeGlobalConfig>
25
+ export function getConfig(key: keyof VxeGlobalConfig, defaultValue?: any): any
19
26
 
20
- export function getIcon(key: string): any
27
+ export function setIcon(options?: VxeGlobalIcon): VxeUIExport
28
+ export function getIcon(): Required<VxeGlobalIcon>
29
+ export function getIcon(key: keyof VxeGlobalIcon): any
21
30
 
31
+ export function setLanguage(locale: VxeGlobalI18nLocale): VxeUIExport
32
+ export function setI18n(locale: VxeGlobalI18nLocale, data: Record<string, any>): VxeUIExport
22
33
  export function getI18n(key: string, args?: any): string
23
34
 
24
35
  export const version: string
@@ -37,13 +48,27 @@ export const interceptor: VxeGlobalInterceptor
37
48
 
38
49
  export const clipboard: VxeGlobalClipboard
39
50
 
51
+ export const globalEvents: VxeGlobalEvents
52
+
53
+ export const globalResize: VxeGlobalResize
54
+
55
+ export const log: VxeGlobalLog
56
+
40
57
  export const hooks: VxeGlobalHooks
41
58
 
42
- export interface VxeCoreExport {
59
+ export interface VxeUIExport {
43
60
  /**
44
61
  * 版本号
45
62
  */
46
- version: string
63
+ coreVersion: string
64
+ /**
65
+ * 设置全局主题
66
+ */
67
+ setTheme: typeof setTheme
68
+ /**
69
+ * 获取全局主题
70
+ */
71
+ getTheme: typeof getTheme
47
72
  /**
48
73
  * 设置全局参数
49
74
  */
@@ -57,9 +82,18 @@ export interface VxeCoreExport {
57
82
  */
58
83
  setIcon: typeof setIcon
59
84
  /**
60
- * 翻译组件语言
85
+ * 设置组件当前语言
86
+ */
87
+ setLanguage: typeof setLanguage
88
+ /**
89
+ * 设置组件语言数据
90
+ */
91
+ setI18n: typeof setI18n
92
+ /**
93
+ * 获取组件语言值
61
94
  */
62
95
  getI18n: typeof getI18n
96
+
63
97
  /**
64
98
  * 获取全局图标
65
99
  */
@@ -93,15 +127,33 @@ export interface VxeCoreExport {
93
127
  * 全局剪贴板
94
128
  */
95
129
  clipboard: VxeGlobalClipboard
130
+ /**
131
+ * 全局事件管理
132
+ */
133
+ globalEvents: VxeGlobalEvents
134
+ /**
135
+ * 全局观察者事件
136
+ */
137
+ globalResize: VxeGlobalResize
138
+
139
+ /**
140
+ * 全局日志
141
+ */
142
+ log: VxeGlobalLog
96
143
 
97
144
  // 扩展插件
98
145
  hooks: VxeGlobalHooks
99
146
  }
100
147
 
101
- export declare const VxeCore: VxeCoreExport
148
+ export const VxeUI: VxeUIExport
102
149
 
103
150
  export * from './global-config'
104
151
  export * from './global-icon'
152
+ export * from './global-theme'
153
+ export * from './global-lang'
154
+ export * from './global-event'
155
+ export * from './global-resize'
156
+
105
157
  export * from './renderer'
106
158
  export * from './validators'
107
159
  export * from './menus'
@@ -109,7 +161,8 @@ export * from './formats'
109
161
  export * from './commands'
110
162
  export * from './interceptor'
111
163
  export * from './clipboard'
164
+ export * from './log'
112
165
 
113
166
  export * from './hooks'
114
167
 
115
- export default VxeCore
168
+ export default VxeUI
@@ -0,0 +1,8 @@
1
+ export function warnLog(): string
2
+ export function errLog(): string
3
+
4
+ export interface VxeGlobalLog {
5
+ create (type: 'log' | 'warn' | 'error', name?: string): ((key: string, args?: any) => string)
6
+ warn(key: string, args?: any): string
7
+ err(key: string, args?: any): string
8
+ }
@@ -1,26 +1,15 @@
1
- import { VxeComponentSlot } from '../tool'
2
-
3
- /* eslint-disable no-use-before-define */
4
-
5
- type RendererOptions = DefineRendererOption<VxeGlobalRendererHandles.RenderResult>
6
-
7
- export interface DefineRendererOption<T> {}
1
+ export interface VxeGlobalRendererOptions {}
8
2
 
9
3
  export namespace VxeGlobalRendererHandles {
10
- export type RenderResult = VxeComponentSlot | VxeComponentSlot[]
11
4
  }
12
5
 
13
6
  /**
14
7
  * 渲染器
15
8
  */
16
9
  export interface VxeGlobalRenderer {
17
- mixin(options: {
18
- [name: string]: RendererOptions
19
- }): VxeGlobalRenderer
20
- get(name: string | null | undefined): DefineRendererOption<VxeGlobalRendererHandles.RenderResult>
21
- add(name: string, options: RendererOptions): VxeGlobalRenderer
22
- forEach(callback: (item: DefineRendererOption<VxeGlobalRendererHandles.RenderResult>, name: string, renderMap: {
23
- [name: string]: RendererOptions
24
- }) => void): VxeGlobalRenderer
10
+ mixin(options: Record<string, VxeGlobalRendererOptions>): VxeGlobalRenderer
11
+ get(name: string | null | undefined): VxeGlobalRendererOptions
12
+ add(name: string, options: VxeGlobalRendererOptions): VxeGlobalRenderer
13
+ forEach(callback: (item: VxeGlobalRendererOptions, name: string, renderMap: Record<string, VxeGlobalRendererOptions>) => void): VxeGlobalRenderer
25
14
  delete(name: string): void
26
15
  }
package/types/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { VxeCoreExport, VxeGlobalConfig } from './core'
1
+ import { VxeUIExport } from './core'
2
2
 
3
3
  declare global {
4
4
  interface Window {
5
- VxeCore: VxeCoreExport;
5
+ VxeUI: VxeUIExport;
6
6
  }
7
7
  }
8
8
 
package/es/src/theme.js DELETED
@@ -1,10 +0,0 @@
1
- import globalConfigStore from './globalStore';
2
- export default function setTheme(options) {
3
- const theme = (options ? options.theme : null) || globalConfigStore.theme || 'default';
4
- if (typeof document !== 'undefined') {
5
- const documentElement = document.documentElement;
6
- if (documentElement) {
7
- documentElement.setAttribute('data-vxe-theme', theme);
8
- }
9
- }
10
- }
package/lib/src/theme.js DELETED
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = setTheme;
7
- var _globalStore = _interopRequireDefault(require("./globalStore"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- function setTheme(options) {
10
- const theme = (options ? options.theme : null) || _globalStore.default.theme || 'default';
11
- if (typeof document !== 'undefined') {
12
- const documentElement = document.documentElement;
13
- if (documentElement) {
14
- documentElement.setAttribute('data-vxe-theme', theme);
15
- }
16
- }
17
- }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=setTheme;var _globalStore=_interopRequireDefault(require("./globalStore"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function setTheme(e){var t,e=(e?e.theme:null)||_globalStore.default.theme||"default";"undefined"!=typeof document&&(t=document.documentElement)&&t.setAttribute("data-vxe-theme",e)}
@@ -1,13 +0,0 @@
1
- import globalConfigStore from './globalStore'
2
-
3
- import { VxeGlobalConfig } from '../../types'
4
-
5
- export default function setTheme (options?: VxeGlobalConfig) {
6
- const theme = (options ? options.theme : null) || globalConfigStore.theme || 'default'
7
- if (typeof document !== 'undefined') {
8
- const documentElement = document.documentElement
9
- if (documentElement) {
10
- documentElement.setAttribute('data-vxe-theme', theme)
11
- }
12
- }
13
- }