@m3ui-vue/m3ui-vue 1.4.3 → 1.5.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/dist/API.md +29 -7
- package/dist/{MButton-D7M324r9.js → MButton-D_uxtJa-.js} +2 -2
- package/dist/{MButton-D7M324r9.js.map → MButton-D_uxtJa-.js.map} +1 -1
- package/dist/{MDialog-DuOnNF9s.js → MDialog-DT4KAPmn.js} +2 -2
- package/dist/{MDialog-DuOnNF9s.js.map → MDialog-DT4KAPmn.js.map} +1 -1
- package/dist/{MListItem-Bb84X6ex.js → MListItem-CwYrxpPZ.js} +2 -2
- package/dist/{MListItem-Bb84X6ex.js.map → MListItem-CwYrxpPZ.js.map} +1 -1
- package/dist/{MLoadingIndicator-BUGRo2Tu.js → MLoadingIndicator-DhzECYRI.js} +2 -2
- package/dist/{MLoadingIndicator-BUGRo2Tu.js.map → MLoadingIndicator-DhzECYRI.js.map} +1 -1
- package/dist/{MSeekBar-BQUvUqb9.js → MSeekBar-DQPF5FTp.js} +2 -2
- package/dist/{MSeekBar-BQUvUqb9.js.map → MSeekBar-DQPF5FTp.js.map} +1 -1
- package/dist/{MSlider-SFdjE1Hy.js → MSlider-BvoMZTy9.js} +2 -2
- package/dist/{MSlider-SFdjE1Hy.js.map → MSlider-BvoMZTy9.js.map} +1 -1
- package/dist/{MSpinner-DKGNN64_.js → MSpinner-CgcCQhS9.js} +2 -2
- package/dist/{MSpinner-DKGNN64_.js.map → MSpinner-CgcCQhS9.js.map} +1 -1
- package/dist/{MTextField-Utsef6Kk.js → MTextField-B72dwF6V.js} +2 -2
- package/dist/{MTextField-Utsef6Kk.js.map → MTextField-B72dwF6V.js.map} +1 -1
- package/dist/{MTooltip-BhTFQ9Z2.js → MTooltip-YyF1CO75.js} +4 -4
- package/dist/{MTooltip-BhTFQ9Z2.js.map → MTooltip-YyF1CO75.js.map} +1 -1
- package/dist/api.json +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/components/MGantt.vue.d.ts +11 -6
- package/dist/components/MGanttControls.vue.d.ts +9 -3
- package/dist/components/MResourceTimeline.vue.d.ts +4 -4
- package/dist/components/MTreeTable.vue.d.ts +1 -1
- package/dist/components/_MTimeSplitter.vue.d.ts +10 -0
- package/dist/composables/_dragCursor.d.ts +2 -0
- package/dist/composables/_useTimeAxis.d.ts +5 -1
- package/dist/composables/useGantt.d.ts +13 -0
- package/dist/composables/useLocale.d.ts +3 -0
- package/dist/draw.js +2 -2
- package/dist/flow.js +1 -1
- package/dist/gantt.js +1608 -1422
- package/dist/gantt.js.map +1 -1
- package/dist/locales/index.js +21 -0
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +5854 -5791
- package/dist/m3ui.js.map +1 -1
- package/dist/map.js +5 -5
- package/dist/media.js +4 -4
- package/dist/pdf.js +4 -4
- package/dist/rich-text-editor.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/{useLocale-B8YKWg-H.js → useLocale-DLcG3qPC.js} +4 -1
- package/dist/useLocale-DLcG3qPC.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MGantt.test.ts +105 -0
- package/src/__tests__/MResourceTimeline.test.ts +16 -0
- package/src/__tests__/MTabs.test.ts +112 -4
- package/src/components/MGantt.vue +138 -43
- package/src/components/MGanttControls.vue +36 -8
- package/src/components/MResourceTimeline.vue +59 -24
- package/src/components/MTabs.vue +163 -77
- package/src/components/_MTimeHeader.vue +3 -2
- package/src/components/_MTimeSplitter.vue +37 -0
- package/src/composables/_dragCursor.ts +15 -0
- package/src/composables/_ganttTime.ts +2 -1
- package/src/composables/_useTimeAxis.ts +10 -3
- package/src/composables/useGantt.ts +13 -0
- package/src/composables/useLocale.ts +6 -0
- package/src/locales/de.ts +3 -0
- package/src/locales/es.ts +3 -0
- package/src/locales/fr.ts +3 -0
- package/src/locales/ja.ts +3 -0
- package/src/locales/ko.ts +3 -0
- package/src/locales/pt.ts +3 -0
- package/src/locales/zh.ts +3 -0
- package/dist/useLocale-B8YKWg-H.js.map +0 -1
|
@@ -34,9 +34,11 @@ import { spanDates, taskSpan, type GanttCalendar } from '../composables/ganttSch
|
|
|
34
34
|
import { DAY, HOUR, defaultSnap, formatDate, parseDate, snapTime } from '../composables/_ganttTime'
|
|
35
35
|
import { prefersReducedMotion } from '../composables/_springAnimation'
|
|
36
36
|
import { useTimeAxis } from '../composables/_useTimeAxis'
|
|
37
|
+
import { holdDragCursor, releaseDragCursor } from '../composables/_dragCursor'
|
|
37
38
|
import { useLocale } from '../composables/useLocale'
|
|
38
39
|
import MTimeHeader from './_MTimeHeader.vue'
|
|
39
40
|
import MTimeBackground from './_MTimeBackground.vue'
|
|
41
|
+
import MTimeSplitter from './_MTimeSplitter.vue'
|
|
40
42
|
|
|
41
43
|
const props = withDefaults(defineProps<{
|
|
42
44
|
events?: TimelineEvent[]
|
|
@@ -410,10 +412,21 @@ type Gesture =
|
|
|
410
412
|
let gesture: Gesture | null = null
|
|
411
413
|
let pressTimer: ReturnType<typeof setTimeout> | undefined
|
|
412
414
|
const dragging = ref<{ id: string; part: Part } | null>(null)
|
|
415
|
+
const splitting = ref(false)
|
|
416
|
+
const initialListW = ref(props.listWidth ?? 220)
|
|
417
|
+
watch(() => props.listWidth, (w) => { if (w !== undefined) initialListW.value = w })
|
|
418
|
+
function setListWidth(w: number) {
|
|
419
|
+
listW.value = w
|
|
420
|
+
emit('update:listWidth', w)
|
|
421
|
+
}
|
|
413
422
|
const draft = ref<{ resourceId: string; start: number; end: number } | null>(null)
|
|
414
423
|
const refused = ref(false)
|
|
415
424
|
const pointer = { x: 0, y: 0 }
|
|
416
425
|
const isControl = (t: EventTarget | null) => t instanceof Element && !!t.closest('input, textarea, select, button, a, [contenteditable], [data-timeline-action]')
|
|
426
|
+
// A mouse press that starts a pan or a drag: no native drag of what's under it, no text selection
|
|
427
|
+
function claimMouse(e: PointerEvent) {
|
|
428
|
+
if (e.pointerType !== 'touch') e.preventDefault()
|
|
429
|
+
}
|
|
417
430
|
|
|
418
431
|
function contentPoint(clientX: number, clientY: number) {
|
|
419
432
|
const r = scroller.value!.getBoundingClientRect()
|
|
@@ -431,6 +444,7 @@ function snapStep(dateOnly: boolean) {
|
|
|
431
444
|
function onEventDown(e: PointerEvent, ev: TimelineEvent, part: Part) {
|
|
432
445
|
if (e.button !== 0 || isControl(e.target)) return
|
|
433
446
|
e.stopPropagation()
|
|
447
|
+
claimMouse(e)
|
|
434
448
|
const s = spans.value.get(ev.id)
|
|
435
449
|
if (!s) return
|
|
436
450
|
const touch = e.pointerType === 'touch'
|
|
@@ -441,6 +455,7 @@ function onEventDown(e: PointerEvent, ev: TimelineEvent, part: Part) {
|
|
|
441
455
|
}
|
|
442
456
|
function onPaneDown(e: PointerEvent) {
|
|
443
457
|
if (e.button !== 0 || isControl(e.target)) return
|
|
458
|
+
claimMouse(e)
|
|
444
459
|
const p = contentPoint(e.clientX, e.clientY)
|
|
445
460
|
const res = resourceAtY(p.y)
|
|
446
461
|
const touch = e.pointerType === 'touch'
|
|
@@ -464,6 +479,8 @@ function onSplitDown(e: PointerEvent) {
|
|
|
464
479
|
if (e.button !== 0) return
|
|
465
480
|
e.preventDefault()
|
|
466
481
|
gesture = { kind: 'split', id: e.pointerId, sx: e.clientX, w: listW.value }
|
|
482
|
+
splitting.value = true
|
|
483
|
+
holdDragCursor('col-resize')
|
|
467
484
|
addWindow()
|
|
468
485
|
}
|
|
469
486
|
function addWindow() {
|
|
@@ -476,7 +493,8 @@ function removeWindow() {
|
|
|
476
493
|
window.removeEventListener('pointerup', onUp)
|
|
477
494
|
window.removeEventListener('pointercancel', onCancel)
|
|
478
495
|
clearTimeout(pressTimer)
|
|
479
|
-
|
|
496
|
+
releaseDragCursor()
|
|
497
|
+
splitting.value = false
|
|
480
498
|
}
|
|
481
499
|
function activate() {
|
|
482
500
|
const g = gesture
|
|
@@ -497,7 +515,7 @@ function activate() {
|
|
|
497
515
|
draft.value = { resourceId: g.resourceId, start: s, end: s + Math.max(step, HOUR) }
|
|
498
516
|
}
|
|
499
517
|
if (g.touch) navigator.vibrate?.(10)
|
|
500
|
-
|
|
518
|
+
holdDragCursor(g.kind === 'event' && g.part !== 'body' ? 'ew-resize' : g.kind === 'event' ? 'grabbing' : 'crosshair')
|
|
501
519
|
startAutoScroll()
|
|
502
520
|
}
|
|
503
521
|
function onMove(e: PointerEvent) {
|
|
@@ -506,20 +524,10 @@ function onMove(e: PointerEvent) {
|
|
|
506
524
|
pointer.x = e.clientX
|
|
507
525
|
pointer.y = e.clientY
|
|
508
526
|
if (g.kind === 'split') {
|
|
509
|
-
|
|
510
|
-
listW.value = w
|
|
511
|
-
emit('update:listWidth', w)
|
|
512
|
-
return
|
|
513
|
-
}
|
|
514
|
-
if (g.kind === 'pan') {
|
|
515
|
-
const dx = e.clientX - g.sx
|
|
516
|
-
const dy = e.clientY - g.sy
|
|
517
|
-
if (!g.moved && Math.hypot(dx, dy) < 4) return
|
|
518
|
-
g.moved = true
|
|
519
|
-
scroller.value!.scrollLeft = g.sl - dx
|
|
520
|
-
scroller.value!.scrollTop = g.st - dy
|
|
527
|
+
setListWidth(Math.round(Math.min(Math.max(0, g.w + e.clientX - g.sx), Math.max(160, view.value.width - 80))))
|
|
521
528
|
return
|
|
522
529
|
}
|
|
530
|
+
if (g.kind === 'pan') return pan(g, e)
|
|
523
531
|
if (!g.active) {
|
|
524
532
|
const d = Math.hypot(e.clientX - g.sx, e.clientY - g.sy)
|
|
525
533
|
if (g.touch) {
|
|
@@ -528,10 +536,30 @@ function onMove(e: PointerEvent) {
|
|
|
528
536
|
}
|
|
529
537
|
if (d < 4) return
|
|
530
538
|
activate()
|
|
531
|
-
if (!g.active)
|
|
539
|
+
if (!g.active) {
|
|
540
|
+
// An event that can't move (readonly, draggable: false) pans the timeline like the background does
|
|
541
|
+
if (g.kind === 'event' && g.part === 'body') {
|
|
542
|
+
const p: Extract<Gesture, { kind: 'pan' }> = { kind: 'pan', id: g.id, sx: g.sx, sy: g.sy, sl: g.sl, st: g.st, moved: true }
|
|
543
|
+
gesture = p
|
|
544
|
+
holdDragCursor('grabbing')
|
|
545
|
+
pan(p, e)
|
|
546
|
+
}
|
|
547
|
+
return
|
|
548
|
+
}
|
|
532
549
|
}
|
|
533
550
|
dragTo(e.clientX, e.clientY)
|
|
534
551
|
}
|
|
552
|
+
function pan(g: Extract<Gesture, { kind: 'pan' }>, e: PointerEvent) {
|
|
553
|
+
const dx = e.clientX - g.sx
|
|
554
|
+
const dy = e.clientY - g.sy
|
|
555
|
+
if (!g.moved && Math.hypot(dx, dy) < 4) return
|
|
556
|
+
if (!g.moved) {
|
|
557
|
+
g.moved = true
|
|
558
|
+
holdDragCursor('grabbing')
|
|
559
|
+
}
|
|
560
|
+
scroller.value!.scrollLeft = g.sl - dx
|
|
561
|
+
scroller.value!.scrollTop = g.st - dy
|
|
562
|
+
}
|
|
535
563
|
function dragTo(clientX: number, clientY: number) {
|
|
536
564
|
const g = gesture
|
|
537
565
|
if (!g || (g.kind !== 'event' && g.kind !== 'empty') || !g.active) return
|
|
@@ -834,6 +862,7 @@ provide(TIMELINE_CONTROLS_KEY, {
|
|
|
834
862
|
zoomOut,
|
|
835
863
|
setScale,
|
|
836
864
|
scrollToDate,
|
|
865
|
+
fit: () => { if (spans.value.size) axis.fit(extent.value) },
|
|
837
866
|
expandAll: () => setFolded([]),
|
|
838
867
|
collapseAll: () => setFolded([...new Set(props.resources.map((r) => r.group).filter((g): g is string => !!g))]),
|
|
839
868
|
})
|
|
@@ -921,20 +950,26 @@ defineExpose(context)
|
|
|
921
950
|
</slot>
|
|
922
951
|
</div>
|
|
923
952
|
</template>
|
|
924
|
-
<
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
:
|
|
928
|
-
|
|
929
|
-
class="absolute inset-y-0 -right-1 z-30 w-2 cursor-col-resize touch-none outline-none hover:bg-primary/20 focus-visible:bg-primary/30"
|
|
953
|
+
<MTimeSplitter
|
|
954
|
+
:label="locale.ganttResize"
|
|
955
|
+
:value="listWidth"
|
|
956
|
+
:active="splitting"
|
|
957
|
+
:grip-top="view.top + Math.max(0, view.height - headerHeight) / 2"
|
|
930
958
|
@pointerdown="onSplitDown"
|
|
931
|
-
@
|
|
932
|
-
@keydown.
|
|
959
|
+
@dblclick="setListWidth(initialListW)"
|
|
960
|
+
@keydown.left.prevent="setListWidth(Math.max(120, listW - 16))"
|
|
961
|
+
@keydown.right.prevent="setListWidth(listW + 16)"
|
|
933
962
|
/>
|
|
934
963
|
</div>
|
|
935
964
|
|
|
936
965
|
<!-- Timeline -->
|
|
937
|
-
<div
|
|
966
|
+
<div
|
|
967
|
+
class="relative shrink-0 select-none [-webkit-user-drag:none]"
|
|
968
|
+
:class="creatable && !readonly ? '' : 'cursor-grab active:cursor-grabbing'"
|
|
969
|
+
:style="{ width: `${timelineWidth}px` }"
|
|
970
|
+
@pointerdown="onPaneDown"
|
|
971
|
+
@dragstart.prevent
|
|
972
|
+
>
|
|
938
973
|
<MTimeBackground :off-times="offTimes" :cells="bottomCells" :today-x="todayMs === null ? null : xOf(todayMs)" />
|
|
939
974
|
<div
|
|
940
975
|
v-for="r in visibleRows"
|
package/src/components/MTabs.vue
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @event update:modelValue Emitted with the value of the tab you picked.
|
|
7
7
|
*/
|
|
8
|
-
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
8
|
+
import { computed, nextTick, onMounted, onUnmounted, onUpdated, ref, watch } from 'vue'
|
|
9
9
|
import MIcon from './MIcon.vue'
|
|
10
10
|
|
|
11
11
|
interface Tab {
|
|
@@ -41,6 +41,7 @@ const emit = defineEmits<{ 'update:modelValue': [string | number] }>()
|
|
|
41
41
|
|
|
42
42
|
const tabEls = ref<HTMLElement[]>([])
|
|
43
43
|
const rowEl = ref<HTMLElement | null>(null)
|
|
44
|
+
const contentEl = ref<HTMLElement | null>(null)
|
|
44
45
|
const indicatorLeft = ref(0)
|
|
45
46
|
const indicatorWidth = ref(0)
|
|
46
47
|
|
|
@@ -121,38 +122,117 @@ function scrollToTab(rect: { left: number; width: number }, smooth: boolean) {
|
|
|
121
122
|
// re-render pulling the row back from wherever the user scrolled it.
|
|
122
123
|
let shownValue: unknown = Symbol('none')
|
|
123
124
|
|
|
125
|
+
function measureTarget() {
|
|
126
|
+
const idx = props.tabs.findIndex((t) => t.value === props.modelValue)
|
|
127
|
+
const rect = getTabRect(idx)
|
|
128
|
+
if (!rect) return null
|
|
129
|
+
if (props.variant === 'primary') {
|
|
130
|
+
const inset = Math.min(rect.width * 0.2, 16)
|
|
131
|
+
return { rect, offset: rect.left + inset, width: rect.width - inset * 2 }
|
|
132
|
+
}
|
|
133
|
+
return { rect, offset: rect.left, width: rect.width }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function snapIndicator() {
|
|
137
|
+
offsetPos = offsetTarget; offsetVel = 0
|
|
138
|
+
widthPos = widthTarget; widthVel = 0
|
|
139
|
+
indicatorLeft.value = offsetPos
|
|
140
|
+
indicatorWidth.value = widthPos
|
|
141
|
+
}
|
|
142
|
+
|
|
124
143
|
function updateIndicator(animate = true, scroll: 'none' | 'instant' | 'smooth' = 'none') {
|
|
125
144
|
nextTick(() => {
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
if (!rect) return
|
|
145
|
+
const m = measureTarget()
|
|
146
|
+
if (!m) return
|
|
129
147
|
if (scroll !== 'none') {
|
|
130
148
|
shownValue = props.modelValue
|
|
131
|
-
|
|
149
|
+
if (scroll === 'smooth') manualScroll = false
|
|
150
|
+
scrollToTab(m.rect, scroll === 'smooth')
|
|
132
151
|
}
|
|
152
|
+
offsetTarget = m.offset
|
|
153
|
+
widthTarget = m.width
|
|
154
|
+
if (animate) ensureRaf()
|
|
155
|
+
else snapIndicator()
|
|
156
|
+
})
|
|
157
|
+
}
|
|
133
158
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
159
|
+
// Tabs can change size after mount: a Material Symbols icon is drawn as its
|
|
160
|
+
// ligature name ("fact_check") until the font loads, so the tab is far wider
|
|
161
|
+
// at first. Re-measure without animation whenever the row or a tab resizes,
|
|
162
|
+
// and re-center the active tab unless the user has scrolled the row by hand
|
|
163
|
+
// since it was last centered for them.
|
|
164
|
+
let manualScroll = false
|
|
165
|
+
function markManualScroll() { manualScroll = true }
|
|
166
|
+
const SCROLL_KEYS = new Set(['ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown'])
|
|
167
|
+
function onRowKeydown(e: KeyboardEvent) { if (SCROLL_KEYS.has(e.key)) manualScroll = true }
|
|
142
168
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
169
|
+
function relayout() {
|
|
170
|
+
const m = measureTarget()
|
|
171
|
+
if (!m) return
|
|
172
|
+
if (Math.abs(m.offset - offsetTarget) >= 0.5 || Math.abs(m.width - widthTarget) >= 0.5) {
|
|
173
|
+
offsetTarget = m.offset
|
|
174
|
+
widthTarget = m.width
|
|
175
|
+
snapIndicator()
|
|
176
|
+
}
|
|
177
|
+
if (!manualScroll) scrollToTab(m.rect, false)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let ro: ResizeObserver | null = null
|
|
181
|
+
const observed = new Set<Element>()
|
|
182
|
+
const lastSize = new WeakMap<Element, string>()
|
|
183
|
+
let listenedRow: HTMLElement | null = null
|
|
184
|
+
|
|
185
|
+
function onResize(entries: ResizeObserverEntry[]) {
|
|
186
|
+
let changed = false
|
|
187
|
+
for (const e of entries) {
|
|
188
|
+
const key = `${e.contentRect.width}x${e.contentRect.height}`
|
|
189
|
+
// The first notification of every newly observed element only reports
|
|
190
|
+
// its current size: ignore it, so it can't cut short a running animation.
|
|
191
|
+
if (lastSize.has(e.target) && lastSize.get(e.target) !== key) changed = true
|
|
192
|
+
lastSize.set(e.target, key)
|
|
193
|
+
}
|
|
194
|
+
if (changed) relayout()
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function syncObserved() {
|
|
198
|
+
const row = rowEl.value
|
|
199
|
+
if (row !== listenedRow) {
|
|
200
|
+
listenedRow?.removeEventListener('wheel', markManualScroll)
|
|
201
|
+
listenedRow?.removeEventListener('touchmove', markManualScroll)
|
|
202
|
+
listenedRow?.removeEventListener('keydown', onRowKeydown)
|
|
203
|
+
row?.addEventListener('wheel', markManualScroll, { passive: true })
|
|
204
|
+
row?.addEventListener('touchmove', markManualScroll, { passive: true })
|
|
205
|
+
row?.addEventListener('keydown', onRowKeydown)
|
|
206
|
+
listenedRow = row
|
|
207
|
+
}
|
|
208
|
+
if (!ro) return
|
|
209
|
+
const want = new Set<Element>()
|
|
210
|
+
if (row) want.add(row)
|
|
211
|
+
if (contentEl.value) for (const el of contentEl.value.querySelectorAll(':scope > button')) want.add(el)
|
|
212
|
+
for (const el of observed) if (!want.has(el)) { ro.unobserve(el); observed.delete(el) }
|
|
213
|
+
for (const el of want) if (!observed.has(el)) { ro.observe(el); observed.add(el) }
|
|
152
214
|
}
|
|
153
215
|
|
|
154
|
-
|
|
155
|
-
|
|
216
|
+
let mounted = false
|
|
217
|
+
onMounted(() => {
|
|
218
|
+
mounted = true
|
|
219
|
+
updateIndicator(false, 'instant')
|
|
220
|
+
if (typeof ResizeObserver !== 'undefined') ro = new ResizeObserver(onResize)
|
|
221
|
+
syncObserved()
|
|
222
|
+
// Fallback for browsers or layouts where the font swap doesn't resize an
|
|
223
|
+
// observed box (and for the first paint before the observer reports).
|
|
224
|
+
document.fonts?.ready.then(() => { if (mounted) relayout() })
|
|
225
|
+
})
|
|
226
|
+
onUpdated(syncObserved)
|
|
227
|
+
onUnmounted(() => {
|
|
228
|
+
mounted = false
|
|
229
|
+
if (rafId) cancelAnimationFrame(rafId)
|
|
230
|
+
ro?.disconnect(); ro = null; observed.clear()
|
|
231
|
+
listenedRow?.removeEventListener('wheel', markManualScroll)
|
|
232
|
+
listenedRow?.removeEventListener('touchmove', markManualScroll)
|
|
233
|
+
listenedRow?.removeEventListener('keydown', onRowKeydown)
|
|
234
|
+
listenedRow = null
|
|
235
|
+
})
|
|
156
236
|
watch(() => props.modelValue, () => updateIndicator(true, 'smooth'))
|
|
157
237
|
// Animated (not a hard snap) here too: a consumer passing an inline `:tabs="[...]"`
|
|
158
238
|
// literal gets a brand-new array reference on every unrelated parent re-render,
|
|
@@ -170,64 +250,70 @@ function select(tab: Tab) {
|
|
|
170
250
|
<template>
|
|
171
251
|
<!-- ── Primary: sliding short indicator with stretch ──────────────── -->
|
|
172
252
|
<div v-if="variant === 'primary'" class="border-b border-outline-variant">
|
|
173
|
-
<div ref="rowEl"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
? '
|
|
186
|
-
|
|
187
|
-
? '
|
|
188
|
-
:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
253
|
+
<div ref="rowEl" :class="scrollable ? 'overflow-x-auto' : 'overflow-x-hidden'" style="scrollbar-width: none">
|
|
254
|
+
<!-- Content-width box: clips the indicator so it never widens the scroll area -->
|
|
255
|
+
<div ref="contentEl" class="relative flex overflow-hidden" :class="scrollable ? 'w-max min-w-full' : 'w-full'">
|
|
256
|
+
<button
|
|
257
|
+
v-for="tab in tabs"
|
|
258
|
+
:key="tab.value"
|
|
259
|
+
:ref="(el) => { if (el) tabEls[tabs.indexOf(tab)] = el as HTMLElement }"
|
|
260
|
+
type="button"
|
|
261
|
+
class="relative flex items-center justify-center pb-1.5 text-title-small transition-colors duration-150 focus-visible:outline-none"
|
|
262
|
+
:class="[
|
|
263
|
+
scrollable ? 'shrink-0' : 'flex-1 min-w-0',
|
|
264
|
+
// LeadingIconTab: 48dp row, 16dp side padding, 8dp from the icon to the label
|
|
265
|
+
leading ? 'h-12 flex-row gap-2 px-4' : ['flex-col gap-1 px-6', tab.icon ? 'h-16' : 'h-12'],
|
|
266
|
+
tab.value === modelValue
|
|
267
|
+
? 'text-primary'
|
|
268
|
+
: tab.disabled
|
|
269
|
+
? 'cursor-not-allowed text-on-surface/38'
|
|
270
|
+
: 'cursor-pointer text-on-surface-variant hover:text-on-surface',
|
|
271
|
+
]"
|
|
272
|
+
:disabled="tab.disabled"
|
|
273
|
+
@click="select(tab)"
|
|
274
|
+
>
|
|
275
|
+
<MIcon v-if="tab.icon" :name="tab.icon" :size="24" />
|
|
276
|
+
<span>{{ tab.label }}</span>
|
|
277
|
+
</button>
|
|
278
|
+
<div
|
|
279
|
+
class="absolute bottom-0 h-[3px] rounded-t-full bg-primary"
|
|
280
|
+
:style="{ left: `${indicatorLeft}px`, width: `${indicatorWidth}px` }"
|
|
281
|
+
/>
|
|
282
|
+
</div>
|
|
200
283
|
</div>
|
|
201
284
|
</div>
|
|
202
285
|
|
|
203
286
|
<!-- ── Secondary: full-width underline indicator ─────────────────── -->
|
|
204
287
|
<div v-else class="border-b border-outline-variant">
|
|
205
|
-
<div ref="rowEl"
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
? '
|
|
217
|
-
|
|
218
|
-
? '
|
|
219
|
-
:
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
288
|
+
<div ref="rowEl" :class="scrollable ? 'overflow-x-auto' : 'overflow-x-hidden'" style="scrollbar-width: none">
|
|
289
|
+
<!-- Content-width box: clips the indicator so it never widens the scroll area -->
|
|
290
|
+
<div ref="contentEl" class="relative flex overflow-hidden" :class="scrollable ? 'w-max min-w-full' : 'w-full'">
|
|
291
|
+
<button
|
|
292
|
+
v-for="tab in tabs"
|
|
293
|
+
:key="tab.value"
|
|
294
|
+
:ref="(el) => { if (el) tabEls[tabs.indexOf(tab)] = el as HTMLElement }"
|
|
295
|
+
type="button"
|
|
296
|
+
class="relative flex items-center justify-center text-title-small transition-colors duration-150 focus-visible:outline-none"
|
|
297
|
+
:class="[
|
|
298
|
+
scrollable ? 'shrink-0' : 'flex-1 min-w-0',
|
|
299
|
+
leading ? 'h-12 flex-row gap-2 px-4' : ['flex-col gap-1 px-6', tab.icon ? 'h-16' : 'h-12'],
|
|
300
|
+
tab.value === modelValue
|
|
301
|
+
? 'text-on-surface'
|
|
302
|
+
: tab.disabled
|
|
303
|
+
? 'cursor-not-allowed text-on-surface/38'
|
|
304
|
+
: 'cursor-pointer text-on-surface-variant hover:text-on-surface',
|
|
305
|
+
]"
|
|
306
|
+
:disabled="tab.disabled"
|
|
307
|
+
@click="select(tab)"
|
|
308
|
+
>
|
|
309
|
+
<MIcon v-if="tab.icon" :name="tab.icon" :size="24" />
|
|
310
|
+
<span>{{ tab.label }}</span>
|
|
311
|
+
</button>
|
|
312
|
+
<div
|
|
313
|
+
class="absolute bottom-0 h-[3px] bg-primary"
|
|
314
|
+
:style="{ left: `${indicatorLeft}px`, width: `${indicatorWidth}px` }"
|
|
315
|
+
/>
|
|
316
|
+
</div>
|
|
231
317
|
</div>
|
|
232
318
|
</div>
|
|
233
319
|
</template>
|
|
@@ -12,8 +12,9 @@ defineProps<{
|
|
|
12
12
|
<template>
|
|
13
13
|
<div class="relative shrink-0 border-b border-outline-variant bg-surface-container-low" :style="{ width: `${width}px` }" aria-hidden="true">
|
|
14
14
|
<div class="absolute inset-x-0 top-0 h-7">
|
|
15
|
-
<div v-for="c in topCells" :key="c.key" class="absolute inset-y-0 border-l border-outline-variant/60" :style="{ left: `${c.x}px`, width: `${c.w}px` }">
|
|
16
|
-
|
|
15
|
+
<div v-for="c in topCells" :key="c.key" class="absolute inset-y-0 overflow-hidden border-l border-outline-variant/60" :style="{ left: `${c.x}px`, width: `${c.w}px` }">
|
|
16
|
+
<!-- Clipped to its cell, so a label pushed to its cell's end never runs into the next one -->
|
|
17
|
+
<span class="absolute top-1.5 truncate pl-2 text-label-medium whitespace-nowrap text-on-surface" :style="{ left: `${c.labelX}px`, maxWidth: `${Math.max(0, c.w - c.labelX)}px` }">{{ c.label }}</span>
|
|
17
18
|
</div>
|
|
18
19
|
</div>
|
|
19
20
|
<div class="absolute inset-x-0 bottom-0 h-7">
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The divider between MGantt's / MResourceTimeline's list and timeline: a line always there (the list's border),
|
|
3
|
+
// with a grip centered in the view, both primary while hovered, focused or dragged. Wider for a finger. Its
|
|
4
|
+
// listeners (pointerdown, keys, dblclick) fall through from the parent.
|
|
5
|
+
defineProps<{
|
|
6
|
+
label: string
|
|
7
|
+
value: number
|
|
8
|
+
active: boolean
|
|
9
|
+
/** Where the grip's center sits, px from the body's top (the middle of what's in view) */
|
|
10
|
+
gripTop: number
|
|
11
|
+
}>()
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div
|
|
16
|
+
role="separator"
|
|
17
|
+
aria-orientation="vertical"
|
|
18
|
+
:aria-label="label"
|
|
19
|
+
:aria-valuenow="value"
|
|
20
|
+
tabindex="0"
|
|
21
|
+
class="group/split absolute inset-y-0 -right-1 z-30 w-2 cursor-col-resize touch-none outline-none pointer-coarse:-right-3 pointer-coarse:w-6"
|
|
22
|
+
>
|
|
23
|
+
<span
|
|
24
|
+
class="pointer-events-none absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 transition-colors duration-150 group-hover/split:bg-primary group-focus-visible/split:bg-primary"
|
|
25
|
+
:class="active ? 'bg-primary' : 'bg-transparent'"
|
|
26
|
+
/>
|
|
27
|
+
<span
|
|
28
|
+
class="pointer-events-none absolute left-1/2 flex h-8 w-3 -translate-1/2 flex-col items-center justify-center gap-[3px] rounded-full border transition-colors duration-150 pointer-coarse:h-10 pointer-coarse:w-4"
|
|
29
|
+
:class="active
|
|
30
|
+
? 'border-primary bg-primary text-on-primary'
|
|
31
|
+
: 'border-outline-variant bg-surface-container-high text-on-surface-variant group-hover/split:border-primary group-hover/split:bg-primary group-hover/split:text-on-primary group-focus-visible/split:border-primary group-focus-visible/split:bg-primary group-focus-visible/split:text-on-primary'"
|
|
32
|
+
:style="{ top: `${gripTop}px` }"
|
|
33
|
+
>
|
|
34
|
+
<span v-for="i in 3" :key="i" class="size-[3px] rounded-full bg-current" />
|
|
35
|
+
</span>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// While a pointer drag runs (a pan, a resize, a splitter), its cursor stays whatever the pointer passes over, even
|
|
2
|
+
// outside the element it started on, and no text gets selected. The `.m3-drag-cursor` rule lives in MGantt.vue's
|
|
3
|
+
// <style> (all component CSS ships in one stylesheet).
|
|
4
|
+
export function holdDragCursor(cursor: string) {
|
|
5
|
+
const b = document.body
|
|
6
|
+
b.style.cursor = cursor
|
|
7
|
+
b.style.userSelect = 'none'
|
|
8
|
+
b.classList.add('m3-drag-cursor')
|
|
9
|
+
}
|
|
10
|
+
export function releaseDragCursor() {
|
|
11
|
+
const b = document.body
|
|
12
|
+
b.style.cursor = ''
|
|
13
|
+
b.style.userSelect = ''
|
|
14
|
+
b.classList.remove('m3-drag-cursor')
|
|
15
|
+
}
|
|
@@ -175,7 +175,8 @@ export function unitLabel(ms: number, unit: TimeUnit, width: number, lang: strin
|
|
|
175
175
|
case 'week':
|
|
176
176
|
return f({ month: 'short', day: 'numeric' })
|
|
177
177
|
case 'month':
|
|
178
|
-
|
|
178
|
+
// Narrow (a phone, zoomed out): "nov 2026"
|
|
179
|
+
if (top) return f({ month: width >= 160 ? 'long' : 'short', year: 'numeric' })
|
|
179
180
|
return f({ month: width >= 90 ? 'long' : 'short' })
|
|
180
181
|
case 'quarter':
|
|
181
182
|
return quarter.replace('{n}', String(Math.floor(d.getMonth() / 3) + 1))
|
|
@@ -80,10 +80,11 @@ export function useTimeAxis(o: TimeAxisOptions) {
|
|
|
80
80
|
// Zoom around a point of the view (px from the timeline's left edge), sprung on a log scale
|
|
81
81
|
let zoomRaf = 0
|
|
82
82
|
let zoomState: { z: number; v: number; target: number; anchor: number; at: number } | null = null
|
|
83
|
-
|
|
83
|
+
/** `at`: the time that ends up at `anchor` (default the one there now) */
|
|
84
|
+
function zoomTo(target: number, anchor?: number, animate = true, atTime?: number) {
|
|
84
85
|
target = clamp(target)
|
|
85
86
|
const a = anchor ?? timelineView.value / 2
|
|
86
|
-
const at = timeAt(view.value.left + a)
|
|
87
|
+
const at = atTime ?? timeAt(view.value.left + a)
|
|
87
88
|
if (!animate || prefersReducedMotion() || !o.scroller.value) {
|
|
88
89
|
cancelAnimationFrame(zoomRaf)
|
|
89
90
|
zoomRaf = 0
|
|
@@ -124,6 +125,12 @@ export function useTimeAxis(o: TimeAxisOptions) {
|
|
|
124
125
|
const zoomIn = () => zoomTo(zoomTarget() * 1.6)
|
|
125
126
|
const zoomOut = () => zoomTo(zoomTarget() / 1.6)
|
|
126
127
|
const setScale = (s: TimeUnit) => zoomTo(SCALE_PX_PER_DAY[s])
|
|
128
|
+
/** Zooms so a span fills the timeline's width (a margin each side), centered */
|
|
129
|
+
function fit(range: { min: number; max: number }, margin = 24) {
|
|
130
|
+
const days = Math.max((range.max - range.min) / DAY, 1 / 24)
|
|
131
|
+
const room = Math.max(40, timelineView.value - 2 * margin)
|
|
132
|
+
zoomTo(room / days, timelineView.value / 2, false, (range.min + range.max) / 2)
|
|
133
|
+
}
|
|
127
134
|
function scrollToDate(date?: string, opts: { align?: 'start' | 'center'; animate?: boolean } = {}) {
|
|
128
135
|
const ms = date ? parseDate(date) : Date.now()
|
|
129
136
|
const x = xOf(ms) - (opts.align === 'start' ? 24 : timelineView.value / 2)
|
|
@@ -218,7 +225,7 @@ export function useTimeAxis(o: TimeAxisOptions) {
|
|
|
218
225
|
|
|
219
226
|
return {
|
|
220
227
|
ppd, scaleNow, view, timelineView, origin, timelineWidth, todayMs, xOf, timeAt,
|
|
221
|
-
zoomTo, zoomIn, zoomOut, setScale, scrollToDate, units, topCells, bottomCells, offTimes,
|
|
228
|
+
zoomTo, zoomIn, zoomOut, setScale, fit, scrollToDate, units, topCells, bottomCells, offTimes,
|
|
222
229
|
onTouchStart, pinchMove, onTouchEnd, pinching, readView,
|
|
223
230
|
}
|
|
224
231
|
}
|
|
@@ -15,6 +15,8 @@ export interface GanttColumn {
|
|
|
15
15
|
align?: 'start' | 'center' | 'end'
|
|
16
16
|
/** Text for a cell */
|
|
17
17
|
format?: (task: GanttTask) => string
|
|
18
|
+
/** Hidden while the chart (its own width, not the window's) is narrower than this, px */
|
|
19
|
+
hideBelow?: number
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/** What MGantt provides to everything inside it (MGanttControls, panels of yours), and its template ref exposes */
|
|
@@ -57,6 +59,11 @@ export interface GanttContext {
|
|
|
57
59
|
criticalPath: ComputedRef<GanttCriticalPath>
|
|
58
60
|
/** The date (snapped) under a page x */
|
|
59
61
|
dateAt(clientX: number): string
|
|
62
|
+
/** Whether the task list is hidden (`v-model:grid-collapsed`) */
|
|
63
|
+
gridCollapsed: ComputedRef<boolean>
|
|
64
|
+
setGridCollapsed(collapsed: boolean): void
|
|
65
|
+
/** Zooms and scrolls so every task fits the timeline's width */
|
|
66
|
+
fit(): void
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
export const GANTT_KEY: InjectionKey<GanttContext> = Symbol('m3-gantt')
|
|
@@ -78,6 +85,12 @@ export interface TimelineControls {
|
|
|
78
85
|
scrollToDate(date?: string): void
|
|
79
86
|
expandAll(): void
|
|
80
87
|
collapseAll(): void
|
|
88
|
+
/** Zooms and scrolls so everything fits the timeline's width */
|
|
89
|
+
fit(): void
|
|
90
|
+
/** Hosts with a list that can hide (MGantt) */
|
|
91
|
+
hasList?: ComputedRef<boolean>
|
|
92
|
+
gridCollapsed?: ComputedRef<boolean>
|
|
93
|
+
setGridCollapsed?(collapsed: boolean): void
|
|
81
94
|
}
|
|
82
95
|
export const TIMELINE_CONTROLS_KEY: InjectionKey<TimelineControls> = Symbol('m3-timeline-controls')
|
|
83
96
|
|
|
@@ -375,6 +375,9 @@ export interface M3Locale {
|
|
|
375
375
|
ganttBaseline: string
|
|
376
376
|
ganttEmpty: string
|
|
377
377
|
ganttResize: string
|
|
378
|
+
ganttFit: string
|
|
379
|
+
ganttShowList: string
|
|
380
|
+
ganttHideList: string
|
|
378
381
|
timelineResource: string
|
|
379
382
|
timelineConflict: string
|
|
380
383
|
timelineMoved: string
|
|
@@ -961,6 +964,9 @@ export const defaultLocale: M3Locale = {
|
|
|
961
964
|
ganttBaseline: 'Baseline',
|
|
962
965
|
ganttEmpty: 'No tasks yet',
|
|
963
966
|
ganttResize: 'Resize the task list',
|
|
967
|
+
ganttFit: 'Fit everything',
|
|
968
|
+
ganttShowList: 'Show task list',
|
|
969
|
+
ganttHideList: 'Hide task list',
|
|
964
970
|
timelineResource: 'Resource',
|
|
965
971
|
timelineConflict: 'Overlaps another booking',
|
|
966
972
|
timelineMoved: '{title}: {resource}, {start} to {end}',
|
package/src/locales/de.ts
CHANGED
|
@@ -354,6 +354,9 @@ export const deLocale: M3Locale = {
|
|
|
354
354
|
ganttBaseline: 'Basisplan',
|
|
355
355
|
ganttEmpty: 'Noch keine Vorgänge',
|
|
356
356
|
ganttResize: 'Breite der Vorgangsliste ändern',
|
|
357
|
+
ganttFit: 'Alles einpassen',
|
|
358
|
+
ganttShowList: 'Vorgangsliste einblenden',
|
|
359
|
+
ganttHideList: 'Vorgangsliste ausblenden',
|
|
357
360
|
timelineResource: 'Ressource',
|
|
358
361
|
timelineConflict: 'Überschneidet sich mit einer anderen Buchung',
|
|
359
362
|
timelineMoved: '{title}: {resource}, {start} bis {end}',
|
package/src/locales/es.ts
CHANGED
|
@@ -354,6 +354,9 @@ export const esLocale: M3Locale = {
|
|
|
354
354
|
ganttBaseline: 'Línea base',
|
|
355
355
|
ganttEmpty: 'Todavía no hay tareas',
|
|
356
356
|
ganttResize: 'Cambiar el ancho de la lista de tareas',
|
|
357
|
+
ganttFit: 'Ajustar todo',
|
|
358
|
+
ganttShowList: 'Mostrar la lista de tareas',
|
|
359
|
+
ganttHideList: 'Ocultar la lista de tareas',
|
|
357
360
|
timelineResource: 'Recurso',
|
|
358
361
|
timelineConflict: 'Se superpone con otra reserva',
|
|
359
362
|
timelineMoved: '{title}: {resource}, de {start} a {end}',
|