@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.
Files changed (85) hide show
  1. package/dist/API.md +29 -7
  2. package/dist/{MButton-D7M324r9.js → MButton-D_uxtJa-.js} +2 -2
  3. package/dist/{MButton-D7M324r9.js.map → MButton-D_uxtJa-.js.map} +1 -1
  4. package/dist/{MDialog-DuOnNF9s.js → MDialog-DT4KAPmn.js} +2 -2
  5. package/dist/{MDialog-DuOnNF9s.js.map → MDialog-DT4KAPmn.js.map} +1 -1
  6. package/dist/{MListItem-Bb84X6ex.js → MListItem-CwYrxpPZ.js} +2 -2
  7. package/dist/{MListItem-Bb84X6ex.js.map → MListItem-CwYrxpPZ.js.map} +1 -1
  8. package/dist/{MLoadingIndicator-BUGRo2Tu.js → MLoadingIndicator-DhzECYRI.js} +2 -2
  9. package/dist/{MLoadingIndicator-BUGRo2Tu.js.map → MLoadingIndicator-DhzECYRI.js.map} +1 -1
  10. package/dist/{MSeekBar-BQUvUqb9.js → MSeekBar-DQPF5FTp.js} +2 -2
  11. package/dist/{MSeekBar-BQUvUqb9.js.map → MSeekBar-DQPF5FTp.js.map} +1 -1
  12. package/dist/{MSlider-SFdjE1Hy.js → MSlider-BvoMZTy9.js} +2 -2
  13. package/dist/{MSlider-SFdjE1Hy.js.map → MSlider-BvoMZTy9.js.map} +1 -1
  14. package/dist/{MSpinner-DKGNN64_.js → MSpinner-CgcCQhS9.js} +2 -2
  15. package/dist/{MSpinner-DKGNN64_.js.map → MSpinner-CgcCQhS9.js.map} +1 -1
  16. package/dist/{MTextField-Utsef6Kk.js → MTextField-BRntFeNR.js} +113 -79
  17. package/dist/MTextField-BRntFeNR.js.map +1 -0
  18. package/dist/{MTooltip-BhTFQ9Z2.js → MTooltip-YyF1CO75.js} +4 -4
  19. package/dist/{MTooltip-BhTFQ9Z2.js.map → MTooltip-YyF1CO75.js.map} +1 -1
  20. package/dist/api.json +1 -1
  21. package/dist/code-editor.js +1 -1
  22. package/dist/components/MGantt.vue.d.ts +11 -6
  23. package/dist/components/MGanttControls.vue.d.ts +9 -3
  24. package/dist/components/MResourceTimeline.vue.d.ts +4 -4
  25. package/dist/components/MTreeTable.vue.d.ts +1 -1
  26. package/dist/components/_MTimeSplitter.vue.d.ts +10 -0
  27. package/dist/composables/_dragCursor.d.ts +2 -0
  28. package/dist/composables/_fieldLayout.d.ts +47 -0
  29. package/dist/composables/_useTimeAxis.d.ts +5 -1
  30. package/dist/composables/useGantt.d.ts +13 -0
  31. package/dist/composables/useLocale.d.ts +3 -0
  32. package/dist/draw.js +2 -2
  33. package/dist/flow.js +1 -1
  34. package/dist/gantt.js +1608 -1422
  35. package/dist/gantt.js.map +1 -1
  36. package/dist/locales/index.js +21 -0
  37. package/dist/locales/index.js.map +1 -1
  38. package/dist/m3ui-vue.css +1 -1
  39. package/dist/m3ui.js +3944 -3961
  40. package/dist/m3ui.js.map +1 -1
  41. package/dist/map.js +5 -5
  42. package/dist/media.js +4 -4
  43. package/dist/pdf.js +4 -4
  44. package/dist/rich-text-editor.js +4 -4
  45. package/dist/styles.css +1 -1
  46. package/dist/{useLocale-B8YKWg-H.js → useLocale-DLcG3qPC.js} +4 -1
  47. package/dist/useLocale-DLcG3qPC.js.map +1 -0
  48. package/package.json +1 -1
  49. package/src/__tests__/MGantt.test.ts +105 -0
  50. package/src/__tests__/MResourceTimeline.test.ts +16 -0
  51. package/src/__tests__/fieldOverflow.test.ts +118 -0
  52. package/src/components/MAutocomplete.vue +21 -24
  53. package/src/components/MColorPicker.vue +3 -3
  54. package/src/components/MDatePicker.vue +4 -4
  55. package/src/components/MDateRangePicker.vue +4 -4
  56. package/src/components/MGantt.vue +138 -43
  57. package/src/components/MGanttControls.vue +36 -8
  58. package/src/components/MMaskField.vue +16 -24
  59. package/src/components/MMultiAutocomplete.vue +19 -25
  60. package/src/components/MMultiSelect.vue +20 -27
  61. package/src/components/MNumberField.vue +16 -26
  62. package/src/components/MPinInput.vue +3 -2
  63. package/src/components/MResourceTimeline.vue +59 -24
  64. package/src/components/MSearchBar.vue +2 -2
  65. package/src/components/MSelect.vue +16 -22
  66. package/src/components/MTagInput.vue +19 -26
  67. package/src/components/MTextField.vue +18 -46
  68. package/src/components/MTimePicker.vue +4 -4
  69. package/src/components/_MTimeHeader.vue +3 -2
  70. package/src/components/_MTimeSplitter.vue +37 -0
  71. package/src/composables/_dragCursor.ts +15 -0
  72. package/src/composables/_fieldLayout.ts +117 -0
  73. package/src/composables/_ganttTime.ts +2 -1
  74. package/src/composables/_useTimeAxis.ts +10 -3
  75. package/src/composables/useGantt.ts +13 -0
  76. package/src/composables/useLocale.ts +6 -0
  77. package/src/locales/de.ts +3 -0
  78. package/src/locales/es.ts +3 -0
  79. package/src/locales/fr.ts +3 -0
  80. package/src/locales/ja.ts +3 -0
  81. package/src/locales/ko.ts +3 -0
  82. package/src/locales/pt.ts +3 -0
  83. package/src/locales/zh.ts +3 -0
  84. package/dist/MTextField-Utsef6Kk.js.map +0 -1
  85. package/dist/useLocale-B8YKWg-H.js.map +0 -1
