vxe-gantt 0.0.2 → 0.0.3

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 (93) hide show
  1. package/README.md +27 -1
  2. package/es/gantt/src/emits.js +4 -0
  3. package/es/gantt/src/gantt-body.js +103 -0
  4. package/es/gantt/src/gantt-chart.js +77 -0
  5. package/es/gantt/src/gantt-header.js +70 -0
  6. package/es/gantt/src/gantt-view.js +768 -0
  7. package/es/gantt/src/gantt.js +1707 -22
  8. package/es/gantt/src/grid-emits.js +16 -0
  9. package/es/gantt/src/grid-props.js +7 -0
  10. package/es/gantt/src/props.js +2 -0
  11. package/es/gantt/src/table-emits.js +97 -0
  12. package/es/gantt/src/table-props.js +298 -0
  13. package/es/gantt/src/util.js +12 -0
  14. package/es/gantt/style.css +599 -0
  15. package/es/gantt/style.min.css +1 -0
  16. package/es/style.css +1 -0
  17. package/es/style.min.css +1 -0
  18. package/es/ui/index.js +47 -3
  19. package/es/ui/src/dom.js +44 -105
  20. package/es/ui/src/log.js +1 -1
  21. package/es/ui/src/utils.js +18 -17
  22. package/es/ui/src/vn.js +1 -32
  23. package/es/vxe-gantt/style.css +599 -0
  24. package/es/vxe-gantt/style.min.css +1 -0
  25. package/lib/gantt/src/emits.js +8 -0
  26. package/lib/gantt/src/emits.min.js +1 -0
  27. package/lib/gantt/src/gantt-body.js +118 -0
  28. package/lib/gantt/src/gantt-body.min.js +1 -0
  29. package/lib/gantt/src/gantt-chart.js +94 -0
  30. package/lib/gantt/src/gantt-chart.min.js +1 -0
  31. package/lib/gantt/src/gantt-header.js +78 -0
  32. package/lib/gantt/src/gantt-header.min.js +1 -0
  33. package/lib/gantt/src/gantt-view.js +810 -0
  34. package/lib/gantt/src/gantt-view.min.js +1 -0
  35. package/lib/gantt/src/gantt.js +1945 -20
  36. package/lib/gantt/src/gantt.min.js +1 -1
  37. package/lib/gantt/src/grid-emits.js +8 -0
  38. package/lib/gantt/src/grid-emits.min.js +1 -0
  39. package/lib/gantt/src/grid-props.js +24 -0
  40. package/lib/gantt/src/grid-props.min.js +1 -0
  41. package/lib/gantt/src/props.js +13 -0
  42. package/lib/gantt/src/props.min.js +1 -0
  43. package/lib/gantt/src/table-emits.js +7 -0
  44. package/lib/gantt/src/table-emits.min.js +1 -0
  45. package/lib/gantt/src/table-props.js +306 -0
  46. package/lib/gantt/src/table-props.min.js +1 -0
  47. package/lib/gantt/src/util.js +19 -0
  48. package/lib/gantt/src/util.min.js +1 -0
  49. package/lib/gantt/style/style.css +599 -0
  50. package/lib/gantt/style/style.min.css +1 -0
  51. package/lib/index.umd.js +6554 -140
  52. package/lib/index.umd.min.js +1 -1
  53. package/lib/style.css +1 -0
  54. package/lib/style.min.css +1 -0
  55. package/lib/ui/index.js +47 -3
  56. package/lib/ui/index.min.js +1 -1
  57. package/lib/ui/src/dom.js +50 -110
  58. package/lib/ui/src/dom.min.js +1 -1
  59. package/lib/ui/src/log.js +1 -1
  60. package/lib/ui/src/log.min.js +1 -1
  61. package/lib/ui/src/utils.js +24 -20
  62. package/lib/ui/src/utils.min.js +1 -1
  63. package/lib/ui/src/vn.js +1 -43
  64. package/lib/ui/src/vn.min.js +0 -1
  65. package/lib/vxe-gantt/style/style.css +599 -0
  66. package/lib/vxe-gantt/style/style.min.css +1 -0
  67. package/package.json +4 -4
  68. package/packages/gantt/src/emits.ts +7 -0
  69. package/packages/gantt/src/gantt-body.ts +119 -0
  70. package/packages/gantt/src/gantt-chart.ts +92 -0
  71. package/packages/gantt/src/gantt-header.ts +79 -0
  72. package/packages/gantt/src/gantt-view.ts +840 -0
  73. package/packages/gantt/src/gantt.ts +1806 -24
  74. package/packages/gantt/src/grid-emits.ts +19 -0
  75. package/packages/gantt/src/grid-props.ts +23 -0
  76. package/packages/gantt/src/props.ts +13 -0
  77. package/packages/gantt/src/table-emits.ts +109 -0
  78. package/packages/gantt/src/table-props.ts +304 -0
  79. package/packages/gantt/src/util.ts +15 -0
  80. package/packages/ui/index.ts +48 -2
  81. package/packages/ui/src/dom.ts +53 -110
  82. package/packages/ui/src/log.ts +1 -1
  83. package/packages/ui/src/utils.ts +22 -21
  84. package/packages/ui/src/vn.ts +0 -37
  85. package/styles/components/gantt-module/all.scss +1 -0
  86. package/styles/components/gantt-module/gantt-chart.scss +46 -0
  87. package/styles/components/gantt.scss +586 -0
  88. package/styles/helpers/baseMixin.scss +96 -0
  89. package/styles/helpers/baseVar.scss +4 -0
  90. package/styles/helpers/placement.scss +39 -0
  91. package/styles/theme/base.scss +7 -0
  92. package/styles/theme/dark.scss +5 -0
  93. package/styles/theme/light.scss +5 -0
