@m3ui-vue/m3ui-vue 0.6.0 → 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.
Files changed (46) hide show
  1. package/README.md +13 -1
  2. package/dist/MIcon-CaEooCmZ.js.map +1 -1
  3. package/dist/{MMenuItem-DbbrJhFE.js → MMenuItem-C7jKU-Qh.js} +13 -13
  4. package/dist/{MMenuItem-DbbrJhFE.js.map → MMenuItem-C7jKU-Qh.js.map} +1 -1
  5. package/dist/barcode.js.map +1 -1
  6. package/dist/chart.js +1 -1
  7. package/dist/chart.js.map +1 -1
  8. package/dist/code-editor.js +1 -1
  9. package/dist/code-editor.js.map +1 -1
  10. package/dist/{common-VrOaLkjh.js → common-0dgrgaPL.js} +287 -213
  11. package/dist/common-0dgrgaPL.js.map +1 -0
  12. package/dist/components/MBar.vue.d.ts +58 -0
  13. package/dist/components/MLightbox.vue.d.ts +53 -0
  14. package/dist/components/MPageProgress.vue.d.ts +15 -0
  15. package/dist/components/MSlider.vue.d.ts +6 -0
  16. package/dist/components/MWindow.vue.d.ts +1 -1
  17. package/dist/composables/useColorPalette.d.ts +9 -0
  18. package/dist/composables/usePageProgress.d.ts +19 -0
  19. package/dist/{dist-Dsrzt6J5.js → dist-CrjSW5DN.js} +248 -241
  20. package/dist/{dist-Dsrzt6J5.js.map → dist-CrjSW5DN.js.map} +1 -1
  21. package/dist/index.d.ts +5 -0
  22. package/dist/m3ui-vue.css +1 -1
  23. package/dist/m3ui.js +3117 -2593
  24. package/dist/m3ui.js.map +1 -1
  25. package/dist/markdown.js +1 -1
  26. package/dist/markdown.js.map +1 -1
  27. package/dist/plugin.d.ts +9 -0
  28. package/dist/qrcode.js.map +1 -1
  29. package/dist/rich-text-editor.js +1 -1
  30. package/dist/rich-text-editor.js.map +1 -1
  31. package/dist/styles.css +1 -1
  32. package/dist/terminal.js.map +1 -1
  33. package/package.json +26 -26
  34. package/src/__tests__/MLightbox.test.ts +195 -0
  35. package/src/__tests__/plugin.test.ts +20 -1
  36. package/src/__tests__/useColorPalette.test.ts +22 -0
  37. package/src/__tests__/usePageProgress.test.ts +52 -0
  38. package/src/components/MBar.vue +158 -0
  39. package/src/components/MLightbox.vue +405 -0
  40. package/src/components/MPageProgress.vue +62 -0
  41. package/src/components/MSlider.vue +174 -52
  42. package/src/composables/useColorPalette.ts +29 -2
  43. package/src/composables/usePageProgress.ts +49 -0
  44. package/src/index.ts +5 -0
  45. package/src/plugin.ts +16 -4
  46. 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: 28, dot: 4, gap: 6, hitArea: 38, radius: 6, iconSize: 14 },
