@m3ui-vue/m3ui-vue 1.4.4 → 1.5.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.
- 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-BRntFeNR.js} +113 -79
- package/dist/MTextField-BRntFeNR.js.map +1 -0
- 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/_fieldLayout.d.ts +47 -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 +3944 -3961
- 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__/fieldOverflow.test.ts +118 -0
- package/src/components/MAutocomplete.vue +21 -24
- package/src/components/MColorPicker.vue +3 -3
- package/src/components/MDatePicker.vue +4 -4
- package/src/components/MDateRangePicker.vue +4 -4
- package/src/components/MGantt.vue +138 -43
- package/src/components/MGanttControls.vue +36 -8
- package/src/components/MMaskField.vue +16 -24
- package/src/components/MMultiAutocomplete.vue +19 -25
- package/src/components/MMultiSelect.vue +20 -27
- package/src/components/MNumberField.vue +16 -26
- package/src/components/MPinInput.vue +3 -2
- package/src/components/MResourceTimeline.vue +59 -24
- package/src/components/MSearchBar.vue +2 -2
- package/src/components/MSelect.vue +16 -22
- package/src/components/MTagInput.vue +19 -26
- package/src/components/MTextField.vue +18 -46
- package/src/components/MTimePicker.vue +4 -4
- package/src/components/_MTimeHeader.vue +3 -2
- package/src/components/_MTimeSplitter.vue +37 -0
- package/src/composables/_dragCursor.ts +15 -0
- package/src/composables/_fieldLayout.ts +117 -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/MTextField-Utsef6Kk.js.map +0 -1
- package/dist/useLocale-B8YKWg-H.js.map +0 -1
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
* start-to-finish, with a lag), milestones and a baseline. The zoom runs from hours to years (`v-model:scale`,
|
|
10
10
|
* Ctrl + wheel, a pinch); the timeline scrolls both ways, rows and columns rendered only near the view.
|
|
11
11
|
*
|
|
12
|
+
* Dragging the timeline with a mouse pans it (bars that can't move too, e.g. `readonly`); a finger scrolls, and a tap
|
|
13
|
+
* on a bar shows its card. The divider beside the list resizes it (double-click: back to `gridWidth`); the list hides
|
|
14
|
+
* with `v-model:grid-collapsed`, and columns with `hideBelow` drop out on a narrow chart.
|
|
15
|
+
*
|
|
12
16
|
* Editing: drag a bar to move it (with a mouse, or a short press with a finger), its ends to resize it, the
|
|
13
17
|
* triangle under it to set the progress, the dots at its ends onto another bar to make a dependency (which end you
|
|
14
18
|
* leave and reach picks the type); click or tap a dependency for its × to remove it (or Delete). A summary moves
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
* @slot default Above the chart: MGanttControls, filters of yours. Props: `{ gantt }`
|
|
24
28
|
* @slot bar A bar's content instead of its label. Props: `{ task, selected, critical }`
|
|
25
29
|
* @slot cell-<key> A cell of that column. Props: `{ task, value }`
|
|
26
|
-
* @slot tooltip The card shown over a hovered or
|
|
30
|
+
* @slot tooltip The card shown over a hovered, dragged or tapped bar. Props: `{ task, slack }`
|
|
27
31
|
* @slot empty Shown while there are no tasks
|
|
28
32
|
* @event task-click / task-dblclick / task-contextmenu `(task, event)`
|
|
29
33
|
* @event link A dependency was drawn: `{ from, to, type }` (it's also added to the task)
|
|
@@ -53,8 +57,10 @@ import { arrowPath } from '../composables/flowPaths'
|
|
|
53
57
|
import { playSamples, prefersReducedMotion, sampleSpring } from '../composables/_springAnimation'
|
|
54
58
|
import { useLocale } from '../composables/useLocale'
|
|
55
59
|
import { useTimeAxis } from '../composables/_useTimeAxis'
|
|
60
|
+
import { holdDragCursor, releaseDragCursor } from '../composables/_dragCursor'
|
|
56
61
|
import MTimeHeader from './_MTimeHeader.vue'
|
|
57
62
|
import MTimeBackground from './_MTimeBackground.vue'
|
|
63
|
+
import MTimeSplitter from './_MTimeSplitter.vue'
|
|
58
64
|
|
|
59
65
|
const props = withDefaults(defineProps<{
|
|
60
66
|
tasks?: GanttTask[]
|
|
@@ -68,8 +74,11 @@ const props = withDefaults(defineProps<{
|
|
|
68
74
|
collapsed?: string[]
|
|
69
75
|
/** The task list's columns (default name, start and duration); `[]` hides the list */
|
|
70
76
|
columns?: GanttColumn[]
|
|
71
|
-
/** The task list's width, px (`v-model:grid-width`; drag its edge) */
|
|
77
|
+
/** The task list's width, px (`v-model:grid-width`; drag its edge, double-click it to restore this width) */
|
|
72
78
|
gridWidth?: number
|
|
79
|
+
/** Hides the task list, leaving the timeline the whole width (`v-model:grid-collapsed`; MGanttControls has a button) */
|
|
80
|
+
gridCollapsed?: boolean
|
|
81
|
+
/** Row height, px. Fingers get on fine with the default; raise it (e.g. 48) for roomier touch targets */
|
|
73
82
|
rowHeight?: number
|
|
74
83
|
/** No editing: drag, resize, link, reorder, rename and delete off */
|
|
75
84
|
readonly?: boolean
|
|
@@ -114,6 +123,7 @@ const emit = defineEmits<{
|
|
|
114
123
|
'update:selection': [string[]]
|
|
115
124
|
'update:collapsed': [string[]]
|
|
116
125
|
'update:gridWidth': [number]
|
|
126
|
+
'update:gridCollapsed': [boolean]
|
|
117
127
|
'task-click': [GanttTask, MouseEvent]
|
|
118
128
|
'task-dblclick': [GanttTask, MouseEvent | KeyboardEvent]
|
|
119
129
|
'task-contextmenu': [GanttTask, MouseEvent]
|
|
@@ -226,15 +236,29 @@ const rowIndex = computed(() => new Map(rows.value.map((r, i) => [r.task.id, i])
|
|
|
226
236
|
// ── Zoom and time ↔ px ────────────────────────────────────────────────────────────────────────────────────
|
|
227
237
|
const scroller = ref<HTMLElement>()
|
|
228
238
|
const headerHeight = 56
|
|
239
|
+
// On a chart narrower than 600 px only the name is listed
|
|
229
240
|
const defaultColumns = computed<GanttColumn[]>(() => [
|
|
230
241
|
{ key: 'name', label: locale.ganttTask },
|
|
231
|
-
{ key: 'start', label: locale.ganttStart, width: 96 },
|
|
232
|
-
{ key: 'duration', label: locale.ganttDuration, width: 80, align: 'end' },
|
|
242
|
+
{ key: 'start', label: locale.ganttStart, width: 96, hideBelow: 600 },
|
|
243
|
+
{ key: 'duration', label: locale.ganttDuration, width: 80, align: 'end', hideBelow: 600 },
|
|
233
244
|
])
|
|
234
|
-
const
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
245
|
+
const allColumns = computed(() => props.columns ?? defaultColumns.value)
|
|
246
|
+
const gridHidden = ref(props.gridCollapsed ?? false)
|
|
247
|
+
watch(() => props.gridCollapsed, (c) => { if (c !== undefined) gridHidden.value = c })
|
|
248
|
+
function setGridCollapsed(c: boolean) {
|
|
249
|
+
if (c === gridHidden.value) return
|
|
250
|
+
gridHidden.value = c
|
|
251
|
+
emit('update:gridCollapsed', c)
|
|
252
|
+
}
|
|
253
|
+
const showGrid = computed(() => allColumns.value.length > 0 && !gridHidden.value)
|
|
254
|
+
// The width double-clicking the divider goes back to
|
|
255
|
+
let initialW = props.gridWidth ?? 320
|
|
256
|
+
const gridW = ref(initialW)
|
|
257
|
+
watch(() => props.gridWidth, (w) => { if (w !== undefined) { gridW.value = w; initialW = w } })
|
|
258
|
+
function setGridWidth(w: number) {
|
|
259
|
+
gridW.value = w
|
|
260
|
+
emit('update:gridWidth', w)
|
|
261
|
+
}
|
|
238
262
|
const listWidth = computed(() => (showGrid.value ? gridW.value : 0))
|
|
239
263
|
|
|
240
264
|
const extent = computed(() => {
|
|
@@ -272,6 +296,15 @@ const axis = useTimeAxis({
|
|
|
272
296
|
})
|
|
273
297
|
const { ppd, view, timelineView, origin, timelineWidth, todayMs, xOf, timeAt, zoomIn, zoomOut, setScale, scrollToDate, topCells, bottomCells, offTimes } = axis
|
|
274
298
|
const scaleNow = axis.scaleNow
|
|
299
|
+
/** Zooms and scrolls so every task fits the timeline's width */
|
|
300
|
+
function fit() {
|
|
301
|
+
if (shown.value.length) axis.fit(extent.value)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// The chart's own width (not the window's) decides what's compact
|
|
305
|
+
const narrow = computed(() => view.value.width > 0 && view.value.width < 600)
|
|
306
|
+
const indent = computed(() => (narrow.value ? 12 : 20))
|
|
307
|
+
const columnList = computed(() => allColumns.value.filter((c) => !c.hideBelow || !view.value.width || view.value.width >= c.hideBelow))
|
|
275
308
|
|
|
276
309
|
function scrollToTask(id: string) {
|
|
277
310
|
let t = byId.value.get(id)
|
|
@@ -376,11 +409,16 @@ function writeBar(id: string, el: HTMLElement) {
|
|
|
376
409
|
if (!s) return
|
|
377
410
|
el.style.transform = `translateX(${s.x}px)`
|
|
378
411
|
el.style.width = `${s.w}px`
|
|
412
|
+
// A label inside a bar scrolled partly away slides along to stay at the timeline's left edge
|
|
413
|
+
const name = byId.value.get(id)?.name ?? ''
|
|
414
|
+
const shift = Math.max(0, Math.min(view.value.left - s.x, s.w - (name.length * 7 + 24)))
|
|
415
|
+
el.style.setProperty('--m3-gantt-label-x', `${shift}px`)
|
|
379
416
|
}
|
|
380
417
|
function writeAll() {
|
|
381
418
|
for (const [id, el] of barEls) writeBar(id, el)
|
|
382
419
|
for (const [key, el] of linkEls) writeLink(key, el)
|
|
383
420
|
}
|
|
421
|
+
watch(() => view.value.left, () => { for (const [id, el] of barEls) writeBar(id, el) })
|
|
384
422
|
function bindBar(id: string, el: unknown) {
|
|
385
423
|
if (el instanceof HTMLElement) {
|
|
386
424
|
barEls.set(id, el)
|
|
@@ -582,13 +620,14 @@ function dateAt(clientX: number) {
|
|
|
582
620
|
// ── Pointer gestures on the timeline ──────────────────────────────────────────────────────────────────────
|
|
583
621
|
type Part = 'body' | 'start' | 'end' | 'progress' | 'link-start' | 'link-end'
|
|
584
622
|
type Gesture =
|
|
585
|
-
| { kind: 'bar'; part: Part; id: number; taskId: string; sx: number; sy: number; sl: number; touch: boolean; active: boolean; spans: Map<string, { start: number; end: number }>; moving: string[] }
|
|
623
|
+
| { kind: 'bar'; part: Part; id: number; taskId: string; sx: number; sy: number; sl: number; st: number; touch: boolean; active: boolean; spans: Map<string, { start: number; end: number }>; moving: string[] }
|
|
586
624
|
| { kind: 'pan'; id: number; sx: number; sy: number; sl: number; st: number; moved: boolean }
|
|
587
625
|
| { kind: 'row'; id: number; taskId: string; sx: number; sy: number; st: number; touch: boolean; active: boolean }
|
|
588
626
|
| { kind: 'split'; id: number; sx: number; w: number }
|
|
589
627
|
let gesture: Gesture | null = null
|
|
590
628
|
let pressTimer: ReturnType<typeof setTimeout> | undefined
|
|
591
629
|
const dragging = ref<{ taskId: string; part: Part } | null>(null)
|
|
630
|
+
const splitting = ref(false)
|
|
592
631
|
const linkDraft = ref<{ from: string; fromEnd: boolean; x: number; y: number; target: string | null; targetEnd: boolean; valid: boolean } | null>(null)
|
|
593
632
|
const rowDrop = ref<{ taskId: string; target: string; where: 'before' | 'after' | 'inside' } | null>(null)
|
|
594
633
|
const pointer = { x: 0, y: 0 }
|
|
@@ -598,20 +637,32 @@ function contentPoint(clientX: number, clientY: number) {
|
|
|
598
637
|
return { x: clientX - r.left - listWidth.value + scroller.value!.scrollLeft, y: clientY - r.top - headerHeight + scroller.value!.scrollTop }
|
|
599
638
|
}
|
|
600
639
|
const isControl = (t: EventTarget | null) => t instanceof Element && !!t.closest('input, textarea, select, button, a, [contenteditable], [data-gantt-action]')
|
|
640
|
+
// A mouse press that starts a pan or a drag: no native drag of the text or SVG under it, no text selection. That
|
|
641
|
+
// also keeps the focus where it was, so a rename in progress is ended by hand
|
|
642
|
+
function claimMouse(e: PointerEvent) {
|
|
643
|
+
if (e.pointerType === 'touch') return
|
|
644
|
+
e.preventDefault()
|
|
645
|
+
const a = document.activeElement
|
|
646
|
+
if (a instanceof HTMLElement && a.matches('[data-gantt-rename]')) a.blur()
|
|
647
|
+
}
|
|
601
648
|
|
|
602
649
|
function onBarDown(e: PointerEvent, task: GanttTask, part: Part) {
|
|
603
650
|
if (e.button !== 0 || isControl(e.target)) return
|
|
604
651
|
if (props.readonly && part !== 'body') return
|
|
605
652
|
e.stopPropagation()
|
|
653
|
+
claimMouse(e)
|
|
654
|
+
if (tapped.value?.id !== task.id) tapped.value = null
|
|
606
655
|
const touch = e.pointerType === 'touch'
|
|
607
|
-
gesture = { kind: 'bar', part, id: e.pointerId, taskId: task.id, sx: e.clientX, sy: e.clientY, sl: scroller.value!.scrollLeft, touch, active: false, spans: new Map(), moving: [] }
|
|
656
|
+
gesture = { kind: 'bar', part, id: e.pointerId, taskId: task.id, sx: e.clientX, sy: e.clientY, sl: scroller.value!.scrollLeft, st: scroller.value!.scrollTop, touch, active: false, spans: new Map(), moving: [] }
|
|
608
657
|
addWindow()
|
|
609
658
|
// A finger scrolls unless it holds still a moment first; handles take it at once
|
|
610
659
|
if (touch && part === 'body') pressTimer = setTimeout(() => activate(e), 250)
|
|
611
660
|
else if (touch) activate(e)
|
|
612
661
|
}
|
|
613
662
|
function onPaneDown(e: PointerEvent) {
|
|
663
|
+
tapped.value = null
|
|
614
664
|
if (e.button !== 0 || e.pointerType === 'touch' || isControl(e.target)) return
|
|
665
|
+
claimMouse(e)
|
|
615
666
|
gesture = { kind: 'pan', id: e.pointerId, sx: e.clientX, sy: e.clientY, sl: scroller.value!.scrollLeft, st: scroller.value!.scrollTop, moved: false }
|
|
616
667
|
addWindow()
|
|
617
668
|
}
|
|
@@ -626,6 +677,8 @@ function onSplitDown(e: PointerEvent) {
|
|
|
626
677
|
if (e.button !== 0) return
|
|
627
678
|
e.preventDefault()
|
|
628
679
|
gesture = { kind: 'split', id: e.pointerId, sx: e.clientX, w: gridW.value }
|
|
680
|
+
splitting.value = true
|
|
681
|
+
holdDragCursor('col-resize')
|
|
629
682
|
addWindow()
|
|
630
683
|
}
|
|
631
684
|
function addWindow() {
|
|
@@ -638,7 +691,8 @@ function removeWindow() {
|
|
|
638
691
|
window.removeEventListener('pointerup', onUp)
|
|
639
692
|
window.removeEventListener('pointercancel', onCancel)
|
|
640
693
|
clearTimeout(pressTimer)
|
|
641
|
-
|
|
694
|
+
releaseDragCursor()
|
|
695
|
+
splitting.value = false
|
|
642
696
|
}
|
|
643
697
|
|
|
644
698
|
function activate(e: PointerEvent) {
|
|
@@ -676,7 +730,8 @@ function activate(e: PointerEvent) {
|
|
|
676
730
|
dragging.value = { taskId: t.id, part: 'body' }
|
|
677
731
|
}
|
|
678
732
|
if (g.touch) navigator.vibrate?.(10)
|
|
679
|
-
|
|
733
|
+
const part = dragging.value!.part
|
|
734
|
+
holdDragCursor(part === 'body' ? 'grabbing' : part.startsWith('link') ? 'crosshair' : 'ew-resize')
|
|
680
735
|
startAutoScroll()
|
|
681
736
|
}
|
|
682
737
|
|
|
@@ -686,20 +741,10 @@ function onMove(e: PointerEvent) {
|
|
|
686
741
|
pointer.x = e.clientX
|
|
687
742
|
pointer.y = e.clientY
|
|
688
743
|
if (g.kind === 'split') {
|
|
689
|
-
|
|
690
|
-
gridW.value = w
|
|
691
|
-
emit('update:gridWidth', w)
|
|
692
|
-
return
|
|
693
|
-
}
|
|
694
|
-
if (g.kind === 'pan') {
|
|
695
|
-
const dx = e.clientX - g.sx
|
|
696
|
-
const dy = e.clientY - g.sy
|
|
697
|
-
if (!g.moved && Math.hypot(dx, dy) < 4) return
|
|
698
|
-
g.moved = true
|
|
699
|
-
scroller.value!.scrollLeft = g.sl - dx
|
|
700
|
-
scroller.value!.scrollTop = g.st - dy
|
|
744
|
+
setGridWidth(Math.round(Math.min(Math.max(120, g.w + e.clientX - g.sx), Math.max(160, view.value.width - 80))))
|
|
701
745
|
return
|
|
702
746
|
}
|
|
747
|
+
if (g.kind === 'pan') return pan(g, e)
|
|
703
748
|
if (!g.active) {
|
|
704
749
|
const d = Math.hypot(e.clientX - g.sx, e.clientY - g.sy)
|
|
705
750
|
if (g.touch) {
|
|
@@ -709,10 +754,30 @@ function onMove(e: PointerEvent) {
|
|
|
709
754
|
}
|
|
710
755
|
if (d < 4) return
|
|
711
756
|
activate(e)
|
|
712
|
-
if (!g.active)
|
|
757
|
+
if (!g.active) {
|
|
758
|
+
// A bar that can't move (readonly, draggable: false) pans the chart like the background does
|
|
759
|
+
if (g.kind === 'bar' && g.part === 'body') {
|
|
760
|
+
const p: Extract<Gesture, { kind: 'pan' }> = { kind: 'pan', id: g.id, sx: g.sx, sy: g.sy, sl: g.sl, st: g.st, moved: false }
|
|
761
|
+
gesture = p
|
|
762
|
+
pan(p, e)
|
|
763
|
+
}
|
|
764
|
+
return
|
|
765
|
+
}
|
|
713
766
|
}
|
|
714
767
|
dragTo(e.clientX, e.clientY)
|
|
715
768
|
}
|
|
769
|
+
function pan(g: Extract<Gesture, { kind: 'pan' }>, e: PointerEvent) {
|
|
770
|
+
const dx = e.clientX - g.sx
|
|
771
|
+
const dy = e.clientY - g.sy
|
|
772
|
+
if (!g.moved && Math.hypot(dx, dy) < 4) return
|
|
773
|
+
if (!g.moved) {
|
|
774
|
+
g.moved = true
|
|
775
|
+
hovered.value = null
|
|
776
|
+
holdDragCursor('grabbing')
|
|
777
|
+
}
|
|
778
|
+
scroller.value!.scrollLeft = g.sl - dx
|
|
779
|
+
scroller.value!.scrollTop = g.st - dy
|
|
780
|
+
}
|
|
716
781
|
|
|
717
782
|
function snapStep(t: GanttTask) {
|
|
718
783
|
return taskSpan(t).dateOnly ? 1440 : (props.snap ?? defaultSnap(ppd.value))
|
|
@@ -841,6 +906,8 @@ function onUp(e: PointerEvent) {
|
|
|
841
906
|
const t = byId.value.get(g.taskId)
|
|
842
907
|
if (!t) return
|
|
843
908
|
selectFromClick(t, e)
|
|
909
|
+
// No hover on a finger: a tap shows the bar's card (another tap, a scroll or a tap elsewhere hides it)
|
|
910
|
+
if (e.pointerType === 'touch') showTip(t.id)
|
|
844
911
|
emit('task-click', t, e)
|
|
845
912
|
return
|
|
846
913
|
}
|
|
@@ -923,13 +990,15 @@ function onTouchMove(e: TouchEvent) {
|
|
|
923
990
|
function onScroll() {
|
|
924
991
|
axis.readView()
|
|
925
992
|
hovered.value = null
|
|
993
|
+
if (!gesture) tapped.value = null
|
|
926
994
|
}
|
|
927
995
|
|
|
928
996
|
// ── Tooltip ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
929
997
|
const hovered = ref<{ id: string; x: number; y: number } | null>(null)
|
|
998
|
+
const tapped = ref<{ id: string; x: number; y: number } | null>(null)
|
|
930
999
|
let hoverTimer: ReturnType<typeof setTimeout> | undefined
|
|
931
1000
|
function onBarEnter(e: PointerEvent, t: GanttTask) {
|
|
932
|
-
if (e.pointerType === 'touch') return
|
|
1001
|
+
if (e.pointerType === 'touch' || gesture) return
|
|
933
1002
|
clearTimeout(hoverTimer)
|
|
934
1003
|
const el = e.currentTarget as HTMLElement
|
|
935
1004
|
hoverTimer = setTimeout(() => {
|
|
@@ -941,23 +1010,36 @@ function onBarLeave() {
|
|
|
941
1010
|
clearTimeout(hoverTimer)
|
|
942
1011
|
hovered.value = null
|
|
943
1012
|
}
|
|
1013
|
+
function showTip(id: string) {
|
|
1014
|
+
if (tapped.value?.id === id) { tapped.value = null; return }
|
|
1015
|
+
const el = barEls.get(id)?.querySelector('[data-gantt-task]') ?? barEls.get(id)
|
|
1016
|
+
const r = el?.getBoundingClientRect()
|
|
1017
|
+
const s = scroller.value?.getBoundingClientRect()
|
|
1018
|
+
if (!r) return
|
|
1019
|
+
// The part of the bar that's in view
|
|
1020
|
+
const left = Math.max(r.left, (s?.left ?? 0) + listWidth.value)
|
|
1021
|
+
const right = Math.min(r.right, s?.right ?? window.innerWidth)
|
|
1022
|
+
tapped.value = { id, x: right > left ? (left + right) / 2 : r.left + r.width / 2, y: r.top }
|
|
1023
|
+
}
|
|
1024
|
+
const tipAt = computed(() => hovered.value ?? tapped.value)
|
|
944
1025
|
const tooltipTask = computed(() => {
|
|
945
|
-
const id = dragging.value?.taskId ??
|
|
1026
|
+
const id = dragging.value?.taskId ?? tipAt.value?.id
|
|
946
1027
|
return id ? byId.value.get(id) : undefined
|
|
947
1028
|
})
|
|
948
1029
|
const tooltipPos = ref({ x: 0, y: 0 })
|
|
949
|
-
|
|
1030
|
+
const clampTipX = (x: number) => Math.min(Math.max(x, 120), window.innerWidth - 120)
|
|
1031
|
+
watch([tooltipTask, tipAt], () => {
|
|
950
1032
|
if (dragging.value) {
|
|
951
1033
|
const el = barEls.get(dragging.value.taskId)
|
|
952
1034
|
const r = el?.getBoundingClientRect()
|
|
953
1035
|
if (r) tooltipPos.value = { x: r.left + r.width / 2, y: r.top }
|
|
954
|
-
} else if (
|
|
1036
|
+
} else if (tipAt.value) tooltipPos.value = { x: clampTipX(tipAt.value.x), y: tipAt.value.y }
|
|
955
1037
|
}, { flush: 'post' })
|
|
956
1038
|
watch(preview, () => {
|
|
957
1039
|
if (!dragging.value) return
|
|
958
1040
|
nextTick(() => {
|
|
959
1041
|
const r = barEls.get(dragging.value?.taskId ?? '')?.getBoundingClientRect()
|
|
960
|
-
if (r) tooltipPos.value = { x:
|
|
1042
|
+
if (r) tooltipPos.value = { x: clampTipX(r.left + r.width / 2), y: r.top }
|
|
961
1043
|
})
|
|
962
1044
|
})
|
|
963
1045
|
|
|
@@ -1207,12 +1289,16 @@ const context: GanttContext = {
|
|
|
1207
1289
|
schedule: runSchedule,
|
|
1208
1290
|
criticalPath: criticalPathInfo,
|
|
1209
1291
|
dateAt,
|
|
1292
|
+
gridCollapsed: computed(() => gridHidden.value),
|
|
1293
|
+
setGridCollapsed,
|
|
1294
|
+
fit,
|
|
1210
1295
|
}
|
|
1211
1296
|
provide(GANTT_KEY, context)
|
|
1212
1297
|
provide(TIMELINE_CONTROLS_KEY, {
|
|
1213
1298
|
...context,
|
|
1214
1299
|
foldable: computed(() => childrenOf.value.size > 1),
|
|
1215
1300
|
folded: computed(() => folded.value.length > 0),
|
|
1301
|
+
hasList: computed(() => allColumns.value.length > 0),
|
|
1216
1302
|
})
|
|
1217
1303
|
|
|
1218
1304
|
onMounted(() => {
|
|
@@ -1313,7 +1399,7 @@ defineExpose(context)
|
|
|
1313
1399
|
role="gridcell"
|
|
1314
1400
|
class="flex h-full min-w-0 items-center px-3"
|
|
1315
1401
|
:class="[c.align === 'end' ? 'justify-end' : c.align === 'center' ? 'justify-center' : '', c.key === 'name' ? 'gap-1' : 'text-on-surface-variant']"
|
|
1316
|
-
:style="{ width: `${columnWidths[ci]}px`, paddingLeft: c.key === 'name' ? `${8 + r.depth *
|
|
1402
|
+
:style="{ width: `${columnWidths[ci]}px`, paddingLeft: c.key === 'name' ? `${8 + r.depth * indent}px` : undefined }"
|
|
1317
1403
|
>
|
|
1318
1404
|
<template v-if="c.key === 'name'">
|
|
1319
1405
|
<button
|
|
@@ -1356,23 +1442,28 @@ defineExpose(context)
|
|
|
1356
1442
|
:class="rowDrop.where === 'inside' ? 'rounded-sm border-2 border-primary' : 'h-0.5 rounded-full bg-primary'"
|
|
1357
1443
|
:style="rowDrop.where === 'inside'
|
|
1358
1444
|
? { top: `${(rowIndex.get(rowDrop.target) ?? 0) * rowHeight + 2}px`, height: `${rowHeight - 4}px`, left: '8px' }
|
|
1359
|
-
: { top: `${((rowIndex.get(rowDrop.target) ?? 0) + (rowDrop.where === 'after' ? 1 : 0)) * rowHeight - 1}px`, left: `${8 + ((rows[rowIndex.get(rowDrop.target) ?? 0]?.depth ?? 0)) *
|
|
1445
|
+
: { top: `${((rowIndex.get(rowDrop.target) ?? 0) + (rowDrop.where === 'after' ? 1 : 0)) * rowHeight - 1}px`, left: `${8 + ((rows[rowIndex.get(rowDrop.target) ?? 0]?.depth ?? 0)) * indent}px` }"
|
|
1360
1446
|
/>
|
|
1361
|
-
<
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
:
|
|
1365
|
-
:
|
|
1366
|
-
tabindex="0"
|
|
1367
|
-
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"
|
|
1447
|
+
<MTimeSplitter
|
|
1448
|
+
:label="locale.ganttResize"
|
|
1449
|
+
:value="listWidth"
|
|
1450
|
+
:active="splitting"
|
|
1451
|
+
:grip-top="view.top + Math.max(0, view.height - headerHeight) / 2"
|
|
1368
1452
|
@pointerdown="onSplitDown"
|
|
1369
|
-
@
|
|
1370
|
-
@keydown.
|
|
1453
|
+
@dblclick="setGridWidth(initialW)"
|
|
1454
|
+
@keydown.left.prevent="setGridWidth(Math.max(120, gridW - 16))"
|
|
1455
|
+
@keydown.right.prevent="setGridWidth(gridW + 16)"
|
|
1371
1456
|
/>
|
|
1372
1457
|
</div>
|
|
1373
1458
|
|
|
1374
1459
|
<!-- Timeline -->
|
|
1375
|
-
<div
|
|
1460
|
+
<div
|
|
1461
|
+
class="relative shrink-0 cursor-grab select-none [-webkit-user-drag:none] active:cursor-grabbing"
|
|
1462
|
+
:style="{ width: `${timelineWidth}px` }"
|
|
1463
|
+
aria-hidden="true"
|
|
1464
|
+
@pointerdown="onPaneDown"
|
|
1465
|
+
@dragstart.prevent
|
|
1466
|
+
>
|
|
1376
1467
|
<MTimeBackground :off-times="offTimes" :cells="bottomCells" :today-x="todayMs === null ? null : xOf(todayMs)" />
|
|
1377
1468
|
<div
|
|
1378
1469
|
v-for="r in visibleRows"
|
|
@@ -1491,7 +1582,7 @@ defineExpose(context)
|
|
|
1491
1582
|
<div class="pointer-events-none absolute inset-y-0 left-0" :class="toneOf(r.task).fill" :style="{ width: `${r.task.progress ?? 0}%` }" />
|
|
1492
1583
|
<div class="pointer-events-none relative flex h-full items-center px-2 text-label-medium whitespace-nowrap">
|
|
1493
1584
|
<slot name="bar" :task="r.task" :selected="selectedSet.has(r.task.id)" :critical="criticalSet.has(r.task.id)">
|
|
1494
|
-
<span v-if="showLabelInside(r.task)" class="truncate">{{ r.task.name }}</span>
|
|
1585
|
+
<span v-if="showLabelInside(r.task)" class="truncate" style="transform: translateX(var(--m3-gantt-label-x, 0px))">{{ r.task.name }}</span>
|
|
1495
1586
|
</slot>
|
|
1496
1587
|
</div>
|
|
1497
1588
|
</div>
|
|
@@ -1587,6 +1678,10 @@ defineExpose(context)
|
|
|
1587
1678
|
</template>
|
|
1588
1679
|
|
|
1589
1680
|
<style>
|
|
1681
|
+
/* A drag's cursor (_dragCursor.ts, set inline on <body>) wins over every element it passes */
|
|
1682
|
+
.m3-drag-cursor * {
|
|
1683
|
+
cursor: inherit !important;
|
|
1684
|
+
}
|
|
1590
1685
|
/* The summary bracket's ends point down at its first and last tasks */
|
|
1591
1686
|
.m3-gantt-summary::before,
|
|
1592
1687
|
.m3-gantt-summary::after {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
/**
|
|
3
|
-
* A toolbar for an MGantt or an MResourceTimeline (put it in their default slot):
|
|
4
|
-
* and out, today, expand and collapse all, undo and redo.
|
|
3
|
+
* A toolbar for an MGantt or an MResourceTimeline (put it in their default slot): show / hide the task list (MGantt),
|
|
4
|
+
* the zoom as named scales, zoom in and out, fit everything, today, expand and collapse all, undo and redo. With a
|
|
5
|
+
* finger (`pointer: coarse`) its icon buttons are 48 px. Not an M3 spec component.
|
|
5
6
|
*
|
|
6
7
|
* @slot default More controls at the start
|
|
7
8
|
* @slot end More controls at the end
|
|
8
9
|
*/
|
|
9
|
-
import { computed, inject } from 'vue'
|
|
10
|
+
import { computed, inject, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
10
11
|
import { TIMELINE_CONTROLS_KEY, type GanttScale } from '../composables/useGantt'
|
|
11
12
|
import { useLocale } from '../composables/useLocale'
|
|
12
13
|
import MIconButton from './MIconButton.vue'
|
|
@@ -16,6 +17,10 @@ const props = withDefaults(defineProps<{
|
|
|
16
17
|
/** The scales offered as a segmented button (`[]` hides it) */
|
|
17
18
|
scales?: GanttScale[]
|
|
18
19
|
zoom?: boolean
|
|
20
|
+
/** A button that zooms and scrolls so every task fits the width */
|
|
21
|
+
fit?: boolean
|
|
22
|
+
/** A button that shows / hides MGantt's task list */
|
|
23
|
+
list?: boolean
|
|
19
24
|
today?: boolean
|
|
20
25
|
/** Expand all / collapse all */
|
|
21
26
|
fold?: boolean
|
|
@@ -24,6 +29,8 @@ const props = withDefaults(defineProps<{
|
|
|
24
29
|
}>(), {
|
|
25
30
|
scales: () => ['day', 'week', 'month', 'quarter'],
|
|
26
31
|
zoom: true,
|
|
32
|
+
fit: true,
|
|
33
|
+
list: true,
|
|
27
34
|
today: true,
|
|
28
35
|
fold: true,
|
|
29
36
|
history: true,
|
|
@@ -41,11 +48,30 @@ const NAMES: Record<GanttScale, keyof typeof locale> = {
|
|
|
41
48
|
quarter: 'ganttScaleQuarter',
|
|
42
49
|
year: 'ganttScaleYear',
|
|
43
50
|
}
|
|
51
|
+
// 48 px targets for a finger
|
|
52
|
+
const coarse = ref(false)
|
|
53
|
+
let mq: MediaQueryList | undefined
|
|
54
|
+
const onMq = () => { coarse.value = !!mq?.matches }
|
|
55
|
+
onMounted(() => {
|
|
56
|
+
mq = window.matchMedia?.('(pointer: coarse)')
|
|
57
|
+
onMq()
|
|
58
|
+
mq?.addEventListener?.('change', onMq)
|
|
59
|
+
})
|
|
60
|
+
onBeforeUnmount(() => mq?.removeEventListener?.('change', onMq))
|
|
61
|
+
const size = computed(() => (coarse.value ? 48 : 'sm'))
|
|
62
|
+
const showList = computed(() => props.list && !!gantt.hasList?.value && !!gantt.setGridCollapsed)
|
|
44
63
|
const options = computed(() => props.scales.map((s) => ({ value: s, label: locale[NAMES[s]] as string })))
|
|
45
64
|
</script>
|
|
46
65
|
|
|
47
66
|
<template>
|
|
48
67
|
<div class="m3-gantt-controls flex flex-wrap items-center gap-2 border-b border-outline-variant px-3 py-2" role="toolbar">
|
|
68
|
+
<MIconButton
|
|
69
|
+
v-if="showList"
|
|
70
|
+
:size="size"
|
|
71
|
+
:icon="gantt.gridCollapsed!.value ? 'left_panel_open' : 'left_panel_close'"
|
|
72
|
+
:label="gantt.gridCollapsed!.value ? locale.ganttShowList : locale.ganttHideList"
|
|
73
|
+
@click="gantt.setGridCollapsed!(!gantt.gridCollapsed!.value)"
|
|
74
|
+
/>
|
|
49
75
|
<slot />
|
|
50
76
|
<MSegmentedButton
|
|
51
77
|
v-if="options.length"
|
|
@@ -56,19 +82,21 @@ const options = computed(() => props.scales.map((s) => ({ value: s, label: local
|
|
|
56
82
|
/>
|
|
57
83
|
<div class="flex items-center">
|
|
58
84
|
<template v-if="zoom">
|
|
59
|
-
<MIconButton icon="zoom_out" :label="locale.ganttZoomOut" @click="gantt.zoomOut()" />
|
|
60
|
-
<MIconButton icon="zoom_in" :label="locale.ganttZoomIn" @click="gantt.zoomIn()" />
|
|
85
|
+
<MIconButton :size="size" icon="zoom_out" :label="locale.ganttZoomOut" @click="gantt.zoomOut()" />
|
|
86
|
+
<MIconButton :size="size" icon="zoom_in" :label="locale.ganttZoomIn" @click="gantt.zoomIn()" />
|
|
61
87
|
</template>
|
|
62
|
-
<MIconButton v-if="
|
|
88
|
+
<MIconButton v-if="fit" :size="size" icon="fit_width" :label="locale.ganttFit" @click="gantt.fit()" />
|
|
89
|
+
<MIconButton v-if="today" :size="size" icon="today" :label="locale.ganttToday" @click="gantt.scrollToDate()" />
|
|
63
90
|
<MIconButton
|
|
64
91
|
v-if="fold && gantt.foldable.value"
|
|
92
|
+
:size="size"
|
|
65
93
|
:icon="gantt.folded.value ? 'unfold_more' : 'unfold_less'"
|
|
66
94
|
:label="gantt.folded.value ? locale.ganttExpandAll : locale.ganttCollapseAll"
|
|
67
95
|
@click="gantt.folded.value ? gantt.expandAll() : gantt.collapseAll()"
|
|
68
96
|
/>
|
|
69
97
|
<template v-if="history && !gantt.readonly.value">
|
|
70
|
-
<MIconButton icon="undo" :label="locale.ganttUndo" :disabled="!gantt.canUndo.value" @click="gantt.undo()" />
|
|
71
|
-
<MIconButton icon="redo" :label="locale.ganttRedo" :disabled="!gantt.canRedo.value" @click="gantt.redo()" />
|
|
98
|
+
<MIconButton :size="size" icon="undo" :label="locale.ganttUndo" :disabled="!gantt.canUndo.value" @click="gantt.undo()" />
|
|
99
|
+
<MIconButton :size="size" icon="redo" :label="locale.ganttRedo" :disabled="!gantt.canRedo.value" @click="gantt.redo()" />
|
|
72
100
|
</template>
|
|
73
101
|
</div>
|
|
74
102
|
<div class="flex-1" />
|
|
@@ -10,6 +10,7 @@ import MIcon from './MIcon.vue'
|
|
|
10
10
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
11
11
|
import { useDebounce } from '../composables/useDebounce'
|
|
12
12
|
import { useLocale } from '../composables/useLocale'
|
|
13
|
+
import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
13
14
|
|
|
14
15
|
export type MaskPreset = 'credit-card' | 'phone' | 'date' | 'time' | 'cpf' | 'cnpj' | 'zip'
|
|
15
16
|
|
|
@@ -128,9 +129,12 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
128
129
|
|
|
129
130
|
const hasTrailing = computed(() => props.clearable)
|
|
130
131
|
|
|
132
|
+
// The label and the text both stop before the trailing controls
|
|
133
|
+
const rightInset = computed<FieldRightInset>(() => (hasTrailing.value ? 'right-12' : 'right-4'))
|
|
134
|
+
|
|
131
135
|
const inputClasses = computed(() => {
|
|
132
136
|
const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
|
|
133
|
-
const pr =
|
|
137
|
+
const pr = FIELD_PADDING_RIGHT[rightInset.value]
|
|
134
138
|
const base = [
|
|
135
139
|
'peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent',
|
|
136
140
|
'transition-[border-color,border-width] duration-150',
|
|
@@ -156,31 +160,18 @@ const inputClasses = computed(() => {
|
|
|
156
160
|
].join(' ')
|
|
157
161
|
})
|
|
158
162
|
|
|
159
|
-
const labelClasses = computed(() =>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
left, 'right-4', `${unfloatedTop} -translate-y-1/2 text-body-large`,
|
|
167
|
-
]
|
|
168
|
-
if (props.variant === 'outlined') {
|
|
169
|
-
return [...base,
|
|
170
|
-
'peer-focus:-top-2.5 peer-focus:translate-y-0 peer-focus:text-label-small peer-focus:right-auto peer-focus:max-w-[calc(100%-1.5rem)] peer-focus:bg-[var(--field-bg)] peer-focus:px-1',
|
|
171
|
-
'peer-[&:not(:placeholder-shown)]:-top-2.5 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:right-auto peer-[&:not(:placeholder-shown)]:max-w-[calc(100%-1.5rem)]',
|
|
172
|
-
'peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1',
|
|
163
|
+
const labelClasses = computed(() =>
|
|
164
|
+
fieldLabelClasses({
|
|
165
|
+
variant: props.variant,
|
|
166
|
+
leading: !!props.leadingIcon,
|
|
167
|
+
right: rightInset.value,
|
|
168
|
+
floated: 'peer',
|
|
169
|
+
color: [
|
|
173
170
|
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
174
171
|
'peer-disabled:text-on-surface/38',
|
|
175
|
-
].join(' ')
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small',
|
|
179
|
-
'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small',
|
|
180
|
-
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
181
|
-
'peer-disabled:text-on-surface/38',
|
|
182
|
-
].join(' ')
|
|
183
|
-
})
|
|
172
|
+
].join(' '),
|
|
173
|
+
}),
|
|
174
|
+
)
|
|
184
175
|
|
|
185
176
|
defineExpose({
|
|
186
177
|
/** The `<input>` (or `<textarea>`) element */
|
|
@@ -225,6 +216,7 @@ defineExpose({
|
|
|
225
216
|
:required="required"
|
|
226
217
|
placeholder=" "
|
|
227
218
|
:class="inputClasses"
|
|
219
|
+
v-overflow-title
|
|
228
220
|
@input="onInput"
|
|
229
221
|
@keydown="onKeydown"
|
|
230
222
|
/>
|
|
@@ -15,6 +15,7 @@ import { useDebounce } from '../composables/useDebounce'
|
|
|
15
15
|
import type { MultiSelectOption } from './MMultiSelect.vue'
|
|
16
16
|
import { useScrollLock } from '../composables/_useScrollLock'
|
|
17
17
|
import { useEscapeStack } from '../composables/_useEscapeStack'
|
|
18
|
+
import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
18
19
|
|
|
19
20
|
// Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
|
|
20
21
|
// auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
|
|
@@ -323,11 +324,15 @@ watch(filteredOptions, () => {
|
|
|
323
324
|
|
|
324
325
|
const isFloated = computed(() => hasValue.value || open.value)
|
|
325
326
|
|
|
327
|
+
// Chips wrap before the trailing controls; the label stops there too
|
|
328
|
+
const rightInset = computed<FieldRightInset>(() => (props.clearable ? 'right-16' : 'right-10'))
|
|
329
|
+
|
|
326
330
|
const triggerClasses = computed(() => {
|
|
327
331
|
const base = [
|
|
328
|
-
'flex min-h-[56px] w-full items-center gap-1.5 flex-wrap',
|
|
332
|
+
'flex min-h-[56px] w-full min-w-0 items-center gap-1.5 flex-wrap',
|
|
329
333
|
'transition-[border-color,border-width] duration-150',
|
|
330
|
-
props.leadingIcon ? 'pl-12
|
|
334
|
+
props.leadingIcon ? 'pl-12' : 'pl-4',
|
|
335
|
+
FIELD_PADDING_RIGHT[rightInset.value],
|
|
331
336
|
]
|
|
332
337
|
|
|
333
338
|
if (props.variant === 'outlined') {
|
|
@@ -350,30 +355,19 @@ const triggerClasses = computed(() => {
|
|
|
350
355
|
return [...base, 'rounded-t-xs border-b pb-2', isFloated.value ? 'pt-7' : 'pt-4', bg, border].join(' ')
|
|
351
356
|
})
|
|
352
357
|
|
|
353
|
-
const labelClasses = computed(() =>
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
:
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
: 'top-2 translate-y-0 text-label-small'
|
|
361
|
-
|
|
362
|
-
const unFloated = props.variant === 'filled'
|
|
363
|
-
? 'top-[53%] -translate-y-1/2 text-body-large'
|
|
364
|
-
: 'top-1/2 -translate-y-1/2 text-body-large'
|
|
365
|
-
|
|
366
|
-
return [
|
|
367
|
-
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
368
|
-
left,
|
|
369
|
-
isFloated.value ? floated : unFloated,
|
|
370
|
-
props.disabled
|
|
358
|
+
const labelClasses = computed(() =>
|
|
359
|
+
fieldLabelClasses({
|
|
360
|
+
variant: props.variant,
|
|
361
|
+
leading: !!props.leadingIcon,
|
|
362
|
+
right: rightInset.value,
|
|
363
|
+
floated: isFloated.value,
|
|
364
|
+
color: props.disabled
|
|
371
365
|
? 'text-on-surface/38'
|
|
372
366
|
: open.value
|
|
373
367
|
? (props.error ? 'text-error' : 'text-primary')
|
|
374
368
|
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
375
|
-
|
|
376
|
-
|
|
369
|
+
}),
|
|
370
|
+
)
|
|
377
371
|
</script>
|
|
378
372
|
|
|
379
373
|
<template>
|
|
@@ -408,15 +402,15 @@ const labelClasses = computed(() => {
|
|
|
408
402
|
<span
|
|
409
403
|
v-for="(chip, i) in displayChips"
|
|
410
404
|
:key="i"
|
|
411
|
-
class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
405
|
+
class="inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
412
406
|
:class="disabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
413
407
|
>
|
|
414
|
-
{{ chip.label }}
|
|
408
|
+
<span v-overflow-title class="min-w-0 truncate">{{ chip.label }}</span>
|
|
415
409
|
<button
|
|
416
410
|
:aria-label="`${locale.remove} ${chip.label}`"
|
|
417
411
|
v-if="!disabled"
|
|
418
412
|
type="button"
|
|
419
|
-
class="flex h-4 w-4 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
413
|
+
class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
420
414
|
@click="removeChip(chip.value, $event)"
|
|
421
415
|
>
|
|
422
416
|
<MIcon name="close" :size="12" />
|