@m3ui-vue/m3ui-vue 1.3.8 → 1.4.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 (111) hide show
  1. package/dist/API.md +1058 -18
  2. package/dist/{MButton-D5eJiDza.js → MButton-DQMTIlaV.js} +2 -2
  3. package/dist/{MButton-D5eJiDza.js.map → MButton-DQMTIlaV.js.map} +1 -1
  4. package/dist/{MDialog-WqB0jewp.js → MDialog-cdgapGfZ.js} +2 -2
  5. package/dist/{MDialog-WqB0jewp.js.map → MDialog-cdgapGfZ.js.map} +1 -1
  6. package/dist/{MListItem-Cf-C2Ru-.js → MListItem-ZkSGIIrb.js} +2 -2
  7. package/dist/{MListItem-Cf-C2Ru-.js.map → MListItem-ZkSGIIrb.js.map} +1 -1
  8. package/dist/{MLoadingIndicator-D4GzEZoH.js → MLoadingIndicator-U6_oGx8z.js} +2 -2
  9. package/dist/{MLoadingIndicator-D4GzEZoH.js.map → MLoadingIndicator-U6_oGx8z.js.map} +1 -1
  10. package/dist/{MSeekBar-B19xoWE3.js → MSeekBar-DTZVizZg.js} +2 -2
  11. package/dist/{MSeekBar-B19xoWE3.js.map → MSeekBar-DTZVizZg.js.map} +1 -1
  12. package/dist/{MSlider-9RoiuebS.js → MSlider-CqJkEYRZ.js} +2 -2
  13. package/dist/{MSlider-9RoiuebS.js.map → MSlider-CqJkEYRZ.js.map} +1 -1
  14. package/dist/{MSpinner-BNF8MN-L.js → MSpinner-Btgc-0nb.js} +2 -2
  15. package/dist/{MSpinner-BNF8MN-L.js.map → MSpinner-Btgc-0nb.js.map} +1 -1
  16. package/dist/{MTextField-CuG0T3qh.js → MTextField-B6M0gJEO.js} +2 -2
  17. package/dist/{MTextField-CuG0T3qh.js.map → MTextField-B6M0gJEO.js.map} +1 -1
  18. package/dist/{MTooltip-Bv7yxngk.js → MTooltip-Dspji4XG.js} +4 -4
  19. package/dist/{MTooltip-Bv7yxngk.js.map → MTooltip-Dspji4XG.js.map} +1 -1
  20. package/dist/api.json +1 -1
  21. package/dist/code-editor.js +1 -1
  22. package/dist/components/MAudioPlayer.vue.d.ts +2 -2
  23. package/dist/components/MAvailabilityCalendar.vue.d.ts +83 -0
  24. package/dist/components/MBeforeAfter.vue.d.ts +61 -0
  25. package/dist/components/MBodyMap.vue.d.ts +70 -0
  26. package/dist/components/MCandlestickChart.vue.d.ts +82 -0
  27. package/dist/components/MCertificate.vue.d.ts +76 -0
  28. package/dist/components/MCreditCardInput.vue.d.ts +75 -0
  29. package/dist/components/MMortgageCalculator.vue.d.ts +83 -0
  30. package/dist/components/MOdontogram.vue.d.ts +86 -0
  31. package/dist/components/MOrderBook.vue.d.ts +89 -0
  32. package/dist/components/MOrderTicket.vue.d.ts +91 -0
  33. package/dist/components/MPosKeypad.vue.d.ts +84 -0
  34. package/dist/components/MProductConfigurator.vue.d.ts +136 -0
  35. package/dist/components/MQuiz.vue.d.ts +102 -0
  36. package/dist/components/MReceipt.vue.d.ts +93 -0
  37. package/dist/components/MSeatMap.vue.d.ts +131 -0
  38. package/dist/components/MSeekBar.vue.d.ts +1 -1
  39. package/dist/components/MTicket.vue.d.ts +83 -0
  40. package/dist/components/MVideoPlayer.vue.d.ts +1 -1
  41. package/dist/components/MVitalsChart.vue.d.ts +73 -0
  42. package/dist/composables/_printElement.d.ts +9 -0
  43. package/dist/composables/cardBrand.d.ts +25 -0
  44. package/dist/composables/mortgage.d.ts +37 -0
  45. package/dist/composables/useLocale.d.ts +131 -0
  46. package/dist/draw.js +2 -2
  47. package/dist/flow.js +1 -1
  48. package/dist/gantt.js +1 -1
  49. package/dist/index.d.ts +35 -0
  50. package/dist/locales/index.js +924 -7
  51. package/dist/locales/index.js.map +1 -1
  52. package/dist/m3ui-vue.css +1 -1
  53. package/dist/m3ui.js +8264 -3553
  54. package/dist/m3ui.js.map +1 -1
  55. package/dist/map.js +5 -5
  56. package/dist/media.js +4 -4
  57. package/dist/pdf.js +4 -4
  58. package/dist/rich-text-editor.js +4 -4
  59. package/dist/styles.css +1 -1
  60. package/dist/{useLocale-D2ucaY-l.js → useLocale-DLKJIRFi.js} +133 -2
  61. package/dist/useLocale-DLKJIRFi.js.map +1 -0
  62. package/package.json +1 -1
  63. package/src/__tests__/MAvailabilityCalendar.test.ts +85 -0
  64. package/src/__tests__/MBeforeAfter.test.ts +79 -0
  65. package/src/__tests__/MBodyMap.test.ts +60 -0
  66. package/src/__tests__/MCandlestickChart.test.ts +66 -0
  67. package/src/__tests__/MCertificate.test.ts +32 -0
  68. package/src/__tests__/MCreditCardInput.test.ts +122 -0
  69. package/src/__tests__/MMortgageCalculator.test.ts +49 -0
  70. package/src/__tests__/MOdontogram.test.ts +93 -0
  71. package/src/__tests__/MOrderBook.test.ts +66 -0
  72. package/src/__tests__/MOrderTicket.test.ts +68 -0
  73. package/src/__tests__/MPosKeypad.test.ts +116 -0
  74. package/src/__tests__/MProductConfigurator.test.ts +73 -0
  75. package/src/__tests__/MQuiz.test.ts +104 -0
  76. package/src/__tests__/MReceipt.test.ts +52 -0
  77. package/src/__tests__/MSeatMap.test.ts +76 -0
  78. package/src/__tests__/MTicket.test.ts +38 -0
  79. package/src/__tests__/MVitalsChart.test.ts +49 -0
  80. package/src/__tests__/mortgage.test.ts +25 -0
  81. package/src/__tests__/ssr.test.ts +11 -0
  82. package/src/components/MAvailabilityCalendar.vue +460 -0
  83. package/src/components/MBeforeAfter.vue +248 -0
  84. package/src/components/MBodyMap.vue +266 -0
  85. package/src/components/MCandlestickChart.vue +479 -0
  86. package/src/components/MCertificate.vue +351 -0
  87. package/src/components/MCreditCardInput.vue +351 -0
  88. package/src/components/MMortgageCalculator.vue +258 -0
  89. package/src/components/MOdontogram.vue +462 -0
  90. package/src/components/MOrderBook.vue +287 -0
  91. package/src/components/MOrderTicket.vue +217 -0
  92. package/src/components/MPosKeypad.vue +406 -0
  93. package/src/components/MProductConfigurator.vue +412 -0
  94. package/src/components/MQuiz.vue +531 -0
  95. package/src/components/MReceipt.vue +249 -0
  96. package/src/components/MSeatMap.vue +431 -0
  97. package/src/components/MTicket.vue +209 -0
  98. package/src/components/MVitalsChart.vue +303 -0
  99. package/src/composables/_printElement.ts +36 -0
  100. package/src/composables/cardBrand.ts +104 -0
  101. package/src/composables/mortgage.ts +70 -0
  102. package/src/composables/useLocale.ts +277 -0
  103. package/src/index.ts +35 -0
  104. package/src/locales/de.ts +131 -0
  105. package/src/locales/es.ts +131 -0
  106. package/src/locales/fr.ts +131 -0
  107. package/src/locales/ja.ts +131 -0
  108. package/src/locales/ko.ts +131 -0
  109. package/src/locales/pt.ts +131 -0
  110. package/src/locales/zh.ts +131 -0
  111. package/dist/useLocale-D2ucaY-l.js.map +0 -1