@@ -1,5 +1,7 @@
1
1
  import XEUtils from 'xe-utils'
2
2
 
3
+ const reClsMap: { [key: string]: any } = {}
4
+
3
5
  let tpImgEl: HTMLImageElement | undefined
4
6
 
5
7
  export function initTpImg () {
@@ -17,7 +19,9 @@ export function getTpImg () {
17
19
  return tpImgEl
18
20
  }
19
21
 
20
- const reClsMap: { [key: string]: any } = {}
22
+ export function getPropClass (property: any, params: any) {
23
+ return property ? XEUtils.isFunction(property) ? property(params) : property : ''
24
+ }
21
25
 
22
26
  function getClsRE (cls: any) {
23
27
  if (!reClsMap[cls]) {
@@ -71,13 +75,20 @@ export function hasControlKey (evnt: KeyboardEvent | MouseEvent | DragEvent) {
71
75
  return evnt.ctrlKey || evnt.metaKey
72
76
  }
73
77
 
74
- export function toCssUnit (val?: number | string | null, unit = 'px') {
78
+ export function toCssUnit (val?: number | string, unit = 'px') {
75
79
  if (XEUtils.isNumber(val) || /^\d+$/.test(`${val}`)) {
76
80
  return `${val}${unit}`
77
81
  }
78
82
  return `${val || ''}`
79
83
  }
80
84
 
85
+ export function queryElement (elem: HTMLTableCellElement, selector: string) {
86
+ if (elem) {
87
+ return elem.querySelector<HTMLElement>(selector)
88
+ }
89
+ return null
90
+ }
91
+
81
92
  export function getDomNode () {
82
93
  const documentElement = document.documentElement
83
94
  const bodyElem = document.body
@@ -89,6 +100,46 @@ export function getDomNode () {
89
100
  }
90
101
  }
91
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
+
92
143
  /**
93
144
  * 检查触发源是否属于目标节点
94
145
  */
@@ -121,16 +172,6 @@ export function getAbsolutePos (elem: any) {
121
172
  return { boundingTop, top: scrollTop + boundingTop, boundingLeft, left: scrollLeft + boundingLeft, visibleHeight, visibleWidth }
122
173
  }
123
174
 
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
175
  const scrollIntoViewIfNeeded = 'scrollIntoViewIfNeeded'
135
176
  const scrollIntoView = 'scrollIntoView'
136
177
 
@@ -153,101 +194,3 @@ export function triggerEvent (targetElem: Element, type: string) {
153
194
  export function isNodeElement (elem: any): elem is HTMLElement {
154
195
  return elem && elem.nodeType === 1
155
196
  }
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
- }
@@ -1,6 +1,6 @@
1
1
  import { log } from '@vxe-ui/core'
2
2
 
3
- const version = `ui v${process.env.VUE_APP_VXE_VERSION}`
3
+ const version = `gantt v${process.env.VUE_APP_VXE_VERSION}`
4
4
 
5
5
  export const warnLog = log.create('warn', version)
6
6
  export const errLog = log.create('error', version)
@@ -1,49 +1,50 @@
1
1
  import XEUtils from 'xe-utils'
2
- import { getConfig } from '@vxe-ui/core'
2
+ import { VxeUI } from '@vxe-ui/core'
3
3
  import DomZIndex from 'dom-zindex'
4
4
 
5
5
  export function isEnableConf (conf: any): boolean {
6
6
  return conf && conf.enabled !== false
7
7
  }
8
8
 
9
- export function nextZIndex () {
10
- return DomZIndex.getNext()
9
+ export function isEmptyValue (cellValue: any) {
10
+ return cellValue === null || cellValue === undefined || cellValue === ''
11
11
  }
12
12
 
13
- export function getLastZIndex () {
14
- return DomZIndex.getCurrent()
13
+ export function parseFile (file: File) {
14
+ const name = file.name
15
+ const tIndex = XEUtils.lastIndexOf(name, '.')
16
+ const type = name.substring(tIndex + 1, name.length).toLowerCase()
17
+ const filename = name.substring(0, tIndex)
18
+ return { filename, type }
15
19
  }
16
20
 
17
- export function nextSubZIndex () {
18
- return DomZIndex.getSubNext()
21
+ export function nextZIndex () {
22
+ return DomZIndex.getNext()
19
23
  }
20
24
 
21
- export function getSubLastZIndex () {
22
- return DomZIndex.getSubCurrent()
25
+ export function getLastZIndex () {
26
+ return DomZIndex.getCurrent()
23
27
  }
24
28
 
25
- export function getGlobalDefaultConfig (value: any, globalValue: any) {
26
- if (XEUtils.eqNull(value)) {
27
- return globalValue
28
- }
29
- return value
29
+ export function hasChildrenList (item: any) {
30
+ return item && item.children && item.children.length > 0
30
31
  }
31
32
 
32
- export function getFuncText (content: string | number | boolean | null | undefined, args?: any) {
33
+ export function getFuncText (content?: string | number | boolean | null, args?: any) {
33
34
  if (content) {
34
- const translate = getConfig().translate
35
+ const translate = VxeUI.getConfig().translate
35
36
  return XEUtils.toValueString(translate ? translate('' + content, args) : content)
36
37
  }
37
38
  return ''
38
39
  }
39
40
 
41
+ export function formatText (value: any, placeholder?: any) {
42
+ return '' + (isEmptyValue(value) ? (placeholder ? VxeUI.getConfig().emptyCell : '') : value)
43
+ }
44
+
40
45
  /**
41
46
  * 判断值为:'' | null | undefined 时都属于空值
42
47
  */
43
48
  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
+ return cellValue === '' || XEUtils.eqNull(cellValue)
49
50
  }
@@ -1,37 +0,0 @@
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 @@
1
+ @use './gantt-chart.scss'
@@ -0,0 +1,46 @@
1
+ .vxe-gantt-view--chart-wrapper {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ pointer-events: none;
6
+ }
7
+ .vxe-gantt-view--chart-row {
8
+ position: relative;
9
+ }
10
+ .vxe-gantt-view--chart-bar {
11
+ display: flex;
12
+ flex-direction: row;
13
+ position: absolute;
14
+ width: 100px;
15
+ top: 50%;
16
+ left: 0;
17
+ color: #ffffff;
18
+ transform: translateY(-50%);
19
+ border-radius: var(--vxe-ui-base-border-radius);
20
+ height: var(--vxe-ui-gantt-view-chart-bar-height);
21
+ background-color: var(--vxe-ui-font-primary-lighten-color);
22
+ pointer-events: all;
23
+ &:hover {
24
+ &::after {
25
+ content: "";
26
+ position: absolute;
27
+ top: 0;
28
+ left: 0;
29
+ width: 100%;
30
+ height: 100%;
31
+ background-color: rgba(0, 0, 0, 0.1);
32
+ border-radius: var(--vxe-ui-base-border-radius);
33
+ }
34
+ }
35
+ }
36
+ .vxe-gantt-view--chart-progress {
37
+ flex-shrink: 0;
38
+ width: 40px;
39
+ text-align: left;
40
+ border-radius: var(--vxe-ui-base-border-radius) 0 0 var(--vxe-ui-base-border-radius);
41
+ background-color: var(--vxe-ui-font-primary-color);
42
+ }
43
+ .vxe-gantt-view--chart-content {
44
+ flex-grow: 1;
45
+ text-align: right;
46
+ }