@@ -1,7 +1,9 @@
1
1
  import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
2
2
  import { mount, flushPromises } from '@vue/test-utils'
3
3
  import { nextTick } from 'vue'
4
+ import { h } from 'vue'
4
5
  import MGantt from '../components/MGantt.vue'
6
+ import MGanttControls from '../components/MGanttControls.vue'
5
7
  import type { GanttTask } from '../composables/ganttSchedule'
6
8
 
7
9
  // A 1200 × 600 chart at 40 px per day, the list 320 wide
@@ -127,4 +129,107 @@ describe('MGantt', () => {
127
129
  pointer(window, 'pointerup', 600)
128
130
  expect(w.emitted('update:tasks')).toBeUndefined()
129
131
  })
132
+ it('readonly: dragging a bar with a mouse pans the chart, and presses claim the mouse (no native drag)', async () => {
133
+ const w = await gantt({ readonly: true })
134
+ const scroller = w.find('.overflow-auto').element as HTMLElement
135
+ scroller.scrollLeft = 300
136
+ scroller.scrollTop = 0
137
+ const down = new PointerEvent('pointerdown', { bubbles: true, cancelable: true, clientX: 500, clientY: 100, pointerId: 1, pointerType: 'mouse', button: 0, buttons: 1 })
138
+ bar(w, 'a').dispatchEvent(down)
139
+ expect(down.defaultPrevented).toBe(true)
140
+ pointer(window, 'pointermove', 520)
141
+ pointer(window, 'pointermove', 560)
142
+ expect(scroller.scrollLeft).toBe(240)
143
+ expect(document.body.style.cursor).toBe('grabbing')
144
+ pointer(window, 'pointerup', 560)
145
+ expect(document.body.style.cursor).toBe('')
146
+ expect(w.emitted('update:tasks')).toBeUndefined()
147
+ // A pan is not a click
148
+ expect(w.emitted('task-click')).toBeUndefined()
149
+
150
+ // The background's press too
151
+ const pane = w.find('.cursor-grab').element
152
+ const paneDown = new PointerEvent('pointerdown', { bubbles: true, cancelable: true, clientX: 700, clientY: 300, pointerId: 1, pointerType: 'mouse', button: 0, buttons: 1 })
153
+ pane.dispatchEvent(paneDown)
154
+ expect(paneDown.defaultPrevented).toBe(true)
155
+ pointer(window, 'pointermove', 650, 300)
156
+ expect(scroller.scrollLeft).toBe(290)
157
+ pointer(window, 'pointerup', 650, 300)
158
+ // And native drags never start on the timeline
159
+ const drag = new Event('dragstart', { bubbles: true, cancelable: true })
160
+ bar(w, 'b').dispatchEvent(drag)
161
+ expect(drag.defaultPrevented).toBe(true)
162
+ })
163
+
164
+ it('a bar with draggable: false pans; a click on it is still a click', async () => {
165
+ const w = await gantt({ tasks: tasks().map((t) => (t.id === 'a' ? { ...t, draggable: false } : t)) })
166
+ const scroller = w.find('.overflow-auto').element as HTMLElement
167
+ scroller.scrollLeft = 300
168
+ pointer(bar(w, 'a'), 'pointerdown', 500)
169
+ pointer(window, 'pointermove', 540)
170
+ pointer(window, 'pointerup', 540)
171
+ expect(scroller.scrollLeft).toBe(260)
172
+ expect(w.emitted('update:tasks')).toBeUndefined()
173
+ pointer(bar(w, 'a'), 'pointerdown', 500)
174
+ pointer(window, 'pointerup', 500)
175
+ expect(w.emitted('task-click')).toHaveLength(1)
176
+ })
177
+
178
+ it('keeps the col-resize cursor while the divider is dragged; double-click restores the width', async () => {
179
+ const w = await gantt({ gridWidth: 320 })
180
+ const sep = w.find('[role="separator"]')
181
+ pointer(sep.element, 'pointerdown', 320)
182
+ expect(document.body.style.cursor).toBe('col-resize')
183
+ expect(document.body.classList.contains('m3-drag-cursor')).toBe(true)
184
+ pointer(window, 'pointermove', 400)
185
+ expect(w.emitted('update:gridWidth')!.at(-1)![0]).toBe(400)
186
+ pointer(window, 'pointerup', 400)
187
+ expect(document.body.style.cursor).toBe('')
188
+ expect(document.body.classList.contains('m3-drag-cursor')).toBe(false)
189
+ await sep.trigger('dblclick')
190
+ expect(w.emitted('update:gridWidth')!.at(-1)![0]).toBe(320)
191
+ })
192
+
193
+ it('collapses and expands the task list (gridCollapsed, and the controls button)', async () => {
194
+ const w = await gantt({ gridCollapsed: true })
195
+ expect(w.find('[role="treegrid"]').exists()).toBe(false)
196
+ await w.setProps({ gridCollapsed: false })
197
+ expect(w.find('[role="treegrid"]').exists()).toBe(true)
198
+
199
+ const c = mount(MGantt, { props: { tasks: tasks(), today: null }, slots: { default: () => h(MGanttControls) }, attachTo: document.body })
200
+ await flushPromises()
201
+ await c.find('[aria-label="Hide task list"]').trigger('click')
202
+ expect(c.emitted('update:gridCollapsed')![0]![0]).toBe(true)
203
+ expect(c.find('[role="treegrid"]').exists()).toBe(false)
204
+ await c.find('[aria-label="Show task list"]').trigger('click')
205
+ expect(c.emitted('update:gridCollapsed')![1]![0]).toBe(false)
206
+ expect(c.find('[role="treegrid"]').exists()).toBe(true)
207
+ })
208
+
209
+ it('hides columns with hideBelow on a narrow chart', async () => {
210
+ vi.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(400)
211
+ const w = await gantt()
212
+ expect(w.findAll('[role="columnheader"]').map((c) => c.text())).toEqual(['Task'])
213
+ })
214
+
215
+ it('a tap on a bar shows its card', async () => {
216
+ const w = await gantt({ readonly: true })
217
+ pointer(bar(w, 'a'), 'pointerdown', 500, 100, { pointerType: 'touch' })
218
+ pointer(window, 'pointerup', 500, 100, { pointerType: 'touch' })
219
+ await nextTick()
220
+ expect(document.body.querySelector('[role="tooltip"]')?.textContent).toContain('Design')
221
+ // Tapping elsewhere hides it
222
+ pointer(w.find('.cursor-grab').element, 'pointerdown', 900, 400, { pointerType: 'touch' })
223
+ await nextTick()
224
+ expect(document.body.querySelector('[role="tooltip"]')).toBeNull()
225
+ w.unmount()
226
+ })
227
+
228
+ it('fits every task in the width', async () => {
229
+ const w = await gantt()
230
+ ;(w.vm as unknown as { fit(): void }).fit()
231
+ await nextTick()
232
+ // 7 days (Mar 2 → the milestone at the start of Mar 9) in 1200 − 320 − 48 px
233
+ expect((w.vm as unknown as { pxPerDay: number }).pxPerDay).toBeCloseTo(832 / 7, 0)
234
+ })
130
235
  })