64
- sm: { track: 28, thumbW: 4, thumbH: 36, dot: 5, gap: 6, hitArea: 46, radius: 8, iconSize: 16 },
65
- md: { track: 54, thumbW: 5, thumbH: 56, dot: 5, gap: 6, hitArea: 66, radius: 12, iconSize: 20 },
66
- lg: { track: 72, thumbW: 5, thumbH: 72, dot: 6, gap: 8, hitArea: 82, radius: 14, iconSize: 24 },
67
- xl: { track: 96, thumbW: 6, thumbH: 90, dot: 7, gap: 8, hitArea: 100, radius: 18, iconSize: 28 },
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
- const ct = computed(() => {
73
- const map: Record<string, { active: string; inactive: string }> = {
74
- primary: { active: 'var(--color-primary)', inactive: 'var(--color-primary-container)' },
75
- secondary: { active: 'var(--color-secondary)', inactive: 'var(--color-secondary-container)' },
76
- tertiary: { active: 'var(--color-tertiary)', inactive: 'var(--color-tertiary-container)' },
77
- error: { active: 'var(--color-error)', inactive: 'var(--color-error-container)' },
78
- }
79
- return map[props.color] ?? map.primary!
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: ct.value.active,
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 = `${pct}%`
196
- base.transform = `translateX(-50%) translateY(50%) scaleX(${dragging.value !== false ? 1.08 : 1})`
285
+ base.bottom = clampedPos(pct)
286
+ base.transform = `translateX(-50%) translateY(50%) scaleX(${grow}) scaleY(${narrow})`
197
287
  } else {
198
- base.left = `${pct}%`
288
+ base.left = clampedPos(pct)
199
289
  base.top = '50%'
200
- base.transform = `translateX(-50%) translateY(-50%) scaleY(${dragging.value !== false ? 1.08 : 1})`
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: `${pct}%`, transform: 'translateY(50%)', transition: nd.value ? 'bottom ' + tr.value : 'none' }
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: `${pct}%`, top: `calc(50% - ${offsetH}px)`, transform: 'translateX(-50%)', transition: nd.value ? 'left ' + tr.value : 'none' }
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: `calc(${pctLo}% - ${s.gap}px)` }
272
- : { top: 0, bottom: 0, left: 0, width: `calc(${pctLo}% - ${s.gap}px)` }
384
+ ? { left: 0, right: 0, bottom: 0, height: fillActiveSize(pctLo) }
385
+ : { top: 0, bottom: 0, left: 0, width: fillActiveSize(pctLo) }
273
386
  ),
274
- borderRadius: `${r}px`, backgroundColor: ct.active, transition: `all ${tr}`,
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: `calc(${100 - pctLo}% - ${s.gap}px)` }
279
- : { top: 0, bottom: 0, right: 0, width: `calc(${100 - pctLo}% - ${s.gap}px)` }
391
+ ? { left: 0, right: 0, top: 0, height: fillInactiveSize(pctLo) }
392
+ : { top: 0, bottom: 0, right: 0, width: fillInactiveSize(pctLo) }
280
393
  ),
