vxe-gantt 0.0.1 → 0.0.2

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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +72 -0
  3. package/README.ja-JP.md +72 -0
  4. package/README.md +56 -2
  5. package/README.zh-TW.md +73 -0
  6. package/es/components.js +12 -0
  7. package/es/gantt/index.js +13 -0
  8. package/es/gantt/src/gantt.js +61 -0
  9. package/es/gantt/style.css +0 -0
  10. package/es/gantt/style.min.css +0 -0
  11. package/es/index.esm.js +3 -0
  12. package/es/style.css +0 -0
  13. package/es/style.min.css +0 -0
  14. package/es/ui/index.js +8 -0
  15. package/es/ui/src/comp.js +2 -0
  16. package/es/ui/src/dom.js +230 -0
  17. package/es/ui/src/log.js +4 -0
  18. package/es/ui/src/utils.js +40 -0
  19. package/es/ui/src/vn.js +32 -0
  20. package/es/ui/style.css +0 -0
  21. package/es/ui/style.min.css +0 -0
  22. package/es/vxe-gantt/index.js +3 -0
  23. package/es/vxe-gantt/style.css +0 -0
  24. package/es/vxe-gantt/style.min.css +0 -0
  25. package/es/vxe-ui/index.js +3 -0
  26. package/es/vxe-ui/style.css +0 -0
  27. package/es/vxe-ui/style.min.css +0 -0
  28. package/helper/vetur/attributes.json +1 -0
  29. package/helper/vetur/tags.json +1 -0
  30. package/lib/components.js +42 -0
  31. package/lib/components.min.js +1 -0
  32. package/lib/gantt/index.js +20 -0
  33. package/lib/gantt/index.min.js +1 -0
  34. package/lib/gantt/src/gantt.js +72 -0
  35. package/lib/gantt/src/gantt.min.js +1 -0
  36. package/lib/gantt/style/index.js +1 -0
  37. package/lib/gantt/style/style.css +0 -0
  38. package/lib/gantt/style/style.min.css +0 -0
  39. package/lib/index.common.js +21 -0
  40. package/lib/index.umd.js +317 -0
  41. package/lib/index.umd.min.js +1 -0
  42. package/lib/style.css +0 -0
  43. package/lib/style.min.css +0 -0
  44. package/lib/ui/index.js +25 -0
  45. package/lib/ui/index.min.js +1 -0
  46. package/lib/ui/src/comp.js +8 -0
  47. package/lib/ui/src/comp.min.js +1 -0
  48. package/lib/ui/src/dom.js +277 -0
  49. package/lib/ui/src/dom.min.js +1 -0
  50. package/lib/ui/src/log.js +10 -0
  51. package/lib/ui/src/log.min.js +1 -0
  52. package/lib/ui/src/utils.js +55 -0
  53. package/lib/ui/src/utils.min.js +1 -0
  54. package/lib/ui/src/vn.js +43 -0
  55. package/lib/ui/src/vn.min.js +1 -0
  56. package/lib/ui/style/index.js +1 -0
  57. package/lib/ui/style/style.css +0 -0
  58. package/lib/ui/style/style.min.css +0 -0
  59. package/lib/vxe-gantt/index.js +21 -0
  60. package/lib/vxe-gantt/index.min.js +1 -0
  61. package/lib/vxe-gantt/style/index.js +1 -0
  62. package/lib/vxe-gantt/style/style.css +0 -0
  63. package/lib/vxe-gantt/style/style.min.css +0 -0
  64. package/lib/vxe-ui/index.js +21 -0
  65. package/lib/vxe-ui/index.min.js +1 -0
  66. package/lib/vxe-ui/style/index.js +1 -0
  67. package/lib/vxe-ui/style/style.css +0 -0
  68. package/lib/vxe-ui/style/style.min.css +0 -0
  69. package/package.json +58 -21
  70. package/packages/components.ts +19 -0
  71. package/packages/gantt/index.ts +17 -0
  72. package/packages/gantt/src/gantt.ts +87 -0
  73. package/packages/index.ts +4 -0
  74. package/packages/ui/index.ts +12 -0
  75. package/packages/ui/src/comp.ts +3 -0
  76. package/packages/ui/src/dom.ts +253 -0
  77. package/packages/ui/src/log.ts +6 -0
  78. package/packages/ui/src/utils.ts +49 -0
  79. package/packages/ui/src/vn.ts +37 -0
  80. package/styles/all.scss +3 -0
  81. package/styles/base.scss +2 -0
  82. package/styles/components/gantt.scss +0 -0
  83. package/styles/components/ui.scss +0 -0
  84. package/styles/cssvar.scss +0 -0
  85. package/styles/theme/dark.scss +2 -0
  86. package/styles/theme/light.scss +2 -0
  87. package/styles/variable.scss +0 -0
  88. package/types/all.d.ts +16 -0
  89. package/types/index.d.ts +4 -0