@@ -99,4 +99,20 @@ describe('MResourceTimeline', () => {
99
99
  expect(w.emitted('update:collapsed')![0]![0]).toEqual(['Kitchen'])
100
100
  expect(w.findAll('[data-timeline-event]')).toHaveLength(2)
101
101
  })
102
+ it('readonly: dragging an event with a mouse pans, and the press claims the mouse (no native drag)', async () => {
103
+ const w = await timeline({ readonly: true })
104
+ const scroller = w.find('.overflow-auto').element as HTMLElement
105
+ scroller.scrollLeft = 300
106
+ const down = new PointerEvent('pointerdown', { bubbles: true, cancelable: true, clientX: 500, clientY: 100, pointerId: 1, pointerType: 'mouse', button: 0, buttons: 1 })
107
+ block(w, 'Morning').element.dispatchEvent(down)
108
+ expect(down.defaultPrevented).toBe(true)
109
+ pointer(window, 'pointermove', 520, 100)
110
+ pointer(window, 'pointermove', 560, 100)
111
+ expect(scroller.scrollLeft).toBe(240)
112
+ expect(document.body.style.cursor).toBe('grabbing')
113
+ pointer(window, 'pointerup', 560, 100)
114
+ expect(document.body.style.cursor).toBe('')
115
+ expect(w.emitted('update:events')).toBeUndefined()
116
+ expect(w.emitted('event-click')).toBeUndefined()
117
+ })
102
118
  })