@@ -0,0 +1,460 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * A booking calendar for stays (hotel, cabin, apartment, equipment rental): picks a check-in and a check-out
4
+ * night with the price of each night under its day, booked nights blocked, and a minimum / maximum stay. Once a
5
+ * check-in is chosen, only the days that make a valid stay stay pickable: a stay can't run over a booked night, but
6
+ * it can check out on the morning a booked night starts.
7
+ *
8
+ * Dates are `YYYY-MM-DD` strings in local time; each date's price and availability are those of the night that
9
+ * starts on it.
10
+ *
11
+ * @slot day Replaces a day's content (the button stays). Slot props: `{ date, day, price, state }`
12
+ * @slot footer Replaces the summary under the months. Slot props: `{ start, end, nights, total, clear }`
13
+ * @event update:modelValue `[checkIn, checkOut]`, either one `null` — powers v-model
14
+ * @event change Emitted when a stay is complete: `{ start, end, nights, total }`
15
+ */
16
+ import { computed, nextTick, ref, watch } from 'vue'
17
+ import MIconButton from './MIconButton.vue'
18
+ import MButton from './MButton.vue'
19
+ import { useLocale } from '../composables/useLocale'
20
+
21
+ const locale = useLocale()
22
+
23
+ type Range = [string | null, string | null]
24
+
25
+ const props = withDefaults(
26
+ defineProps<{
27
+ /** `[checkIn, checkOut]` as `YYYY-MM-DD` (v-model) */
28
+ modelValue?: Range
29
+ /** Price of the night starting on each date: a map or a function */
30
+ prices?: Record<string, number> | ((date: string) => number | undefined)
31
+ /** Nights already booked or closed: a list of dates or a function */
32
+ unavailable?: string[] | ((date: string) => boolean)
33
+ /** Shortest stay, in nights */
34
+ minNights?: number
35
+ /** Longest stay, in nights */
36
+ maxNights?: number
37
+ /** First bookable date. Defaults to today */
38
+ min?: string
39
+ /** Last bookable night */
40
+ max?: string
41
+ /** Months shown side by side (they wrap on narrow screens) */
42
+ months?: number
43
+ /** 0 = Sunday … 6 = Saturday. Defaults to the locale's first day of the week */
44
+ firstDayOfWeek?: number
45
+ /** ISO 4217 code to format prices */
46
+ currency?: string
47
+ /** Colors the cheapest quarter of the nights shown as deals */
48
+ highlightDeals?: boolean
49
+ /** Hides the summary under the months */
50
+ hideFooter?: boolean
51
+ disabled?: boolean
52
+ }>(),
53
+ {
54
+ modelValue: () => [null, null],
55
+ minNights: 1,
56
+ months: 2,
57
+ highlightDeals: false,
58
+ hideFooter: false,
59
+ disabled: false,
60
+ },
61
+ )
62
+
63
+ const emit = defineEmits<{
64
+ 'update:modelValue': [Range]
65
+ change: [{ start: string; end: string; nights: number; total: number }]
66
+ }>()
67
+
68
+ // ── date helpers (local time, YYYY-MM-DD) ──
69
+ const pad = (n: number) => String(n).padStart(2, '0')
70
+ function key(d: Date) {
71
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`
72
+ }
73
+ function parse(k: string) {
74
+ const [y, m, d] = k.split('-').map(Number)
75
+ return new Date(y!, m! - 1, d!)
76
+ }
77
+ function addDays(k: string, n: number) {
78
+ const d = parse(k)
79
+ d.setDate(d.getDate() + n)
80
+ return key(d)
81
+ }
82
+ function diffDays(a: string, b: string) {
83
+ return Math.round((parse(b).getTime() - parse(a).getTime()) / 86_400_000)
84
+ }
85
+
86
+ const minDate = computed(() => props.min ?? key(new Date()))
87
+
88
+ const firstDay = computed(() => {
89
+ if (props.firstDayOfWeek !== undefined) return props.firstDayOfWeek
90
+ try {
91
+ const loc = new Intl.Locale(locale.lang) as Intl.Locale & { getWeekInfo?: () => { firstDay: number }; weekInfo?: { firstDay: number } }
92
+ const info = loc.getWeekInfo?.() ?? loc.weekInfo
93
+ if (info) return info.firstDay % 7
94
+ } catch { /* old engines */ }
95
+ return 0
96
+ })
97
+
98
+ const start = computed(() => props.modelValue[0])
99
+ const end = computed(() => props.modelValue[1])
100
+
101
+ // ── view ──
102
+ const initial = start.value ? parse(start.value) : parse(minDate.value)
103
+ const view = ref(new Date(initial.getFullYear(), initial.getMonth(), 1))
104
+
105
+ const unavailableSet = computed(() => (Array.isArray(props.unavailable) ? new Set(props.unavailable) : null))
106
+ function isBooked(k: string) {
107
+ if (typeof props.unavailable === 'function') return props.unavailable(k)
108
+ return unavailableSet.value?.has(k) ?? false
109
+ }
110
+ function priceOf(k: string) {
111
+ return typeof props.prices === 'function' ? props.prices(k) : props.prices?.[k]
112
+ }
113
+ function inBounds(k: string) {
114
+ return k >= minDate.value && (!props.max || k <= props.max)
115
+ }
116
+
117
+ /** First booked (or out of range) night on or after `from`, within `limit` nights */
118
+ function firstBlocked(from: string, limit: number) {
119
+ for (let i = 0; i < limit; i++) {
120
+ const k = addDays(from, i)
121
+ if (isBooked(k) || !inBounds(k)) return i
122
+ }
123
+ return -1
124
+ }
125
+
126
+ function canCheckIn(k: string) {
127
+ if (!inBounds(k) || isBooked(k)) return false
128
+ // the minimum stay must fit before the next booked night
129
+ return firstBlocked(k, props.minNights) === -1
130
+ }
131
+
132
+ function canCheckOut(k: string) {
133
+ const s = start.value
134
+ if (!s || end.value) return false
135
+ const n = diffDays(s, k)
136
+ if (n < props.minNights || (props.maxNights !== undefined && n > props.maxNights)) return false
137
+ return firstBlocked(s, n) === -1
138
+ }
139
+
140
+ const hover = ref<string | null>(null)
141
+
142
+ type DayState = 'start' | 'end' | 'range' | 'preview' | 'booked' | 'disabled' | 'available' | 'checkout-only'
143
+
144
+ function stateOf(k: string): DayState {
145
+ if (k === start.value) return 'start'
146
+ if (k === end.value) return 'end'
147
+ if (start.value && end.value && k > start.value && k < end.value) return 'range'
148
+ if (start.value && !end.value) {
149
+ if (canCheckOut(k)) {
150
+ if (hover.value && canCheckOut(hover.value) && k > start.value && k < hover.value) return 'preview'
151
+ return isBooked(k) ? 'checkout-only' : 'available'
152
+ }
153
+ if (k > start.value) return isBooked(k) ? 'booked' : 'disabled'
154
+ }
155
+ if (isBooked(k)) return 'booked'
156
+ if (!canCheckIn(k)) return 'disabled'
157
+ return 'available'
158
+ }
159
+
160
+ function pickable(k: string) {
161
+ const s = stateOf(k)
162
+ return s !== 'booked' && s !== 'disabled'
163
+ }
164
+
165
+ interface Cell { key: string; day: number; price?: number }
166
+ const monthsView = computed(() =>
167
+ Array.from({ length: props.months }, (_, i) => {
168
+ const first = new Date(view.value.getFullYear(), view.value.getMonth() + i, 1)
169
+ const lead = (first.getDay() - firstDay.value + 7) % 7
170
+ const days = new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate()
171
+ const cells: (Cell | null)[] = Array.from({ length: lead }, () => null)
172
+ for (let d = 1; d <= days; d++) {
173
+ const k = key(new Date(first.getFullYear(), first.getMonth(), d))
174
+ cells.push({ key: k, day: d, price: priceOf(k) })
175
+ }
176
+ return {
177
+ id: key(first).slice(0, 7),
178
+ label: new Intl.DateTimeFormat(locale.lang, { month: 'long', year: 'numeric' }).format(first),
179
+ cells,
180
+ }
181
+ }),
182
+ )
183
+
184
+ const weekdays = computed(() => {
185
+ const f = new Intl.DateTimeFormat(locale.lang, { weekday: 'narrow' })
186
+ const long = new Intl.DateTimeFormat(locale.lang, { weekday: 'long' })
187
+ // 2023-01-01 was a Sunday
188
+ return Array.from({ length: 7 }, (_, i) => {
189
+ const d = new Date(2023, 0, 1 + ((i + firstDay.value) % 7))
190
+ return { short: f.format(d), long: long.format(d) }
191
+ })
192
+ })
193
+
194
+ /** Prices at or under this are deals */
195
+ const dealLimit = computed(() => {
196
+ if (!props.highlightDeals) return -Infinity
197
+ const ps = monthsView.value.flatMap((m) => m.cells).filter((c): c is Cell => !!c && c.price !== undefined && pickable(c.key)).map((c) => c.price!)
198
+ if (ps.length < 4) return -Infinity
199
+ ps.sort((a, b) => a - b)
200
+ return ps[Math.floor(ps.length / 4) - 1]!
201
+ })
202
+
203
+ function money(n: number, compact = false) {
204
+ return new Intl.NumberFormat(locale.lang, {
205
+ ...(props.currency ? { style: 'currency', currency: props.currency } : {}),
206
+ ...(compact ? { maximumFractionDigits: 0 } : {}),
207
+ }).format(n)
208
+ }
209
+
210
+ const nights = computed(() => (start.value && end.value ? diffDays(start.value, end.value) : 0))
211
+ const total = computed(() => {
212
+ let t = 0
213
+ for (let i = 0; i < nights.value; i++) t += priceOf(addDays(start.value!, i)) ?? 0
214
+ return Math.round(t * 100) / 100
215
+ })
216
+
217
+ function select(k: string) {
218
+ if (props.disabled || !pickable(k)) return
219
+ if (start.value && !end.value && canCheckOut(k)) {
220
+ const range: Range = [start.value, k]
221
+ emit('update:modelValue', range)
222
+ const n = diffDays(start.value, k)
223
+ let t = 0
224
+ for (let i = 0; i < n; i++) t += priceOf(addDays(start.value, i)) ?? 0
225
+ emit('change', { start: start.value, end: k, nights: n, total: Math.round(t * 100) / 100 })
226
+ } else if (canCheckIn(k)) {
227
+ emit('update:modelValue', [k, null])
228
+ }
229
+ }
230
+
231
+ function clear() {
232
+ emit('update:modelValue', [null, null])
233
+ }
234
+
235
+ const hint = computed(() => {
236
+ if (!start.value) return locale.availSelectCheckIn
237
+ if (!end.value) return props.minNights > 1 ? `${locale.availSelectCheckOut} · ${locale.availMinNights.replace('{n}', String(props.minNights))}` : locale.availSelectCheckOut
238
+ return ''
239
+ })
240
+
241
+ function nightsText(n: number) {
242
+ return n === 1 ? locale.availNight : locale.availNights.replace('{n}', String(n))
243
+ }
244
+
245
+ function dayLabel(c: Cell) {
246
+ const s = stateOf(c.key)
247
+ const parts = [new Intl.DateTimeFormat(locale.lang, { dateStyle: 'full' }).format(parse(c.key))]
248
+ if (c.price !== undefined && s !== 'booked') parts.push(money(c.price))
249
+ if (s === 'start') parts.push(locale.availCheckIn)
250
+ if (s === 'end') parts.push(locale.availCheckOut)
251
+ if (s === 'booked') parts.push(locale.availUnavailable)
252
+ return parts.join(', ')
253
+ }
254
+
255
+ // ── navigation ──
256
+ const canPrev = computed(() => {
257
+ const m = parse(minDate.value)
258
+ return view.value > new Date(m.getFullYear(), m.getMonth(), 1)
259
+ })
260
+ const canNext = computed(() => {
261
+ if (!props.max) return true
262
+ const m = parse(props.max)
263
+ return new Date(view.value.getFullYear(), view.value.getMonth() + props.months - 1, 1) < new Date(m.getFullYear(), m.getMonth(), 1)
264
+ })
265
+ function shift(n: number) {
266
+ view.value = new Date(view.value.getFullYear(), view.value.getMonth() + n, 1)
267
+ }
268
+
269
+ // Roving focus: one day is tabbable
270
+ const focusKey = ref(start.value ?? (inBounds(key(new Date())) ? key(new Date()) : minDate.value))
271
+ const rootEl = ref<HTMLElement | null>(null)
272
+ const tabKey = computed(() => {
273
+ const keys = monthsView.value.flatMap((m) => m.cells).filter(Boolean).map((c) => c!.key)
274
+ return keys.includes(focusKey.value) ? focusKey.value : keys[0]
275
+ })
276
+
277
+ function ensureVisible(k: string) {
278
+ const d = parse(k)
279
+ const first = new Date(d.getFullYear(), d.getMonth(), 1)
280
+ const last = new Date(view.value.getFullYear(), view.value.getMonth() + props.months - 1, 1)
281
+ if (first < view.value) view.value = first
282
+ else if (first > last) view.value = new Date(d.getFullYear(), d.getMonth() - props.months + 1, 1)
283
+ }
284
+
285
+ async function onKeydown(e: KeyboardEvent, k: string) {
286
+ const moves: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 }
287
+ let next: string | null = null
288
+ if (e.key in moves) next = addDays(k, moves[e.key]!)
289
+ else if (e.key === 'PageUp' || e.key === 'PageDown') {
290
+ const d = parse(k)
291
+ d.setMonth(d.getMonth() + (e.key === 'PageUp' ? -1 : 1))
292
+ next = key(d)
293
+ } else if (e.key === 'Home') next = addDays(k, -((parse(k).getDay() - firstDay.value + 7) % 7))
294
+ else if (e.key === 'End') next = addDays(k, 6 - ((parse(k).getDay() - firstDay.value + 7) % 7))
295
+ else if (e.key === 'Enter' || e.key === ' ') {
296
+ e.preventDefault()
297
+ select(k)
298
+ return
299
+ } else if (e.key === 'Escape' && start.value && !end.value) {
300
+ e.preventDefault()
301
+ clear()
302
+ return
303
+ }
304
+ if (!next) return
305
+ e.preventDefault()
306
+ focusKey.value = next
307
+ ensureVisible(next)
308
+ hover.value = next
309
+ await nextTick()
310
+ rootEl.value?.querySelector<HTMLElement>(`[data-date="${next}"]`)?.focus()
311
+ }
312
+
313
+ watch(start, (s) => {
314
+ if (s) focusKey.value = s
315
+ })
316
+
317
+ defineExpose({ nights, total, clear })
318
+ </script>
319
+
320
+ <template>
321
+ <div ref="rootEl" class="m3-availability text-on-surface" @mouseleave="hover = null">
322
+ <div class="flex flex-wrap gap-x-8 gap-y-4">
323
+ <div v-for="(m, mi) in monthsView" :key="m.id" class="min-w-64 flex-1">
324
+ <div class="mb-2 flex h-12 items-center">
325
+ <MIconButton
326
+ icon="chevron_left"
327
+ :aria-label="locale.previous"
328
+ :class="mi === 0 ? '' : 'invisible'"
329
+ :disabled="!canPrev"
330
+ data-nav="prev"
331
+ @click="shift(-1)"
332
+ />
333
+ <h3 class="flex-1 text-center text-title-medium capitalize">{{ m.label }}</h3>
334
+ <MIconButton
335
+ icon="chevron_right"
336
+ :aria-label="locale.next"
337
+ :class="mi === monthsView.length - 1 ? '' : 'invisible'"
338
+ :disabled="!canNext"
339
+ data-nav="next"
340
+ @click="shift(1)"
341
+ />
342
+ </div>
343
+ <div role="grid" :aria-label="m.label" class="grid grid-cols-7">
344
+ <div role="row" class="contents">
345
+ <span
346
+ v-for="w in weekdays"
347
+ :key="w.long"
348
+ role="columnheader"
349
+ :aria-label="w.long"
350
+ class="flex h-8 items-center justify-center text-label-medium text-on-surface-variant"
351
+ >{{ w.short }}</span>
352
+ </div>
353
+ <div role="row" class="contents">
354
+ <template v-for="(c, ci) in m.cells" :key="c?.key ?? `x${ci}`">
355
+ <span v-if="!c" role="gridcell" />
356
+ <div
357
+ v-else
358
+ role="gridcell"
359
+ class="m3-availability__cell relative flex h-14 items-center justify-center"
360
+ :data-state="stateOf(c.key)"
361
+ :data-lone="stateOf(c.key) === 'start' && !end && !(hover && hover !== start && canCheckOut(hover)) ? '' : undefined"
362
+ >
363
+ <button
364
+ type="button"
365
+ class="m3-availability__day relative z-[1] flex h-12 w-full max-w-12 flex-col items-center justify-center rounded-full text-body-large leading-tight"
366
+ :class="[
367
+ stateOf(c.key) === 'start' || stateOf(c.key) === 'end' ? 'bg-primary text-on-primary' : '',
368
+ stateOf(c.key) === 'booked' ? 'text-on-surface/40 line-through' : '',
369
+ stateOf(c.key) === 'disabled' ? 'text-on-surface/40' : '',
370
+ ]"
371
+ :tabindex="c.key === tabKey ? 0 : -1"
372
+ :aria-label="dayLabel(c)"
373
+ :aria-pressed="stateOf(c.key) === 'start' || stateOf(c.key) === 'end' || stateOf(c.key) === 'range'"
374
+ :aria-disabled="!pickable(c.key) || disabled || undefined"
375
+ :data-date="c.key"
376
+ @click="select(c.key)"
377
+ @mouseenter="hover = c.key"
378
+ @focus="focusKey = c.key"
379
+ @keydown="onKeydown($event, c.key)"
380
+ >
381
+ <slot name="day" :date="c.key" :day="c.day" :price="c.price" :state="stateOf(c.key)">
382
+ <span :class="{ 'font-medium': c.key === key(new Date()) }">{{ c.day }}</span>
383
+ <span
384
+ v-if="c.price !== undefined && stateOf(c.key) !== 'booked' && stateOf(c.key) !== 'disabled'"
385
+ class="text-[10px] tabular-nums"
386
+ :class="stateOf(c.key) === 'start' || stateOf(c.key) === 'end'
387
+ ? 'text-on-primary/80'
388
+ : c.price <= dealLimit ? 'font-medium text-success' : 'text-on-surface-variant'"
389
+ >{{ money(c.price, true) }}</span>
390
+ </slot>
391
+ </button>
392
+ </div>
393
+ </template>
394
+ </div>
395
+ </div>
396
+ </div>
397
+ </div>
398
+
399
+ <div v-if="!hideFooter" class="mt-3 flex min-h-12 flex-wrap items-center gap-3 border-t border-outline-variant pt-3">
400
+ <slot name="footer" :start="start" :end="end" :nights="nights" :total="total" :clear="clear">
401
+ <p class="flex-1 text-body-large" data-summary>
402
+ <template v-if="nights">
403
+ {{ nightsText(nights) }}<template v-if="prices"> · <strong class="tabular-nums">{{ money(total) }}</strong></template>
404
+ </template>
405
+ <span v-else class="text-on-surface-variant">{{ hint }}</span>
406
+ </p>
407
+ <MButton v-if="start" variant="text" @click="clear">{{ locale.clear }}</MButton>
408
+ </slot>
409
+ </div>
410
+ </div>
411
+ </template>
412
+
413
+ <style>
414
+ /* The band between check-in and check-out runs behind the day circles */
415
+ .m3-availability__cell[data-state='range']::before,
416
+ .m3-availability__cell[data-state='preview']::before,
417
+ .m3-availability__cell[data-state='start']::before,
418
+ .m3-availability__cell[data-state='end']::before {
419
+ content: '';
420
+ position: absolute;
421
+ inset: 4px 0;
422
+ background: var(--color-secondary-container);
423
+ }
424
+ .m3-availability__cell[data-state='preview']::before {
425
+ background: color-mix(in srgb, var(--color-secondary-container) 55%, transparent);
426
+ }
427
+ .m3-availability__cell[data-state='start']::before {
428
+ left: 50%;
429
+ }
430
+ .m3-availability__cell[data-state='end']::before {
431
+ right: 50%;
432
+ }
433
+ /* A lone check-in (no check-out yet, none previewed) has no band */
434
+ .m3-availability__cell[data-lone]::before {
435
+ display: none;
436
+ }
437
+ .m3-availability__cell[data-state='range'] .m3-availability__day,
438
+ .m3-availability__cell[data-state='preview'] .m3-availability__day {
439
+ color: var(--color-on-secondary-container);
440
+ }
441
+ .m3-availability__day:not([aria-disabled]):not([aria-pressed='true']):hover {
442
+ background: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
443
+ }
444
+ .m3-availability__day[aria-disabled] {
445
+ cursor: default;
446
+ }
447
+ .m3-availability__day:focus-visible {
448
+ outline: 3px solid var(--color-secondary);
449
+ outline-offset: -1px;
450
+ }
451
+ .m3-availability__cell[data-state='checkout-only'] .m3-availability__day::after {
452
+ content: '';
453
+ position: absolute;
454
+ bottom: 4px;
455
+ width: 4px;
456
+ height: 4px;
457
+ border-radius: 50%;
458
+ background: var(--color-outline);
459
+ }
460
+ </style>