@operato/gantt 8.0.0-alpha.4 → 8.0.0-alpha.40
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/CHANGELOG.md +88 -0
- package/dist/src/gantt-chart-controller.d.ts +5 -6
- package/dist/src/gantt-chart-controller.js +92 -37
- package/dist/src/gantt-chart-controller.js.map +1 -1
- package/dist/src/ox-gantt-chart.d.ts +370 -2
- package/dist/src/ox-gantt-chart.js +72 -138
- package/dist/src/ox-gantt-chart.js.map +1 -1
- package/dist/src/ox-gantt-resize-splitter.d.ts +6 -2
- package/dist/src/ox-gantt-resize-splitter.js +70 -39
- package/dist/src/ox-gantt-resize-splitter.js.map +1 -1
- package/dist/src/ox-gantt.js +10 -1
- package/dist/src/ox-gantt.js.map +1 -1
- package/dist/src/ox-resource-chart.js +2 -0
- package/dist/src/ox-resource-chart.js.map +1 -1
- package/dist/src/ox-task-tooltip.d.ts +3 -1
- package/dist/src/ox-task-tooltip.js +36 -11
- package/dist/src/ox-task-tooltip.js.map +1 -1
- package/dist/stories/ox-gantt.stories.js +17 -1
- package/dist/stories/ox-gantt.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/src/gantt-chart-controller.ts +100 -34
- package/src/ox-gantt-chart.ts +73 -137
- package/src/ox-gantt-resize-splitter.ts +72 -44
- package/src/ox-gantt.ts +10 -1
- package/src/ox-resource-chart.ts +2 -0
- package/src/ox-task-tooltip.ts +31 -9
- package/stories/ox-gantt.stories.ts +17 -1
- package/themes/calendar-theme.css +3 -1
- package/assets/images/icon-editor-gradient-direction.png +0 -0
- package/assets/images/icon-properties-label.png +0 -0
- package/assets/images/icon-properties-line-type.png +0 -0
- package/assets/images/icon-properties-table.png +0 -0
package/src/ox-gantt-chart.ts
CHANGED
|
@@ -13,8 +13,10 @@ import { Task, TimeScale } from './types.js'
|
|
|
13
13
|
import { levelDown, levelUp } from './utils'
|
|
14
14
|
import { OxTaskTooltip } from './ox-task-tooltip.js'
|
|
15
15
|
|
|
16
|
+
import { gesture } from '@operato/utils/gesture-mixin.js'
|
|
17
|
+
|
|
16
18
|
@customElement('ox-gantt-chart')
|
|
17
|
-
export class OxGanttChart extends LitElement {
|
|
19
|
+
export class OxGanttChart extends gesture(LitElement) {
|
|
18
20
|
static styles = [
|
|
19
21
|
MDTypeScaleStyles,
|
|
20
22
|
ScrollbarStyles,
|
|
@@ -23,15 +25,21 @@ export class OxGanttChart extends LitElement {
|
|
|
23
25
|
display: flex;
|
|
24
26
|
overflow: hidden;
|
|
25
27
|
position: relative;
|
|
28
|
+
user-select: none;
|
|
26
29
|
}
|
|
30
|
+
|
|
27
31
|
div[chart-container] {
|
|
28
32
|
display: block;
|
|
29
33
|
overflow-x: auto;
|
|
30
34
|
overflow-y: hidden;
|
|
35
|
+
overscroll-behavior: none;
|
|
36
|
+
touch-action: none;
|
|
31
37
|
}
|
|
38
|
+
|
|
32
39
|
svg {
|
|
33
40
|
min-width: 100%;
|
|
34
41
|
}
|
|
42
|
+
|
|
35
43
|
svg[header] {
|
|
36
44
|
display: block;
|
|
37
45
|
min-width: 100%;
|
|
@@ -44,27 +52,27 @@ export class OxGanttChart extends LitElement {
|
|
|
44
52
|
top: 0;
|
|
45
53
|
z-index: 1;
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
position: absolute;
|
|
49
|
-
top: 44px; /* 헤더 바로 아래 위치 */
|
|
50
|
-
right: 4px;
|
|
51
|
-
display: flex;
|
|
52
|
-
align-items: center;
|
|
53
|
-
gap: 2px;
|
|
54
|
-
}
|
|
55
|
+
|
|
55
56
|
.scroll-button {
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 46px; /* 헤더 바로 아래 위치 */
|
|
59
|
+
width: 14px;
|
|
60
|
+
height: 14px;
|
|
58
61
|
background-color: var(--ox-gantt-header-color, var(--md-sys-color-on-secondary-container));
|
|
62
|
+
opacity: 0.5;
|
|
59
63
|
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
|
|
60
64
|
cursor: pointer;
|
|
61
65
|
transform: rotate(90deg);
|
|
62
66
|
}
|
|
67
|
+
|
|
63
68
|
.scroll-button.left {
|
|
69
|
+
left: 6px;
|
|
64
70
|
transform: rotate(-90deg);
|
|
65
71
|
}
|
|
72
|
+
|
|
66
73
|
.scroll-button.right {
|
|
67
74
|
transform: rotate(90deg);
|
|
75
|
+
right: 6px;
|
|
68
76
|
}
|
|
69
77
|
`
|
|
70
78
|
]
|
|
@@ -86,15 +94,31 @@ export class OxGanttChart extends LitElement {
|
|
|
86
94
|
@query('[chart-container]') container!: HTMLDivElement
|
|
87
95
|
@query('ox-task-tooltip') tooltip!: OxTaskTooltip
|
|
88
96
|
|
|
89
|
-
private ganttChartController
|
|
97
|
+
private ganttChartController!: GanttChartController
|
|
98
|
+
|
|
99
|
+
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
|
|
100
|
+
this.initHeaderGestureHandlers()
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
102
|
+
this.addEventListener('date-range-cleared', e => this.clearSelection())
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
connectedCallback(): void {
|
|
106
|
+
super.connectedCallback()
|
|
93
107
|
this.ganttChartController = new GanttChartController(this, this.fromDate, this.toDate, this.axisScale)
|
|
108
|
+
|
|
109
|
+
this.addEventListener('pinch', this.ganttChartController.handlePinchForBody as EventListener)
|
|
110
|
+
this.addEventListener('drag', this.ganttChartController.handleDragForBody as EventListener)
|
|
111
|
+
this.addEventListener('doubletap', this.ganttChartController.handleDoubleTapForBody as EventListener)
|
|
94
112
|
}
|
|
95
113
|
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
disconnectedCallback(): void {
|
|
115
|
+
super.disconnectedCallback()
|
|
116
|
+
|
|
117
|
+
this.removeEventListener('pinch', this.ganttChartController.handlePinchForBody as EventListener)
|
|
118
|
+
this.removeEventListener('drag', this.ganttChartController.handleDragForBody as EventListener)
|
|
119
|
+
this.removeEventListener('doubletap', this.ganttChartController.handleDoubleTapForBody as EventListener)
|
|
120
|
+
|
|
121
|
+
this.ganttChartController.dispose()
|
|
98
122
|
}
|
|
99
123
|
|
|
100
124
|
updated(changedProperties: PropertyValues<this>) {
|
|
@@ -103,8 +127,9 @@ export class OxGanttChart extends LitElement {
|
|
|
103
127
|
}
|
|
104
128
|
|
|
105
129
|
if (changedProperties.has('tasks')) {
|
|
106
|
-
this.
|
|
107
|
-
this.
|
|
130
|
+
const flattenTasks = this.flattenTasks(this.tasks)
|
|
131
|
+
this.ganttChartController.setTasks(flattenTasks)
|
|
132
|
+
this.svgBody.style.height = Math.max(flattenTasks.length * 30, 2000) + 'px'
|
|
108
133
|
}
|
|
109
134
|
|
|
110
135
|
if (changedProperties.has('locale')) {
|
|
@@ -130,22 +155,15 @@ export class OxGanttChart extends LitElement {
|
|
|
130
155
|
|
|
131
156
|
render() {
|
|
132
157
|
return html`
|
|
133
|
-
<div
|
|
134
|
-
chart-container
|
|
135
|
-
@wheel=${(e: WheelEvent) => this.ganttChartController.handleWheelForBody(e, this.container)}
|
|
136
|
-
@touchstart=${(e: TouchEvent) => this.ganttChartController.handleTouchStartForBody(e, this.container)}
|
|
137
|
-
@touchmove=${(e: TouchEvent) => this.ganttChartController.handleTouchMoveForBody(e, this.container)}
|
|
138
|
-
>
|
|
158
|
+
<div chart-container @wheel=${(e: WheelEvent) => this.ganttChartController.handleWheelForBody(e, this.container)}>
|
|
139
159
|
<svg
|
|
140
160
|
header
|
|
141
161
|
@date-range-selected=${(e: CustomEvent) => this.handleDateRangeSelected(e)}
|
|
142
162
|
@wheel=${this.handleWheelForHeader.bind(this)}
|
|
143
163
|
></svg>
|
|
144
164
|
<svg body></svg>
|
|
145
|
-
<div class="scroll-
|
|
146
|
-
|
|
147
|
-
<div class="scroll-button right" @click=${this.scrollToEnd}></div>
|
|
148
|
-
</div>
|
|
165
|
+
<div class="scroll-button left" @click=${this.scrollToStart} @touchstart=${this.scrollToStart}></div>
|
|
166
|
+
<div class="scroll-button right" @click=${this.scrollToEnd} @touchstart=${this.scrollToEnd}></div>
|
|
149
167
|
<ox-task-tooltip></ox-task-tooltip>
|
|
150
168
|
</div>
|
|
151
169
|
`
|
|
@@ -250,7 +268,7 @@ export class OxGanttChart extends LitElement {
|
|
|
250
268
|
|
|
251
269
|
handleDateRangeSelected(event: CustomEvent) {
|
|
252
270
|
const detail = event.detail
|
|
253
|
-
this.dispatchEvent(new CustomEvent('date-range-selected', { detail }))
|
|
271
|
+
this.dispatchEvent(new CustomEvent('date-range-selected', { detail, bubbles: true, composed: true }))
|
|
254
272
|
}
|
|
255
273
|
|
|
256
274
|
updateLocale(locale: string) {
|
|
@@ -264,135 +282,44 @@ export class OxGanttChart extends LitElement {
|
|
|
264
282
|
initHeaderGestureHandlers() {
|
|
265
283
|
const header = d3.select(this.svgHeader)
|
|
266
284
|
|
|
267
|
-
let isDragging = false
|
|
268
285
|
let startX: number | null = null
|
|
269
|
-
let lastTouchDistance: number | null = null
|
|
270
286
|
|
|
271
|
-
const
|
|
287
|
+
const handlePointerDown = (event: PointerEvent) => {
|
|
272
288
|
event.preventDefault()
|
|
289
|
+
event.stopPropagation()
|
|
273
290
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
} else {
|
|
277
|
-
isDragging = true
|
|
278
|
-
const touch = event.touches[0]
|
|
279
|
-
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
280
|
-
startX = touch.clientX - containerOffsetX
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const handleTouchMove = (event: TouchEvent) => {
|
|
285
|
-
event.preventDefault()
|
|
291
|
+
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
292
|
+
startX = event.clientX - containerOffsetX
|
|
286
293
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
const zoomFactor = currentDistance / lastTouchDistance
|
|
290
|
-
this.ganttChartController.baseWidth *= zoomFactor
|
|
291
|
-
|
|
292
|
-
if (this.ganttChartController.baseWidth > 60) {
|
|
293
|
-
if (this.ganttChartController.level == 'year-quarter') {
|
|
294
|
-
this.ganttChartController.baseWidth = 60
|
|
295
|
-
} else {
|
|
296
|
-
this.ganttChartController.level = levelUp(this.ganttChartController.level)
|
|
297
|
-
this.ganttChartController.baseWidth = 30
|
|
298
|
-
}
|
|
299
|
-
} else if (this.ganttChartController.baseWidth < 30) {
|
|
300
|
-
if (this.ganttChartController.level == 'week-day') {
|
|
301
|
-
this.ganttChartController.baseWidth = 30
|
|
302
|
-
} else {
|
|
303
|
-
this.ganttChartController.level = levelDown(this.ganttChartController.level)
|
|
304
|
-
this.ganttChartController.baseWidth = 60
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
lastTouchDistance = currentDistance
|
|
309
|
-
this.ganttChartController.updateTimeScale()
|
|
310
|
-
this.requestUpdate()
|
|
311
|
-
|
|
312
|
-
// Dispatch custom event to sync with ox-resource-chart
|
|
313
|
-
const customEvent = new CustomEvent('timescale-changed', {
|
|
314
|
-
detail: {
|
|
315
|
-
baseWidth: this.ganttChartController.baseWidth,
|
|
316
|
-
level: this.ganttChartController.level
|
|
317
|
-
},
|
|
318
|
-
bubbles: true,
|
|
319
|
-
composed: true
|
|
320
|
-
})
|
|
321
|
-
this.dispatchEvent(customEvent)
|
|
322
|
-
} else if (isDragging && startX !== null) {
|
|
323
|
-
const touch = event.touches[0]
|
|
324
|
-
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
325
|
-
const currentX = touch.clientX - containerOffsetX
|
|
326
|
-
this.highlightSelection(startX, currentX)
|
|
327
|
-
}
|
|
294
|
+
window.addEventListener('pointermove', handlePointerMove)
|
|
295
|
+
window.addEventListener('pointerup', handlePointerUp)
|
|
328
296
|
}
|
|
329
297
|
|
|
330
|
-
const
|
|
298
|
+
const handlePointerMove = (event: PointerEvent) => {
|
|
331
299
|
event.preventDefault()
|
|
300
|
+
event.stopPropagation()
|
|
332
301
|
|
|
333
|
-
if (event.touches.length < 2) {
|
|
334
|
-
lastTouchDistance = null
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (!isDragging || startX === null) {
|
|
338
|
-
const touch = event.changedTouches[0]
|
|
339
|
-
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
340
|
-
const clickX = touch.clientX - containerOffsetX
|
|
341
|
-
this.finalizeSelection(clickX, clickX)
|
|
342
|
-
return
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const touch = event.changedTouches[0]
|
|
346
302
|
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
347
|
-
const
|
|
348
|
-
this.finalizeSelection(startX, endX)
|
|
349
|
-
|
|
350
|
-
isDragging = false
|
|
351
|
-
startX = null
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const getTouchDistance = (touches: TouchList): number => {
|
|
355
|
-
const dx = touches[0].clientX - touches[1].clientX
|
|
356
|
-
const dy = touches[0].clientY - touches[1].clientY
|
|
357
|
-
return Math.sqrt(dx * dx + dy * dy)
|
|
358
|
-
}
|
|
303
|
+
const currentX = event.clientX - containerOffsetX
|
|
359
304
|
|
|
360
|
-
|
|
361
|
-
isDragging = true
|
|
362
|
-
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
363
|
-
startX = event.clientX - containerOffsetX
|
|
305
|
+
this.highlightSelection(startX!, currentX)
|
|
364
306
|
}
|
|
365
307
|
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
370
|
-
const currentX = event.clientX - containerOffsetX
|
|
371
|
-
this.highlightSelection(startX, currentX)
|
|
372
|
-
}
|
|
308
|
+
const handlePointerUp = (event: PointerEvent) => {
|
|
309
|
+
event.preventDefault()
|
|
310
|
+
event.stopPropagation()
|
|
373
311
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
377
|
-
const clickX = event.clientX - containerOffsetX
|
|
378
|
-
this.finalizeSelection(clickX, clickX)
|
|
379
|
-
return
|
|
380
|
-
}
|
|
312
|
+
window.removeEventListener('pointermove', handlePointerMove)
|
|
313
|
+
window.removeEventListener('pointerup', handlePointerUp)
|
|
381
314
|
|
|
382
315
|
const containerOffsetX = header.node()!.getBoundingClientRect().left
|
|
383
316
|
const endX = event.clientX - containerOffsetX
|
|
384
|
-
this.finalizeSelection(startX
|
|
317
|
+
this.finalizeSelection(startX!, endX)
|
|
385
318
|
|
|
386
|
-
isDragging = false
|
|
387
319
|
startX = null
|
|
388
320
|
}
|
|
389
321
|
|
|
390
|
-
header.on('
|
|
391
|
-
header.on('mousemove', handleMouseMove)
|
|
392
|
-
header.on('mouseup', handleMouseUp)
|
|
393
|
-
header.on('touchstart', handleTouchStart)
|
|
394
|
-
header.on('touchmove', handleTouchMove)
|
|
395
|
-
header.on('touchend', handleTouchEnd)
|
|
322
|
+
header.on('pointerdown', handlePointerDown)
|
|
396
323
|
}
|
|
397
324
|
|
|
398
325
|
highlightSelection(startX: number, endX: number) {
|
|
@@ -515,4 +442,13 @@ export class OxGanttChart extends LitElement {
|
|
|
515
442
|
|
|
516
443
|
header.node()?.dispatchEvent(customEvent)
|
|
517
444
|
}
|
|
445
|
+
|
|
446
|
+
clearSelection() {
|
|
447
|
+
const header = d3.select(this.svgHeader)
|
|
448
|
+
const body = d3.select(this.svgBody)
|
|
449
|
+
|
|
450
|
+
// 선택한 영역을 나타내는 모든 'selection-rect' 요소를 제거합니다.
|
|
451
|
+
header.selectAll('.selection-rect').remove()
|
|
452
|
+
body.selectAll('.selection-rect').remove()
|
|
453
|
+
}
|
|
518
454
|
}
|
|
@@ -10,15 +10,29 @@ export class OxGanttResizeSplitter extends LitElement {
|
|
|
10
10
|
background-color: var(--splitter-background-color);
|
|
11
11
|
width: var(--width);
|
|
12
12
|
height: var(--height);
|
|
13
|
+
z-index: 2;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
:host(:hover) {
|
|
16
17
|
background-color: var(--splitter-hover-background-color);
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
/* 터치 영역을 넓히기 위해 실제 터치 영역을 더 크게 설정 */
|
|
19
21
|
div {
|
|
20
22
|
width: var(--width);
|
|
21
23
|
height: var(--height);
|
|
24
|
+
touch-action: none; /* 터치 이벤트 처리에 방해되지 않도록 설정 */
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
div.touch-target {
|
|
28
|
+
width: var(--width);
|
|
29
|
+
height: var(--height);
|
|
30
|
+
transform: scale(1, 5);
|
|
31
|
+
transform-origin: center;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
:host([vertical]) div.touch-target {
|
|
35
|
+
transform: scale(5, 1); /* 세로 스플리터는 세로 방향으로 터치 영역을 확장 */
|
|
22
36
|
}
|
|
23
37
|
`
|
|
24
38
|
|
|
@@ -39,14 +53,37 @@ export class OxGanttResizeSplitter extends LitElement {
|
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
render() {
|
|
42
|
-
return html
|
|
56
|
+
return html`
|
|
57
|
+
<div
|
|
58
|
+
class="touch-target"
|
|
59
|
+
@mousedown=${(e: MouseEvent) => this.onMouseDown(e)}
|
|
60
|
+
@touchstart=${this.onTouchStart}
|
|
61
|
+
></div>
|
|
62
|
+
<div></div>
|
|
63
|
+
<!-- 실제 보이는 스플리터 -->
|
|
64
|
+
`
|
|
43
65
|
}
|
|
44
66
|
|
|
45
67
|
private onMouseDown(e: MouseEvent) {
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
this.startDrag(e.clientX, e.clientY)
|
|
69
|
+
window.addEventListener('mousemove', this.onMouseMove)
|
|
70
|
+
window.addEventListener('mouseup', this.onMouseUp)
|
|
71
|
+
e.stopPropagation()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private onTouchStart(e: TouchEvent) {
|
|
75
|
+
// 터치가 touch-target에서 시작된 경우에만 작동
|
|
76
|
+
if ((e.target as HTMLElement).classList.contains('touch-target')) {
|
|
77
|
+
const touch = e.touches[0]
|
|
78
|
+
this.startDrag(touch.clientX, touch.clientY)
|
|
79
|
+
window.addEventListener('touchmove', this.onTouchMove)
|
|
80
|
+
window.addEventListener('touchend', this.onTouchEnd)
|
|
49
81
|
}
|
|
82
|
+
e.stopPropagation()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private startDrag(clientX: number, clientY: number) {
|
|
86
|
+
this.dragstart = { x: clientX, y: clientY }
|
|
50
87
|
|
|
51
88
|
this.dispatchEvent(
|
|
52
89
|
new CustomEvent('splitter-dragstart', {
|
|
@@ -54,44 +91,28 @@ export class OxGanttResizeSplitter extends LitElement {
|
|
|
54
91
|
composed: true
|
|
55
92
|
})
|
|
56
93
|
)
|
|
57
|
-
|
|
58
|
-
this.parentElement!.addEventListener('mousemove', this.onMouseMoveHandler)
|
|
59
|
-
this.parentElement!.addEventListener('mouseup', this.onMouseUpHandler)
|
|
60
|
-
window.addEventListener('mousemove', this.onMouseMoveHandler)
|
|
61
|
-
window.addEventListener('mouseup', this.onMouseUpHandler)
|
|
62
|
-
|
|
63
|
-
e.stopPropagation()
|
|
64
94
|
}
|
|
65
95
|
|
|
66
|
-
private
|
|
67
|
-
|
|
96
|
+
private onMouseMove = (e: MouseEvent) => {
|
|
97
|
+
this.moveDrag(e.clientX, e.clientY)
|
|
98
|
+
}
|
|
68
99
|
|
|
69
|
-
private
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
100
|
+
private onTouchMove = (e: TouchEvent) => {
|
|
101
|
+
const touch = e.touches[0]
|
|
102
|
+
this.moveDrag(touch.clientX, touch.clientY)
|
|
103
|
+
}
|
|
73
104
|
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
e.clientX < parentRect.left ||
|
|
77
|
-
e.clientX > parentRect.right ||
|
|
78
|
-
e.clientY < parentRect.top ||
|
|
79
|
-
e.clientY > parentRect.bottom
|
|
80
|
-
) {
|
|
81
|
-
this.onMouseUp(e)
|
|
82
|
-
return
|
|
83
|
-
}
|
|
105
|
+
private moveDrag(clientX: number, clientY: number) {
|
|
106
|
+
if (!this.dragstart) return
|
|
84
107
|
|
|
85
|
-
|
|
108
|
+
const deltaX = clientX - this.dragstart.x
|
|
109
|
+
const deltaY = clientY - this.dragstart.y
|
|
86
110
|
|
|
87
111
|
this.dispatchEvent(
|
|
88
112
|
new CustomEvent('splitter-drag', {
|
|
89
113
|
bubbles: true,
|
|
90
114
|
composed: true,
|
|
91
|
-
detail: {
|
|
92
|
-
x: e.clientX - this.dragstart!.x,
|
|
93
|
-
y: e.clientY - this.dragstart!.y
|
|
94
|
-
}
|
|
115
|
+
detail: { x: deltaX, y: deltaY }
|
|
95
116
|
})
|
|
96
117
|
)
|
|
97
118
|
|
|
@@ -102,30 +123,37 @@ export class OxGanttResizeSplitter extends LitElement {
|
|
|
102
123
|
}
|
|
103
124
|
|
|
104
125
|
document.body.style.userSelect = 'none'
|
|
126
|
+
}
|
|
105
127
|
|
|
106
|
-
|
|
128
|
+
private onMouseUp = (e: MouseEvent) => {
|
|
129
|
+
this.endDrag(e.clientX, e.clientY)
|
|
130
|
+
window.removeEventListener('mousemove', this.onMouseMove)
|
|
131
|
+
window.removeEventListener('mouseup', this.onMouseUp)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private onTouchEnd = (e: TouchEvent) => {
|
|
135
|
+
const touch = e.changedTouches[0]
|
|
136
|
+
this.endDrag(touch.clientX, touch.clientY)
|
|
137
|
+
window.removeEventListener('touchmove', this.onTouchMove)
|
|
138
|
+
window.removeEventListener('touchend', this.onTouchEnd)
|
|
107
139
|
}
|
|
108
140
|
|
|
109
|
-
private
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
141
|
+
private endDrag(clientX: number, clientY: number) {
|
|
142
|
+
if (!this.dragstart) return
|
|
143
|
+
|
|
144
|
+
const deltaX = clientX - this.dragstart.x
|
|
145
|
+
const deltaY = clientY - this.dragstart.y
|
|
114
146
|
|
|
115
147
|
this.dispatchEvent(
|
|
116
148
|
new CustomEvent('splitter-dragend', {
|
|
117
149
|
bubbles: true,
|
|
118
150
|
composed: true,
|
|
119
|
-
detail: {
|
|
120
|
-
x: e.clientX - this.dragstart!.x,
|
|
121
|
-
y: e.clientY - this.dragstart!.y
|
|
122
|
-
}
|
|
151
|
+
detail: { x: deltaX, y: deltaY }
|
|
123
152
|
})
|
|
124
153
|
)
|
|
125
154
|
|
|
155
|
+
this.dragstart = undefined
|
|
126
156
|
document.body.style.cursor = ''
|
|
127
157
|
document.body.style.userSelect = ''
|
|
128
|
-
|
|
129
|
-
e.stopPropagation()
|
|
130
158
|
}
|
|
131
159
|
}
|
package/src/ox-gantt.ts
CHANGED
|
@@ -23,6 +23,7 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
23
23
|
font-family: Arial, sans-serif;
|
|
24
24
|
text-wrap: nowrap;
|
|
25
25
|
position: relative;
|
|
26
|
+
user-select: none;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
.container {
|
|
@@ -49,6 +50,7 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
49
50
|
overflow-y: overlay;
|
|
50
51
|
box-sizing: border-box;
|
|
51
52
|
border: 1px solid var(--ox-gantt-border-color, var(--md-sys-color-outline));
|
|
53
|
+
overscroll-behavior: none; /* diabled rubber-band effect */
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
.resource-chart-container {
|
|
@@ -56,6 +58,7 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
56
58
|
padding: 0;
|
|
57
59
|
box-sizing: border-box;
|
|
58
60
|
border: 1px solid var(--ox-gantt-border-color, var(--md-sys-color-outline));
|
|
61
|
+
overscroll-behavior: none;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
.task-container {
|
|
@@ -64,6 +67,8 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
64
67
|
display: flex;
|
|
65
68
|
overflow: hidden;
|
|
66
69
|
box-sizing: border-box;
|
|
70
|
+
user-select: none;
|
|
71
|
+
overscroll-behavior: none;
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
.task-table-container {
|
|
@@ -72,6 +77,7 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
72
77
|
overflow-y: overlay;
|
|
73
78
|
box-sizing: border-box;
|
|
74
79
|
border: 1px solid var(--ox-gantt-border-color, var(--md-sys-color-outline));
|
|
80
|
+
overscroll-behavior: none; /* diabled rubber-band effect */
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
.task-chart-container {
|
|
@@ -104,6 +110,9 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
104
110
|
border: 1px solid var(--ox-gantt-border-color, var(--md-sys-color-outline));
|
|
105
111
|
padding: 4px;
|
|
106
112
|
text-align: left;
|
|
113
|
+
white-space: nowrap;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
text-overflow: ellipsis;
|
|
107
116
|
}
|
|
108
117
|
|
|
109
118
|
th {
|
|
@@ -312,7 +321,7 @@ export class OxGantt extends localize(i18next)(LitElement) {
|
|
|
312
321
|
}
|
|
313
322
|
|
|
314
323
|
renderTaskRows(tasks: Task[], level: number = 0, columnConfig: ColumnConfig[]): TemplateResult[] {
|
|
315
|
-
return tasks.flatMap(task => {
|
|
324
|
+
return (tasks || []).flatMap(task => {
|
|
316
325
|
if (task.collapsed) {
|
|
317
326
|
return [this.renderTaskRow(task, level, columnConfig)]
|
|
318
327
|
} else {
|
package/src/ox-resource-chart.ts
CHANGED
|
@@ -16,12 +16,14 @@ export class OxResourceChart extends LitElement {
|
|
|
16
16
|
display: flex;
|
|
17
17
|
overflow: hidden;
|
|
18
18
|
position: relative;
|
|
19
|
+
user-select: none;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
div[chart-container] {
|
|
22
23
|
flex-direction: column;
|
|
23
24
|
overflow-x: auto;
|
|
24
25
|
overflow-y: hidden;
|
|
26
|
+
overscroll-behavior: none;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
svg[header] {
|
package/src/ox-task-tooltip.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit'
|
|
2
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
2
|
+
import { customElement, property, query } from 'lit/decorators.js'
|
|
3
3
|
|
|
4
4
|
@customElement('ox-task-tooltip')
|
|
5
5
|
export class OxTaskTooltip extends LitElement {
|
|
6
6
|
static styles = css`
|
|
7
7
|
:host {
|
|
8
|
-
position: fixed;
|
|
8
|
+
position: fixed;
|
|
9
9
|
background-color: var(--ox-gantt-tooltip-background-color, var(--md-sys-color-surface-variant, #f9f9f9));
|
|
10
10
|
border: 1px solid var(--ox-gantt-tooltip-border-color, var(--md-sys-color-outline, #ccc));
|
|
11
11
|
padding: var(--spacing-medium, 10px);
|
|
@@ -21,17 +21,18 @@ export class OxTaskTooltip extends LitElement {
|
|
|
21
21
|
transition:
|
|
22
22
|
visibility 0.1s,
|
|
23
23
|
opacity 0.1s;
|
|
24
|
-
opacity: 0;
|
|
24
|
+
opacity: 0;
|
|
25
25
|
}
|
|
26
26
|
:host([visible]) {
|
|
27
27
|
visibility: visible;
|
|
28
|
-
opacity: 1;
|
|
28
|
+
opacity: 1;
|
|
29
29
|
}
|
|
30
30
|
.title {
|
|
31
31
|
font-weight: bold;
|
|
32
32
|
font-size: 16px;
|
|
33
33
|
margin-bottom: 8px;
|
|
34
|
-
color: var(--ox-gantt-tooltip-title-color, var(--md-sys-color-primary, #0078d4));
|
|
34
|
+
color: var(--ox-gantt-tooltip-title-color, var(--md-sys-color-primary, #0078d4));
|
|
35
|
+
outline: none;
|
|
35
36
|
}
|
|
36
37
|
.detail {
|
|
37
38
|
display: grid;
|
|
@@ -42,14 +43,24 @@ export class OxTaskTooltip extends LitElement {
|
|
|
42
43
|
.label {
|
|
43
44
|
font-weight: bold;
|
|
44
45
|
color: var(--ox-gantt-tooltip-color, var(--md-sys-color-secondary, #333));
|
|
45
|
-
text-align: right;
|
|
46
|
+
text-align: right;
|
|
46
47
|
}
|
|
47
48
|
.colon {
|
|
48
49
|
text-align: center;
|
|
49
50
|
color: var(--ox-gantt-tooltip-color, var(--md-sys-color-secondary, #333));
|
|
50
51
|
}
|
|
51
52
|
.value {
|
|
52
|
-
text-align: left;
|
|
53
|
+
text-align: left;
|
|
54
|
+
color: var(--ox-gantt-tooltip-color, var(--md-sys-color-on-surface, #333));
|
|
55
|
+
}
|
|
56
|
+
.close-button {
|
|
57
|
+
position: absolute;
|
|
58
|
+
top: 4px;
|
|
59
|
+
right: 8px;
|
|
60
|
+
background: none;
|
|
61
|
+
border: none;
|
|
62
|
+
font-size: 16px;
|
|
63
|
+
cursor: pointer;
|
|
53
64
|
color: var(--ox-gantt-tooltip-color, var(--md-sys-color-on-surface, #333));
|
|
54
65
|
}
|
|
55
66
|
`
|
|
@@ -59,6 +70,9 @@ export class OxTaskTooltip extends LitElement {
|
|
|
59
70
|
@property({ type: String }) endDate = ''
|
|
60
71
|
@property({ type: Number }) progress = 0
|
|
61
72
|
@property({ type: String }) type = ''
|
|
73
|
+
@property({ type: Boolean, attribute: true }) visible: boolean = false
|
|
74
|
+
|
|
75
|
+
@query('.title') titleElement!: HTMLDivElement
|
|
62
76
|
|
|
63
77
|
show(x: number, y: number) {
|
|
64
78
|
const tooltipWidth = this.offsetWidth
|
|
@@ -100,15 +114,23 @@ export class OxTaskTooltip extends LitElement {
|
|
|
100
114
|
}
|
|
101
115
|
|
|
102
116
|
this.setAttribute('visible', '')
|
|
117
|
+
|
|
118
|
+
setTimeout(() => {
|
|
119
|
+
this.titleElement.addEventListener('blur', this.hide)
|
|
120
|
+
this.titleElement.focus({ preventScroll: true })
|
|
121
|
+
}, 500)
|
|
103
122
|
}
|
|
104
123
|
|
|
105
|
-
hide() {
|
|
124
|
+
hide = () => {
|
|
125
|
+
this.titleElement.removeEventListener('blur', this.hide)
|
|
106
126
|
this.removeAttribute('visible')
|
|
107
127
|
}
|
|
108
128
|
|
|
109
129
|
render() {
|
|
110
130
|
return html`
|
|
111
|
-
<div class="
|
|
131
|
+
<div class="close-button" @click=${this.hide} @touchstart=${this.hide}>✕</div>
|
|
132
|
+
<div class="title" tabindex="0">${this.title}</div>
|
|
133
|
+
|
|
112
134
|
<div class="detail">
|
|
113
135
|
<span class="label">Type</span><span class="colon">:</span><span class="value">${this.type}</span>
|
|
114
136
|
<span class="label">Start Date</span><span class="colon">:</span><span class="value">${this.startDate}</span>
|