@@ -0,0 +1,253 @@
1
+ import XEUtils from 'xe-utils'
2
+
3
+ let tpImgEl: HTMLImageElement | undefined
4
+
5
+ export function initTpImg () {
6
+ if (!tpImgEl) {
7
+ tpImgEl = new Image()
8
+ tpImgEl.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
9
+ }
10
+ return tpImgEl
11
+ }
12
+
13
+ export function getTpImg () {
14
+ if (!tpImgEl) {
15
+ return initTpImg()
16
+ }
17
+ return tpImgEl
18
+ }
19
+
20
+ const reClsMap: { [key: string]: any } = {}
21
+
22
+ function getClsRE (cls: any) {
23
+ if (!reClsMap[cls]) {
24
+ reClsMap[cls] = new RegExp(`(?:^|\\s)${cls}(?!\\S)`, 'g')
25
+ }
26
+ return reClsMap[cls]
27
+ }
28
+
29
+ function getNodeOffset (elem: any, container: any, rest: any): any {
30
+ if (elem) {
31
+ const parentElem = elem.parentNode
32
+ rest.top += elem.offsetTop
33
+ rest.left += elem.offsetLeft
34
+ if (parentElem && parentElem !== document.documentElement && parentElem !== document.body) {
35
+ rest.top -= parentElem.scrollTop
36
+ rest.left -= parentElem.scrollLeft
37
+ }
38
+ if (container && (elem === container || elem.offsetParent === container) ? 0 : elem.offsetParent) {
39
+ return getNodeOffset(elem.offsetParent, container, rest)
40
+ }
41
+ }
42
+ return rest
43
+ }
44
+
45
+ export function isPx (val: any) {
46
+ return val && /^\d+(px)?$/.test(val)
47
+ }
48
+
49
+ export function isScale (val: any) {
50
+ return val && /^\d+%$/.test(val)
51
+ }
52
+
53
+ export function hasClass (elem: any, cls: any) {
54
+ return !!(elem && elem.className && elem.className.match && elem.className.match(getClsRE(cls)))
55
+ }
56
+
57
+ export function removeClass (elem: any, cls: any) {
58
+ if (elem && hasClass(elem, cls)) {
59
+ elem.className = elem.className.replace(getClsRE(cls), '')
60
+ }
61
+ }
62
+
63
+ export function addClass (elem: any, cls: string) {
64
+ if (elem && !hasClass(elem, cls)) {
65
+ removeClass(elem, cls)
66
+ elem.className = `${elem.className} ${cls}`
67
+ }
68
+ }
69
+
70
+ export function hasControlKey (evnt: KeyboardEvent | MouseEvent | DragEvent) {
71
+ return evnt.ctrlKey || evnt.metaKey
72
+ }
73
+
74
+ export function toCssUnit (val?: number | string | null, unit = 'px') {
75
+ if (XEUtils.isNumber(val) || /^\d+$/.test(`${val}`)) {
76
+ return `${val}${unit}`
77
+ }
78
+ return `${val || ''}`
79
+ }
80
+
81
+ export function getDomNode () {
82
+ const documentElement = document.documentElement
83
+ const bodyElem = document.body
84
+ return {
85
+ scrollTop: documentElement.scrollTop || bodyElem.scrollTop,
86
+ scrollLeft: documentElement.scrollLeft || bodyElem.scrollLeft,
87
+ visibleHeight: documentElement.clientHeight || bodyElem.clientHeight,
88
+ visibleWidth: documentElement.clientWidth || bodyElem.clientWidth
89
+ }
90
+ }
91
+
92
+ /**
93
+ * 检查触发源是否属于目标节点
94
+ */
95
+ export function getEventTargetNode (evnt: any, container: any, queryCls?: string, queryMethod?: (target: Element) => boolean) {
96
+ let targetElem
97
+ let target = (evnt.target.shadowRoot && evnt.composed) ? (evnt.composedPath()[0] || evnt.target) : evnt.target
98
+ while (target && target.nodeType && target !== document) {
99
+ if (queryCls && hasClass(target, queryCls) && (!queryMethod || queryMethod(target))) {
100
+ targetElem = target
101
+ } else if (target === container) {
102
+ return { flag: queryCls ? !!targetElem : true, container, targetElem: targetElem }
103
+ }
104
+ target = target.parentNode
105
+ }
106
+ return { flag: false }
107
+ }
108
+
109
+ /**
110
+ * 获取元素相对于 document 的位置
111
+ */
112
+ export function getOffsetPos (elem: any, container: any) {
113
+ return getNodeOffset(elem, container, { left: 0, top: 0 })
114
+ }
115
+
116
+ export function getAbsolutePos (elem: any) {
117
+ const bounding = elem.getBoundingClientRect()
118
+ const boundingTop = bounding.top
119
+ const boundingLeft = bounding.left
120
+ const { scrollTop, scrollLeft, visibleHeight, visibleWidth } = getDomNode()
121
+ return { boundingTop, top: scrollTop + boundingTop, boundingLeft, left: scrollLeft + boundingLeft, visibleHeight, visibleWidth }
122
+ }
123
+
124
+ export function getPaddingTopBottomSize (elem: HTMLElement) {
125
+ if (elem) {
126
+ const computedStyle = getComputedStyle(elem)
127
+ const paddingTop = XEUtils.toNumber(computedStyle.paddingTop)
128
+ const paddingBottom = XEUtils.toNumber(computedStyle.paddingBottom)
129
+ return paddingTop + paddingBottom
130
+ }
131
+ return 0
132
+ }
133
+
134
+ const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
135
+ const scrollIntoView = 'scrollIntoView'
136
+
137
+ export function scrollToView (elem: any) {
138
+ if (elem) {
139
+ if (elem[scrollIntoViewIfNeeded]) {
140
+ elem[scrollIntoViewIfNeeded]()
141
+ } else if (elem[scrollIntoView]) {
142
+ elem[scrollIntoView]()
143
+ }
144
+ }
145
+ }
146
+
147
+ export function triggerEvent (targetElem: Element, type: string) {
148
+ if (targetElem) {
149
+ targetElem.dispatchEvent(new Event(type))
150
+ }
151
+ }
152
+
153
+ export function isNodeElement (elem: any): elem is HTMLElement {
154
+ return elem && elem.nodeType === 1
155
+ }
156
+
157
+ export function updatePanelPlacement (targetElem: HTMLElement | null | undefined, panelElem: HTMLElement | null | undefined, options: {
158
+ placement?: '' | 'top' | 'bottom' | null
159
+ teleportTo?: boolean
160
+ marginSize?: number
161
+ }) {
162
+ const { placement, teleportTo, marginSize } = Object.assign({ teleportTo: false, marginSize: 32 }, options)
163
+ let panelPlacement: 'top' | 'bottom' = 'bottom'
164
+ let top: number | '' = ''
165
+ let bottom: number | '' = ''
166
+ let left: number | '' = ''
167
+ const right: number | '' = ''
168
+ let minWidth: number | '' = ''
169
+ const stys: Record<string, string> = {}
170
+ if (panelElem && targetElem) {
171
+ const documentElement = document.documentElement
172
+ const bodyElem = document.body
173
+ const targetHeight = targetElem.offsetHeight
174
+ const panelHeight = panelElem.offsetHeight
175
+ const panelWidth = panelElem.offsetWidth
176
+
177
+ const panelRect = panelElem.getBoundingClientRect()
178
+ const targetRect = targetElem.getBoundingClientRect()
179
+ const visibleHeight = documentElement.clientHeight || bodyElem.clientHeight
180
+ const visibleWidth = documentElement.clientWidth || bodyElem.clientWidth
181
+ minWidth = targetElem.offsetWidth
182
+ if (teleportTo) {
183
+ left = targetRect.left
184
+ top = targetRect.top + targetHeight
185
+ if (placement === 'top') {
186
+ panelPlacement = 'top'
187
+ top = targetRect.top - panelHeight
188
+ } else if (!placement) {
189
+ // 如果下面不够放,则向上
190
+ if (top + panelHeight + marginSize > visibleHeight) {
191
+ panelPlacement = 'top'
192
+ top = targetRect.top - panelHeight
193
+ }
194
+ // 如果上面不够放,则向下(优先)
195
+ if (top < marginSize) {
196
+ panelPlacement = 'bottom'
197
+ top = targetRect.top + targetHeight
198
+ }
199
+ }
200
+ // 如果溢出右边
201
+ if (left + panelWidth + marginSize > visibleWidth) {
202
+ left -= left + panelWidth + marginSize - visibleWidth
203
+ }
204
+ // 如果溢出左边
205
+ if (left < marginSize) {
206
+ left = marginSize
207
+ }
208
+ } else {
209
+ if (placement === 'top') {
210
+ panelPlacement = 'top'
211
+ bottom = targetHeight
212
+ } else if (!placement) {
213
+ // 如果下面不够放,则向上
214
+ top = targetHeight
215
+ if (targetRect.top + targetRect.height + marginSize > visibleHeight) {
216
+ // 如果上面不够放,则向下(优先)
217
+ if (targetRect.top - targetHeight - panelHeight > marginSize) {
218
+ panelPlacement = 'top'
219
+ top = ''
220
+ bottom = targetHeight
221
+ }
222
+ }
223
+ }
224
+ // 是否超出右侧
225
+ if (panelRect.left + panelRect.width + marginSize > visibleWidth) {
226
+ left = -(panelRect.left + panelRect.width + marginSize - visibleWidth)
227
+ }
228
+ }
229
+ if (XEUtils.isNumber(top)) {
230
+ stys.top = toCssUnit(top)
231
+ }
232
+ if (XEUtils.isNumber(bottom)) {
233
+ stys.bottom = toCssUnit(bottom)
234
+ }
235
+ if (XEUtils.isNumber(left)) {
236
+ stys.left = toCssUnit(left)
237
+ }
238
+ if (XEUtils.isNumber(right)) {
239
+ stys.right = toCssUnit(right)
240
+ }
241
+ if (XEUtils.isNumber(minWidth)) {
242
+ stys.minWidth = toCssUnit(minWidth)
243
+ }
244
+ }
245
+ return {
246
+ top: top || 0,
247
+ bottom: bottom || 0,
248
+ left: left || 0,
249
+ right: right || 0,
250
+ style: stys,
251
+ placement: panelPlacement
252
+ }
253
+ }
@@ -0,0 +1,6 @@
1
+ import { log } from '@vxe-ui/core'
2
+
3
+ const version = `ui v${process.env.VUE_APP_VXE_VERSION}`
4
+
5
+ export const warnLog = log.create('warn', version)
6
+ export const errLog = log.create('error', version)
@@ -0,0 +1,49 @@
1
+ import XEUtils from 'xe-utils'
2
+ import { getConfig } from '@vxe-ui/core'
3
+ import DomZIndex from 'dom-zindex'
4
+
5
+ export function isEnableConf (conf: any): boolean {
6
+ return conf && conf.enabled !== false
7
+ }
8
+
9
+ export function nextZIndex () {
10
+ return DomZIndex.getNext()
11
+ }
12
+
13
+ export function getLastZIndex () {
14
+ return DomZIndex.getCurrent()
15
+ }
16
+
17
+ export function nextSubZIndex () {
18
+ return DomZIndex.getSubNext()
19
+ }
20
+
21
+ export function getSubLastZIndex () {
22
+ return DomZIndex.getSubCurrent()
23
+ }
24
+
25
+ export function getGlobalDefaultConfig (value: any, globalValue: any) {
26
+ if (XEUtils.eqNull(value)) {
27
+ return globalValue
28
+ }
29
+ return value
30
+ }
31
+
32
+ export function getFuncText (content: string | number | boolean | null | undefined, args?: any) {
33
+ if (content) {
34
+ const translate = getConfig().translate
35
+ return XEUtils.toValueString(translate ? translate('' + content, args) : content)
36
+ }
37
+ return ''
38
+ }
39
+
40
+ /**
41
+ * 判断值为:'' | null | undefined 时都属于空值
42
+ */
43
+ export function eqEmptyValue (cellValue: any) {
44
+ return cellValue === null || cellValue === undefined || cellValue === ''
45
+ }
46
+
47
+ export function handleBooleanDefaultValue (value: boolean | undefined | null) {
48
+ return XEUtils.isBoolean(value) ? value : null
49
+ }
@@ -0,0 +1,37 @@
1
+ import XEUtils from 'xe-utils'
2
+ import { VxeComponentSlotType } from '@vxe-ui/core'
3
+
4
+ export function getOnName (type: string) {
5
+ return 'on' + type.substring(0, 1).toLocaleUpperCase() + type.substring(1)
6
+ }
7
+
8
+ export function getModelEvent (name: string) {
9
+ switch (name) {
10
+ case 'input':
11
+ case 'textarea':
12
+ return 'input'
13
+ case 'select':
14
+ return 'change'
15
+ }
16
+ return 'update:modelValue'
17
+ }
18
+
19
+ export function getChangeEvent (name: string) {
20
+ switch (name) {
21
+ case 'input':
22
+ case 'textarea':
23
+ case 'VxeInput':
24
+ case 'VxeTextarea':
25
+ case '$input':// 已废弃
26
+ case '$textarea':// 已废弃
27
+ return 'input'
28
+ }
29
+ return 'change'
30
+ }
31
+
32
+ export function getSlotVNs (vns: VxeComponentSlotType | VxeComponentSlotType[] | undefined) {
33
+ if (XEUtils.isArray(vns)) {
34
+ return vns
35
+ }
36
+ return vns ? [vns] : []
37
+ }
@@ -0,0 +1,3 @@
1
+ @use './base.scss';
2
+
3
+ @use './components/gantt.scss';
@@ -0,0 +1,2 @@
1
+ @use './theme/light.scss';
2
+ @use './theme/dark.scss';
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ [data-vxe-ui-theme="dark"] {
2
+ }
@@ -0,0 +1,2 @@
1
+ [data-vxe-ui-theme="light"] {
2
+ }
File without changes
package/types/all.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { App } from 'vue'
2
+ import { VxeUIExport, VxeGlobalConfig } from 'vxe-pc-ui'
3
+
4
+ declare global {
5
+ interface Window {
6
+ VxeUIGantt: VxeUIExport
7
+ }
8
+ }
9
+
10
+ export function install (app: App, options?: VxeGlobalConfig): void
11
+
12
+ // Vxe core
13
+ export * from 'vxe-pc-ui/types/ui'
14
+
15
+ // Vxe Gantt
16
+ export * from 'vxe-pc-ui/types/components/gantt'
@@ -0,0 +1,4 @@
1
+ import * as VxeUIGanttExport from './all'
2
+
3
+ export * from './all'
4
+ export default VxeUIGanttExport