@wimi/gantt 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.
- package/README.md +785 -0
- package/dist/VanillaGantt.common.js +4751 -0
- package/dist/VanillaGantt.common.js.map +1 -0
- package/dist/VanillaGantt.css +1 -0
- package/dist/VanillaGantt.umd.js +4762 -0
- package/dist/VanillaGantt.umd.js.map +1 -0
- package/dist/VanillaGantt.umd.min.js +2 -0
- package/dist/VanillaGantt.umd.min.js.map +1 -0
- package/dist/demo.html +1 -0
- package/package.json +23 -0
- package/src/VanillaGantt.js +1924 -0
- package/src/index.js +1 -0
- package/src/vanilla-gantt.css +399 -0
- package/types/index.d.ts +356 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
export type GanttTimeValue = string | number | Date
|
|
2
|
+
|
|
3
|
+
export type GanttTimeUnit = 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'
|
|
4
|
+
|
|
5
|
+
export interface GanttRecord {
|
|
6
|
+
id?: string | number
|
|
7
|
+
name?: string
|
|
8
|
+
type?: string
|
|
9
|
+
height?: number
|
|
10
|
+
load?: number
|
|
11
|
+
expanded?: boolean
|
|
12
|
+
children?: GanttRecord[]
|
|
13
|
+
tasks?: GanttTaskRecord[]
|
|
14
|
+
[key: string]: unknown
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GanttTaskRecord {
|
|
18
|
+
id?: string | number
|
|
19
|
+
title?: string
|
|
20
|
+
subtitle?: string
|
|
21
|
+
startDate?: GanttTimeValue
|
|
22
|
+
endDate?: GanttTimeValue
|
|
23
|
+
lane?: string
|
|
24
|
+
status?: string
|
|
25
|
+
height?: number
|
|
26
|
+
offsetY?: number
|
|
27
|
+
progress?: number
|
|
28
|
+
locked?: boolean
|
|
29
|
+
striped?: boolean
|
|
30
|
+
draggable?: boolean
|
|
31
|
+
logistics?: boolean
|
|
32
|
+
completed?: boolean
|
|
33
|
+
predecessorIncomplete?: boolean
|
|
34
|
+
replan?: 'before' | 'after' | string
|
|
35
|
+
workStatus?: string
|
|
36
|
+
parentAggregate?: boolean
|
|
37
|
+
[key: string]: unknown
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface GanttLane {
|
|
41
|
+
key: string
|
|
42
|
+
offset: number
|
|
43
|
+
height: number
|
|
44
|
+
[key: string]: unknown
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface GanttTimelineDateInfo {
|
|
48
|
+
type: GanttTimeUnit
|
|
49
|
+
unit: GanttTimeUnit
|
|
50
|
+
step: number
|
|
51
|
+
scaleIndex: number
|
|
52
|
+
dateIndex: number
|
|
53
|
+
key: string
|
|
54
|
+
title: string
|
|
55
|
+
label: string
|
|
56
|
+
startDate: Date
|
|
57
|
+
endDate: Date
|
|
58
|
+
days: number
|
|
59
|
+
x: number
|
|
60
|
+
width: number
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface GanttTimelineHeaderStyle {
|
|
64
|
+
backgroundColor?: string
|
|
65
|
+
fontSize?: number
|
|
66
|
+
fontWeight?: string
|
|
67
|
+
color?: string
|
|
68
|
+
textAlign?: 'center' | 'end' | 'left' | 'right' | 'start'
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface GanttTableHeaderStyle {
|
|
72
|
+
backgroundColor?: string
|
|
73
|
+
fontSize?: number
|
|
74
|
+
fontWeight?: string
|
|
75
|
+
color?: string
|
|
76
|
+
textAlign?: 'center' | 'end' | 'left' | 'right' | 'start'
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface GanttTimelineScale {
|
|
80
|
+
rowHeight?: number
|
|
81
|
+
unit: GanttTimeUnit
|
|
82
|
+
step: number
|
|
83
|
+
colWidth?: number
|
|
84
|
+
startOfWeek?: 'sunday' | 'monday'
|
|
85
|
+
visible?: boolean
|
|
86
|
+
style?: GanttTimelineHeaderStyle
|
|
87
|
+
format?: (dateInfo: GanttTimelineDateInfo) => string
|
|
88
|
+
customLayout?: GanttRenderer<GanttTimelineRenderContext>
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface GanttLineStyle {
|
|
92
|
+
lineColor?: string
|
|
93
|
+
lineWidth?: number
|
|
94
|
+
lineDash?: number[]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface GanttTaskBarStyle {
|
|
98
|
+
barColor?: string
|
|
99
|
+
completedBarColor?: string
|
|
100
|
+
width?: number
|
|
101
|
+
cornerRadius?: number
|
|
102
|
+
borderWidth?: number
|
|
103
|
+
borderLineWidth?: number
|
|
104
|
+
borderColor?: string
|
|
105
|
+
minSize?: number
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface GanttTableColumn {
|
|
109
|
+
field?: string
|
|
110
|
+
title?: string
|
|
111
|
+
width?: number
|
|
112
|
+
minWidth?: number
|
|
113
|
+
maxWidth?: number
|
|
114
|
+
resizable?: boolean
|
|
115
|
+
align?: 'center' | 'end' | 'left' | 'right' | 'start'
|
|
116
|
+
headerAlign?: 'center' | 'end' | 'left' | 'right' | 'start'
|
|
117
|
+
headerStyle?: GanttTableHeaderStyle
|
|
118
|
+
tree?: boolean
|
|
119
|
+
className?: string
|
|
120
|
+
valueGetter?: (context: GanttCellRenderContext) => unknown
|
|
121
|
+
renderHeader?: GanttRenderer<GanttHeaderCellRenderContext>
|
|
122
|
+
renderCell?: GanttRenderer<GanttCellRenderContext>
|
|
123
|
+
[key: string]: unknown
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface GanttTaskListTableOptions {
|
|
127
|
+
tableWidth?: 'auto' | number
|
|
128
|
+
minTableWidth?: number
|
|
129
|
+
maxTableWidth?: number
|
|
130
|
+
columnResizable?: boolean
|
|
131
|
+
headerStyle?: GanttTableHeaderStyle
|
|
132
|
+
columns?: GanttTableColumn[]
|
|
133
|
+
renderHeader?: GanttRenderer<GanttRenderContext>
|
|
134
|
+
renderCell?: GanttRenderer<GanttCellRenderContext>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface GanttTimelineHeaderOptions {
|
|
138
|
+
backgroundColor?: string
|
|
139
|
+
colWidth?: number
|
|
140
|
+
style?: GanttTimelineHeaderStyle
|
|
141
|
+
scales: GanttTimelineScale[]
|
|
142
|
+
customLayout?: GanttRenderer<GanttTimelineRenderContext>
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface GanttTaskBarOptions {
|
|
146
|
+
tasksField?: string
|
|
147
|
+
startDateField?: string
|
|
148
|
+
endDateField?: string
|
|
149
|
+
progressField?: string
|
|
150
|
+
laneField?: string
|
|
151
|
+
statusField?: string
|
|
152
|
+
labelText?: string | ((taskRecord: GanttTaskRecord) => string)
|
|
153
|
+
subLabelText?: string | ((taskRecord: GanttTaskRecord) => string)
|
|
154
|
+
barStyle?: GanttTaskBarStyle | ((args: GanttTaskBarInteractionContext) => GanttTaskBarStyle)
|
|
155
|
+
projectStyle?: GanttTaskBarStyle | ((args: GanttTaskBarInteractionContext) => GanttTaskBarStyle)
|
|
156
|
+
customLayout?: GanttRenderer<GanttTaskBarCustomLayoutContext>
|
|
157
|
+
clip?: boolean
|
|
158
|
+
draggable?: boolean | ((context: GanttTaskBarCustomLayoutContext) => boolean)
|
|
159
|
+
dragStep?: number
|
|
160
|
+
tooltip?: boolean | GanttTaskBarTooltipOptions
|
|
161
|
+
onClick?: (context: GanttTaskBarEventContext) => void
|
|
162
|
+
onContextMenu?: (context: GanttTaskBarEventContext) => void
|
|
163
|
+
onMouseEnter?: (context: GanttTaskBarEventContext) => void
|
|
164
|
+
onMouseLeave?: (context: GanttTaskBarEventContext) => void
|
|
165
|
+
onDragStart?: (context: GanttTaskBarDragContext) => false | void
|
|
166
|
+
onDrag?: (context: GanttTaskBarDragContext) => void
|
|
167
|
+
onDragEnd?: (context: GanttTaskBarDragContext) => void
|
|
168
|
+
lanes?: GanttLane[]
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface GanttTaskBarTooltipOptions {
|
|
172
|
+
visible?: boolean
|
|
173
|
+
customLayout?: GanttRenderer<GanttTaskBarEventContext>
|
|
174
|
+
className?: string
|
|
175
|
+
offsetX?: number
|
|
176
|
+
offsetY?: number
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export type GanttDependencyType =
|
|
180
|
+
| 'finish_to_start'
|
|
181
|
+
| 'start_to_start'
|
|
182
|
+
| 'finish_to_finish'
|
|
183
|
+
| 'start_to_finish'
|
|
184
|
+
|
|
185
|
+
export interface GanttTaskLink {
|
|
186
|
+
id?: string | number
|
|
187
|
+
type?: GanttDependencyType
|
|
188
|
+
from: string | number | Array<string | number>
|
|
189
|
+
to: string | number | Array<string | number>
|
|
190
|
+
linkLineStyle?: GanttLineStyle
|
|
191
|
+
color?: string
|
|
192
|
+
dashed?: boolean
|
|
193
|
+
[key: string]: unknown
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface GanttDependencyOptions {
|
|
197
|
+
links?: GanttTaskLink[]
|
|
198
|
+
linkLineStyle?: GanttLineStyle
|
|
199
|
+
showLinks?: boolean
|
|
200
|
+
highlightConnected?: boolean
|
|
201
|
+
dimOpacity?: number
|
|
202
|
+
linkCreatable?: boolean
|
|
203
|
+
linkSelectable?: boolean
|
|
204
|
+
linkDeletable?: boolean
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface GanttBackgroundRange {
|
|
208
|
+
id?: string | number
|
|
209
|
+
startDate: GanttTimeValue
|
|
210
|
+
endDate: GanttTimeValue
|
|
211
|
+
color?: string
|
|
212
|
+
fill?: string
|
|
213
|
+
opacity?: number
|
|
214
|
+
[key: string]: unknown
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export interface GanttRowBackgroundRange extends GanttBackgroundRange {
|
|
218
|
+
recordKey: string | number
|
|
219
|
+
height?: number
|
|
220
|
+
offsetY?: number
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export interface GanttGridOptions {
|
|
224
|
+
backgroundColor?: string
|
|
225
|
+
alternatingBackgroundColor?: string
|
|
226
|
+
verticalLine?: GanttLineStyle | ((args: GridVerticalLineStyleContext) => GanttLineStyle)
|
|
227
|
+
horizontalLine?: GanttLineStyle | ((args: GridHorizontalLineStyleContext) => GanttLineStyle)
|
|
228
|
+
backgroundRanges?: GanttBackgroundRange[]
|
|
229
|
+
rowBackgroundRanges?: GanttRowBackgroundRange[]
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface GanttMarkLine {
|
|
233
|
+
date: GanttTimeValue
|
|
234
|
+
content?: string
|
|
235
|
+
contentStyle?: {
|
|
236
|
+
color?: string
|
|
237
|
+
fontSize?: number
|
|
238
|
+
fontWeight?: string
|
|
239
|
+
}
|
|
240
|
+
style?: GanttLineStyle
|
|
241
|
+
position?: 'left' | 'right' | 'middle' | 'date'
|
|
242
|
+
scrollToMarkLine?: boolean
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface GanttScrollPayload {
|
|
246
|
+
scrollLeft: number
|
|
247
|
+
scrollTop: number
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface GanttRenderContext {
|
|
251
|
+
gantt: VanillaGantt
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface GanttHeaderCellRenderContext extends GanttRenderContext {
|
|
255
|
+
column: GanttTableColumn
|
|
256
|
+
columnIndex: number
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface GanttCellRenderContext extends GanttRenderContext {
|
|
260
|
+
value: unknown
|
|
261
|
+
record: GanttRecord & { level: number }
|
|
262
|
+
row: GanttRecord & { level: number }
|
|
263
|
+
column: GanttTableColumn
|
|
264
|
+
columnIndex: number
|
|
265
|
+
expanded: boolean
|
|
266
|
+
toggle: () => void
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export interface GanttTaskBarInteractionContext {
|
|
270
|
+
taskRecord: GanttTaskRecord
|
|
271
|
+
index: number
|
|
272
|
+
startDate: Date
|
|
273
|
+
endDate: Date
|
|
274
|
+
ganttInstance: VanillaGantt
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface GanttTaskBarCustomLayoutContext extends GanttRenderContext {
|
|
278
|
+
taskRecord: GanttTaskRecord
|
|
279
|
+
task: GanttTaskRecord
|
|
280
|
+
sourceTask?: GanttTaskRecord
|
|
281
|
+
rowRecord?: GanttRecord & { level: number }
|
|
282
|
+
row?: GanttRecord & { level: number }
|
|
283
|
+
taskKey?: string | number
|
|
284
|
+
rowKey?: string | number
|
|
285
|
+
x: number
|
|
286
|
+
y: number
|
|
287
|
+
width: number
|
|
288
|
+
height: number
|
|
289
|
+
startDate: Date
|
|
290
|
+
endDate: Date
|
|
291
|
+
originalStartDate?: Date
|
|
292
|
+
originalEndDate?: Date
|
|
293
|
+
progress?: number
|
|
294
|
+
event?: Event
|
|
295
|
+
ganttInstance: VanillaGantt
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export interface GanttTaskBarEventContext extends GanttTaskBarCustomLayoutContext {
|
|
299
|
+
event: MouseEvent | PointerEvent
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface GanttTaskBarDragContext extends GanttTaskBarCustomLayoutContext {
|
|
303
|
+
event: PointerEvent
|
|
304
|
+
sourceTask: GanttTaskRecord
|
|
305
|
+
originalStartDate: Date
|
|
306
|
+
originalEndDate: Date
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export interface GanttTimelineRenderContext extends GanttRenderContext {
|
|
310
|
+
dateInfo: GanttTimelineDateInfo
|
|
311
|
+
unit: GanttTimelineDateInfo
|
|
312
|
+
scale: GanttTimelineScale
|
|
313
|
+
scaleIndex: number
|
|
314
|
+
major: boolean
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export interface GridVerticalLineStyleContext {
|
|
318
|
+
index: number
|
|
319
|
+
dateIndex: number
|
|
320
|
+
date?: Date
|
|
321
|
+
ganttInstance: VanillaGantt
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export interface GridHorizontalLineStyleContext {
|
|
325
|
+
index: number
|
|
326
|
+
ganttInstance: VanillaGantt
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export type GanttRenderer<T> = (context: T) => Node | string | { rootContainer?: Node } | null | undefined
|
|
330
|
+
|
|
331
|
+
export interface VanillaGanttOptions {
|
|
332
|
+
records?: GanttRecord[]
|
|
333
|
+
recordKeyField?: string
|
|
334
|
+
taskKeyField?: string
|
|
335
|
+
minDate?: GanttTimeValue
|
|
336
|
+
maxDate?: GanttTimeValue
|
|
337
|
+
rowHeight?: number
|
|
338
|
+
taskHeight?: number
|
|
339
|
+
headerRowHeight?: number
|
|
340
|
+
taskListTable?: GanttTaskListTableOptions
|
|
341
|
+
timelineHeader?: GanttTimelineHeaderOptions
|
|
342
|
+
taskBar?: GanttTaskBarOptions
|
|
343
|
+
dependency?: GanttDependencyOptions
|
|
344
|
+
grid?: GanttGridOptions
|
|
345
|
+
markLine?: GanttMarkLine | GanttMarkLine[] | null
|
|
346
|
+
onScroll?: (payload: GanttScrollPayload) => void
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
declare class VanillaGantt {
|
|
350
|
+
constructor(container: string | HTMLElement, options?: VanillaGanttOptions)
|
|
351
|
+
setOptions(options?: VanillaGanttOptions): void
|
|
352
|
+
destroy(): void
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export { VanillaGantt }
|
|
356
|
+
export default VanillaGantt
|