@m3ui-vue/m3ui-vue 0.8.7 → 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.
- package/README.md +13 -3
- package/dist/{MMenuItem-DmrsQrK7.js → MTextField-B0wGv1Mx.js} +374 -364
- package/dist/MTextField-B0wGv1Mx.js.map +1 -0
- package/dist/barcode.js +9 -11
- package/dist/barcode.js.map +1 -1
- package/dist/code-editor.js +2 -2
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MCarousel.vue.d.ts +55 -36
- package/dist/components/MDialog.vue.d.ts +4 -2
- package/dist/components/MEmojiSelector.vue.d.ts +21 -5
- package/dist/components/MFabMenu.vue.d.ts +1 -1
- package/dist/components/MFlex.vue.d.ts +1 -1
- package/dist/components/MLightbox.vue.d.ts +15 -5
- package/dist/components/MScheduler.vue.d.ts +38 -1
- package/dist/components/MShape.vue.d.ts +1 -1
- package/dist/components/MSimpleCarousel.vue.d.ts +2 -2
- package/dist/components/MSlider.vue.d.ts +1 -1
- package/dist/components/MStack.vue.d.ts +1 -1
- package/dist/components/MToolbar.vue.d.ts +1 -1
- package/dist/components/MWindow.vue.d.ts +1 -1
- package/dist/composables/_carouselStrategy.d.ts +101 -0
- package/dist/composables/useLocale.d.ts +23 -0
- package/dist/data/emoji-names/emoji-names-de.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-en.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-es.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-fr.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-ja.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-ko.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-pt.d.ts +2 -0
- package/dist/data/emoji-names/emoji-names-zh.d.ts +2 -0
- package/dist/data/emojis.d.ts +7 -1
- package/dist/emoji-names-de-BphO5XpV.js +1877 -0
- package/dist/emoji-names-de-BphO5XpV.js.map +1 -0
- package/dist/emoji-names-en-9ZvMRvzi.js +1877 -0
- package/dist/emoji-names-en-9ZvMRvzi.js.map +1 -0
- package/dist/emoji-names-es-DvfWU3Pj.js +1877 -0
- package/dist/emoji-names-es-DvfWU3Pj.js.map +1 -0
- package/dist/emoji-names-fr-B-jhUlsP.js +1877 -0
- package/dist/emoji-names-fr-B-jhUlsP.js.map +1 -0
- package/dist/emoji-names-ja-l8cMFJo1.js +1877 -0
- package/dist/emoji-names-ja-l8cMFJo1.js.map +1 -0
- package/dist/emoji-names-ko-YP-o9G0c.js +1877 -0
- package/dist/emoji-names-ko-YP-o9G0c.js.map +1 -0
- package/dist/emoji-names-pt-DGj_Js4M.js +1877 -0
- package/dist/emoji-names-pt-DGj_Js4M.js.map +1 -0
- package/dist/emoji-names-zh-Dzecwtw_.js +1877 -0
- package/dist/emoji-names-zh-Dzecwtw_.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/locales/index.js +168 -7
- package/dist/locales/index.js.map +1 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +3926 -2430
- package/dist/m3ui.js.map +1 -1
- package/dist/plugin.d.ts +6 -0
- package/dist/rich-text-editor.js +9 -9
- package/dist/styles.css +1 -1
- package/dist/terminal.js +34 -27
- package/dist/terminal.js.map +1 -1
- package/dist/{useLocale-Bircp823.js → useLocale-CmI675Ab.js} +25 -2
- package/dist/useLocale-CmI675Ab.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/MCarousel.test.ts +183 -21
- package/src/__tests__/MDialog.test.ts +18 -0
- package/src/__tests__/MEmojiSelector.test.ts +138 -0
- package/src/__tests__/MLightbox.test.ts +313 -5
- package/src/__tests__/MPagination.test.ts +37 -0
- package/src/__tests__/MPullToRefresh.test.ts +39 -0
- package/src/__tests__/MScheduler.test.ts +122 -0
- package/src/__tests__/MTerminal.test.ts +63 -0
- package/src/__tests__/attrsFallthrough.test.ts +65 -0
- package/src/__tests__/plugin.test.ts +28 -1
- package/src/components/MBarcode.vue +4 -2
- package/src/components/MBottomSheet.vue +1 -1
- package/src/components/MCarousel.vue +526 -200
- package/src/components/MCodeEditor.vue +3 -2
- package/src/components/MCommandPalette.vue +1 -1
- package/src/components/MContextMenu.vue +3 -1
- package/src/components/MDatePickerModal.vue +1 -1
- package/src/components/MDateRangePickerModal.vue +1 -1
- package/src/components/MDialog.vue +19 -6
- package/src/components/MEmojiSelector.vue +479 -78
- package/src/components/MFab.vue +3 -1
- package/src/components/MLightbox.vue +750 -268
- package/src/components/MLoadingOverlay.vue +6 -1
- package/src/components/MMenu.vue +3 -1
- package/src/components/MNavigationDrawer.vue +5 -1
- package/src/components/MNavigationRail.vue +8 -2
- package/src/components/MOverlay.vue +1 -0
- package/src/components/MPagination.vue +8 -5
- package/src/components/MPullToRefresh.vue +13 -1
- package/src/components/MScheduler.vue +282 -115
- package/src/components/MSideSheet.vue +1 -1
- package/src/components/MSplitButton.vue +3 -1
- package/src/components/MSpotlightSearch.vue +1 -1
- package/src/components/MTerminal.vue +22 -10
- package/src/components/MTimePickerModal.vue +1 -1
- package/src/components/MTooltip.vue +3 -0
- package/src/components/MTour.vue +2 -2
- package/src/composables/_carouselStrategy.ts +712 -0
- package/src/composables/useLocale.ts +48 -0
- package/src/data/emoji-names/emoji-names-de.ts +1875 -0
- package/src/data/emoji-names/emoji-names-en.ts +1875 -0
- package/src/data/emoji-names/emoji-names-es.ts +1875 -0
- package/src/data/emoji-names/emoji-names-fr.ts +1875 -0
- package/src/data/emoji-names/emoji-names-ja.ts +1875 -0
- package/src/data/emoji-names/emoji-names-ko.ts +1875 -0
- package/src/data/emoji-names/emoji-names-pt.ts +1875 -0
- package/src/data/emoji-names/emoji-names-zh.ts +1875 -0
- package/src/data/emojis.ts +29 -198
- package/src/index.ts +2 -2
- package/src/locales/de.ts +24 -0
- package/src/locales/es.ts +24 -0
- package/src/locales/fr.ts +24 -0
- package/src/locales/ja.ts +24 -0
- package/src/locales/ko.ts +24 -0
- package/src/locales/pt.ts +24 -0
- package/src/locales/zh.ts +24 -0
- package/src/plugin.ts +12 -1
- package/dist/MMenuItem-DmrsQrK7.js.map +0 -1
- package/dist/useLocale-Bircp823.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { ref,
|
|
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
|
|
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
|
-
|
|
48
|
-
|
|
68
|
+
defineSlots<{
|
|
69
|
+
/** Content of an event block. */
|
|
70
|
+
event?: (scope: { event: SchedulerEvent; allDay: boolean }) => unknown
|
|
71
|
+
}>()
|
|
49
72
|
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
93
|
+
const diff = (dt.getDay() - props.weekStartsOn + 7) % 7
|
|
94
|
+
return addDays(dt, -diff)
|
|
61
95
|
}
|
|
62
96
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
102
|
+
function setDate(d: Date) {
|
|
103
|
+
currentDate.value = d
|
|
104
|
+
emit('update:date', fmt(d))
|
|
105
|
+
}
|
|
80
106
|
|
|
81
|
-
function
|
|
82
|
-
|
|
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 =
|
|
94
|
-
const end =
|
|
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
|
-
|
|
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
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
122
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
133
|
-
|
|
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="
|
|
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="
|
|
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
|
-
|
|
178
|
-
|
|
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
|
-
<
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
<
|
|
191
|
-
|
|
192
|
-
class="
|
|
193
|
-
|
|
194
|
-
>
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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
|
-
<
|
|
219
|
-
<
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
</
|
|
232
|
-
</
|
|
233
|
-
</
|
|
234
|
-
</
|
|
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"
|
|
@@ -144,7 +144,7 @@ onBeforeUnmount(() => {
|
|
|
144
144
|
|
|
145
145
|
<template>
|
|
146
146
|
<Teleport to="body">
|
|
147
|
-
<Transition name="m3-spot">
|
|
147
|
+
<Transition name="m3-spot" appear>
|
|
148
148
|
<div
|
|
149
149
|
v-if="modelValue"
|
|
150
150
|
class="fixed inset-0 z-50 flex items-start justify-center bg-scrim/32 pt-[12vh]"
|
|
@@ -38,8 +38,10 @@ function writeLines(lines: string[]) {
|
|
|
38
38
|
})
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// xterm draws on a canvas, so it can't use the CSS variables directly: read them (from the
|
|
42
|
+
// container, so a palette set on an ancestor applies too) and hand xterm plain colors.
|
|
41
43
|
function getThemeColors() {
|
|
42
|
-
const style = getComputedStyle(document.documentElement)
|
|
44
|
+
const style = getComputedStyle(containerRef.value ?? document.documentElement)
|
|
43
45
|
return {
|
|
44
46
|
background: style.getPropertyValue('--color-surface-container-lowest').trim() || '#0f0d13',
|
|
45
47
|
foreground: style.getPropertyValue('--color-on-surface').trim() || '#e6e1e5',
|
|
@@ -49,6 +51,14 @@ function getThemeColors() {
|
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
|
|
54
|
+
// Theme (.dark) and palette (data-palette) changes don't reach the canvas on their own: re-read
|
|
55
|
+
// the colors whenever <html> changes, like useFieldBg does.
|
|
56
|
+
let themeObserver: MutationObserver | null = null
|
|
57
|
+
let unmounted = false
|
|
58
|
+
function applyTheme() {
|
|
59
|
+
if (terminal) terminal.options.theme = getThemeColors()
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
onMounted(async () => {
|
|
53
63
|
if (!containerRef.value) return
|
|
54
64
|
|
|
@@ -58,8 +68,8 @@ onMounted(async () => {
|
|
|
58
68
|
])
|
|
59
69
|
|
|
60
70
|
try { await import('@xterm/xterm/css/xterm.css') } catch { /* consumer will provide styles */ }
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
// Unmounted while xterm was loading: don't create a terminal (and observers) nobody will dispose.
|
|
72
|
+
if (unmounted || !containerRef.value) return
|
|
63
73
|
|
|
64
74
|
terminal = new xtermMod.Terminal({
|
|
65
75
|
fontFamily: "'JetBrains Mono', 'Fira Code', 'Consolas', monospace",
|
|
@@ -67,13 +77,7 @@ onMounted(async () => {
|
|
|
67
77
|
lineHeight: 1.4,
|
|
68
78
|
cursorBlink: !props.readonly,
|
|
69
79
|
disableStdin: props.readonly,
|
|
70
|
-
theme:
|
|
71
|
-
background: colors.background,
|
|
72
|
-
foreground: colors.foreground,
|
|
73
|
-
cursor: colors.cursor,
|
|
74
|
-
cursorAccent: colors.cursorAccent,
|
|
75
|
-
selectionBackground: colors.selectionBackground,
|
|
76
|
-
},
|
|
80
|
+
theme: getThemeColors(),
|
|
77
81
|
scrollback: 1000,
|
|
78
82
|
convertEol: true,
|
|
79
83
|
})
|
|
@@ -110,6 +114,12 @@ onMounted(async () => {
|
|
|
110
114
|
try { fitAddon?.fit() } catch { /* ignore */ }
|
|
111
115
|
})
|
|
112
116
|
resizeObserver.observe(containerRef.value)
|
|
117
|
+
|
|
118
|
+
themeObserver = new MutationObserver(applyTheme)
|
|
119
|
+
themeObserver.observe(document.documentElement, {
|
|
120
|
+
attributes: true,
|
|
121
|
+
attributeFilter: ['class', 'style', 'data-theme', 'data-palette'],
|
|
122
|
+
})
|
|
113
123
|
})
|
|
114
124
|
|
|
115
125
|
watch(() => props.lines, (newLines) => {
|
|
@@ -119,7 +129,9 @@ watch(() => props.lines, (newLines) => {
|
|
|
119
129
|
})
|
|
120
130
|
|
|
121
131
|
onBeforeUnmount(() => {
|
|
132
|
+
unmounted = true
|
|
122
133
|
resizeObserver?.disconnect()
|
|
134
|
+
themeObserver?.disconnect()
|
|
123
135
|
terminal?.dispose()
|
|
124
136
|
})
|
|
125
137
|
|
|
@@ -234,7 +234,7 @@ function onKeydown(e: KeyboardEvent) { if (e.key === 'Escape') cancel() }
|
|
|
234
234
|
|
|
235
235
|
<template>
|
|
236
236
|
<Teleport to="body">
|
|
237
|
-
<Transition name="m3-tp-modal">
|
|
237
|
+
<Transition name="m3-tp-modal" appear>
|
|
238
238
|
<div
|
|
239
239
|
v-if="show"
|
|
240
240
|
class="fixed inset-0 z-50 flex items-center justify-center bg-scrim/32 p-4"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { nextTick, onMounted, onUnmounted, ref } from 'vue'
|
|
3
3
|
|
|
4
|
+
defineOptions({ inheritAttrs: false })
|
|
5
|
+
|
|
4
6
|
const props = withDefaults(defineProps<{
|
|
5
7
|
text?: string
|
|
6
8
|
placement?: 'top' | 'bottom' | 'left' | 'right'
|
|
@@ -85,6 +87,7 @@ onUnmounted(() => {
|
|
|
85
87
|
<template>
|
|
86
88
|
<span
|
|
87
89
|
ref="triggerEl"
|
|
90
|
+
v-bind="$attrs"
|
|
88
91
|
class="inline-flex"
|
|
89
92
|
@mouseenter="show"
|
|
90
93
|
@mouseleave="hide"
|