@m3ui-vue/m3ui-vue 0.8.0 → 0.8.2
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 +9 -1
- package/dist/{MMenuItem-vSLbJGqe.js → MMenuItem-BAWmUTT3.js} +367 -189
- package/dist/MMenuItem-BAWmUTT3.js.map +1 -0
- package/dist/code-editor.js +1 -1
- package/dist/code-editor.js.map +1 -1
- package/dist/components/MButton.vue.d.ts +7 -0
- package/dist/components/MCalendar.vue.d.ts +0 -1
- package/dist/components/MCarousel.vue.d.ts +12 -14
- package/dist/components/MContextMenu.vue.d.ts +25 -4
- package/dist/components/MDatePicker.vue.d.ts +1 -3
- package/dist/components/MDatePickerModal.vue.d.ts +0 -1
- package/dist/components/MDateRangePicker.vue.d.ts +1 -3
- package/dist/components/MDateRangePickerModal.vue.d.ts +0 -1
- package/dist/components/MKanban.vue.d.ts +1 -0
- package/dist/components/MMenu.vue.d.ts +20 -2
- package/dist/components/MMenuDivider.vue.d.ts +13 -1
- package/dist/components/MMenuItem.vue.d.ts +3 -0
- package/dist/components/MScheduler.vue.d.ts +0 -1
- package/dist/components/MShape.vue.d.ts +51 -0
- package/dist/components/MShortNavigationBar.vue.d.ts +34 -0
- package/dist/components/MSimpleCarousel.vue.d.ts +45 -0
- package/dist/components/MToggleButton.vue.d.ts +29 -0
- package/dist/components/MTree.vue.d.ts +0 -1
- package/dist/components/MTreeTable.vue.d.ts +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +5599 -3973
- package/dist/m3ui.js.map +1 -1
- package/dist/rich-text-editor.js +8 -8
- package/dist/styles/palettes.css +22 -22
- package/dist/styles.css +1 -1
- package/package.json +4 -1
- package/src/__tests__/MCarousel.test.ts +33 -0
- package/src/__tests__/MShape.test.ts +36 -0
- package/src/__tests__/MToggleButton.test.ts +27 -0
- package/src/components/MAutocomplete.vue +5 -1
- package/src/components/MButton.vue +15 -2
- package/src/components/MCalendar.vue +9 -5
- package/src/components/MCarousel.vue +123 -173
- package/src/components/MCodeEditor.vue +6 -1
- package/src/components/MCommandPalette.vue +4 -0
- package/src/components/MContextMenu.vue +287 -13
- package/src/components/MDatePicker.vue +12 -9
- package/src/components/MDatePickerModal.vue +9 -4
- package/src/components/MDateRangePicker.vue +12 -9
- package/src/components/MDateRangePickerModal.vue +9 -4
- package/src/components/MKanban.vue +5 -1
- package/src/components/MMenu.vue +308 -20
- package/src/components/MMenuDivider.vue +16 -0
- package/src/components/MMenuItem.vue +60 -18
- package/src/components/MMultiAutocomplete.vue +5 -1
- package/src/components/MMultiSelect.vue +5 -1
- package/src/components/MScheduler.vue +10 -6
- package/src/components/MSearchBar.vue +5 -1
- package/src/components/MSelect.vue +5 -1
- package/src/components/MShape.vue +107 -0
- package/src/components/MShortNavigationBar.vue +113 -0
- package/src/components/MSimpleCarousel.vue +325 -0
- package/src/components/MSpotlightSearch.vue +6 -0
- package/src/components/MToggleButton.vue +188 -0
- package/src/components/MTopAppBar.vue +6 -2
- package/src/components/MTree.vue +4 -2
- package/src/components/MTreeTable.vue +5 -1
- package/src/composables/useColorPalette.ts +1 -1
- package/src/index.ts +8 -1
- package/src/styles/palettes.css +22 -22
- package/dist/MMenuItem-vSLbJGqe.js.map +0 -1
|
@@ -1,129 +1,124 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { ref, computed, onMounted, onBeforeUnmount,
|
|
2
|
+
import { ref, computed, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
|
3
3
|
import MIcon from './MIcon.vue'
|
|
4
4
|
|
|
5
5
|
export interface CarouselItem {
|
|
6
6
|
src: string
|
|
7
7
|
alt?: string
|
|
8
8
|
label?: string
|
|
9
|
-
supportingText?: string
|
|
10
|
-
ratio?: number
|
|
11
9
|
}
|
|
12
10
|
|
|
11
|
+
/*
|
|
12
|
+
* Ported from the real M3 `HorizontalMultiBrowseCarousel` (Carousel.kt/Keylines.kt), not the
|
|
13
|
+
* "flat fixed-width items" look this library's old MCarousel had (now MSimpleCarousel). The real
|
|
14
|
+
* spec's signature behavior: one large "focal" item at rest, with neighbors progressively masked
|
|
15
|
+
* down toward a small "peek" size the further they are from the focal position — items grow/shrink
|
|
16
|
+
* continuously as you scroll, they're not just fixed-size slides.
|
|
17
|
+
*
|
|
18
|
+
* Real defaults ported exactly: minSmallItemWidth = MinSmallItemSize = 40dp, maxSmallItemWidth =
|
|
19
|
+
* MaxSmallItemSize = 56dp, itemSpacing = 0dp, targetSmallSize = clamp(largeSize/3, min, max), and
|
|
20
|
+
* the left-aligned focal convention (createLeftAlignedKeylineList — the focal item sits at the
|
|
21
|
+
* scroll container's left edge, not centered).
|
|
22
|
+
*
|
|
23
|
+
* Deliberately NOT ported: the real `Arrangement.findLowestCostArrangement` combinatorial search
|
|
24
|
+
* that decides exactly how many large/medium/small items fit a given width to the pixel. That's a
|
|
25
|
+
* large amount of code for a difference only visible at unusual width/item-count combinations —
|
|
26
|
+
* this uses a direct triangular falloff from the focal position instead, which converges to the
|
|
27
|
+
* same large-focal-item-with-shrinking-neighbors look for realistic carousels.
|
|
28
|
+
*/
|
|
13
29
|
const props = withDefaults(
|
|
14
30
|
defineProps<{
|
|
15
31
|
items: CarouselItem[]
|
|
16
|
-
|
|
32
|
+
/** Target width of the large, fully-visible focal item, in px (preferredItemWidth). */
|
|
33
|
+
itemWidth?: number
|
|
34
|
+
/** Spacing between item slots, in px. Real default (CarouselDefaults.ItemSpacing) is 0. */
|
|
35
|
+
itemSpacing?: number
|
|
36
|
+
/** Real default (CarouselDefaults.MinSmallItemSize) is 40. */
|
|
37
|
+
minSmallItemWidth?: number
|
|
38
|
+
/** Real default (CarouselDefaults.MaxSmallItemSize) is 56. */
|
|
39
|
+
maxSmallItemWidth?: number
|
|
17
40
|
height?: string
|
|
18
41
|
showArrows?: boolean
|
|
19
|
-
showIndicators?: boolean
|
|
20
42
|
autoplay?: boolean
|
|
21
43
|
interval?: number
|
|
22
|
-
gap?: number
|
|
23
|
-
visibleItems?: number
|
|
24
|
-
animated?: boolean
|
|
25
44
|
}>(),
|
|
26
45
|
{
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
itemWidth: 280,
|
|
47
|
+
itemSpacing: 0,
|
|
48
|
+
minSmallItemWidth: 40,
|
|
49
|
+
maxSmallItemWidth: 56,
|
|
50
|
+
height: '220px',
|
|
29
51
|
showArrows: true,
|
|
30
|
-
showIndicators: true,
|
|
31
52
|
autoplay: false,
|
|
32
53
|
interval: 5000,
|
|
33
|
-
gap: 8,
|
|
34
|
-
visibleItems: 3,
|
|
35
|
-
animated: false,
|
|
36
54
|
},
|
|
37
55
|
)
|
|
38
56
|
|
|
39
57
|
const emit = defineEmits<{ change: [index: number] }>()
|
|
40
58
|
|
|
41
|
-
const trackEl = ref<HTMLElement>()
|
|
42
|
-
const itemEls = ref<HTMLElement[]>([])
|
|
59
|
+
const trackEl = ref<HTMLElement | null>(null)
|
|
60
|
+
const itemEls = ref<(HTMLElement | null)[]>([])
|
|
61
|
+
const containerWidth = ref(0)
|
|
43
62
|
const activeIndex = ref(0)
|
|
44
|
-
const scrollPos = ref(0)
|
|
45
|
-
const isPageBased = computed(() => props.layout === 'multi-browse' || props.layout === 'uncontained')
|
|
46
63
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const track = trackEl.value
|
|
51
|
-
return Math.max(1, Math.ceil(track.scrollWidth / track.clientWidth))
|
|
52
|
-
})
|
|
64
|
+
function setItemRef(el: unknown, i: number) {
|
|
65
|
+
itemEls.value[i] = (el as HTMLElement) ?? null
|
|
66
|
+
}
|
|
53
67
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (track.scrollWidth <= track.clientWidth) return 0
|
|
59
|
-
const _ = scrollPos.value
|
|
60
|
-
return Math.round(track.scrollLeft / track.clientWidth)
|
|
68
|
+
const targetLarge = computed(() => Math.min(props.itemWidth, containerWidth.value || props.itemWidth))
|
|
69
|
+
const targetSmall = computed(() => {
|
|
70
|
+
const raw = targetLarge.value / 3
|
|
71
|
+
return Math.min(Math.max(raw, props.minSmallItemWidth), props.maxSmallItemWidth)
|
|
61
72
|
})
|
|
62
|
-
const itemTransforms = ref<string[]>([])
|
|
63
|
-
const imageTransforms = ref<string[]>([])
|
|
64
|
-
let autoTimer: ReturnType<typeof setInterval> | null = null
|
|
65
|
-
let rafId = 0
|
|
66
|
-
let scrollTimeout: ReturnType<typeof setTimeout> | null = null
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
const maskWidths = ref<number[]>([])
|
|
75
|
+
const imgOffsets = ref<number[]>([])
|
|
76
|
+
let rafId = 0
|
|
71
77
|
|
|
72
|
-
// ── Scroll handling (only transforms, never layout) ────────────
|
|
73
78
|
function onScroll() {
|
|
74
79
|
if (rafId) return
|
|
75
80
|
rafId = requestAnimationFrame(() => {
|
|
76
81
|
rafId = 0
|
|
77
|
-
|
|
82
|
+
updateMasks()
|
|
78
83
|
})
|
|
79
|
-
|
|
80
|
-
if (scrollTimeout) clearTimeout(scrollTimeout)
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
function
|
|
86
|
+
function updateMasks() {
|
|
84
87
|
if (!trackEl.value) return
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
const transforms: string[] = []
|
|
91
|
-
const imgTransforms: string[] = []
|
|
88
|
+
const trackLeft = trackEl.value.getBoundingClientRect().left
|
|
89
|
+
const large = targetLarge.value
|
|
90
|
+
const small = targetSmall.value
|
|
91
|
+
const widths: number[] = []
|
|
92
|
+
const offsets: number[] = []
|
|
92
93
|
let closest = 0
|
|
93
94
|
let closestDist = Infinity
|
|
94
95
|
|
|
95
|
-
const refX = props.layout === 'multi-browse' ? trackRect.left : centerX
|
|
96
|
-
|
|
97
96
|
for (let i = 0; i < itemEls.value.length; i++) {
|
|
98
97
|
const el = itemEls.value[i]
|
|
99
|
-
if (!el) {
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
transforms.push('')
|
|
110
|
-
} else if (props.layout === 'uncontained' && props.animated) {
|
|
111
|
-
const s = 1 - norm * 0.12
|
|
112
|
-
transforms.push(`scale(${s})`)
|
|
113
|
-
imgTransforms.push('')
|
|
98
|
+
if (!el) { widths.push(large); offsets.push(0); continue }
|
|
99
|
+
const offset = el.getBoundingClientRect().left - trackLeft
|
|
100
|
+
|
|
101
|
+
let width: number
|
|
102
|
+
let imgOffset: number
|
|
103
|
+
if (offset <= 0) {
|
|
104
|
+
// Exiting (or resting) on the left: mask grows in from the left, keep the right portion
|
|
105
|
+
// of the image visible (matches the real maskStart clipping from the item's start edge).
|
|
106
|
+
width = Math.max(large + offset, small)
|
|
107
|
+
imgOffset = -(large - width)
|
|
114
108
|
} else {
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
// Upcoming on the right: mask shrinks from the right, keep the left portion visible.
|
|
110
|
+
width = Math.max(large - offset, small)
|
|
111
|
+
imgOffset = 0
|
|
117
112
|
}
|
|
113
|
+
widths.push(width)
|
|
114
|
+
offsets.push(imgOffset)
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
closest = i
|
|
122
|
-
}
|
|
116
|
+
const dist = Math.abs(offset)
|
|
117
|
+
if (dist < closestDist) { closestDist = dist; closest = i }
|
|
123
118
|
}
|
|
124
119
|
|
|
125
|
-
|
|
126
|
-
|
|
120
|
+
maskWidths.value = widths
|
|
121
|
+
imgOffsets.value = offsets
|
|
127
122
|
|
|
128
123
|
if (closest !== activeIndex.value) {
|
|
129
124
|
activeIndex.value = closest
|
|
@@ -131,107 +126,83 @@ function updateTransforms() {
|
|
|
131
126
|
}
|
|
132
127
|
}
|
|
133
128
|
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return `${(props.items[i]?.ratio ?? 1) * 260}px`
|
|
143
|
-
default:
|
|
144
|
-
return '80%'
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
129
|
+
// The item element's own width IS the animated mask width — not a fixed-width outer "slot"
|
|
130
|
+
// with a shrinking element inside it. That was the first cut of this component, and it was
|
|
131
|
+
// wrong: shrinking an inner element while its outer flex-item stayed at the full large width
|
|
132
|
+
// just left dead space where the flex item used to be, instead of letting flex naturally close
|
|
133
|
+
// the gap by reflowing the next item up against it (exactly what the real component's keyline
|
|
134
|
+
// masking achieves, just via a different mechanism — Compose positions items directly from
|
|
135
|
+
// keyline offsets rather than relying on flow layout, but the visual result needs to be the same:
|
|
136
|
+
// no gaps between items regardless of their current mask size).
|
|
148
137
|
function itemStyle(i: number) {
|
|
149
|
-
|
|
138
|
+
return {
|
|
139
|
+
width: `${maskWidths.value[i] ?? targetLarge.value}px`,
|
|
140
|
+
height: '100%',
|
|
150
141
|
flexShrink: '0',
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const t = itemTransforms.value[i]
|
|
154
|
-
if (t) {
|
|
155
|
-
style.transform = t
|
|
156
|
-
style.transition = 'transform 120ms ease-out'
|
|
142
|
+
overflow: 'hidden',
|
|
143
|
+
position: 'relative' as const,
|
|
157
144
|
}
|
|
158
|
-
return style
|
|
159
145
|
}
|
|
160
146
|
|
|
161
147
|
function imgStyle(i: number) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
148
|
+
return {
|
|
149
|
+
width: `${targetLarge.value}px`,
|
|
150
|
+
height: '100%',
|
|
151
|
+
position: 'absolute' as const,
|
|
152
|
+
left: `${imgOffsets.value[i] ?? 0}px`,
|
|
153
|
+
top: '0',
|
|
154
|
+
}
|
|
165
155
|
}
|
|
166
156
|
|
|
167
|
-
// ── Navigation ─────────────────────────────────────────────────
|
|
168
157
|
function scrollToItem(index: number) {
|
|
169
158
|
const el = itemEls.value[index]
|
|
170
159
|
if (!el || !trackEl.value) return
|
|
171
|
-
|
|
172
|
-
const scrollLeft = el.offsetLeft - (track.clientWidth - el.offsetWidth) / 2
|
|
173
|
-
track.scrollTo({ left: scrollLeft, behavior: 'smooth' })
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function scrollToPage(page: number) {
|
|
177
|
-
if (!trackEl.value) return
|
|
178
|
-
const track = trackEl.value
|
|
179
|
-
track.scrollTo({ left: page * track.clientWidth, behavior: 'smooth' })
|
|
160
|
+
trackEl.value.scrollTo({ left: el.offsetLeft, behavior: 'smooth' })
|
|
180
161
|
}
|
|
181
162
|
|
|
182
163
|
function next() {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
trackEl.value.scrollBy({ left: trackEl.value.clientWidth, behavior: 'smooth' })
|
|
186
|
-
} else {
|
|
187
|
-
const i = activeIndex.value < props.items.length - 1 ? activeIndex.value + 1 : 0
|
|
188
|
-
scrollToItem(i)
|
|
189
|
-
}
|
|
164
|
+
const i = activeIndex.value < props.items.length - 1 ? activeIndex.value + 1 : 0
|
|
165
|
+
scrollToItem(i)
|
|
190
166
|
}
|
|
191
|
-
|
|
192
167
|
function prev() {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
trackEl.value.scrollBy({ left: -trackEl.value.clientWidth, behavior: 'smooth' })
|
|
196
|
-
} else {
|
|
197
|
-
const i = activeIndex.value > 0 ? activeIndex.value - 1 : props.items.length - 1
|
|
198
|
-
scrollToItem(i)
|
|
199
|
-
}
|
|
168
|
+
const i = activeIndex.value > 0 ? activeIndex.value - 1 : props.items.length - 1
|
|
169
|
+
scrollToItem(i)
|
|
200
170
|
}
|
|
201
171
|
|
|
172
|
+
function onKeydown(e: KeyboardEvent) {
|
|
173
|
+
if (e.key === 'ArrowRight') next()
|
|
174
|
+
else if (e.key === 'ArrowLeft') prev()
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let autoTimer: ReturnType<typeof setInterval> | null = null
|
|
202
178
|
function startAutoplay() {
|
|
203
179
|
stopAutoplay()
|
|
204
|
-
if (props.autoplay && props.items.length > 1)
|
|
205
|
-
autoTimer = setInterval(next, props.interval)
|
|
206
|
-
}
|
|
180
|
+
if (props.autoplay && props.items.length > 1) autoTimer = setInterval(next, props.interval)
|
|
207
181
|
}
|
|
208
|
-
|
|
209
182
|
function stopAutoplay() {
|
|
210
183
|
if (autoTimer) { clearInterval(autoTimer); autoTimer = null }
|
|
211
184
|
}
|
|
212
185
|
|
|
213
|
-
|
|
214
|
-
if (e.key === 'ArrowRight') next()
|
|
215
|
-
else if (e.key === 'ArrowLeft') prev()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const trackPadding = computed(() => {
|
|
219
|
-
if (props.layout === 'hero') return '0 24px'
|
|
220
|
-
if (props.layout === 'uncontained') return '0 24px'
|
|
221
|
-
return '0'
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
watch(() => props.autoplay, startAutoplay)
|
|
186
|
+
let resizeObserver: ResizeObserver | null = null
|
|
225
187
|
onMounted(() => {
|
|
188
|
+
if (trackEl.value) {
|
|
189
|
+
containerWidth.value = trackEl.value.clientWidth
|
|
190
|
+
resizeObserver = new ResizeObserver(() => {
|
|
191
|
+
if (trackEl.value) containerWidth.value = trackEl.value.clientWidth
|
|
192
|
+
updateMasks()
|
|
193
|
+
})
|
|
194
|
+
resizeObserver.observe(trackEl.value)
|
|
195
|
+
}
|
|
196
|
+
nextTick(updateMasks)
|
|
226
197
|
startAutoplay()
|
|
227
|
-
nextTick(() => updateTransforms())
|
|
228
198
|
})
|
|
229
199
|
onBeforeUnmount(() => {
|
|
230
200
|
stopAutoplay()
|
|
231
201
|
if (rafId) cancelAnimationFrame(rafId)
|
|
202
|
+
resizeObserver?.disconnect()
|
|
232
203
|
})
|
|
233
204
|
|
|
234
|
-
defineExpose({ next, prev, scrollToItem
|
|
205
|
+
defineExpose({ next, prev, scrollToItem })
|
|
235
206
|
</script>
|
|
236
207
|
|
|
237
208
|
<template>
|
|
@@ -245,30 +216,27 @@ defineExpose({ next, prev, scrollToItem, scrollToPage })
|
|
|
245
216
|
<div
|
|
246
217
|
ref="trackEl"
|
|
247
218
|
class="carousel-track flex overflow-x-auto"
|
|
248
|
-
:
|
|
249
|
-
:style="{ height, gap: `${gap}px`, padding: trackPadding }"
|
|
219
|
+
:style="{ height, gap: `${itemSpacing}px` }"
|
|
250
220
|
@scroll.passive="onScroll"
|
|
251
221
|
>
|
|
252
222
|
<div
|
|
253
223
|
v-for="(item, i) in items"
|
|
254
224
|
:key="i"
|
|
255
225
|
:ref="(el) => setItemRef(el, i)"
|
|
256
|
-
class="
|
|
226
|
+
class="rounded-2xl"
|
|
257
227
|
:style="itemStyle(i)"
|
|
258
228
|
>
|
|
259
229
|
<img
|
|
260
230
|
:src="item.src"
|
|
261
231
|
:alt="item.alt ?? item.label ?? ''"
|
|
262
|
-
class="pointer-events-none
|
|
232
|
+
class="pointer-events-none object-cover"
|
|
263
233
|
:style="imgStyle(i)"
|
|
264
234
|
/>
|
|
265
|
-
|
|
266
235
|
<div
|
|
267
|
-
v-if="item.label
|
|
268
|
-
class="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 via-black/30 to-transparent px-
|
|
236
|
+
v-if="item.label"
|
|
237
|
+
class="absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 via-black/30 to-transparent px-4 pb-3 pt-8"
|
|
269
238
|
>
|
|
270
|
-
<p
|
|
271
|
-
<p v-if="item.supportingText" class="mt-0.5 text-body-small text-white/80">{{ item.supportingText }}</p>
|
|
239
|
+
<p class="text-title-medium font-medium text-white">{{ item.label }}</p>
|
|
272
240
|
</div>
|
|
273
241
|
</div>
|
|
274
242
|
</div>
|
|
@@ -289,22 +257,7 @@ defineExpose({ next, prev, scrollToItem, scrollToPage })
|
|
|
289
257
|
<MIcon name="chevron_right" :size="24" />
|
|
290
258
|
</button>
|
|
291
259
|
</template>
|
|
292
|
-
|
|
293
|
-
</div>
|
|
294
|
-
|
|
295
|
-
<div
|
|
296
|
-
v-if="showIndicators && totalPages > 1"
|
|
297
|
-
class="flex justify-center gap-1.5 pt-3"
|
|
298
|
-
>
|
|
299
|
-
<button
|
|
300
|
-
v-for="p in totalPages"
|
|
301
|
-
:key="p"
|
|
302
|
-
type="button"
|
|
303
|
-
class="h-2 cursor-pointer rounded-full transition-all duration-300"
|
|
304
|
-
:class="(p - 1) === activePage ? 'w-5 bg-on-surface' : 'w-2 bg-on-surface/30 hover:bg-on-surface/50'"
|
|
305
|
-
@click="isPageBased ? scrollToPage(p - 1) : scrollToItem(p - 1)"
|
|
306
|
-
/>
|
|
307
|
-
</div>
|
|
260
|
+
</div>
|
|
308
261
|
</template>
|
|
309
262
|
|
|
310
263
|
<style scoped>
|
|
@@ -316,10 +269,7 @@ defineExpose({ next, prev, scrollToItem, scrollToPage })
|
|
|
316
269
|
.carousel-track::-webkit-scrollbar {
|
|
317
270
|
display: none;
|
|
318
271
|
}
|
|
319
|
-
.
|
|
320
|
-
scroll-snap-align: center;
|
|
321
|
-
}
|
|
322
|
-
.snap-start > * {
|
|
272
|
+
.carousel-track > * {
|
|
323
273
|
scroll-snap-align: start;
|
|
324
274
|
}
|
|
325
275
|
</style>
|
|
@@ -307,7 +307,12 @@ onBeforeUnmount(() => view?.destroy())
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
.code-editor-container :deep(.cm-activeLine) {
|
|
310
|
-
|
|
310
|
+
/* CodeMirror renders the selection highlight on a layer with z-index: -1
|
|
311
|
+
(@codemirror/view's selectionLayer has `above: false` by design, so it always
|
|
312
|
+
sits behind the line content). An opaque active-line background would paint
|
|
313
|
+
straight over it and hide the selection on the current line — this needs to
|
|
314
|
+
stay a translucent tint so a selection underneath still shows through. */
|
|
315
|
+
background: color-mix(in srgb, var(--color-on-surface) 5%, transparent);
|
|
311
316
|
}
|
|
312
317
|
|
|
313
318
|
.code-editor-container :deep(.cm-selectionBackground) {
|
|
@@ -99,6 +99,10 @@ function scrollToActive() {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
function onGlobalKeydown(e: KeyboardEvent) {
|
|
102
|
+
// See MSpotlightSearch for why: each mounted instance listens for its own
|
|
103
|
+
// hotkey independently, so if more than one is mounted at once, a single
|
|
104
|
+
// keypress would otherwise toggle all of them. First one to handle it wins.
|
|
105
|
+
if (e.defaultPrevented) return
|
|
102
106
|
if ((e.metaKey || e.ctrlKey) && e.key === props.hotkey) {
|
|
103
107
|
e.preventDefault()
|
|
104
108
|
if (props.modelValue) close()
|