vxe-gantt 0.0.3 → 3.0.0-beta.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.
Files changed (106) hide show
  1. package/README.md +14 -46
  2. package/es/components.js +3 -2
  3. package/es/gantt/src/gantt-body.js +83 -49
  4. package/es/gantt/src/gantt-chart.js +91 -43
  5. package/es/gantt/src/gantt-header.js +63 -36
  6. package/es/gantt/src/gantt-view.js +638 -586
  7. package/es/gantt/src/gantt.js +1346 -1178
  8. package/es/gantt/src/util.js +1 -4
  9. package/es/gantt/style.css +62 -28
  10. package/es/gantt/style.min.css +1 -1
  11. package/es/index.esm.js +5 -2
  12. package/es/style.css +1 -1
  13. package/es/style.min.css +1 -1
  14. package/es/ui/index.js +9 -3
  15. package/es/ui/src/comp.js +1 -2
  16. package/es/ui/src/log.js +3 -2
  17. package/es/ui/src/utils.js +17 -17
  18. package/es/vxe-gantt/style.css +62 -28
  19. package/es/vxe-gantt/style.min.css +1 -1
  20. package/helper/vetur/attributes.json +1 -1
  21. package/helper/vetur/tags.json +1 -1
  22. package/lib/components.js +20 -19
  23. package/lib/components.min.js +1 -1
  24. package/lib/gantt/index.js +3 -3
  25. package/lib/gantt/index.min.js +1 -1
  26. package/lib/gantt/src/gantt-body.js +109 -87
  27. package/lib/gantt/src/gantt-body.min.js +1 -1
  28. package/lib/gantt/src/gantt-chart.js +109 -69
  29. package/lib/gantt/src/gantt-chart.min.js +1 -1
  30. package/lib/gantt/src/gantt-header.js +75 -56
  31. package/lib/gantt/src/gantt-header.min.js +1 -1
  32. package/lib/gantt/src/gantt-view.js +684 -686
  33. package/lib/gantt/src/gantt-view.min.js +1 -1
  34. package/lib/gantt/src/gantt.js +1630 -1559
  35. package/lib/gantt/src/gantt.min.js +1 -1
  36. package/lib/gantt/src/util.js +1 -4
  37. package/lib/gantt/src/util.min.js +1 -1
  38. package/lib/gantt/style/style.css +62 -28
  39. package/lib/gantt/style/style.min.css +1 -1
  40. package/lib/index.common.js +12 -7
  41. package/lib/index.umd.js +10704 -5870
  42. package/lib/index.umd.min.js +1 -1
  43. package/lib/style.css +1 -1
  44. package/lib/style.min.css +1 -1
  45. package/lib/ui/index.js +12 -16
  46. package/lib/ui/index.min.js +1 -1
  47. package/lib/ui/src/comp.js +3 -2
  48. package/lib/ui/src/comp.min.js +1 -1
  49. package/lib/ui/src/dom.js +33 -33
  50. package/lib/ui/src/dom.min.js +1 -1
  51. package/lib/ui/src/log.js +4 -3
  52. package/lib/ui/src/log.min.js +1 -1
  53. package/lib/ui/src/utils.js +21 -24
  54. package/lib/ui/src/utils.min.js +1 -1
  55. package/lib/vxe-gantt/index.js +4 -2
  56. package/lib/vxe-gantt/index.min.js +1 -1
  57. package/lib/vxe-gantt/style/style.css +62 -28
  58. package/lib/vxe-gantt/style/style.min.css +1 -1
  59. package/lib/vxe-ui/index.js +4 -2
  60. package/lib/vxe-ui/index.min.js +1 -1
  61. package/package.json +13 -13
  62. package/packages/components.ts +8 -5
  63. package/packages/gantt/index.ts +2 -2
  64. package/packages/gantt/src/gantt-body.ts +89 -53
  65. package/packages/gantt/src/gantt-chart.ts +100 -49
  66. package/packages/gantt/src/gantt-header.ts +69 -39
  67. package/packages/gantt/src/gantt-view.ts +692 -624
  68. package/packages/gantt/src/gantt.ts +1459 -1240
  69. package/packages/gantt/src/util.ts +1 -4
  70. package/packages/index.ts +6 -2
  71. package/packages/ui/index.ts +9 -3
  72. package/packages/ui/src/comp.ts +2 -2
  73. package/packages/ui/src/log.ts +3 -1
  74. package/packages/ui/src/utils.ts +22 -21
  75. package/styles/components/gantt-module/gantt-chart.scss +28 -9
  76. package/styles/components/gantt.scss +36 -21
  77. package/styles/theme/base.scss +5 -1
  78. package/types/all.d.ts +3 -3
  79. package/types/index.d.ts +2 -2
  80. package/README.en.md +0 -72
  81. package/README.ja-JP.md +0 -72
  82. package/README.zh-TW.md +0 -73
  83. package/es/gantt/src/emits.js +0 -4
  84. package/es/gantt/src/grid-emits.js +0 -16
  85. package/es/gantt/src/grid-props.js +0 -7
  86. package/es/gantt/src/props.js +0 -2
  87. package/es/gantt/src/table-emits.js +0 -97
  88. package/es/gantt/src/table-props.js +0 -298
  89. package/lib/gantt/src/emits.js +0 -8
  90. package/lib/gantt/src/emits.min.js +0 -1
  91. package/lib/gantt/src/grid-emits.js +0 -8
  92. package/lib/gantt/src/grid-emits.min.js +0 -1
  93. package/lib/gantt/src/grid-props.js +0 -24
  94. package/lib/gantt/src/grid-props.min.js +0 -1
  95. package/lib/gantt/src/props.js +0 -13
  96. package/lib/gantt/src/props.min.js +0 -1
  97. package/lib/gantt/src/table-emits.js +0 -7
  98. package/lib/gantt/src/table-emits.min.js +0 -1
  99. package/lib/gantt/src/table-props.js +0 -306
  100. package/lib/gantt/src/table-props.min.js +0 -1
  101. package/packages/gantt/src/emits.ts +0 -7
  102. package/packages/gantt/src/grid-emits.ts +0 -19
  103. package/packages/gantt/src/grid-props.ts +0 -23
  104. package/packages/gantt/src/props.ts +0 -13
  105. package/packages/gantt/src/table-emits.ts +0 -109
  106. package/packages/gantt/src/table-props.ts +0 -304