@@ -0,0 +1,118 @@
1
+ import { describe, it, expect } from 'vitest'
2
+ import { mount } from '@vue/test-utils'
3
+ import { nextTick } from 'vue'
4
+ import MSelect from '../components/MSelect.vue'
5
+ import MTextField from '../components/MTextField.vue'
6
+ import MAutocomplete from '../components/MAutocomplete.vue'
7
+ import MMultiSelect from '../components/MMultiSelect.vue'
8
+ import MTagInput from '../components/MTagInput.vue'
9
+ import MDatePicker from '../components/MDatePicker.vue'
10
+ import MDateRangePicker from '../components/MDateRangePicker.vue'
11
+
12
+ const LONG = 'No cumple, pendientes y en proceso (P, EP)'
13
+ const options = [{ value: 'x', label: LONG }]
14
+
15
+ function cls(el: Element | null | undefined) {
16
+ return (el?.getAttribute('class') ?? '').split(/\s+/)
17
+ }
18
+
19
+ /** Simulates a value cut by overflow (happy-dom has no layout) */
20
+ function fakeOverflow(el: HTMLElement, cut: boolean) {
21
+ Object.defineProperty(el, 'scrollWidth', { configurable: true, value: cut ? 300 : 100 })
22
+ Object.defineProperty(el, 'clientWidth', { configurable: true, value: 100 })
23
+ }
24
+
25
+ describe('long content in narrow fields', () => {
26
+ it('MSelect keeps a long value on one line, cut with an ellipsis', () => {
27
+ const w = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options } })
28
+ const value = w.find('[role="combobox"] span')
29
+ expect(value.text()).toBe(LONG)
30
+ expect(cls(value.element)).toEqual(expect.arrayContaining(['truncate', 'min-w-0']))
31
+ })
32
+
33
+ it('MSelect reserves room for the clear button as well as the arrow', () => {
34
+ const plain = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options } })
35
+ expect(cls(plain.find('[role="combobox"]').element)).toContain('pr-10')
36
+ const clearable = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options, clearable: true } })
37
+ const trigger = clearable.find('[role="combobox"]')
38
+ expect(cls(trigger.element)).toContain('pr-16')
39
+ expect(cls(trigger.element)).not.toContain('pr-10')
40
+ // The floated label stops there too (filled: it sits in the same row as the clear button)
41
+ expect(cls(clearable.find('label').element)).toContain('right-16')
42
+ })
43
+
44
+ it('MSelect puts the whole value in a title only when it is cut', async () => {
45
+ const w = mount(MSelect, { props: { modelValue: 'x', label: 'Estado', options }, attachTo: document.body })
46
+ const value = w.find('[role="combobox"] span').element as HTMLElement
47
+ fakeOverflow(value, false)
48
+ value.dispatchEvent(new Event('pointerenter'))
49
+ expect(value.hasAttribute('title')).toBe(false)
50
+ fakeOverflow(value, true)
51
+ value.dispatchEvent(new Event('pointerenter'))
52
+ expect(value.getAttribute('title')).toBe(LONG)
53
+ w.unmount()
54
+ })
55
+
56
+ it('MTextField: the label stops before a trailing button, and the outlined floated label before the corner', () => {
57
+ const w = mount(MTextField, { props: { modelValue: '', label: 'Etiqueta larga', clearable: true } })
58
+ expect(cls(w.find('label').element)).toContain('right-12')
59
+ expect(cls(w.find('input').element)).toContain('pr-12')
60
+
61
+ const icon = mount(MTextField, { props: { modelValue: '', label: 'Etiqueta', variant: 'outlined', leadingIcon: 'search' } })
62
+ const label = cls(icon.find('label').element)
63
+ expect(label).toContain('left-11')
64
+ // left-11 (44px) + 12px from the far corner
65
+ expect(label).toContain('peer-focus:max-w-[calc(100%-3.5rem)]')
66
+ expect(label).not.toContain('peer-focus:max-w-[calc(100%-1.5rem)]')
67
+ })
68
+
69
+ it('MTextField puts a cut value in a title', () => {
70
+ const w = mount(MTextField, { props: { modelValue: LONG, label: 'Nombre' }, attachTo: document.body })
71
+ const input = w.find('input').element as HTMLInputElement
72
+ fakeOverflow(input, true)
73
+ input.dispatchEvent(new Event('pointerenter'))
74
+ expect(input.getAttribute('title')).toBe(LONG)
75
+ w.unmount()
76
+ })
77
+
78
+ it('MAutocomplete reserves room for the clear button', () => {
79
+ const w = mount(MAutocomplete, { props: { modelValue: 'x', label: 'Estado', options, clearable: true } })
80
+ expect(cls(w.find('input').element)).toContain('pr-16')
81
+ })
82
+
83
+ it('chip fields cut a long chip instead of overflowing the field', () => {
84
+ const multi = mount(MMultiSelect, { props: { modelValue: ['x'], label: 'Estados', options } })
85
+ const chip = multi.find('[role="button"] > span')
86
+ expect(cls(chip.element)).toEqual(expect.arrayContaining(['max-w-full', 'min-w-0']))
87
+ expect(cls(chip.find('span').element)).toContain('truncate')
88
+
89
+ const tags = mount(MTagInput, { props: { modelValue: [LONG], label: 'Etiquetas' } })
90
+ const tag = tags.find('span.rounded-full')
91
+ expect(cls(tag.element)).toContain('max-w-full')
92
+ expect(cls(tag.find('span').element)).toContain('truncate')
93
+ })
94
+
95
+ it('date pickers cut a long value and a long label', () => {
96
+ for (const w of [
97
+ mount(MDatePicker, { props: { modelValue: '2026-11-22', label: 'Fecha de inicio del período' } }),
98
+ mount(MDateRangePicker, { props: { modelValue: { start: '2026-11-01', end: '2026-11-22' }, label: 'Período' } }),
99
+ ]) {
100
+ expect(cls(w.find('button span.flex-1').element)).toEqual(expect.arrayContaining(['truncate', 'min-w-0']))
101
+ expect(cls(w.find('label').element)).toEqual(expect.arrayContaining(['truncate', 'max-w-[calc(100%-1.5rem)]']))
102
+ }
103
+ })
104
+
105
+ it('keeps the title in step when the value changes while it is shown', async () => {
106
+ const w = mount(MSelect, {
107
+ props: { modelValue: 'x', label: 'Estado', options: [...options, { value: 'y', label: `${LONG} (2)` }] },
108
+ attachTo: document.body,
109
+ })
110
+ const value = w.find('[role="combobox"] span').element as HTMLElement
111
+ fakeOverflow(value, true)
112
+ value.dispatchEvent(new Event('pointerenter'))
113
+ await w.setProps({ modelValue: 'y' })
114
+ await nextTick()
115
+ expect(value.getAttribute('title')).toBe(`${LONG} (2)`)
116
+ w.unmount()
117
+ })
118
+ })
@@ -14,6 +14,7 @@ import { useDebounce } from '../composables/useDebounce'
14
14
  import type { SelectOption } from './MSelect.vue'
