@m3ui-vue/m3ui-vue 0.8.8 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +13 -3
  2. package/dist/{MMenuItem-5xojJYAL.js → MTextField-B0wGv1Mx.js} +374 -364
  3. package/dist/MTextField-B0wGv1Mx.js.map +1 -0
  4. package/dist/barcode.js +9 -11
  5. package/dist/barcode.js.map +1 -1
  6. package/dist/code-editor.js +2 -2
  7. package/dist/code-editor.js.map +1 -1
  8. package/dist/components/MCarousel.vue.d.ts +55 -36
  9. package/dist/components/MDialog.vue.d.ts +4 -2
  10. package/dist/components/MEmojiSelector.vue.d.ts +21 -5
  11. package/dist/components/MFabMenu.vue.d.ts +1 -1
  12. package/dist/components/MFlex.vue.d.ts +1 -1
  13. package/dist/components/MLightbox.vue.d.ts +15 -5
  14. package/dist/components/MScheduler.vue.d.ts +38 -1
  15. package/dist/components/MShape.vue.d.ts +1 -1
  16. package/dist/components/MSimpleCarousel.vue.d.ts +2 -2
  17. package/dist/components/MSlider.vue.d.ts +1 -1
  18. package/dist/components/MStack.vue.d.ts +1 -1
  19. package/dist/components/MToolbar.vue.d.ts +1 -1
  20. package/dist/components/MWindow.vue.d.ts +1 -1
  21. package/dist/composables/_carouselStrategy.d.ts +101 -0
  22. package/dist/composables/useLocale.d.ts +19 -0
  23. package/dist/data/emoji-names/emoji-names-de.d.ts +2 -0
  24. package/dist/data/emoji-names/emoji-names-en.d.ts +2 -0
  25. package/dist/data/emoji-names/emoji-names-es.d.ts +2 -0
  26. package/dist/data/emoji-names/emoji-names-fr.d.ts +2 -0
  27. package/dist/data/emoji-names/emoji-names-ja.d.ts +2 -0
  28. package/dist/data/emoji-names/emoji-names-ko.d.ts +2 -0
  29. package/dist/data/emoji-names/emoji-names-pt.d.ts +2 -0
  30. package/dist/data/emoji-names/emoji-names-zh.d.ts +2 -0
  31. package/dist/data/emojis.d.ts +7 -1
  32. package/dist/emoji-names-de-BphO5XpV.js +1877 -0
  33. package/dist/emoji-names-de-BphO5XpV.js.map +1 -0
  34. package/dist/emoji-names-en-9ZvMRvzi.js +1877 -0
  35. package/dist/emoji-names-en-9ZvMRvzi.js.map +1 -0
  36. package/dist/emoji-names-es-DvfWU3Pj.js +1877 -0
  37. package/dist/emoji-names-es-DvfWU3Pj.js.map +1 -0
  38. package/dist/emoji-names-fr-B-jhUlsP.js +1877 -0
  39. package/dist/emoji-names-fr-B-jhUlsP.js.map +1 -0
  40. package/dist/emoji-names-ja-l8cMFJo1.js +1877 -0
  41. package/dist/emoji-names-ja-l8cMFJo1.js.map +1 -0
  42. package/dist/emoji-names-ko-YP-o9G0c.js +1877 -0
  43. package/dist/emoji-names-ko-YP-o9G0c.js.map +1 -0
  44. package/dist/emoji-names-pt-DGj_Js4M.js +1877 -0
  45. package/dist/emoji-names-pt-DGj_Js4M.js.map +1 -0
  46. package/dist/emoji-names-zh-Dzecwtw_.js +1877 -0
  47. package/dist/emoji-names-zh-Dzecwtw_.js.map +1 -0
  48. package/dist/index.d.ts +2 -2
  49. package/dist/locales/index.js +140 -7
  50. package/dist/locales/index.js.map +1 -1
  51. package/dist/m3ui-vue.css +1 -1
  52. package/dist/m3ui.js +3885 -2400
  53. package/dist/m3ui.js.map +1 -1
  54. package/dist/plugin.d.ts +6 -0
  55. package/dist/rich-text-editor.js +9 -9
  56. package/dist/styles.css +1 -1
  57. package/dist/terminal.js +34 -27
  58. package/dist/terminal.js.map +1 -1
  59. package/dist/{useLocale-D3ZWZ8jY.js → useLocale-CmI675Ab.js} +21 -2
  60. package/dist/useLocale-CmI675Ab.js.map +1 -0
  61. package/package.json +1 -1
  62. package/src/__tests__/MCarousel.test.ts +183 -21
  63. package/src/__tests__/MDialog.test.ts +18 -0
  64. package/src/__tests__/MEmojiSelector.test.ts +138 -0
  65. package/src/__tests__/MLightbox.test.ts +313 -5
  66. package/src/__tests__/MScheduler.test.ts +122 -0
  67. package/src/__tests__/MTerminal.test.ts +63 -0
  68. package/src/__tests__/attrsFallthrough.test.ts +65 -0
  69. package/src/__tests__/plugin.test.ts +28 -1
  70. package/src/components/MBarcode.vue +4 -2
  71. package/src/components/MBottomSheet.vue +1 -1
  72. package/src/components/MCarousel.vue +526 -200
  73. package/src/components/MCodeEditor.vue +3 -2
  74. package/src/components/MCommandPalette.vue +1 -1
  75. package/src/components/MContextMenu.vue +3 -1
  76. package/src/components/MDatePickerModal.vue +1 -1
  77. package/src/components/MDateRangePickerModal.vue +1 -1
  78. package/src/components/MDialog.vue +19 -6
  79. package/src/components/MEmojiSelector.vue +479 -78
  80. package/src/components/MFab.vue +3 -1
  81. package/src/components/MLightbox.vue +750 -268
  82. package/src/components/MLoadingOverlay.vue +6 -1
  83. package/src/components/MMenu.vue +3 -1
  84. package/src/components/MNavigationDrawer.vue +5 -1
  85. package/src/components/MNavigationRail.vue +3 -0
  86. package/src/components/MOverlay.vue +1 -0
  87. package/src/components/MScheduler.vue +282 -115
  88. package/src/components/MSideSheet.vue +1 -1
  89. package/src/components/MSplitButton.vue +3 -1
  90. package/src/components/MSpotlightSearch.vue +1 -1
  91. package/src/components/MTerminal.vue +22 -10
  92. package/src/components/MTimePickerModal.vue +1 -1
  93. package/src/components/MTooltip.vue +3 -0
  94. package/src/components/MTour.vue +2 -2
  95. package/src/composables/_carouselStrategy.ts +712 -0
  96. package/src/composables/useLocale.ts +38 -0
  97. package/src/data/emoji-names/emoji-names-de.ts +1875 -0
  98. package/src/data/emoji-names/emoji-names-en.ts +1875 -0
  99. package/src/data/emoji-names/emoji-names-es.ts +1875 -0
  100. package/src/data/emoji-names/emoji-names-fr.ts +1875 -0
  101. package/src/data/emoji-names/emoji-names-ja.ts +1875 -0
  102. package/src/data/emoji-names/emoji-names-ko.ts +1875 -0
  103. package/src/data/emoji-names/emoji-names-pt.ts +1875 -0
  104. package/src/data/emoji-names/emoji-names-zh.ts +1875 -0
  105. package/src/data/emojis.ts +29 -198
  106. package/src/index.ts +2 -2
  107. package/src/locales/de.ts +19 -0
  108. package/src/locales/es.ts +19 -0
  109. package/src/locales/fr.ts +19 -0
  110. package/src/locales/ja.ts +19 -0
  111. package/src/locales/ko.ts +19 -0
  112. package/src/locales/pt.ts +19 -0
  113. package/src/locales/zh.ts +19 -0
  114. package/src/plugin.ts +12 -1
  115. package/dist/MMenuItem-5xojJYAL.js.map +0 -1
  116. package/dist/useLocale-D3ZWZ8jY.js.map +0 -1