@@ -1,92 +1,143 @@
1
- import { h, inject, VNode, ref, Ref, onMounted, onUnmounted } from 'vue'
1
+ import { VNode, CreateElement } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
+ import { VxeUI } from '@vxe-ui/core'
3
4
  import XEUtils from 'xe-utils'
4
5
  import { getCellRestHeight } from './util'
6
+ import { getStringValue } from '../../ui/src/utils'
5
7
 
6
- import type { VxeTablePropTypes } from 'vxe-table'
8
+ import type { VxeTablePropTypes, TableInternalData } from 'vxe-table'
7
9
  import type { VxeGanttViewConstructor, VxeGanttViewPrivateMethods, VxeGanttConstructor, VxeGanttPrivateMethods } from '../../../types'
8
10
 
11
+ const { renderEmptyElement } = VxeUI
12
+
9
13
  export default defineVxeComponent({
10
14
  name: 'VxeGanttViewChart',
11
- setup () {
12
- const $xeGantt = inject('$xeGantt', {} as (VxeGanttConstructor & VxeGanttPrivateMethods))
13
- const $xeGanttView = inject('$xeGanttView', {} as VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
14
-
15
- const { reactData, internalData } = $xeGanttView
16
- const { refTable } = $xeGantt.getRefMaps()
17
- const { computeProgressField } = $xeGantt.getComputeMaps()
18
-
19
- const refElem = ref() as Ref<HTMLDivElement>
20
-
21
- const renderVN = () => {
22
- const $xeTable = refTable.value
15
+ inject: {
16
+ $xeGantt: {
17
+ default: null
18
+ },
19
+ $xeGanttView: {
20
+ default: null
21
+ }
22
+ },
23
+ props: {},
24
+ data () {
25
+ return {}
26
+ },
27
+ computed: {
28
+ ...({} as {
29
+ $xeGantt(): (VxeGanttConstructor & VxeGanttPrivateMethods)
30
+ $xeGanttView(): (VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
31
+ })
32
+ },
33
+ methods: {
34
+ //
35
+ // Render
36
+ //
37
+ renderVN (h: CreateElement) {
38
+ const _vm = this
39
+ const $xeGantt = _vm.$xeGantt
40
+ const $xeGanttView = _vm.$xeGanttView
41
+ const $xeTable = $xeGanttView.internalData.xeTable
23
42
 
24
- const fullAllDataRowIdData = $xeTable ? $xeTable.internalData.fullAllDataRowIdData : {}
43
+ const tableInternalData = ($xeTable ? $xeTable as unknown : {}) as TableInternalData
44
+ const fullAllDataRowIdData = tableInternalData.fullAllDataRowIdData || {}
25
45
  let cellOpts: VxeTablePropTypes.CellConfig = {}
26
46
  let rowOpts : VxeTablePropTypes.RowConfig = {}
27
47
  let defaultRowHeight = 0
28
48
  if ($xeTable) {
29
- const { computeCellOpts, computeRowOpts, computeDefaultRowHeight } = $xeTable.getComputeMaps()
30
- cellOpts = computeCellOpts.value
31
- rowOpts = computeRowOpts.value
32
- defaultRowHeight = computeDefaultRowHeight.value
49
+ cellOpts = $xeTable.computeCellOpts
50
+ rowOpts = $xeTable.computeRowOpts
51
+ defaultRowHeight = $xeTable.computeDefaultRowHeight
33
52
  }
34
53
 
54
+ const { reactData } = $xeGanttView
35
55
  const { tableData } = reactData
36
- const progressField = computeProgressField.value
56
+ const titleField = $xeGantt.computeTitleField
57
+ const progressField = $xeGantt.computeProgressField
58
+ const taskBarOpts = $xeGantt.computeTaskBarOpts
59
+ const { showProgress, showContent, contentMethod, barStyle } = taskBarOpts
60
+ const { round } = barStyle || {}
37
61
 
38
- const trVNs:VNode[] = []
62
+ const trVNs: VNode[] = []
39
63
  tableData.forEach((row, rIndex) => {
40
64
  const rowid = $xeTable ? $xeTable.getRowid(row) : ''
41
65
  const rowRest = fullAllDataRowIdData[rowid] || {}
42
66
  const cellHeight = getCellRestHeight(rowRest, cellOpts, rowOpts, defaultRowHeight)
43
- const progressValue = XEUtils.get(row, progressField)
67
+ let title = getStringValue(XEUtils.get(row, titleField))
68
+ const progressValue = showProgress ? Math.min(100, Math.max(0, XEUtils.toNumber(XEUtils.get(row, progressField)))) : 0
69
+ if (contentMethod) {
70
+ title = getStringValue(contentMethod({ row, title }))
71
+ }
44
72
  trVNs.push(
45
73
  h('div', {
46
74
  key: rIndex,
47
- rowid,
48
- class: 'vxe-gantt-view--chart-row',
75
+ attrs: {
76
+ rowid
77
+ },
78
+ class: ['vxe-gantt-view--chart-row', {
79
+ 'is--round': round
80
+ }],
49
81
  style: {
50
82
  height: `${cellHeight}px`
51
83
  }
52
84
  }, [
53
85
  h('div', {
54
86
  class: 'vxe-gantt-view--chart-bar',
55
- rowid
87
+ attrs: {
88
+ rowid
89
+ },
90
+ on: {
91
+ click (evnt: MouseEvent) {
92
+ $xeGantt.handleTaskBarClickEvent(evnt, { row })
93
+ },
94
+ dblclick (evnt: MouseEvent) {
95
+ $xeGantt.handleTaskBarDblclickEvent(evnt, { row })
96
+ }
97
+ }
56
98
  }, [
57
- h('div', {
58
- class: 'vxe-gantt-view--chart-progress',
59
- style: progressValue
60
- ? {
61
- width: `${progressValue}%`
62
- }
63
- : undefined
64
- }),
65
- h('div', {
66
- class: 'vxe-gantt-view--chart-content'
67
- })
99
+ showProgress
100
+ ? h('div', {
101
+ class: 'vxe-gantt-view--chart-progress',
102
+ style: {
103
+ width: `${progressValue || 0}%`
104
+ }
105
+ })
106
+ : renderEmptyElement($xeGantt),
107
+ showContent
108
+ ? h('div', {
109
+ class: 'vxe-gantt-view--chart-content'
110
+ }, title)
111
+ : renderEmptyElement($xeGantt)
68
112
  ])
69
113
  ])
70
114
  )
71
115
  })
72
116
  return h('div', {
73
- ref: refElem,
117
+ ref: 'refElem',
74
118
  class: 'vxe-gantt-view--chart-wrapper'
75
119
  }, trVNs)
76
120
  }
121
+ },
122
+ mounted () {
123
+ const _vm = this
124
+ const $xeGanttView = _vm.$xeGanttView
125
+ const { internalData } = $xeGanttView
77
126
 
78
- onMounted(() => {
79
- const { elemStore } = internalData
80
- const prefix = 'main-chart-'
81
- elemStore[`${prefix}wrapper`] = refElem
82
- })
83
-
84
- onUnmounted(() => {
85
- const { elemStore } = internalData
86
- const prefix = 'main-chart-'
87
- elemStore[`${prefix}wrapper`] = null
88
- })
127
+ const { elemStore } = internalData
128
+ const prefix = 'main-chart-'
129
+ elemStore[`${prefix}wrapper`] = _vm.$refs.refElem as HTMLDivElement
130
+ },
131
+ destroyed () {
132
+ const _vm = this
133
+ const $xeGanttView = _vm.$xeGanttView
134
+ const { internalData } = $xeGanttView
89
135
 
90
- return renderVN
136
+ const { elemStore } = internalData
137
+ const prefix = 'main-chart-'
138
+ elemStore[`${prefix}wrapper`] = null
139
+ },
140
+ render (this: any, h) {
141
+ return this.renderVN(h)
91
142
  }
92
143
  })
@@ -1,42 +1,63 @@
1
- import { h, inject, ref, Ref, onMounted, onUnmounted } from 'vue'
1
+ import { CreateElement } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
 
4
- import type { VxeGanttViewConstructor, VxeGanttViewPrivateMethods } from '../../../types'
4
+ import type { VxeGanttViewConstructor, VxeGanttViewPrivateMethods, VxeGanttConstructor, VxeGanttPrivateMethods } from '../../../types'
5
5
 
6
6
  export default defineVxeComponent({
7
7
  name: 'VxeGanttView',
8
- setup () {
9
- const $xeGanttView = inject('$xeGanttView', {} as VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
10
-
11
- const { reactData, internalData } = $xeGanttView
12
-
13
- const refElem = ref() as Ref<HTMLDivElement>
14
- const refHeaderScroll = ref() as Ref<HTMLDivElement>
15
- const refHeaderTable = ref() as Ref<HTMLTableElement>
16
- const refHeaderXSpace = ref() as Ref<HTMLDivElement>
8
+ inject: {
9
+ $xeGantt: {
10
+ default: null
11
+ },
12
+ $xeGanttView: {
13
+ default: null
14
+ }
15
+ },
16
+ props: {},
17
+ data () {
18
+ return {}
19
+ },
20
+ computed: {
21
+ ...({} as {
22
+ $xeGantt(): (VxeGanttConstructor & VxeGanttPrivateMethods)
23
+ $xeGanttView(): (VxeGanttViewConstructor & VxeGanttViewPrivateMethods)
24
+ })
25
+ },
26
+ methods: {
27
+ //
28
+ // Render
29
+ //
30
+ renderVN (h: CreateElement) {
31
+ const _vm = this
32
+ const $xeGanttView = _vm.$xeGanttView
33
+ const { reactData } = $xeGanttView
17
34
 
18
- const renderVN = () => {
19
- const { tableColumn, headerGroups } = reactData
35
+ const { tableColumn, headerGroups, viewCellWidth } = reactData
20
36
  return h('div', {
21
- ref: refElem,
37
+ ref: 'refElem',
22
38
  class: 'vxe-gantt-view--header-wrapper'
23
39
  }, [
24
40
  h('div', {
25
- ref: refHeaderScroll,
41
+ ref: 'refHeaderScroll',
26
42
  class: 'vxe-gantt-view--header-inner-wrapper',
27
- onScroll: $xeGanttView.triggerHeaderScrollEvent
43
+ on: {
44
+ scroll: $xeGanttView.triggerHeaderScrollEvent
45
+ }
28
46
  }, [
29
47
  h('div', {
30
- ref: refHeaderXSpace,
48
+ ref: 'refHeaderXSpace',
31
49
  class: 'vxe-body--x-space'
32
50
  }),
33
51
  h('table', {
34
- ref: refHeaderTable,
52
+ ref: 'refHeaderTable',
35
53
  class: 'vxe-gantt-view--header-table'
36
54
  }, [
37
55
  h('colgroup', {}, tableColumn.map((column, cIndex) => {
38
56
  return h('col', {
39
- key: cIndex
57
+ key: cIndex,
58
+ style: {
59
+ width: `${viewCellWidth}px`
60
+ }
40
61
  })
41
62
  })),
42
63
  h('thead', {}, headerGroups.map((cols, rIndex) => {
@@ -46,8 +67,10 @@ export default defineVxeComponent({
46
67
  return h('th', {
47
68
  key: cIndex,
48
69
  class: 'vxe-gantt-view--header-column',
49
- colspan: column.children ? column.children.length : null,
50
- title: `${column.field}`
70
+ attrs: {
71
+ colspan: column.children ? column.children.length : null,
72
+ title: `${column.field}`
73
+ }
51
74
  }, column.title)
52
75
  }))
53
76
  }))
@@ -55,25 +78,32 @@ export default defineVxeComponent({
55
78
  ])
56
79
  ])
57
80
  }
81
+ },
82
+ mounted () {
83
+ const _vm = this
84
+ const $xeGanttView = _vm.$xeGanttView
85
+ const { internalData } = $xeGanttView
58
86
 
59
- onMounted(() => {
60
- const { elemStore } = internalData
61
- const prefix = 'main-header-'
62
- elemStore[`${prefix}wrapper`] = refElem
63
- elemStore[`${prefix}scroll`] = refHeaderScroll
64
- elemStore[`${prefix}table`] = refHeaderTable
65
- elemStore[`${prefix}xSpace`] = refHeaderXSpace
66
- })
67
-
68
- onUnmounted(() => {
69
- const { elemStore } = internalData
70
- const prefix = 'main-header-'
71
- elemStore[`${prefix}wrapper`] = null
72
- elemStore[`${prefix}scroll`] = null
73
- elemStore[`${prefix}table`] = null
74
- elemStore[`${prefix}xSpace`] = null
75
- })
87
+ const { elemStore } = internalData
88
+ const prefix = 'main-header-'
89
+ elemStore[`${prefix}wrapper`] = _vm.$refs.refElem as HTMLDivElement
90
+ elemStore[`${prefix}scroll`] = _vm.$refs.refHeaderScroll as HTMLDivElement
91
+ elemStore[`${prefix}table`] = _vm.$refs.refHeaderTable as HTMLDivElement
92
+ elemStore[`${prefix}xSpace`] = _vm.$refs.refHeaderXSpace as HTMLDivElement
93
+ },
94
+ destroyed () {
95
+ const _vm = this
96
+ const $xeGanttView = _vm.$xeGanttView
97
+ const { internalData } = $xeGanttView
76
98
 
77
- return renderVN
99
+ const { elemStore } = internalData
100
+ const prefix = 'main-header-'
101
+ elemStore[`${prefix}wrapper`] = null
102
+ elemStore[`${prefix}scroll`] = null
103
+ elemStore[`${prefix}table`] = null
104
+ elemStore[`${prefix}xSpace`] = null
105
+ },
106
+ render (this: any, h) {
107
+ return this.renderVN(h)
78
108
  }
79
109
  })