15
15
  import { useScrollLock } from '../composables/_useScrollLock'
16
16
  import { useEscapeStack } from '../composables/_useEscapeStack'
17
+ import { FIELD_PADDING_RIGHT, fieldLabelClasses, vOverflowTitle, type FieldRightInset } from '../composables/_fieldLayout'
17
18
 
18
19
  // Root is a fragment (field div + a sibling Teleport for the dropdown panel), so Vue can't
19
20
  // auto-apply a consumer's class/attrs to either one — forward them onto the field div below.
@@ -279,11 +280,15 @@ const displayValue = computed(() => {
279
280
  return selectedLabel.value
280
281
  })
281
282
 
283
+ // The text and the label stop before the clear button and the arrow
284
+ const rightInset = computed<FieldRightInset>(() => (props.clearable ? 'right-16' : 'right-10'))
285
+
282
286
  const triggerClasses = computed(() => {
283
287
  const pl = props.leadingIcon ? 'pl-12' : 'pl-4'
284
288
  const base = [
285
- 'flex w-full items-center pr-10 text-body-large transition-[border-color,border-width] duration-150',
289
+ 'flex w-full min-w-0 items-center text-body-large transition-[border-color,border-width] duration-150',
286
290
  pl,
291
+ FIELD_PADDING_RIGHT[rightInset.value],
287
292
  ]
288
293
 
289
294
  if (props.variant === 'outlined') {
@@ -308,29 +313,20 @@ const triggerClasses = computed(() => {
308
313
 
309
314
  const isFloated = computed(() => hasValue.value || open.value)
310
315
 
311
- const labelClasses = computed(() => {
312
- const left = props.leadingIcon
313
- ? (props.variant === 'outlined' ? 'left-11' : 'left-12')
314
- : (props.variant === 'outlined' ? 'left-3' : 'left-4')
315
-
316
- const floated = props.variant === 'outlined'
317
- ? '-top-2.5 translate-y-0 text-label-small bg-[var(--field-bg)] px-1 right-auto max-w-[calc(100%-1.5rem)]'
318
- : 'top-2 translate-y-0 text-label-small'
319
-
320
- const unFloated = props.variant === 'filled'
321
- ? 'top-[53%] -translate-y-1/2 text-body-large'
322
- : 'top-1/2 -translate-y-1/2 text-body-large'
323
-
324
- return [
325
- 'pointer-events-none absolute right-10 truncate transition-all duration-200',
326
- left,
327
- isFloated.value ? floated : unFloated,
328
- open.value
329
- ? (props.error ? 'text-error' : 'text-primary')
330
- : (props.error ? 'text-error' : 'text-on-surface-variant'),
331
- 'peer-disabled:text-on-surface/38',
332
- ].join(' ')
333
- })
316
+ const labelClasses = computed(() =>
317
+ fieldLabelClasses({
318
+ variant: props.variant,
319
+ leading: !!props.leadingIcon,
320
+ right: rightInset.value,
321
+ floated: isFloated.value,
322
+ color: [
323
+ open.value
324
+ ? (props.error ? 'text-error' : 'text-primary')
325
+ : (props.error ? 'text-error' : 'text-on-surface-variant'),
326
+ 'peer-disabled:text-on-surface/38',
327
+ ].join(' '),
328
+ }),
329
+ )
334
330
  </script>
335
331
 
336
332
  <template>
@@ -370,6 +366,7 @@ const labelClasses = computed(() => {
370
366
  :aria-required="required || undefined"
371
367
  :aria-invalid="error || undefined"
372
368
  :aria-disabled="disabled"
369
+ v-overflow-title
373
370
  :class="[
374
371
  triggerClasses,
375
372
  'peer outline-none text-on-surface cursor-text',
@@ -12,6 +12,7 @@ import MColorPanel from './_MColorPanel.vue'
12
12
  import { useFieldBg } from '../composables/useFieldBg'
13
13
  import { useLocale } from '../composables/useLocale'
14
14
  import { defaultColorPresets, normalizeHex, pushRecentColor } from '../composables/_colorUtils'
15
+ import { OUTLINED_FLOATED_LABEL, vOverflowTitle } from '../composables/_fieldLayout'
15
16
 
16
17
  const props = withDefaults(defineProps<{
17
18
  /** Selected color in hex format (v-model). `#rrggbb`, or `#rrggbbaa` when `alpha` is on and the color isn't opaque. */
@@ -156,7 +157,7 @@ onUnmounted(() => {
156
157
  :class="disabled ? 'opacity-38' : ''"
157
158
  :style="{ background: `linear-gradient(${modelValue}, ${modelValue}), repeating-conic-gradient(#d4d4d4 0 25%, #fff 0 50%) 0 0 / 8px 8px` }"
158
159
  />
159
- <span class="flex-1 font-mono" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ modelValue }}</span>
160
+ <span v-overflow-title class="min-w-0 truncate flex-1 font-mono" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ modelValue }}</span>
160
161
  <MIcon
161
162
  name="palette"
162
163
  :size="24"
@@ -166,8 +167,7 @@ onUnmounted(() => {
166
167
  </button>
167
168
  <label
168
169
  v-if="label"
169
- class="pointer-events-none absolute -top-2.5 left-3 bg-(--field-bg) px-1 text-label-small transition-colors"
170
- :class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
170
+ :class="[OUTLINED_FLOATED_LABEL, 'transition-colors', disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant']"
171
171
  >
172
172
  {{ label }}
173
173
  </label>
@@ -13,6 +13,7 @@ import { useFieldBg } from '../composables/useFieldBg'
13
13
  import { useLocale } from '../composables/useLocale'
14
14
  import { POPUP_MARGIN, dropdownX, fitPopup } from '../composables/_popupPosition'
15
15
  import { useCalendarMonth } from '../composables/_useCalendarMonth'
16
+ import { OUTLINED_FLOATED_LABEL, vOverflowTitle } from '../composables/_fieldLayout'
16
17
 
17
18
  const props = defineProps<{
18
19
  /** Selected date (YYYY-MM-DD, v-model) */
@@ -179,8 +180,8 @@ onUnmounted(() => {
179
180
  @click="!disabled && (open = !open)"
180
181
  >
181
182
  <MIcon name="calendar_today" :size="24" class="shrink-0" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'" />
182
- <span v-if="displayValue" class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
183
- <span v-else class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ placeholder || label || localeStrings.selectDate }}</span>
183
+ <span v-overflow-title v-if="displayValue" class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
184
+ <span v-overflow-title v-else class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ placeholder || label || localeStrings.selectDate }}</span>
184
185
  <MIcon
185
186
  v-if="modelValue"
186
187
  name="close"
@@ -191,8 +192,7 @@ onUnmounted(() => {
191
192
  </button>
192
193
  <label
193
194
  v-if="label"
194
- class="pointer-events-none absolute -top-2.5 left-3 bg-(--field-bg) px-1 text-label-small transition-colors"
195
- :class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
195
+ :class="[OUTLINED_FLOATED_LABEL, 'transition-colors', disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant']"
196
196
  >
197
197
  {{ label }}
198
198
  </label>
@@ -13,6 +13,7 @@ import { useFieldBg } from '../composables/useFieldBg'
13
13
  import { useLocale } from '../composables/useLocale'
14
14
  import { POPUP_MARGIN, dropdownX, fitPopup } from '../composables/_popupPosition'
15
15
  import { isoDate as fmt, useCalendarMonth } from '../composables/_useCalendarMonth'
16
+ import { OUTLINED_FLOATED_LABEL, vOverflowTitle } from '../composables/_fieldLayout'
16
17
 
17
18
  export interface DateRange {
18
19
  start: string | null
@@ -214,8 +215,8 @@ onUnmounted(() => {
214
215
  @click="!disabled && (open = !open)"
215
216
  >
216
217
  <MIcon name="date_range" :size="24" class="shrink-0" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'" />
217
- <span v-if="displayValue" class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
218
- <span v-else class="flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ label || placeholder || localeStrings.selectRange }}</span>
218
+ <span v-overflow-title v-if="displayValue" class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface'">{{ displayValue }}</span>
219
+ <span v-overflow-title v-else class="min-w-0 truncate flex-1" :class="disabled ? 'text-on-surface/38' : 'text-on-surface-variant'">{{ label || placeholder || localeStrings.selectRange }}</span>
219
220
  <MIcon
220
221
  v-if="modelValue.start || modelValue.end"
221
222
  name="close"
@@ -226,8 +227,7 @@ onUnmounted(() => {
226
227
  </button>
227
228
  <label
228
229
  v-if="label"
229
- class="pointer-events-none absolute -top-2.5 left-3 bg-(--field-bg) px-1 text-label-small transition-colors"
230
- :class="disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant'"
230
+ :class="[OUTLINED_FLOATED_LABEL, 'transition-colors', disabled ? 'text-on-surface/38' : open ? (error ? 'text-error' : 'text-primary') : error ? 'text-error' : 'text-on-surface-variant']"
231
231
  >
232
232
  {{ label }}
233
233
  </label>