@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
|
@@ -12,6 +12,7 @@ import MCheckbox from './MCheckbox.vue'
|
|
|
12
12
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
13
13
|
import { useLocale } from '../composables/useLocale'
|
|
14
14
|
import { useScrollLock } from '../composables/_useScrollLock'
|
|
15
|
+
import { FIELD_PADDING_RIGHT, FIELD_VALUE, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
15
16
|
|
|
16
17
|
const locale = useLocale()
|
|
17
18
|
|
|
@@ -223,12 +224,16 @@ onUnmounted(() => {
|
|
|
223
224
|
window.removeEventListener('scroll', onScroll, true)
|
|
224
225
|
})
|
|
225
226
|
|
|
227
|
+
// Chips wrap before the trailing controls; the label stops there too
|
|
228
|
+
const rightInset = computed<FieldRightInset>(() => (props.clearable ? 'right-16' : 'right-10'))
|
|
229
|
+
|
|
226
230
|
const triggerClasses = computed(() => {
|
|
227
231
|
const base = [
|
|
228
|
-
'flex min-h-[56px] w-full items-center gap-1.5 flex-wrap outline-none',
|
|
232
|
+
'flex min-h-[56px] w-full min-w-0 items-center gap-1.5 flex-wrap outline-none',
|
|
229
233
|
'transition-[border-color,border-width] duration-150',
|
|
230
234
|
props.disabled ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
231
|
-
props.leadingIcon ? 'pl-12
|
|
235
|
+
props.leadingIcon ? 'pl-12' : 'pl-4',
|
|
236
|
+
FIELD_PADDING_RIGHT[rightInset.value],
|
|
232
237
|
]
|
|
233
238
|
|
|
234
239
|
if (props.variant === 'outlined') {
|
|
@@ -257,31 +262,19 @@ const triggerClasses = computed(() => {
|
|
|
257
262
|
].join(' ')
|
|
258
263
|
})
|
|
259
264
|
|
|
260
|
-
const labelClasses = computed(() =>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
:
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
: 'top-2 translate-y-0 text-label-small'
|
|
268
|
-
|
|
269
|
-
const unFloated = props.variant === 'filled'
|
|
270
|
-
? 'top-[53%] -translate-y-1/2 text-body-large'
|
|
271
|
-
: 'top-1/2 -translate-y-1/2 text-body-large'
|
|
272
|
-
const active = highlighted.value || hasValue.value
|
|
273
|
-
|
|
274
|
-
return [
|
|
275
|
-
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
276
|
-
left,
|
|
277
|
-
active ? floated : unFloated,
|
|
278
|
-
props.disabled
|
|
265
|
+
const labelClasses = computed(() =>
|
|
266
|
+
fieldLabelClasses({
|
|
267
|
+
variant: props.variant,
|
|
268
|
+
leading: !!props.leadingIcon,
|
|
269
|
+
right: rightInset.value,
|
|
270
|
+
floated: highlighted.value || hasValue.value,
|
|
271
|
+
color: props.disabled
|
|
279
272
|
? 'text-on-surface/38'
|
|
280
273
|
: highlighted.value
|
|
281
274
|
? (props.error ? 'text-error' : 'text-primary')
|
|
282
275
|
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
283
|
-
|
|
284
|
-
|
|
276
|
+
}),
|
|
277
|
+
)
|
|
285
278
|
</script>
|
|
286
279
|
|
|
287
280
|
<template>
|
|
@@ -324,15 +317,15 @@ const labelClasses = computed(() => {
|
|
|
324
317
|
<span
|
|
325
318
|
v-for="(chip, i) in displayChips"
|
|
326
319
|
:key="i"
|
|
327
|
-
class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
320
|
+
class="inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
328
321
|
:class="disabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
329
322
|
>
|
|
330
|
-
{{ chip.label }}
|
|
323
|
+
<span v-overflow-title class="min-w-0 truncate">{{ chip.label }}</span>
|
|
331
324
|
<button
|
|
332
325
|
:aria-label="`${locale.remove} ${chip.label}`"
|
|
333
326
|
v-if="!disabled"
|
|
334
327
|
type="button"
|
|
335
|
-
class="flex h-4 w-4 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
328
|
+
class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
336
329
|
@click="removeChip(chip.value, $event)"
|
|
337
330
|
>
|
|
338
331
|
<MIcon name="close" :size="12" />
|
|
@@ -354,7 +347,7 @@ const labelClasses = computed(() => {
|
|
|
354
347
|
<MIcon name="unfold_less" :size="14" />
|
|
355
348
|
</span>
|
|
356
349
|
</template>
|
|
357
|
-
<span v-else-if="!open" class="text-body-large text-on-surface-variant opacity-0">
|
|
350
|
+
<span v-else-if="!open" :class="[FIELD_VALUE, 'text-body-large text-on-surface-variant opacity-0']">
|
|
358
351
|
{{ placeholder }}
|
|
359
352
|
</span>
|
|
360
353
|
</div>
|
|
@@ -11,6 +11,7 @@ import MIcon from './MIcon.vue'
|
|
|
11
11
|
import MIconButton from './MIconButton.vue'
|
|
12
12
|
import { useFieldBg } from '../composables/useFieldBg'
|
|
13
13
|
import { useDebounce } from '../composables/useDebounce'
|
|
14
|
+
import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
14
15
|
|
|
15
16
|
const props = withDefaults(
|
|
16
17
|
defineProps<{
|
|
@@ -107,9 +108,12 @@ function onKeydown(e: KeyboardEvent) {
|
|
|
107
108
|
if (e.key === 'ArrowDown') { e.preventDefault(); decrement() }
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
// The label and the text both stop before the trailing controls
|
|
112
|
+
const rightInset = computed<FieldRightInset>(() => (props.stepper ? 'right-24' : 'right-4'))
|
|
113
|
+
|
|
110
114
|
const inputClasses = computed(() => {
|
|
111
115
|
const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
|
|
112
|
-
const pr =
|
|
116
|
+
const pr = FIELD_PADDING_RIGHT[rightInset.value]
|
|
113
117
|
const base = [
|
|
114
118
|
'peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent',
|
|
115
119
|
'transition-[border-color,border-width] duration-150',
|
|
@@ -135,33 +139,18 @@ const inputClasses = computed(() => {
|
|
|
135
139
|
].join(' ')
|
|
136
140
|
})
|
|
137
141
|
|
|
138
|
-
const labelClasses = computed(() =>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
:
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
'pointer-events-none absolute truncate transition-all duration-200',
|
|
146
|
-
left, 'right-4', `${unfloatedTop} -translate-y-1/2 text-body-large`,
|
|
147
|
-
]
|
|
148
|
-
|
|
149
|
-
if (props.variant === 'outlined') {
|
|
150
|
-
return [...base,
|
|
151
|
-
'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',
|
|
152
|
-
'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)]',
|
|
153
|
-
'peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1',
|
|
142
|
+
const labelClasses = computed(() =>
|
|
143
|
+
fieldLabelClasses({
|
|
144
|
+
variant: props.variant,
|
|
145
|
+
leading: !!props.leadingIcon,
|
|
146
|
+
right: rightInset.value,
|
|
147
|
+
floated: 'peer',
|
|
148
|
+
color: [
|
|
154
149
|
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
155
150
|
'peer-disabled:text-on-surface/38',
|
|
156
|
-
].join(' ')
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
'peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small',
|
|
160
|
-
'peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small',
|
|
161
|
-
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
162
|
-
'peer-disabled:text-on-surface/38',
|
|
163
|
-
].join(' ')
|
|
164
|
-
})
|
|
151
|
+
].join(' '),
|
|
152
|
+
}),
|
|
153
|
+
)
|
|
165
154
|
|
|
166
155
|
defineExpose({
|
|
167
156
|
/** The `<input>` (or `<textarea>`) element */
|
|
@@ -206,6 +195,7 @@ defineExpose({
|
|
|
206
195
|
:step="step"
|
|
207
196
|
placeholder=" "
|
|
208
197
|
:class="inputClasses"
|
|
198
|
+
v-overflow-title
|
|
209
199
|
@input="onInput"
|
|
210
200
|
@keydown="onKeydown"
|
|
211
201
|
/>
|
|
@@ -167,7 +167,8 @@ watch(
|
|
|
167
167
|
|
|
168
168
|
const boxClasses = computed(() => {
|
|
169
169
|
const base = [
|
|
170
|
-
|
|
170
|
+
// Shrinks below 48px when the row is narrower than all the boxes (flex: 0 1 3rem)
|
|
171
|
+
'h-14 w-12 min-w-0 shrink text-center text-title-large outline-none',
|
|
171
172
|
'transition-[border-color,border-width] duration-150',
|
|
172
173
|
'disabled:cursor-not-allowed disabled:text-on-surface/38',
|
|
173
174
|
props.error ? 'caret-error' : 'caret-primary',
|
|
@@ -193,7 +194,7 @@ const boxClasses = computed(() => {
|
|
|
193
194
|
|
|
194
195
|
<template>
|
|
195
196
|
<div class="flex flex-col gap-1">
|
|
196
|
-
<div role="group" :aria-label="label" class="flex items-center gap-2">
|
|
197
|
+
<div role="group" :aria-label="label" class="flex min-w-0 items-center gap-2">
|
|
197
198
|
<template v-for="(digit, i) in digits" :key="i">
|
|
198
199
|
<input
|
|
199
200
|
:ref="(el) => setInputEl(el, i)"
|
|
@@ -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"
|
|
@@ -183,7 +183,7 @@ useEscapeStack(() => expanded.value, () => close())
|
|
|
183
183
|
:placeholder="placeholder ?? locale.search"
|
|
184
184
|
:disabled="disabled"
|
|
185
185
|
:aria-expanded="expanded"
|
|
186
|
-
class="w-full bg-transparent text-body-large text-on-surface outline-none placeholder:text-on-surface-variant"
|
|
186
|
+
class="w-full min-w-0 bg-transparent text-body-large text-on-surface outline-none placeholder:text-on-surface-variant text-ellipsis"
|
|
187
187
|
:class="textAlign === 'center' ? 'text-center' : ''"
|
|
188
188
|
@focus="open"
|
|
189
189
|
@input="onInput"
|
|
@@ -233,7 +233,7 @@ useEscapeStack(() => expanded.value, () => close())
|
|
|
233
233
|
role="searchbox"
|
|
234
234
|
:value="modelValue"
|
|
235
235
|
:placeholder="placeholder ?? locale.search"
|
|
236
|
-
class="w-full bg-transparent text-body-large text-on-surface outline-none placeholder:text-on-surface-variant"
|
|
236
|
+
class="w-full min-w-0 bg-transparent text-body-large text-on-surface outline-none placeholder:text-on-surface-variant text-ellipsis"
|
|
237
237
|
:class="textAlign === 'center' ? 'text-center' : ''"
|
|
238
238
|
@input="onInput"
|
|
239
239
|
@keydown="onKeydown"
|
|
@@ -11,6 +11,7 @@ import { useFieldBg } from '../composables/useFieldBg'
|
|
|
11
11
|
import { useLocale } from '../composables/useLocale'
|
|
12
12
|
import { useScrollLock } from '../composables/_useScrollLock'
|
|
13
13
|
import { useEscapeStack } from '../composables/_useEscapeStack'
|
|
14
|
+
import { FIELD_PADDING_RIGHT, FIELD_VALUE, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
14
15
|
|
|
15
16
|
export interface SelectOption {
|
|
16
17
|
label: string
|
|
@@ -179,12 +180,16 @@ onUnmounted(() => {
|
|
|
179
180
|
window.removeEventListener('scroll', onScroll, true)
|
|
180
181
|
})
|
|
181
182
|
|
|
183
|
+
// The value and the label stop before the clear button and the arrow
|
|
184
|
+
const rightInset = computed<FieldRightInset>(() => (props.clearable ? 'right-16' : 'right-10'))
|
|
185
|
+
|
|
182
186
|
const triggerClasses = computed(() => {
|
|
183
187
|
const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
|
|
184
188
|
const base = [
|
|
185
|
-
'flex w-full items-center
|
|
189
|
+
'flex w-full min-w-0 items-center text-body-large outline-none transition-[border-color,border-width] duration-150',
|
|
186
190
|
props.disabled ? 'cursor-not-allowed' : 'cursor-pointer',
|
|
187
191
|
pl,
|
|
192
|
+
FIELD_PADDING_RIGHT[rightInset.value],
|
|
188
193
|
]
|
|
189
194
|
|
|
190
195
|
if (props.variant === 'outlined') {
|
|
@@ -209,30 +214,19 @@ const triggerClasses = computed(() => {
|
|
|
209
214
|
|
|
210
215
|
const isFloated = computed(() => hasValue.value || highlighted.value)
|
|
211
216
|
|
|
212
|
-
const labelClasses = computed(() =>
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
: 'top-2 translate-y-0 text-label-small'
|
|
220
|
-
|
|
221
|
-
const unFloated = props.variant === 'filled'
|
|
222
|
-
? 'top-[53%] -translate-y-1/2 text-body-large'
|
|
223
|
-
: 'top-1/2 -translate-y-1/2 text-body-large'
|
|
224
|
-
|
|
225
|
-
return [
|
|
226
|
-
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
227
|
-
left,
|
|
228
|
-
isFloated.value ? floated : unFloated,
|
|
229
|
-
props.disabled
|
|
217
|
+
const labelClasses = computed(() =>
|
|
218
|
+
fieldLabelClasses({
|
|
219
|
+
variant: props.variant,
|
|
220
|
+
leading: !!props.leadingIcon,
|
|
221
|
+
right: rightInset.value,
|
|
222
|
+
floated: isFloated.value,
|
|
223
|
+
color: props.disabled
|
|
230
224
|
? 'text-on-surface/38'
|
|
231
225
|
: highlighted.value
|
|
232
226
|
? (props.error ? 'text-error' : 'text-primary')
|
|
233
227
|
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
234
|
-
|
|
235
|
-
|
|
228
|
+
}),
|
|
229
|
+
)
|
|
236
230
|
</script>
|
|
237
231
|
|
|
238
232
|
<template>
|
|
@@ -274,7 +268,7 @@ const labelClasses = computed(() => {
|
|
|
274
268
|
@focus="focused = true"
|
|
275
269
|
@blur="focused = false"
|
|
276
270
|
>
|
|
277
|
-
<span v-if="hasValue" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ selectedLabel }}</span>
|
|
271
|
+
<span v-if="hasValue" v-overflow-title :class="[FIELD_VALUE, disabled ? 'text-on-surface/38' : 'text-on-surface']">{{ selectedLabel }}</span>
|
|
278
272
|
</div>
|
|
279
273
|
|
|
280
274
|
<!-- Floating label -->
|
|
@@ -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
|
const locale = useLocale()
|
|
15
16
|
const props = withDefaults(
|
|
@@ -139,12 +140,16 @@ function focusInput() {
|
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
|
|
143
|
+
// Chips wrap before the trailing controls; the label stops there too
|
|
144
|
+
const rightInset = computed<FieldRightInset>(() => ('right-10'))
|
|
145
|
+
|
|
142
146
|
const triggerClasses = computed(() => {
|
|
143
147
|
const base = [
|
|
144
|
-
'flex min-h-[56px] w-full items-center gap-1.5 flex-wrap',
|
|
148
|
+
'flex min-h-[56px] w-full min-w-0 items-center gap-1.5 flex-wrap',
|
|
145
149
|
'transition-[border-color,border-width] duration-150',
|
|
146
150
|
props.disabled ? 'cursor-not-allowed' : 'cursor-text',
|
|
147
|
-
props.leadingIcon ? 'pl-12
|
|
151
|
+
props.leadingIcon ? 'pl-12' : 'pl-4',
|
|
152
|
+
FIELD_PADDING_RIGHT[rightInset.value],
|
|
148
153
|
]
|
|
149
154
|
|
|
150
155
|
if (props.variant === 'outlined') {
|
|
@@ -167,31 +172,19 @@ const triggerClasses = computed(() => {
|
|
|
167
172
|
return [...base, 'rounded-t-xs border-b pb-2', hasValue.value || focused.value ? 'pt-7' : 'pt-4', bg, border].join(' ')
|
|
168
173
|
})
|
|
169
174
|
|
|
170
|
-
const labelClasses = computed(() =>
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
: 'top-2 translate-y-0 text-label-small'
|
|
178
|
-
|
|
179
|
-
const unFloated = props.variant === 'filled'
|
|
180
|
-
? 'top-[53%] -translate-y-1/2 text-body-large'
|
|
181
|
-
: 'top-1/2 -translate-y-1/2 text-body-large'
|
|
182
|
-
const active = focused.value || hasValue.value
|
|
183
|
-
|
|
184
|
-
return [
|
|
185
|
-
'pointer-events-none absolute right-10 truncate transition-all duration-200',
|
|
186
|
-
left,
|
|
187
|
-
active ? floated : unFloated,
|
|
188
|
-
props.disabled
|
|
175
|
+
const labelClasses = computed(() =>
|
|
176
|
+
fieldLabelClasses({
|
|
177
|
+
variant: props.variant,
|
|
178
|
+
leading: !!props.leadingIcon,
|
|
179
|
+
right: rightInset.value,
|
|
180
|
+
floated: focused.value || hasValue.value,
|
|
181
|
+
color: props.disabled
|
|
189
182
|
? 'text-on-surface/38'
|
|
190
183
|
: focused.value
|
|
191
184
|
? (props.error ? 'text-error' : 'text-primary')
|
|
192
185
|
: (props.error ? 'text-error' : 'text-on-surface-variant'),
|
|
193
|
-
|
|
194
|
-
|
|
186
|
+
}),
|
|
187
|
+
)
|
|
195
188
|
|
|
196
189
|
defineExpose({
|
|
197
190
|
/** The `<input>` (or `<textarea>`) element */
|
|
@@ -235,15 +228,15 @@ defineExpose({
|
|
|
235
228
|
<span
|
|
236
229
|
v-for="(tag, i) in modelValue"
|
|
237
230
|
:key="i"
|
|
238
|
-
class="inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
231
|
+
class="inline-flex max-w-full min-w-0 items-center gap-1 rounded-full px-2 py-0.5 text-label-small"
|
|
239
232
|
:class="disabled ? 'bg-on-surface/12 text-on-surface/38' : 'bg-secondary-container text-on-secondary-container'"
|
|
240
233
|
>
|
|
241
|
-
{{ tag }}
|
|
234
|
+
<span v-overflow-title class="min-w-0 truncate">{{ tag }}</span>
|
|
242
235
|
<button
|
|
243
236
|
:aria-label="`${locale.remove} ${tag}`"
|
|
244
237
|
v-if="!disabled"
|
|
245
238
|
type="button"
|
|
246
|
-
class="flex h-4 w-4 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
239
|
+
class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full hover:bg-on-secondary-container/20"
|
|
247
240
|
@click="removeTag(i, $event)"
|
|
248
241
|
>
|
|
249
242
|
<MIcon name="close" :size="12" />
|
|
@@ -13,6 +13,7 @@ import { useAutoGrow } from "../composables/useAutoGrow";
|
|
|
13
13
|
import { useFieldBg } from "../composables/useFieldBg";
|
|
14
14
|
import { useDebounce } from "../composables/useDebounce";
|
|
15
15
|
import { useLocale } from '../composables/useLocale'
|
|
16
|
+
import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
|
|
16
17
|
|
|
17
18
|
const locale = useLocale()
|
|
18
19
|
const props = withDefaults(
|
|
@@ -86,10 +87,12 @@ useAutoGrow(() => (props.multiline && props.autoGrow ? textareaEl.value : null),
|
|
|
86
87
|
|
|
87
88
|
const showClear = computed(() => props.clearable && String(props.modelValue).length > 0 && !props.disabled)
|
|
88
89
|
|
|
90
|
+
// The label and the text both stop before a trailing button (the #trailing slot or the clear button)
|
|
91
|
+
const rightInset = computed<FieldRightInset>(() => (slots.trailing || props.clearable ? "right-12" : "right-4"));
|
|
92
|
+
|
|
89
93
|
const inputClasses = computed(() => {
|
|
90
|
-
const hasTrailing = !!slots.trailing || props.clearable;
|
|
91
94
|
const pl = props.leadingIcon ? "pl-12" : "pl-4";
|
|
92
|
-
const pr =
|
|
95
|
+
const pr = FIELD_PADDING_RIGHT[rightInset.value];
|
|
93
96
|
const size = props.multiline ? (props.autoGrow ? "resize-none min-h-[56px]" : "resize-y min-h-[56px]") : "h-14";
|
|
94
97
|
const base = [
|
|
95
98
|
"peer block w-full text-body-large text-on-surface outline-none placeholder:text-transparent",
|
|
@@ -126,50 +129,18 @@ const inputClasses = computed(() => {
|
|
|
126
129
|
].join(" ");
|
|
127
130
|
});
|
|
128
131
|
|
|
129
|
-
const labelClasses = computed(() =>
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
:
|
|
135
|
-
|
|
136
|
-
:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
left,
|
|
142
|
-
"right-4",
|
|
143
|
-
`${unfloatedTop} -translate-y-1/2 text-body-large`,
|
|
144
|
-
];
|
|
145
|
-
|
|
146
|
-
if (props.variant === "outlined") {
|
|
147
|
-
// When floated: drop right-4 (right-auto) and cap max-width so the label
|
|
148
|
-
// shrinks to its own text width. The bg then only covers the glyphs + px-1,
|
|
149
|
-
// cutting the border just where the text sits instead of a long strip.
|
|
150
|
-
return [
|
|
151
|
-
...base,
|
|
152
|
-
"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",
|
|
153
|
-
"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)]",
|
|
154
|
-
"peer-[&:not(:placeholder-shown)]:text-label-small peer-[&:not(:placeholder-shown)]:bg-[var(--field-bg)] peer-[&:not(:placeholder-shown)]:px-1",
|
|
155
|
-
props.error
|
|
156
|
-
? "text-error peer-focus:text-error"
|
|
157
|
-
: "text-on-surface-variant peer-focus:text-primary",
|
|
158
|
-
"peer-disabled:text-on-surface/38",
|
|
159
|
-
].join(" ");
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Filled: label floats to top-2 (slightly higher than before)
|
|
163
|
-
return [
|
|
164
|
-
...base,
|
|
165
|
-
"peer-focus:top-2 peer-focus:translate-y-0 peer-focus:text-label-small",
|
|
166
|
-
"peer-[&:not(:placeholder-shown)]:top-2 peer-[&:not(:placeholder-shown)]:translate-y-0 peer-[&:not(:placeholder-shown)]:text-label-small",
|
|
167
|
-
props.error
|
|
168
|
-
? "text-error peer-focus:text-error"
|
|
169
|
-
: "text-on-surface-variant peer-focus:text-primary",
|
|
170
|
-
"peer-disabled:text-on-surface/38",
|
|
171
|
-
].join(" ");
|
|
172
|
-
});
|
|
132
|
+
const labelClasses = computed(() =>
|
|
133
|
+
fieldLabelClasses({
|
|
134
|
+
variant: props.variant,
|
|
135
|
+
leading: !!props.leadingIcon,
|
|
136
|
+
right: rightInset.value,
|
|
137
|
+
floated: 'peer',
|
|
138
|
+
color: [
|
|
139
|
+
props.error ? 'text-error peer-focus:text-error' : 'text-on-surface-variant peer-focus:text-primary',
|
|
140
|
+
'peer-disabled:text-on-surface/38',
|
|
141
|
+
].join(' '),
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
173
144
|
|
|
174
145
|
function onInput(event: Event) {
|
|
175
146
|
const target = event.target as HTMLInputElement | HTMLTextAreaElement;
|
|
@@ -238,6 +209,7 @@ defineExpose({
|
|
|
238
209
|
:autocomplete="autocomplete"
|
|
239
210
|
placeholder=" "
|
|
240
211
|
:class="inputClasses"
|
|
212
|
+
v-overflow-title
|
|
241
213
|
@input="onInput"
|
|
242
214
|
/>
|
|
243
215
|
|