281
- borderRadius: `${r}px`, backgroundColor: ct.inactive, transition: `all ${tr}`,
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}% - ${s.gap}px)` }
292
- : { left: 0, right: 0, bottom: `calc(${pctLo}% + ${s.gap}px)`, height: `calc(${centerPct - pctLo}% - ${s.gap}px)` }
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}% - ${s.gap}px)` }
295
- : { top: 0, bottom: 0, left: `calc(${pctLo}% + ${s.gap}px)`, width: `calc(${centerPct - pctLo}% - ${s.gap}px)` }
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)}% - ${s.gap}px)` }
303
- : { top: 0, bottom: 0, right: 0, width: `calc(${100 - Math.max(pctLo, centerPct)}% - ${s.gap}px)` }
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)}% - ${s.gap}px)` }
311
- : { top: 0, bottom: 0, left: 0, width: `calc(${Math.min(pctLo, centerPct)}% - ${s.gap}px)` }
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}% - ${s.gap}px)` }
322
- : { top: 0, bottom: 0, left: 0, width: `calc(${pctLo}% - ${s.gap}px)` }
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}% + ${s.gap}px)`, height: `calc(${pctHi - pctLo}% - ${s.gap * 2}px)` }
329
- : { top: 0, bottom: 0, left: `calc(${pctLo}% + ${s.gap}px)`, width: `calc(${pctHi - pctLo}% - ${s.gap * 2}px)` }
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}% - ${s.gap}px)` }
336
- : { top: 0, bottom: 0, right: 0, width: `calc(${100 - pctHi}% - ${s.gap}px)` }
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: `${s.radius}px`, transform: 'translateX(-50%)' }
352
- : { top: '50%', left: `${s.radius}px`, transform: 'translateY(-50%)' }
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: (variant === 'standard' && pctLo > 0) || (variant === 'range' && pctLo > 0) ? ct.inactive : ct.active,
475
+ backgroundColor: ct.active,
476
+ opacity: startDotHidden ? 0 : 1,
363
477
  ...(isVertical
364
- ? { left: '50%', bottom: `${s.radius}px`, transform: 'translateX(-50%)' }
365
- : { top: '50%', left: `${s.radius}px`, transform: 'translateY(-50%)' }
478
+ ? { left: '50%', bottom: `${s.dotInset}px`, transform: 'translateX(-50%)' }
479
+ : { top: '50%', left: `${s.dotInset}px`, transform: 'translateY(-50%)' }
366
480
  ),
367
- transition: 'background-color 150ms ease',
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: (variant === 'standard' && pctLo >= 100) || (variant === 'range' && pctHi >= 100) ? ct.active : ct.inactive,
490
+ backgroundColor: ct.active,
491
+ opacity: endDotHidden ? 0 : 1,
377
492
  ...(isVertical
378
- ? { left: '50%', top: `${s.radius}px`, transform: 'translateX(-50%)' }
379
- : { top: '50%', right: `${s.radius}px`, transform: 'translateY(-50%)' }
493
+ ? { left: '50%', top: `${s.dotInset}px`, transform: 'translateX(-50%)' }
494
+ : { top: '50%', right: `${s.dotInset}px`, transform: 'translateY(-50%)' }
380
495
  ),
381
- transition: 'background-color 150ms ease',
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
- <div class="pointer-events-none" :style="thumbPos(pctLo)" />
405
- <div v-if="isRange" class="pointer-events-none" :style="thumbPos(pctHi)" />
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
@@ -41,10 +41,15 @@ export const palettes: Palette[] = [
41
41
 
42
42
  const current = ref(localStorage.getItem('m3-palette') ?? 'purple')
43
43
 
44
+ // Whether palette changes are written to localStorage. Defaults to true (existing behavior).
45
+ // An app can disable it via `createM3UI({ persistPalette: false })` or `useColorPalette().setPersistPalette(false)`
46
+ // so its chosen palette can't be overridden by a stored value on the next boot.
47
+ const persistEnabled = ref(true)
48
+
44
49
  export function useColorPalette() {
45
50
  watchEffect(() => {
46
51
  const id = current.value
47
- localStorage.setItem('m3-palette', id)
52
+ if (persistEnabled.value) localStorage.setItem('m3-palette', id)
48
53
 
49
54
  if (id === 'purple') {
50
55
  document.documentElement.removeAttribute('data-palette')
@@ -60,7 +65,12 @@ export function useColorPalette() {
60
65
  setTimeout(() => document.documentElement.classList.remove('theme-transitioning'), 300)
61
66
  }
62
67
 
63
- return { palette: current, palettes, set }
68
+ function setPersistPalette(enabled: boolean) {
69
+ persistEnabled.value = enabled
70
+ if (enabled) localStorage.setItem('m3-palette', current.value)
71
+ }
72
+
73
+ return { palette: current, palettes, set, persistPalette: persistEnabled, setPersistPalette }
64
74
  }
65
75
 
66
76
  // Apply on module load so palette is visible before any component mounts
@@ -68,3 +78,20 @@ const saved = localStorage.getItem('m3-palette')
68
78
  if (saved && saved !== 'purple') {
69
79
  document.documentElement.setAttribute('data-palette', saved)
70
80
  }
81
+
82
+ /**
83
+ * Internal: used by `createM3UI({ palette, persistPalette: false })` to force a palette on boot,
84
+ * bypassing whatever is already in localStorage, without waiting for a component to call
85
+ * `useColorPalette()` (which is what actually reacts to `current` via the watchEffect above).
86
+ * Not exported from the package's public entry points.
87
+ */
88
+ export function __forcePalette(id: string, persist: boolean) {
89
+ persistEnabled.value = persist
90
+ current.value = id
91
+ if (id === 'purple') {
92
+ document.documentElement.removeAttribute('data-palette')
93
+ } else {
94
+ document.documentElement.setAttribute('data-palette', id)
95
+ }
96
+ if (persist) localStorage.setItem('m3-palette', id)
97
+ }
@@ -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'
@@ -77,6 +79,8 @@ export { default as MInfiniteScroll } from './components/MInfiniteScroll.vue'
77
79
  export { default as MJsonViewer } from './components/MJsonViewer.vue'
78
80
  export { default as MKanban } from './components/MKanban.vue'
79
81
  export { default as MKbd } from './components/MKbd.vue'
82
+ export { default as MLightbox } from './components/MLightbox.vue'
83
+ export type { LightboxItem } from './components/MLightbox.vue'
80
84
  export { default as MList } from './components/MList.vue'
81
85
  export { default as MListItem } from './components/MListItem.vue'
82
86
  export { default as MListSubheader } from './components/MListSubheader.vue'
@@ -96,6 +100,7 @@ export { default as MNumberField } from './components/MNumberField.vue'
96
100
  export { default as MNavigationDrawer } from './components/MNavigationDrawer.vue'
97
101
  export { default as MNavigationRail } from './components/MNavigationRail.vue'
98
102
  export { default as MOverlay } from './components/MOverlay.vue'
103
+ export { default as MPageProgress } from './components/MPageProgress.vue'
99
104
  export { default as MPagination } from './components/MPagination.vue'
100
105
  export { default as MPasswordMeter } from './components/MPasswordMeter.vue'
101
106
  export { default as MPinInput } from './components/MPinInput.vue'
package/src/plugin.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  import type { App, MaybeRef } from 'vue'
2
2
  import type { Palette } from './composables/useColorPalette'
3
+ import { __forcePalette } from './composables/useColorPalette'
3
4
  import type { M3Locale } from './composables/useLocale'
4
5
  import { M3_LOCALE_KEY } from './composables/useLocale'
5
6
 
6
7
  export interface M3UIOptions {
7
8
  palette?: string
9
+ /**
10
+ * Set to `false` to make `palette` a hard default that always wins on boot, ignoring
11
+ * whatever is already stored in localStorage, and to stop future `useColorPalette().set()`
12
+ * calls from persisting either. Palette switching still works live within the session
13
+ * (`set()` still applies immediately) — only the "remember it for next time" part is disabled.
14
+ * Defaults to `true`, matching prior behavior (`palette` only seeds the very first visit,
15
+ * and any later choice persists and wins over it).
16
+ */
17
+ persistPalette?: boolean
8
18
  customPalettes?: Palette[]
9
19
  locale?: MaybeRef<Partial<M3Locale>>
10
20
  }
@@ -12,10 +22,12 @@ export interface M3UIOptions {
12
22
  export function createM3UI(options: M3UIOptions = {}) {
13
23
  return {
14
24
  install(app: App) {
15
- // `options.palette` is only the first-visit default — once the user picks a palette via
16
- // `useColorPalette().set()` it's persisted to localStorage, and that choice must win on
17
- // every later boot instead of being clobbered back to the plugin's static default.
18
- if (options.palette && options.palette !== 'purple' && !localStorage.getItem('m3-palette')) {
25
+ if (options.persistPalette === false) {
26
+ if (options.palette) __forcePalette(options.palette, false)
27
+ } else if (options.palette && options.palette !== 'purple' && !localStorage.getItem('m3-palette')) {
28
+ // `options.palette` is only the first-visit default — once the user picks a palette via
29
+ // `useColorPalette().set()` it's persisted to localStorage, and that choice must win on
30
+ // every later boot instead of being clobbered back to the plugin's static default.
19
31
  document.documentElement.setAttribute('data-palette', options.palette)
20
32
  localStorage.setItem('m3-palette', options.palette)
21
33
  }