@@ -1,6 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import MSpinner from './MSpinner.vue'
3
3
 
4
+ defineOptions({ inheritAttrs: false })
5
+
4
6
  withDefaults(defineProps<{
5
7
  visible: boolean
6
8
  text?: string
@@ -13,6 +15,7 @@ withDefaults(defineProps<{
13
15
  <template>
14
16
  <Teleport v-if="fullscreen" to="body">
15
17
  <Transition
18
+ appear
16
19
  enter-active-class="transition-opacity duration-200"
17
20
  enter-from-class="opacity-0"
18
21
  leave-active-class="transition-opacity duration-150"
@@ -20,6 +23,7 @@ withDefaults(defineProps<{
20
23
  >
21
24
  <div
22
25
  v-if="visible"
26
+ v-bind="$attrs"
23
27
  class="fixed inset-0 z-300 flex flex-col items-center justify-center gap-4"
24
28
  :class="opaque ? 'bg-surface' : 'bg-surface/80 backdrop-blur-sm'"
25
29
  >
@@ -30,9 +34,10 @@ withDefaults(defineProps<{
30
34
  </Transition>
31
35
  </Teleport>
32
36
 
33
- <div v-else class="relative">
37
+ <div v-else v-bind="$attrs" class="relative">
34
38
  <slot name="content" />
35
39
  <Transition
40
+ appear
36
41
  enter-active-class="transition-opacity duration-200"
37
42
  enter-from-class="opacity-0"
38
43
  leave-active-class="transition-opacity duration-150"
@@ -3,6 +3,8 @@ import { computed, Fragment, inject, nextTick, onMounted, onUnmounted, provide,
3
3
  import MIcon from './MIcon.vue'
4
4
  import MMenuDivider from './MMenuDivider.vue'
5
5
 
6
+ defineOptions({ inheritAttrs: false })
7
+
6
8
  const props = withDefaults(
7
9
  defineProps<{
8
10
  /** Which edge of the trigger the dropdown aligns to. */
@@ -385,7 +387,7 @@ const origin = computed(() =>
385
387
  </script>
386
388
 
387
389
  <template>
388
- <div ref="triggerEl" class="inline-block" @click="toggle">
390
+ <div ref="triggerEl" v-bind="$attrs" class="inline-block" @click="toggle">
389
391
  <slot name="trigger" :open="open" />
390
392
  </div>
391
393
 
@@ -24,6 +24,8 @@ export interface DrawerSection {
24
24
  collapsible?: boolean;
25
25
  }
26
26
 
27
+ defineOptions({ inheritAttrs: false })
28
+
27
29
  const props = withDefaults(
28
30
  defineProps<{
29
31
  modelValue: boolean;
@@ -131,7 +133,7 @@ watch(
131
133
  <template>
132
134
  <!-- ── Modal variant ──────────────────────────────────────── -->
133
135
  <Teleport v-if="modal" to="body">
134
- <Transition name="nd" :duration="{ enter: 300, leave: 280 }">
136
+ <Transition name="nd" :duration="{ enter: 300, leave: 280 }" appear>
135
137
  <div
136
138
  v-if="modelValue"
137
139
  class="fixed inset-0 z-100 flex"
@@ -144,6 +146,7 @@ watch(
144
146
  <div class="nd-scrim absolute inset-0 bg-scrim/32" @click="close" />
145
147
 
146
148
  <nav
149
+ v-bind="$attrs"
147
150
  :class="[
148
151
  'nd-panel relative flex flex-col bg-surface-container-low shadow-elevation-1',
149
152
  `nd-panel-${side}`,
@@ -270,6 +273,7 @@ watch(
270
273
  <!-- ── Standard (inline) variant ──────────────────────────── -->
271
274
  <template v-else>
272
275
  <nav
276
+ v-bind="$attrs"
273
277
  class="nd-inline flex h-full shrink-0 flex-col bg-surface"
274
278
  :class="[
275
279
  inlineSide === 'right' ? 'border-l border-outline-variant rounded-l-lg' : 'border-r border-outline-variant rounded-r-lg',
@@ -15,6 +15,8 @@ export interface NavRailItem {
15
15
  to?: ItemLink
16
16
  }
17
17
 
18
+ defineOptions({ inheritAttrs: false })
19
+
18
20
  const props = withDefaults(defineProps<{
19
21
  modelValue: string | number
20
22
  items: NavRailItem[]
@@ -173,6 +175,7 @@ onUnmounted(() => {
173
175
  that actually reacts to `expanded` when `modal` is set.
174
176
  -->
175
177
  <nav
178
+ v-bind="$attrs"
176
179
  class="flex h-full flex-col border-r border-outline-variant bg-surface transition-[width] duration-200"
177
180
  :class="railExpanded ? 'w-[220px]' : 'w-20'"
178
181
  >
@@ -26,6 +26,7 @@ function handleScrimClick() {
26
26
  <template>
27
27
  <Teleport to="body">
28
28
  <Transition
29
+ appear
29
30
  enter-active-class="transition-opacity duration-200"
30
31
  leave-active-class="transition-opacity duration-150"
31
32
  enter-from-class="opacity-0"
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ref, computed } from 'vue'
2
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
3
3
  import MIconButton from './MIconButton.vue'
4
4
  import { useLocale } from '../composables/useLocale'
5
5
 
@@ -8,129 +8,250 @@ const locale = useLocale()
8
8
  export interface SchedulerEvent {
9
9
  id: string | number
10
10
  title: string
11
+ /**
12
+ * Start: a datetime (`2026-10-17T09:30`, or ISO with a zone). For an all-day event, a date
13
+ * (`2026-10-17`).
14
+ */
11
15
  start: string
16
+ /** End: a datetime (exclusive). For an all-day event, the last day (inclusive). */
12
17
  end: string
18
+ /** Shown in the all-day row instead of the time grid. Events that span days go there too. */
19
+ allDay?: boolean
13
20
  color?: 'primary' | 'secondary' | 'tertiary' | 'error' | 'success'
14
21
  }
15
22
 
16
23
  const props = withDefaults(
17
24
  defineProps<{
18
25
  events?: SchedulerEvent[]
26
+ /** 'week' or 'day'; use v-model:view to follow the header's toggle. */
19
27
  view?: 'week' | 'day'
28
+ /** The date shown (`YYYY-MM-DD`), today by default; use v-model:date to follow navigation. */
29
+ date?: string
20
30
  startHour?: number
21
31
  endHour?: number
32
+ /** First day of the week: 0 = Sunday, 1 = Monday. */
33
+ weekStartsOn?: 0 | 1
34
+ /** Height of one hour row, in px. */
35
+ hourHeight?: number
36
+ /** A line across today's column at the current time. */
37
+ nowIndicator?: boolean
22
38
  locale?: string
23
39
  prevLabel?: string
24
40
  nextLabel?: string
25
41
  todayLabel?: string
26
42
  dayViewLabel?: string
27
43
  weekViewLabel?: string
44
+ allDayLabel?: string
28
45
  }>(),
29
46
  {
30
47
  events: () => [],
31
48
  view: 'week',
32
49
  startHour: 7,
33
50
  endHour: 22,
51
+ weekStartsOn: 1,
52
+ hourHeight: 56,
53
+ nowIndicator: true,
34
54
  },
35
55
  )
36
56
 
37
57
  // Falls back to the app's own configured locale (via createM3UI/useLocale) rather than a
38
- // fixed default, matching the pattern MRelativeTime already uses — previously this defaulted
39
- // to a hardcoded 'es-ES' regardless of what locale the app actually provided.
58
+ // fixed default, matching the pattern MRelativeTime already uses.
40
59
  const resolvedLocale = computed(() => props.locale ?? locale.lang)
41
60
 
42
61
  const emit = defineEmits<{
43
62
  eventClick: [SchedulerEvent]
44
63
  slotClick: [{ date: string; hour: number }]
64
+ 'update:date': [string]
65
+ 'update:view': ['week' | 'day']
45
66
  }>()
46
67
 
47
- const currentDate = ref(new Date())
48
- const currentView = ref(props.view)
68
+ defineSlots<{
69
+ /** Content of an event block. */
70
+ event?: (scope: { event: SchedulerEvent; allDay: boolean }) => unknown
71
+ }>()
49
72
 
50
- const hours = computed(() =>
51
- Array.from({ length: props.endHour - props.startHour }, (_, i) => props.startHour + i),
52
- )
73
+ // ── Dates ─────────────────────────────────────────────────────────────────────────────────────
74
+
75
+ /** A date-only string is local midnight (`new Date('2026-10-17')` alone would be UTC). */
76
+ function parse(s: string) {
77
+ return /^\d{4}-\d{2}-\d{2}$/.test(s) ? new Date(`${s}T00:00`) : new Date(s)
78
+ }
79
+
80
+ function fmt(d: Date) {
81
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
82
+ }
83
+
84
+ function addDays(d: Date, n: number) {
85
+ const out = new Date(d)
86
+ out.setDate(out.getDate() + n)
87
+ return out
88
+ }
53
89
 
54
90
  function startOfWeek(d: Date) {
55
91
  const dt = new Date(d)
56
- const day = dt.getDay()
57
- const diff = day === 0 ? -6 : 1 - day
58
- dt.setDate(dt.getDate() + diff)
59
92
  dt.setHours(0, 0, 0, 0)
60
- return dt
93
+ const diff = (dt.getDay() - props.weekStartsOn + 7) % 7
94
+ return addDays(dt, -diff)
61
95
  }
62
96
 
63
- const weekDays = computed(() => {
64
- const start = startOfWeek(currentDate.value)
65
- return Array.from({ length: 7 }, (_, i) => {
66
- const d = new Date(start)
67
- d.setDate(d.getDate() + i)
68
- return d
69
- })
70
- })
71
-
72
- const visibleDays = computed(() =>
73
- currentView.value === 'day' ? [currentDate.value] : weekDays.value,
74
- )
97
+ const currentDate = ref(props.date ? parse(props.date) : new Date())
98
+ const currentView = ref(props.view)
99
+ watch(() => props.date, (d) => d && fmt(parse(d)) !== fmt(currentDate.value) && (currentDate.value = parse(d)))
100
+ watch(() => props.view, (v) => (currentView.value = v))
75
101
 
76
- const todayIso = (() => {
77
- const d = new Date()
78
- return fmt(d)
79
- })()
102
+ function setDate(d: Date) {
103
+ currentDate.value = d
104
+ emit('update:date', fmt(d))
105
+ }
80
106
 
81
- function fmt(d: Date) {
82
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
107
+ function setView(v: 'week' | 'day') {
108
+ currentView.value = v
109
+ emit('update:view', v)
83
110
  }
84
111
 
112
+ const visibleDays = computed(() => {
113
+ if (currentView.value === 'day') {
114
+ const d = new Date(currentDate.value)
115
+ d.setHours(0, 0, 0, 0)
116
+ return [d]
117
+ }
118
+ const start = startOfWeek(currentDate.value)
119
+ return Array.from({ length: 7 }, (_, i) => addDays(start, i))
120
+ })
121
+ const visibleKeys = computed(() => visibleDays.value.map(fmt))
122
+
123
+ const now = ref(new Date())
124
+ let nowTimer: ReturnType<typeof setInterval> | null = null
125
+ onMounted(() => (nowTimer = setInterval(() => (now.value = new Date()), 60_000)))
126
+ onBeforeUnmount(() => nowTimer && clearInterval(nowTimer))
127
+ const todayKey = computed(() => fmt(now.value))
128
+
85
129
  const dayFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'short' }))
86
130
  const dateFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { day: 'numeric' }))
131
+ const timeFormat = computed(() => new Intl.DateTimeFormat(resolvedLocale.value, { hour: '2-digit', minute: '2-digit' }))
87
132
 
88
133
  const headerLabel = computed(() => {
89
134
  if (currentView.value === 'day') {
90
135
  return new Intl.DateTimeFormat(resolvedLocale.value, { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' })
91
136
  .format(currentDate.value)
92
137
  }
93
- const start = weekDays.value[0]!
94
- const end = weekDays.value[6]!
138
+ const start = visibleDays.value[0]!
139
+ const end = visibleDays.value[6]!
95
140
  const f = new Intl.DateTimeFormat(resolvedLocale.value, { day: 'numeric', month: 'short' })
96
141
  return `${f.format(start)} – ${f.format(end)}, ${end.getFullYear()}`
97
142
  })
98
143
 
99
144
  function navigate(delta: number) {
100
- const d = new Date(currentDate.value)
101
- if (currentView.value === 'week') d.setDate(d.getDate() + delta * 7)
102
- else d.setDate(d.getDate() + delta)
103
- currentDate.value = d
145
+ setDate(addDays(currentDate.value, delta * (currentView.value === 'week' ? 7 : 1)))
104
146
  }
105
147
 
106
- function goToday() { currentDate.value = new Date() }
107
-
108
- function eventsForDayHour(day: Date, hour: number) {
109
- const dayStr = fmt(day)
110
- return props.events.filter((ev) => {
111
- const start = new Date(ev.start)
112
- const end = new Date(ev.end)
113
- const evDay = fmt(start)
114
- if (evDay !== dayStr) return false
115
- const evStartHour = start.getHours()
116
- const evEndHour = end.getHours() + (end.getMinutes() > 0 ? 1 : 0)
117
- return hour >= evStartHour && hour < evEndHour
118
- })
148
+ function openDay(d: Date) {
149
+ if (currentView.value === 'day') return
150
+ setDate(d)
151
+ setView('day')
119
152
  }
120
153
 
121
- function isEventStart(ev: SchedulerEvent, hour: number) {
122
- return new Date(ev.start).getHours() === hour
154
+ // ── Layout ────────────────────────────────────────────────────────────────────────────────────
155
+
156
+ const hours = computed(() => Array.from({ length: props.endHour - props.startHour }, (_, i) => props.startHour + i))
157
+ const gridStyle = computed(() => ({
158
+ gridTemplateColumns: `4rem repeat(${visibleDays.value.length}, ${currentView.value === 'week' ? 'minmax(5.5rem, 1fr)' : 'minmax(0, 1fr)'})`,
159
+ }))
160
+
161
+ /** Everything that doesn't fit in one day's time grid goes to the all-day row. */
162
+ function isBandEvent(ev: SchedulerEvent) {
163
+ if (ev.allDay) return true
164
+ const start = parse(ev.start)
165
+ const lastInstant = new Date(parse(ev.end).getTime() - 1)
166
+ return fmt(start) !== fmt(lastInstant)
123
167
  }
124
168
 
125
- function eventDuration(ev: SchedulerEvent) {
126
- const start = new Date(ev.start)
127
- const end = new Date(ev.end)
128
- return Math.max(1, Math.ceil((end.getTime() - start.getTime()) / 3600000))
169
+ interface Bar { event: SchedulerEvent; from: number; to: number; lane: number; clippedStart: boolean; clippedEnd: boolean }
170
+
171
+ const bars = computed<Bar[]>(() => {
172
+ const keys = visibleKeys.value
173
+ const first = keys[0]!
174
+ const last = keys[keys.length - 1]!
175
+ const placed: Bar[] = []
176
+ const laneEnds: number[] = []
177
+ const candidates = props.events
178
+ .filter(isBandEvent)
179
+ .map((event) => {
180
+ const startKey = fmt(parse(event.start))
181
+ const endKey = event.allDay ? fmt(parse(event.end)) : fmt(new Date(parse(event.end).getTime() - 1))
182
+ return { event, startKey, endKey }
183
+ })
184
+ .filter(({ startKey, endKey }) => endKey >= first && startKey <= last)
185
+ .sort((a, b) => a.startKey.localeCompare(b.startKey) || b.endKey.localeCompare(a.endKey))
186
+ for (const { event, startKey, endKey } of candidates) {
187
+ const from = startKey < first ? 0 : keys.indexOf(startKey)
188
+ const to = endKey > last ? keys.length - 1 : keys.indexOf(endKey)
189
+ let lane = laneEnds.findIndex((end) => end < from)
190
+ if (lane === -1) lane = laneEnds.length
191
+ laneEnds[lane] = to
192
+ placed.push({ event, from, to, lane, clippedStart: startKey < first, clippedEnd: endKey > last })
193
+ }
194
+ return placed
195
+ })
196
+ const laneCount = computed(() => bars.value.reduce((n, b) => Math.max(n, b.lane + 1), 0))
197
+
198
+ interface Block { event: SchedulerEvent; top: number; height: number; column: number; columns: number; minutes: number }
199
+
200
+ /** Timed events of one day, placed in side-by-side columns where they overlap. */
201
+ function blocksFor(day: Date): Block[] {
202
+ const key = fmt(day)
203
+ const lo = props.startHour * 60
204
+ const hi = props.endHour * 60
205
+ const items = props.events
206
+ .filter((ev) => !isBandEvent(ev) && fmt(parse(ev.start)) === key)
207
+ .map((event) => {
208
+ const s = parse(event.start)
209
+ const e = parse(event.end)
210
+ const startMin = s.getHours() * 60 + s.getMinutes()
211
+ const endMin = fmt(e) === key ? e.getHours() * 60 + e.getMinutes() : 24 * 60
212
+ return { event, startMin, endMin: Math.max(endMin, startMin + 15) }
213
+ })
214
+ .filter((it) => it.endMin > lo && it.startMin < hi)
215
+ .sort((a, b) => a.startMin - b.startMin || b.endMin - a.endMin)
216
+
217
+ const blocks: Block[] = []
218
+ let cluster: { item: (typeof items)[number]; column: number }[] = []
219
+ let clusterEnd = -1
220
+ const flush = () => {
221
+ const columns = cluster.reduce((n, c) => Math.max(n, c.column + 1), 0)
222
+ for (const { item, column } of cluster) {
223
+ const top = ((Math.max(item.startMin, lo) - lo) / 60) * props.hourHeight
224
+ const bottom = ((Math.min(item.endMin, hi) - lo) / 60) * props.hourHeight
225
+ blocks.push({ event: item.event, top, height: Math.max(bottom - top, 20), column, columns, minutes: item.endMin - item.startMin })
226
+ }
227
+ cluster = []
228
+ }
229
+ for (const item of items) {
230
+ if (item.startMin >= clusterEnd && cluster.length) flush()
231
+ const taken = new Set(cluster.filter((c) => c.item.endMin > item.startMin).map((c) => c.column))
232
+ let column = 0
233
+ while (taken.has(column)) column++
234
+ cluster.push({ item, column })
235
+ clusterEnd = Math.max(clusterEnd, item.endMin)
236
+ }
237
+ if (cluster.length) flush()
238
+ return blocks
129
239
  }
130
240
 
241
+ const nowTop = computed(() => {
242
+ const min = now.value.getHours() * 60 + now.value.getMinutes()
243
+ if (min < props.startHour * 60 || min >= props.endHour * 60) return null
244
+ return ((min - props.startHour * 60) / 60) * props.hourHeight
245
+ })
246
+
131
247
  function timeLabel(ev: SchedulerEvent) {
132
- const f = new Intl.DateTimeFormat(resolvedLocale.value, { hour: '2-digit', minute: '2-digit' })
133
- return `${f.format(new Date(ev.start))} – ${f.format(new Date(ev.end))}`
248
+ return `${timeFormat.value.format(parse(ev.start))} – ${timeFormat.value.format(parse(ev.end))}`
249
+ }
250
+
251
+ function onColumnClick(e: MouseEvent, day: Date) {
252
+ const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
253
+ const hour = Math.min(props.startHour + Math.floor((e.clientY - rect.top) / props.hourHeight), props.endHour - 1)
254
+ emit('slotClick', { date: fmt(day), hour: Math.max(hour, props.startHour) })
134
255
  }
135
256
 
136
257
  const eventColors: Record<string, string> = {
@@ -145,14 +266,14 @@ const eventColors: Record<string, string> = {
145
266
  <template>
146
267
  <div class="flex flex-col overflow-hidden rounded-lg border border-outline-variant">
147
268
  <!-- Header -->
148
- <div class="flex items-center justify-between border-b border-outline-variant bg-surface-container px-4 py-3">
269
+ <div class="flex flex-wrap items-center justify-between gap-2 border-b border-outline-variant bg-surface-container px-4 py-3">
149
270
  <div class="flex items-center gap-1">
150
271
  <MIconButton icon="chevron_left" :label="prevLabel ?? locale.previous" :size="36" @click="navigate(-1)" />
151
272
  <MIconButton icon="chevron_right" :label="nextLabel ?? locale.next" :size="36" @click="navigate(1)" />
152
273
  <button
153
274
  type="button"
154
275
  class="ml-2 cursor-pointer rounded-full border border-outline px-3 py-1 text-label-medium text-on-surface transition-colors hover:bg-on-surface/8"
155
- @click="goToday"
276
+ @click="setDate(new Date())"
156
277
  >
157
278
  {{ todayLabel ?? locale.today }}
158
279
  </button>
@@ -167,71 +288,117 @@ const eventColors: Record<string, string> = {
167
288
  type="button"
168
289
  class="cursor-pointer rounded-full px-3 py-1 text-label-medium transition-all duration-150"
169
290
  :class="currentView === v ? 'bg-secondary-container text-on-secondary-container shadow-elevation-1' : 'text-on-surface-variant hover:bg-on-surface/8'"
170
- @click="currentView = v"
291
+ @click="setView(v)"
171
292
  >
172
293
  {{ v === 'day' ? (dayViewLabel ?? locale.dayView) : (weekViewLabel ?? locale.weekView) }}
173
294
  </button>
174
295
  </div>
175
296
  </div>
176
297
 
177
- <!-- Grid -->
178
- <div class="overflow-auto">
179
- <table class="w-full border-collapse">
298
+ <div class="min-h-0 flex-1 overflow-auto">
299
+ <div class="min-w-fit">
180
300
  <!-- Day headers -->
181
- <thead>
182
- <tr>
183
- <th class="sticky top-0 z-10 w-16 border-b border-r border-outline-variant bg-surface-container p-2" />
184
- <th
185
- v-for="day in visibleDays"
186
- :key="fmt(day)"
187
- class="sticky top-0 z-10 border-b border-r border-outline-variant bg-surface-container px-2 py-2 text-center last:border-r-0"
188
- :class="fmt(day) === todayIso ? 'bg-primary-container/30' : ''"
301
+ <div class="sticky top-0 z-20 grid border-b border-outline-variant bg-surface-container" :style="gridStyle">
302
+ <div class="border-r border-outline-variant" />
303
+ <button
304
+ v-for="day in visibleDays"
305
+ :key="fmt(day)"
306
+ type="button"
307
+ class="border-r border-outline-variant px-2 py-2 text-center last:border-r-0"
308
+ :class="[fmt(day) === todayKey ? 'bg-primary-container/30' : '', currentView === 'week' ? 'cursor-pointer hover:bg-on-surface/8' : 'cursor-default']"
309
+ :tabindex="currentView === 'week' ? 0 : -1"
310
+ @click="openDay(day)"
311
+ >
312
+ <span class="block text-label-small uppercase text-on-surface-variant">{{ dayFormat.format(day) }}</span>
313
+ <span
314
+ class="mx-auto mt-0.5 flex h-8 w-8 items-center justify-center rounded-full text-title-medium"
315
+ :class="fmt(day) === todayKey ? 'bg-primary font-medium text-on-primary' : 'text-on-surface'"
316
+ >
317
+ {{ dateFormat.format(day) }}
318
+ </span>
319
+ </button>
320
+ </div>
321
+
322
+ <!-- All-day row: all-day events and events spanning several days -->
323
+ <div v-if="laneCount" class="grid border-b border-outline-variant" :style="gridStyle" data-scheduler-all-day>
324
+ <div class="flex items-start justify-end border-r border-outline-variant px-2 py-1.5 text-right text-label-small text-on-surface-variant">
325
+ {{ allDayLabel ?? locale.allDay }}
326
+ </div>
327
+ <div
328
+ class="grid gap-y-1 py-1"
329
+ :style="{ gridColumn: `2 / span ${visibleDays.length}`, gridTemplateColumns: `repeat(${visibleDays.length}, minmax(0, 1fr))`, gridTemplateRows: `repeat(${laneCount}, 1.5rem)` }"
330
+ >
331
+ <button
332
+ v-for="bar in bars"
333
+ :key="bar.event.id"
334
+ type="button"
335
+ class="mx-0.5 flex min-w-0 cursor-pointer items-center overflow-hidden border-l-[3px] px-2 text-left text-label-small font-medium transition-opacity hover:opacity-90"
336
+ :class="[eventColors[bar.event.color ?? 'primary'], bar.clippedStart ? 'rounded-r border-l-0' : 'rounded', bar.clippedEnd ? 'rounded-r-none' : '']"
337
+ :style="{ gridColumn: `${bar.from + 1} / ${bar.to + 2}`, gridRow: bar.lane + 1 }"
338
+ :aria-label="bar.event.title"
339
+ data-scheduler-bar
340
+ @click="emit('eventClick', bar.event)"
189
341
  >
190
- <div class="text-label-small uppercase text-on-surface-variant">{{ dayFormat.format(day) }}</div>
191
- <div
192
- class="mx-auto mt-0.5 flex h-8 w-8 items-center justify-center rounded-full text-title-medium"
193
- :class="fmt(day) === todayIso ? 'bg-primary text-on-primary font-medium' : 'text-on-surface'"
194
- >
195
- {{ dateFormat.format(day) }}
196
- </div>
197
- </th>
198
- </tr>
199
- </thead>
200
-
201
- <tbody>
202
- <tr v-for="hour in hours" :key="hour">
203
- <!-- Hour label -->
204
- <td class="w-16 border-r border-b border-outline-variant/50 p-0 pr-2 text-right align-top">
205
- <span class="relative -top-2.5 text-label-small text-on-surface-variant">
206
- {{ String(hour).padStart(2, '0') }}:00
207
- </span>
208
- </td>
209
-
210
- <!-- Day cells -->
211
- <td
212
- v-for="day in visibleDays"
213
- :key="fmt(day)"
214
- class="relative h-14 border-r border-b border-outline-variant/50 p-0 last:border-r-0"
215
- :class="fmt(day) === todayIso ? 'bg-primary-container/5' : ''"
216
- @click="emit('slotClick', { date: fmt(day), hour })"
342
+ <slot name="event" :event="bar.event" :all-day="true">
343
+ <span v-if="bar.clippedStart" aria-hidden="true" class="mr-1">‹</span>
344
+ <span class="truncate">{{ bar.event.title }}</span>
345
+ <span v-if="bar.clippedEnd" aria-hidden="true" class="ml-auto pl-1">›</span>
346
+ </slot>
347
+ </button>
348
+ </div>
349
+ </div>
350
+
351
+ <!-- Time grid -->
352
+ <div class="grid" :style="gridStyle">
353
+ <div class="border-r border-outline-variant">
354
+ <div v-for="hour in hours" :key="hour" class="relative pr-2 text-right" :style="{ height: `${hourHeight}px` }">
355
+ <span v-if="hour !== startHour" class="relative -top-2 text-label-small text-on-surface-variant">{{ String(hour).padStart(2, '0') }}:00</span>
356
+ </div>
357
+ </div>
358
+
359
+ <div
360
+ v-for="day in visibleDays"
361
+ :key="fmt(day)"
362
+ class="relative cursor-pointer border-r border-outline-variant/50 last:border-r-0"
363
+ :class="fmt(day) === todayKey ? 'bg-primary-container/5' : ''"
364
+ :data-scheduler-day="fmt(day)"
365
+ @click="onColumnClick($event, day)"
366
+ >
367
+ <div v-for="hour in hours" :key="hour" class="border-b border-outline-variant/50" :style="{ height: `${hourHeight}px` }" />
368
+
369
+ <button
370
+ v-for="b in blocksFor(day)"
371
+ :key="b.event.id"
372
+ type="button"
373
+ class="absolute z-5 cursor-pointer overflow-hidden rounded border-l-[3px] px-2 py-1 text-left transition-opacity hover:opacity-90"
374
+ :class="eventColors[b.event.color ?? 'primary']"
375
+ :style="{
376
+ top: `${b.top + 1}px`,
377
+ height: `${b.height - 2}px`,
378
+ left: `calc(${(b.column / b.columns) * 100}% + 2px)`,
379
+ width: `calc(${100 / b.columns}% - 4px)`,
380
+ }"
381
+ :aria-label="`${b.event.title}, ${timeLabel(b.event)}`"
382
+ data-scheduler-event
383
+ @click.stop="emit('eventClick', b.event)"
217
384
  >
218
- <template v-for="ev in eventsForDayHour(day, hour)" :key="ev.id">
219
- <button
220
- v-if="isEventStart(ev, hour)"
221
- type="button"
222
- class="absolute inset-x-0.5 top-0.5 z-5 cursor-pointer overflow-hidden rounded border-l-[3px] px-2 py-1 text-left transition-opacity hover:opacity-90"
223
- :class="eventColors[ev.color ?? 'primary']"
224
- :style="{ height: `calc(${eventDuration(ev) * 100}% - 4px)` }"
225
- @click.stop="emit('eventClick', ev)"
226
- >
227
- <p class="truncate text-label-small font-medium">{{ ev.title }}</p>
228
- <p class="truncate text-label-small opacity-70">{{ timeLabel(ev) }}</p>
229
- </button>
230
- </template>
231
- </td>
232
- </tr>
233
- </tbody>
234
- </table>
385
+ <slot name="event" :event="b.event" :all-day="false">
386
+ <p class="truncate text-label-small font-medium">{{ b.event.title }}</p>
387
+ <p v-if="b.minutes >= 45" class="truncate text-label-small opacity-70">{{ timeLabel(b.event) }}</p>
388
+ </slot>
389
+ </button>
390
+
391
+ <div
392
+ v-if="nowIndicator && fmt(day) === todayKey && nowTop !== null"
393
+ class="pointer-events-none absolute inset-x-0 z-10 h-0.5 bg-error"
394
+ :style="{ top: `${nowTop}px` }"
395
+ data-scheduler-now
396
+ >
397
+ <span class="absolute -top-1 -left-1 h-2.5 w-2.5 rounded-full bg-error" />
398
+ </div>
399
+ </div>
400
+ </div>
401
+ </div>
235
402
  </div>
236
403
  </div>
237
404
  </template>
@@ -17,7 +17,7 @@ const motion = useSheetMotion('x', close)
17
17
 
18
18
  <template>
19
19
  <Teleport to="body">
20
- <Transition :css="false" @enter="motion.onEnter" @leave="motion.onLeave">
20
+ <Transition :css="false" @enter="motion.onEnter" @leave="motion.onLeave" appear>
21
21
  <div v-if="modelValue" class="fixed inset-0 z-200 flex justify-end">
22
22
  <!-- Scrim -->
23
23
  <div data-sheet-scrim class="absolute inset-0 bg-scrim/32" @click="close" />
@@ -9,6 +9,8 @@ export interface SplitButtonItem {
9
9
  onClick?: () => void
10
10
  }
11
11
 
12
+ defineOptions({ inheritAttrs: false })
13
+
12
14
  const props = withDefaults(defineProps<{
13
15
  label: string
14
16
  icon?: string
@@ -159,7 +161,7 @@ onUnmounted(() => {
159
161
  </script>
160
162
 
161
163
  <template>
162
- <div ref="containerEl" :class="containerClasses">
164
+ <div ref="containerEl" v-bind="$attrs" :class="containerClasses">
163
165
  <!-- Main action -->
164
166
  <button
165
167
  type="button"