@m3ui-vue/m3ui-vue 0.6.1 → 0.6.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 +3 -0
- package/dist/MIcon-CaEooCmZ.js.map +1 -1
- package/dist/{MMenuItem-DbbrJhFE.js → MMenuItem-C7jKU-Qh.js} +13 -13
- package/dist/{MMenuItem-DbbrJhFE.js.map → MMenuItem-C7jKU-Qh.js.map} +1 -1
- package/dist/barcode.js.map +1 -1
- package/dist/chart.js +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/code-editor.js +1 -1
- package/dist/code-editor.js.map +1 -1
- package/dist/{common-VrOaLkjh.js → common-0dgrgaPL.js} +287 -213
- package/dist/common-0dgrgaPL.js.map +1 -0
- package/dist/components/MBar.vue.d.ts +58 -0
- package/dist/components/MPageProgress.vue.d.ts +15 -0
- package/dist/components/MSlider.vue.d.ts +6 -0
- package/dist/components/MWindow.vue.d.ts +1 -1
- package/dist/composables/usePageProgress.d.ts +19 -0
- package/dist/{dist-Dsrzt6J5.js → dist-CrjSW5DN.js} +248 -241
- package/dist/{dist-Dsrzt6J5.js.map → dist-CrjSW5DN.js.map} +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/m3ui-vue.css +1 -1
- package/dist/m3ui.js +2918 -2639
- package/dist/m3ui.js.map +1 -1
- package/dist/markdown.js +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/qrcode.js.map +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/rich-text-editor.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/terminal.js.map +1 -1
- package/package.json +26 -26
- package/src/__tests__/usePageProgress.test.ts +52 -0
- package/src/components/MBar.vue +158 -0
- package/src/components/MPageProgress.vue +62 -0
- package/src/components/MSlider.vue +174 -52
- package/src/composables/usePageProgress.ts +49 -0
- package/src/index.ts +3 -0
- package/dist/common-VrOaLkjh.js.map +0 -1
|
@@ -18,6 +18,12 @@ const props = withDefaults(
|
|
|
18
18
|
stops?: boolean
|
|
19
19
|
icon?: string
|
|
20
20
|
color?: 'primary' | 'secondary' | 'tertiary' | 'error'
|
|
21
|
+
/** Custom color (hex, rgb(), a CSS var, etc.) for the filled/active portion of the track and the corner dot. Defaults to `color`'s M3 token. */
|
|
22
|
+
fillColor?: string
|
|
23
|
+
/** Replaces the draggable bar thumb with an icon. */
|
|
24
|
+
thumbIcon?: string
|
|
25
|
+
/** Custom color (hex, rgb(), a CSS var, etc.) for the thumb (bar or icon). Defaults to `color`'s M3 token. */
|
|
26
|
+
thumbColor?: string
|
|
21
27
|
}>(),
|
|
22
28
|
{
|
|
23
29
|
min: 0,
|
|
@@ -59,26 +65,67 @@ const pctLo = computed(() => toPct(val.value.lo))
|
|
|
59
65
|
const pctHi = computed(() => toPct(val.value.hi))
|
|
60
66
|
const centerPct = computed(() => toPct(0))
|
|
61
67
|
|
|
68
|
+
// Start/end anchor dots hide once the fill has actually covered their spot —
|
|
69
|
+
// visible while that corner is still "unreached" track, hidden once passed.
|
|
70
|
+
// Standard never gets a start indicator at all (matches the official M3
|
|
71
|
+
// slider: only the far/unreached end is ever marked).
|
|
72
|
+
const startDotHidden = computed(() => {
|
|
73
|
+
if (props.variant === 'centered') return Math.min(pctLo.value, centerPct.value) <= 0
|
|
74
|
+
if (props.variant === 'range') return pctLo.value <= 0
|
|
75
|
+
return true
|
|
76
|
+
})
|
|
77
|
+
const endDotHidden = computed(() => {
|
|
78
|
+
if (props.variant === 'centered') return Math.max(pctLo.value, centerPct.value) >= 100
|
|
79
|
+
if (props.variant === 'range') return pctHi.value >= 100
|
|
80
|
+
return pctLo.value >= 100
|
|
81
|
+
})
|
|
82
|
+
|
|
62
83
|
const sizeMap = {
|
|
63
|
-
xs: { track: 16, thumbW: 4, thumbH:
|
|
64
|
-
sm: { track: 28, thumbW: 4, thumbH:
|
|
65
|
-
md: { track: 54, thumbW: 5, thumbH:
|
|
66
|
-
lg: { track: 72, thumbW: 5, thumbH:
|
|
67
|
-
xl: { track: 96, thumbW: 6, thumbH:
|
|
84
|
+
xs: { track: 16, thumbW: 4, thumbH: 32, dot: 4, gap: 7, hitArea: 38, radius: 6, dotInset: 12, thumbInset: 5, iconSize: 14, thumbIconSize: 22 },
|
|
85
|
+
sm: { track: 28, thumbW: 4, thumbH: 40, dot: 5, gap: 7, hitArea: 46, radius: 8, dotInset: 13, thumbInset: 6, iconSize: 16, thumbIconSize: 28 },
|
|
86
|
+
md: { track: 54, thumbW: 5, thumbH: 62, dot: 5, gap: 8, hitArea: 66, radius: 12, dotInset: 15, thumbInset: 7, iconSize: 20, thumbIconSize: 42 },
|
|
87
|
+
lg: { track: 72, thumbW: 5, thumbH: 78, dot: 6, gap: 10, hitArea: 82, radius: 14, dotInset: 17, thumbInset: 8, iconSize: 24, thumbIconSize: 52 },
|
|
88
|
+
xl: { track: 96, thumbW: 6, thumbH: 98, dot: 7, gap: 10, hitArea: 100, radius: 18, dotInset: 19, thumbInset: 9, iconSize: 28, thumbIconSize: 66 },
|
|
68
89
|
}
|
|
69
90
|
|
|
70
91
|
const s = computed(() => sizeMap[props.size] ?? sizeMap.xs)
|
|
71
92
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
93
|
+
// The corner `icon` is much bigger than the plain dot, so dotInset alone
|
|
94
|
+
// isn't enough clearance from the thumb's resting spot — it reads as jammed
|
|
95
|
+
// into the corner right at 0%/100%. Give it its own, thumb-aware inset. This
|
|
96
|
+
// only meaningfully changes the "not yet reached" look; once the thumb has
|
|
97
|
+
// moved past, it's already far away regardless of the exact inset.
|
|
98
|
+
const iconInset = computed(() => s.value.thumbInset + s.value.thumbW / 2 + s.value.iconSize / 2 + 3)
|
|
99
|
+
|
|
100
|
+
// A thumbIcon is much wider along the travel axis than the plain bar, so the
|
|
101
|
+
// fixed track gap isn't enough to clear it — it'd visually touch the fill on
|
|
102
|
+
// both sides. Widen the gap to the icon's own half-width when thumbIcon is set.
|
|
103
|
+
const gap = computed(() => {
|
|
104
|
+
if (!props.thumbIcon) return s.value.gap
|
|
105
|
+
return Math.max(s.value.gap, s.value.thumbIconSize / 2 + 4)
|
|
80
106
|
})
|
|
81
107
|
|
|
108
|
+
const paletteMap: Record<string, { active: string; inactive: string }> = {
|
|
109
|
+
primary: { active: 'var(--color-primary)', inactive: 'var(--color-primary-container)' },
|
|
110
|
+
secondary: { active: 'var(--color-secondary)', inactive: 'var(--color-secondary-container)' },
|
|
111
|
+
tertiary: { active: 'var(--color-tertiary)', inactive: 'var(--color-tertiary-container)' },
|
|
112
|
+
error: { active: 'var(--color-error)', inactive: 'var(--color-error-container)' },
|
|
113
|
+
}
|
|
114
|
+
// `fillColor`/`thumbColor` accept a custom CSS color (hex, rgb(), a var, …) —
|
|
115
|
+
// not just an M3 role — that's the point of a "custom color" prop, otherwise
|
|
116
|
+
// it'd just duplicate `color`. A known role name still works as a shortcut.
|
|
117
|
+
// For a custom color there's no ready-made "container" tone, so the inactive
|
|
118
|
+
// shade is derived by mixing it down against the current surface.
|
|
119
|
+
function resolvePalette(custom: string | undefined, base: 'primary' | 'secondary' | 'tertiary' | 'error') {
|
|
120
|
+
const value = custom ?? base
|
|
121
|
+
if (value in paletteMap) return paletteMap[value]!
|
|
122
|
+
return { active: value, inactive: `color-mix(in srgb, ${value} 30%, var(--color-surface-container-highest))` }
|
|
123
|
+
}
|
|
124
|
+
// `ct` (fill + corner dot) and `thumbCt` (thumb bar/icon) each fall back to the
|
|
125
|
+
// base `color` prop, but can be overridden independently via `fillColor`/`thumbColor`.
|
|
126
|
+
const ct = computed(() => resolvePalette(props.fillColor, props.color))
|
|
127
|
+
const thumbCt = computed(() => resolvePalette(props.thumbColor, props.color))
|
|
128
|
+
|
|
82
129
|
function clamp(v: number) {
|
|
83
130
|
const stepped = Math.round((v - props.min) / props.step) * props.step + props.min
|
|
84
131
|
return Math.max(props.min, Math.min(props.max, +stepped.toFixed(10)))
|
|
@@ -173,31 +220,97 @@ const stopPositions = computed(() => {
|
|
|
173
220
|
return positions.length <= 28 ? positions : []
|
|
174
221
|
})
|
|
175
222
|
|
|
223
|
+
// Standard variant: the fill pill always keeps a gap on the side facing the
|
|
224
|
+
// thumb, even at 0%/100% — matches the official M3 slider, which never lets
|
|
225
|
+
// the track touch the handle.
|
|
226
|
+
// Standard variant fill edges must track the thumb's *clamped* position, not
|
|
227
|
+
// the raw pct — otherwise, near 0%/100% where the thumb is pinned by
|
|
228
|
+
// thumbInset, the pill (still sized off the raw value) creeps past the pinned
|
|
229
|
+
// thumb and swallows the gap that's supposed to stay visible there.
|
|
230
|
+
function fillActiveSize(pct: number) {
|
|
231
|
+
return `calc(${clampedPos(pct)} - ${gap.value}px)`
|
|
232
|
+
}
|
|
233
|
+
function fillInactiveSize(pct: number) {
|
|
234
|
+
return `calc(100% - ${clampedPos(pct)} - ${gap.value}px)`
|
|
235
|
+
}
|
|
236
|
+
|
|
176
237
|
const r = computed(() => s.value.radius)
|
|
238
|
+
const smallR = computed(() => Math.max(2, r.value / 4))
|
|
239
|
+
|
|
240
|
+
// Standard variant only: the pill's outer end (away from the thumb) stays
|
|
241
|
+
// fully rounded like a cap; the end facing the thumb-gap goes square, matching
|
|
242
|
+
// the official M3 slider's track segments.
|
|
243
|
+
function pillRadiusOuterStart() {
|
|
244
|
+
return isVertical.value
|
|
245
|
+
? `${smallR.value}px ${smallR.value}px ${r.value}px ${r.value}px`
|
|
246
|
+
: `${r.value}px ${smallR.value}px ${smallR.value}px ${r.value}px`
|
|
247
|
+
}
|
|
248
|
+
function pillRadiusOuterEnd() {
|
|
249
|
+
return isVertical.value
|
|
250
|
+
? `${r.value}px ${r.value}px ${smallR.value}px ${smallR.value}px`
|
|
251
|
+
: `${smallR.value}px ${r.value}px ${r.value}px ${smallR.value}px`
|
|
252
|
+
}
|
|
177
253
|
const nd = computed(() => dragging.value === false)
|
|
178
254
|
const tr = computed(() => nd.value ? '75ms ease' : '0s')
|
|
179
255
|
|
|
256
|
+
// Keeps the thumb from ever touching the very ends of the track. Sits closer
|
|
257
|
+
// to the edge than the corner dot (dot stays visible further in, toward
|
|
258
|
+
// center) — only bites near 0%/100%; elsewhere it's a no-op (thumb still
|
|
259
|
+
// tracks pct% exactly, staying flush with the fill edge as always).
|
|
260
|
+
function clampedPos(pct: number) {
|
|
261
|
+
const inset = s.value.thumbInset
|
|
262
|
+
return `clamp(${inset}px, ${pct}%, calc(100% - ${inset}px))`
|
|
263
|
+
}
|
|
264
|
+
|
|
180
265
|
function thumbPos(pct: number) {
|
|
181
266
|
const tw = isVertical.value ? s.value.thumbH : s.value.thumbW
|
|
182
267
|
const th = isVertical.value ? s.value.thumbW : s.value.thumbH
|
|
183
268
|
const br = Math.min(tw, th) / 2
|
|
269
|
+
const isDragging = dragging.value !== false
|
|
184
270
|
const base: Record<string, string> = {
|
|
185
271
|
position: 'absolute',
|
|
186
272
|
width: `${tw}px`,
|
|
187
273
|
height: `${th}px`,
|
|
188
274
|
borderRadius: `${br}px`,
|
|
189
|
-
backgroundColor:
|
|
275
|
+
backgroundColor: thumbCt.value.active,
|
|
190
276
|
zIndex: '2',
|
|
191
277
|
transition: nd.value ? 'left 75ms ease, bottom 75ms ease, transform 80ms ease' : 'transform 80ms ease',
|
|
192
278
|
}
|
|
279
|
+
// Pressed state pinches the thumb thinner along the travel axis (like the
|
|
280
|
+
// official M3 slider handle) while slightly growing the cross axis.
|
|
281
|
+
const grow = isDragging ? 1.08 : 1
|
|
282
|
+
const narrow = isDragging ? 0.6 : 1
|
|
193
283
|
if (isVertical.value) {
|
|
194
284
|
base.left = '50%'
|
|
195
|
-
base.bottom =
|
|
196
|
-
base.transform = `translateX(-50%) translateY(50%) scaleX(${
|
|
285
|
+
base.bottom = clampedPos(pct)
|
|
286
|
+
base.transform = `translateX(-50%) translateY(50%) scaleX(${grow}) scaleY(${narrow})`
|
|
197
287
|
} else {
|
|
198
|
-
base.left =
|
|
288
|
+
base.left = clampedPos(pct)
|
|
199
289
|
base.top = '50%'
|
|
200
|
-
base.transform = `translateX(-50%) translateY(-50%) scaleY(${
|
|
290
|
+
base.transform = `translateX(-50%) translateY(-50%) scaleY(${grow}) scaleX(${narrow})`
|
|
291
|
+
}
|
|
292
|
+
return base
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Icon-thumb variant: same clamped position, but grows slightly on press
|
|
296
|
+
// instead of pinching thin (an icon can't sensibly narrow).
|
|
297
|
+
function thumbIconPos(pct: number) {
|
|
298
|
+
const isDragging = dragging.value !== false
|
|
299
|
+
const scale = isDragging ? 1.15 : 1
|
|
300
|
+
const base: Record<string, string> = {
|
|
301
|
+
position: 'absolute',
|
|
302
|
+
color: thumbCt.value.active,
|
|
303
|
+
zIndex: '2',
|
|
304
|
+
transition: nd.value ? 'left 75ms ease, bottom 75ms ease, transform 80ms ease' : 'transform 80ms ease',
|
|
305
|
+
}
|
|
306
|
+
if (isVertical.value) {
|
|
307
|
+
base.left = '50%'
|
|
308
|
+
base.bottom = clampedPos(pct)
|
|
309
|
+
base.transform = `translateX(-50%) translateY(50%) scale(${scale})`
|
|
310
|
+
} else {
|
|
311
|
+
base.left = clampedPos(pct)
|
|
312
|
+
base.top = '50%'
|
|
313
|
+
base.transform = `translateX(-50%) translateY(-50%) scale(${scale})`
|
|
201
314
|
}
|
|
202
315
|
return base
|
|
203
316
|
}
|
|
@@ -206,9 +319,9 @@ function tooltipPos(pct: number) {
|
|
|
206
319
|
const offsetH = s.value.track / 2 + 36
|
|
207
320
|
const offsetV = s.value.track / 2 + 40
|
|
208
321
|
if (isVertical.value) {
|
|
209
|
-
return { left: `calc(50% - ${offsetV}px)`, bottom:
|
|
322
|
+
return { left: `calc(50% - ${offsetV}px)`, bottom: clampedPos(pct), transform: 'translateY(50%)', transition: nd.value ? 'bottom ' + tr.value : 'none' }
|
|
210
323
|
}
|
|
211
|
-
return { left:
|
|
324
|
+
return { left: clampedPos(pct), top: `calc(50% - ${offsetH}px)`, transform: 'translateX(-50%)', transition: nd.value ? 'left ' + tr.value : 'none' }
|
|
212
325
|
}
|
|
213
326
|
|
|
214
327
|
const displayValue = computed(() => {
|
|
@@ -268,17 +381,17 @@ const tooltipPct = computed(() => {
|
|
|
268
381
|
<template v-if="variant === 'standard'">
|
|
269
382
|
<div class="absolute" :style="{
|
|
270
383
|
...(isVertical
|
|
271
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
272
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
384
|
+
? { left: 0, right: 0, bottom: 0, height: fillActiveSize(pctLo) }
|
|
385
|
+
: { top: 0, bottom: 0, left: 0, width: fillActiveSize(pctLo) }
|
|
273
386
|
),
|
|
274
|
-
borderRadius:
|
|
387
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
275
388
|
}" />
|
|
276
389
|
<div class="absolute" :style="{
|
|
277
390
|
...(isVertical
|
|
278
|
-
? { left: 0, right: 0, top: 0, height:
|
|
279
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
391
|
+
? { left: 0, right: 0, top: 0, height: fillInactiveSize(pctLo) }
|
|
392
|
+
: { top: 0, bottom: 0, right: 0, width: fillInactiveSize(pctLo) }
|
|
280
393
|
),
|
|
281
|
-
borderRadius:
|
|
394
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
282
395
|
}" />
|
|
283
396
|
</template>
|
|
284
397
|
|
|
@@ -288,27 +401,27 @@ const tooltipPct = computed(() => {
|
|
|
288
401
|
<div class="absolute" :style="{
|
|
289
402
|
...(isVertical
|
|
290
403
|
? pctLo >= centerPct
|
|
291
|
-
? { left: 0, right: 0, bottom: `${centerPct}%`, height: `calc(${pctLo - centerPct}% - ${
|
|
292
|
-
: { left: 0, right: 0, bottom: `calc(${pctLo}% + ${
|
|
404
|
+
? { left: 0, right: 0, bottom: `${centerPct}%`, height: `calc(${pctLo - centerPct}% - ${gap}px)` }
|
|
405
|
+
: { left: 0, right: 0, bottom: `calc(${pctLo}% + ${gap}px)`, height: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
293
406
|
: pctLo >= centerPct
|
|
294
|
-
? { top: 0, bottom: 0, left: `${centerPct}%`, width: `calc(${pctLo - centerPct}% - ${
|
|
295
|
-
: { top: 0, bottom: 0, left: `calc(${pctLo}% + ${
|
|
407
|
+
? { top: 0, bottom: 0, left: `${centerPct}%`, width: `calc(${pctLo - centerPct}% - ${gap}px)` }
|
|
408
|
+
: { top: 0, bottom: 0, left: `calc(${pctLo}% + ${gap}px)`, width: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
296
409
|
),
|
|
297
410
|
borderRadius: `${r}px`, backgroundColor: ct.active, transition: `all ${tr}`,
|
|
298
411
|
}" />
|
|
299
412
|
<!-- Inactive: above/right of thumb -->
|
|
300
413
|
<div class="absolute" :style="{
|
|
301
414
|
...(isVertical
|
|
302
|
-
? { left: 0, right: 0, top: 0, height: `calc(${100 - Math.max(pctLo, centerPct)}% - ${
|
|
303
|
-
: { top: 0, bottom: 0, right: 0, width: `calc(${100 - Math.max(pctLo, centerPct)}% - ${
|
|
415
|
+
? { left: 0, right: 0, top: 0, height: `calc(${100 - Math.max(pctLo, centerPct)}% - ${gap}px)` }
|
|
416
|
+
: { top: 0, bottom: 0, right: 0, width: `calc(${100 - Math.max(pctLo, centerPct)}% - ${gap}px)` }
|
|
304
417
|
),
|
|
305
418
|
borderRadius: `${r}px`, backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
306
419
|
}" />
|
|
307
420
|
<!-- Inactive: below/left of thumb -->
|
|
308
421
|
<div class="absolute" :style="{
|
|
309
422
|
...(isVertical
|
|
310
|
-
? { left: 0, right: 0, bottom: 0, height: `calc(${Math.min(pctLo, centerPct)}% - ${
|
|
311
|
-
: { top: 0, bottom: 0, left: 0, width: `calc(${Math.min(pctLo, centerPct)}% - ${
|
|
423
|
+
? { left: 0, right: 0, bottom: 0, height: `calc(${Math.min(pctLo, centerPct)}% - ${gap}px)` }
|
|
424
|
+
: { top: 0, bottom: 0, left: 0, width: `calc(${Math.min(pctLo, centerPct)}% - ${gap}px)` }
|
|
312
425
|
),
|
|
313
426
|
borderRadius: `${r}px`, backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
314
427
|
}" />
|
|
@@ -318,22 +431,22 @@ const tooltipPct = computed(() => {
|
|
|
318
431
|
<template v-else-if="variant === 'range'">
|
|
319
432
|
<div class="absolute" :style="{
|
|
320
433
|
...(isVertical
|
|
321
|
-
? { left: 0, right: 0, bottom: 0, height: `calc(${pctLo}% - ${
|
|
322
|
-
: { top: 0, bottom: 0, left: 0, width: `calc(${pctLo}% - ${
|
|
434
|
+
? { left: 0, right: 0, bottom: 0, height: `calc(${pctLo}% - ${gap}px)` }
|
|
435
|
+
: { top: 0, bottom: 0, left: 0, width: `calc(${pctLo}% - ${gap}px)` }
|
|
323
436
|
),
|
|
324
437
|
borderRadius: `${r}px`, backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
325
438
|
}" />
|
|
326
439
|
<div class="absolute" :style="{
|
|
327
440
|
...(isVertical
|
|
328
|
-
? { left: 0, right: 0, bottom: `calc(${pctLo}% + ${
|
|
329
|
-
: { top: 0, bottom: 0, left: `calc(${pctLo}% + ${
|
|
441
|
+
? { left: 0, right: 0, bottom: `calc(${pctLo}% + ${gap}px)`, height: `calc(${pctHi - pctLo}% - ${gap * 2}px)` }
|
|
442
|
+
: { top: 0, bottom: 0, left: `calc(${pctLo}% + ${gap}px)`, width: `calc(${pctHi - pctLo}% - ${gap * 2}px)` }
|
|
330
443
|
),
|
|
331
444
|
borderRadius: `${r}px`, backgroundColor: ct.active, transition: `all ${tr}`,
|
|
332
445
|
}" />
|
|
333
446
|
<div class="absolute" :style="{
|
|
334
447
|
...(isVertical
|
|
335
|
-
? { left: 0, right: 0, top: 0, height: `calc(${100 - pctHi}% - ${
|
|
336
|
-
: { top: 0, bottom: 0, right: 0, width: `calc(${100 - pctHi}% - ${
|
|
448
|
+
? { left: 0, right: 0, top: 0, height: `calc(${100 - pctHi}% - ${gap}px)` }
|
|
449
|
+
: { top: 0, bottom: 0, right: 0, width: `calc(${100 - pctHi}% - ${gap}px)` }
|
|
337
450
|
),
|
|
338
451
|
borderRadius: `${r}px`, backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
339
452
|
}" />
|
|
@@ -348,8 +461,8 @@ const tooltipPct = computed(() => {
|
|
|
348
461
|
:style="{
|
|
349
462
|
color: (variant === 'standard' && pctLo > 0) || (variant === 'range' && pctLo > 0) ? ct.inactive : ct.active,
|
|
350
463
|
...(isVertical
|
|
351
|
-
? { left: '50%', bottom: `${
|
|
352
|
-
: { top: '50%', left: `${
|
|
464
|
+
? { left: '50%', bottom: `${iconInset}px`, transform: 'translateX(-50%)' }
|
|
465
|
+
: { top: '50%', left: `${iconInset}px`, transform: 'translateY(-50%)' }
|
|
353
466
|
),
|
|
354
467
|
transition: 'color 150ms ease',
|
|
355
468
|
}"
|
|
@@ -359,12 +472,13 @@ const tooltipPct = computed(() => {
|
|
|
359
472
|
class="absolute rounded-full"
|
|
360
473
|
:style="{
|
|
361
474
|
width: `${s.dot}px`, height: `${s.dot}px`,
|
|
362
|
-
backgroundColor:
|
|
475
|
+
backgroundColor: ct.active,
|
|
476
|
+
opacity: startDotHidden ? 0 : 1,
|
|
363
477
|
...(isVertical
|
|
364
|
-
? { left: '50%', bottom: `${s.
|
|
365
|
-
: { top: '50%', left: `${s.
|
|
478
|
+
? { left: '50%', bottom: `${s.dotInset}px`, transform: 'translateX(-50%)' }
|
|
479
|
+
: { top: '50%', left: `${s.dotInset}px`, transform: 'translateY(-50%)' }
|
|
366
480
|
),
|
|
367
|
-
transition: '
|
|
481
|
+
transition: 'opacity 150ms ease',
|
|
368
482
|
}"
|
|
369
483
|
/>
|
|
370
484
|
<!-- End dot -->
|
|
@@ -373,12 +487,13 @@ const tooltipPct = computed(() => {
|
|
|
373
487
|
class="absolute rounded-full"
|
|
374
488
|
:style="{
|
|
375
489
|
width: `${s.dot}px`, height: `${s.dot}px`,
|
|
376
|
-
backgroundColor:
|
|
490
|
+
backgroundColor: ct.active,
|
|
491
|
+
opacity: endDotHidden ? 0 : 1,
|
|
377
492
|
...(isVertical
|
|
378
|
-
? { left: '50%', top: `${s.
|
|
379
|
-
: { top: '50%', right: `${s.
|
|
493
|
+
? { left: '50%', top: `${s.dotInset}px`, transform: 'translateX(-50%)' }
|
|
494
|
+
: { top: '50%', right: `${s.dotInset}px`, transform: 'translateY(-50%)' }
|
|
380
495
|
),
|
|
381
|
-
transition: '
|
|
496
|
+
transition: 'opacity 150ms ease',
|
|
382
497
|
}"
|
|
383
498
|
/>
|
|
384
499
|
|
|
@@ -391,6 +506,7 @@ const tooltipPct = computed(() => {
|
|
|
391
506
|
:style="{
|
|
392
507
|
width: `${s.dot}px`, height: `${s.dot}px`,
|
|
393
508
|
backgroundColor: pos <= pctLo ? ct.inactive : ct.active,
|
|
509
|
+
opacity: Math.abs(pos - pctLo) < 0.01 || (isRange && Math.abs(pos - pctHi) < 0.01) ? 0 : 1,
|
|
394
510
|
...(isVertical
|
|
395
511
|
? { left: '50%', bottom: `${pos}%`, transform: 'translateX(-50%) translateY(50%)' }
|
|
396
512
|
: { top: '50%', left: `${pos}%`, transform: 'translateX(-50%) translateY(-50%)' }
|
|
@@ -401,8 +517,14 @@ const tooltipPct = computed(() => {
|
|
|
401
517
|
</div>
|
|
402
518
|
|
|
403
519
|
<!-- Thumb(s) -->
|
|
404
|
-
<
|
|
405
|
-
|
|
520
|
+
<template v-if="thumbIcon">
|
|
521
|
+
<MIcon :name="thumbIcon" :size="s.thumbIconSize" class="pointer-events-none" :style="thumbIconPos(pctLo)" />
|
|
522
|
+
<MIcon v-if="isRange" :name="thumbIcon" :size="s.thumbIconSize" class="pointer-events-none" :style="thumbIconPos(pctHi)" />
|
|
523
|
+
</template>
|
|
524
|
+
<template v-else>
|
|
525
|
+
<div class="pointer-events-none" :style="thumbPos(pctLo)" />
|
|
526
|
+
<div v-if="isRange" class="pointer-events-none" :style="thumbPos(pctHi)" />
|
|
527
|
+
</template>
|
|
406
528
|
|
|
407
529
|
<!-- Tooltip -->
|
|
408
530
|
<Transition
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
|
|
3
|
+
const progress = ref(0)
|
|
4
|
+
const isActive = ref(false)
|
|
5
|
+
|
|
6
|
+
let hideTimer: ReturnType<typeof setTimeout> | null = null
|
|
7
|
+
let trickleTimer: ReturnType<typeof setInterval> | null = null
|
|
8
|
+
|
|
9
|
+
function clearTimers() {
|
|
10
|
+
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null }
|
|
11
|
+
if (trickleTimer) { clearInterval(trickleTimer); trickleTimer = null }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Starts (or restarts) the bar and trickles it toward 90% while the real work finishes. */
|
|
15
|
+
function start() {
|
|
16
|
+
clearTimers()
|
|
17
|
+
isActive.value = true
|
|
18
|
+
progress.value = 5
|
|
19
|
+
|
|
20
|
+
trickleTimer = setInterval(() => {
|
|
21
|
+
if (progress.value < 90) progress.value += (90 - progress.value) * 0.1
|
|
22
|
+
}, 200)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Sets an explicit percentage, for callers that know real progress (e.g. an upload). */
|
|
26
|
+
function set(pct: number) {
|
|
27
|
+
clearTimers()
|
|
28
|
+
isActive.value = true
|
|
29
|
+
progress.value = Math.min(100, Math.max(0, pct))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Completes the bar and fades it out. */
|
|
33
|
+
function done() {
|
|
34
|
+
clearTimers()
|
|
35
|
+
progress.value = 100
|
|
36
|
+
hideTimer = setTimeout(() => {
|
|
37
|
+
isActive.value = false
|
|
38
|
+
progress.value = 0
|
|
39
|
+
}, 200)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Shared page-loading progress state (e.g. for a top progress bar between route
|
|
44
|
+
* navigations). Module-level so any number of callers/components stay in sync —
|
|
45
|
+
* call `start()`/`done()` from a router guard, a fetch wrapper, or by hand.
|
|
46
|
+
*/
|
|
47
|
+
export function usePageProgress() {
|
|
48
|
+
return { progress, isActive, start, set, done }
|
|
49
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { useDevice } from './composables/useDevice'
|
|
|
16
16
|
export { useNotification } from './composables/useNotification'
|
|
17
17
|
export type { Notification, NotificationVariant, NotificationPosition, NotificationOptions } from './composables/useNotification'
|
|
18
18
|
export { useDebounce } from './composables/useDebounce'
|
|
19
|
+
export { usePageProgress } from './composables/usePageProgress'
|
|
19
20
|
|
|
20
21
|
// Components
|
|
21
22
|
export { default as MAbsolute } from './components/MAbsolute.vue'
|
|
@@ -26,6 +27,7 @@ export { default as MAppLayout } from './components/MAppLayout.vue'
|
|
|
26
27
|
export { default as MAspectRatio } from './components/MAspectRatio.vue'
|
|
27
28
|
export { default as MAvatar } from './components/MAvatar.vue'
|
|
28
29
|
export { default as MBadge } from './components/MBadge.vue'
|
|
30
|
+
export { default as MBar } from './components/MBar.vue'
|
|
29
31
|
export { default as MBottomSheet } from './components/MBottomSheet.vue'
|
|
30
32
|
export { default as MBox } from './components/MBox.vue'
|
|
31
33
|
export { default as MBreadcrumbs } from './components/MBreadcrumbs.vue'
|
|
@@ -98,6 +100,7 @@ export { default as MNumberField } from './components/MNumberField.vue'
|
|
|
98
100
|
export { default as MNavigationDrawer } from './components/MNavigationDrawer.vue'
|
|
99
101
|
export { default as MNavigationRail } from './components/MNavigationRail.vue'
|
|
100
102
|
export { default as MOverlay } from './components/MOverlay.vue'
|
|
103
|
+
export { default as MPageProgress } from './components/MPageProgress.vue'
|
|
101
104
|
export { default as MPagination } from './components/MPagination.vue'
|
|
102
105
|
export { default as MPasswordMeter } from './components/MPasswordMeter.vue'
|
|
103
106
|
export { default as MPinInput } from './components/MPinInput.vue'
|