@m3ui-vue/m3ui-vue 0.6.3 → 0.6.4
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 +8 -6
- package/dist/m3ui.js +88 -71
- package/dist/m3ui.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MSlider.vue +82 -33
package/package.json
CHANGED
|
@@ -234,21 +234,74 @@ function fillInactiveSize(pct: number) {
|
|
|
234
234
|
return `calc(100% - ${clampedPos(pct)} - ${gap.value}px)`
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
+
// Range & centered variants: same fix as above — any fill edge that sits at a
|
|
238
|
+
// real draggable thumb must anchor to its clamped (thumbInset-aware) position,
|
|
239
|
+
// not the raw pct, or the fill creeps past a thumb pinned near 0%/100% and
|
|
240
|
+
// swallows the gap that's supposed to stay visible there.
|
|
241
|
+
|
|
242
|
+
// Range: both pctLo and pctHi are thumbs.
|
|
243
|
+
function rangeInactiveBeforeSize() {
|
|
244
|
+
return `calc(${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
245
|
+
}
|
|
246
|
+
function rangeActiveStart() {
|
|
247
|
+
return `calc(${clampedPos(pctLo.value)} + ${gap.value}px)`
|
|
248
|
+
}
|
|
249
|
+
function rangeActiveSize() {
|
|
250
|
+
return `calc(${clampedPos(pctHi.value)} - ${clampedPos(pctLo.value)} - ${gap.value * 2}px)`
|
|
251
|
+
}
|
|
252
|
+
function rangeInactiveAfterSize() {
|
|
253
|
+
return `calc(100% - ${clampedPos(pctHi.value)} - ${gap.value}px)`
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Centered: only pctLo is a thumb — centerPct is a fixed anchor, never inset.
|
|
257
|
+
function centeredActiveStart() {
|
|
258
|
+
return pctLo.value >= centerPct.value
|
|
259
|
+
? `${centerPct.value}%`
|
|
260
|
+
: `calc(${clampedPos(pctLo.value)} + ${gap.value}px)`
|
|
261
|
+
}
|
|
262
|
+
function centeredActiveSize() {
|
|
263
|
+
return pctLo.value >= centerPct.value
|
|
264
|
+
? `calc(${clampedPos(pctLo.value)} - ${centerPct.value}% - ${gap.value}px)`
|
|
265
|
+
: `calc(${centerPct.value}% - ${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
266
|
+
}
|
|
267
|
+
function centeredFarInactiveSize() {
|
|
268
|
+
return pctLo.value >= centerPct.value
|
|
269
|
+
? `calc(100% - ${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
270
|
+
: `calc(100% - ${centerPct.value}% - ${gap.value}px)`
|
|
271
|
+
}
|
|
272
|
+
function centeredNearInactiveSize() {
|
|
273
|
+
return pctLo.value <= centerPct.value
|
|
274
|
+
? `calc(${clampedPos(pctLo.value)} - ${gap.value}px)`
|
|
275
|
+
: `calc(${centerPct.value}% - ${gap.value}px)`
|
|
276
|
+
}
|
|
277
|
+
|
|
237
278
|
const r = computed(() => s.value.radius)
|
|
238
279
|
const smallR = computed(() => Math.max(2, r.value / 4))
|
|
280
|
+
// Outer track-end corners: the original `r` shape-scale token, just a touch
|
|
281
|
+
// softer/rounder than the plain token value.
|
|
282
|
+
const fullR = computed(() => r.value * 1.3)
|
|
283
|
+
|
|
284
|
+
// A segment bounded by a gap on *both* sides — range's middle (active)
|
|
285
|
+
// segment between the two thumbs, and centered's active segment (its far
|
|
286
|
+
// side sits at the fixed center junction, its near side at the thumb gap;
|
|
287
|
+
// it never touches a real track end since the near/far inactive segments
|
|
288
|
+
// always cover those) — goes square on every corner, never a rounded cap.
|
|
289
|
+
function pillRadiusSquareBoth() {
|
|
290
|
+
return `${smallR.value}px`
|
|
291
|
+
}
|
|
239
292
|
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
293
|
+
// The pill's outer end (away from the thumb/gap) stays a full stadium cap;
|
|
294
|
+
// the end facing a thumb-gap goes square, matching the official M3 slider's
|
|
295
|
+
// track segments.
|
|
243
296
|
function pillRadiusOuterStart() {
|
|
244
297
|
return isVertical.value
|
|
245
|
-
? `${smallR.value}px ${smallR.value}px ${
|
|
246
|
-
: `${
|
|
298
|
+
? `${smallR.value}px ${smallR.value}px ${fullR.value}px ${fullR.value}px`
|
|
299
|
+
: `${fullR.value}px ${smallR.value}px ${smallR.value}px ${fullR.value}px`
|
|
247
300
|
}
|
|
248
301
|
function pillRadiusOuterEnd() {
|
|
249
302
|
return isVertical.value
|
|
250
|
-
? `${
|
|
251
|
-
: `${smallR.value}px ${
|
|
303
|
+
? `${fullR.value}px ${fullR.value}px ${smallR.value}px ${smallR.value}px`
|
|
304
|
+
: `${smallR.value}px ${fullR.value}px ${fullR.value}px ${smallR.value}px`
|
|
252
305
|
}
|
|
253
306
|
const nd = computed(() => dragging.value === false)
|
|
254
307
|
const tr = computed(() => nd.value ? '75ms ease' : '0s')
|
|
@@ -373,8 +426,8 @@ const tooltipPct = computed(() => {
|
|
|
373
426
|
<div
|
|
374
427
|
class="absolute"
|
|
375
428
|
:style="isVertical
|
|
376
|
-
? { left: '50%', top: '0', bottom: '0', width: `${s.track}px`, transform: 'translateX(-50%)', borderRadius: `${
|
|
377
|
-
: { top: '50%', left: '0', right: '0', height: `${s.track}px`, transform: 'translateY(-50%)', borderRadius: `${
|
|
429
|
+
? { left: '50%', top: '0', bottom: '0', width: `${s.track}px`, transform: 'translateX(-50%)', borderRadius: `${fullR}px` }
|
|
430
|
+
: { top: '50%', left: '0', right: '0', height: `${s.track}px`, transform: 'translateY(-50%)', borderRadius: `${fullR}px` }
|
|
378
431
|
"
|
|
379
432
|
>
|
|
380
433
|
<!-- Standard: active from left/bottom -->
|
|
@@ -397,58 +450,54 @@ const tooltipPct = computed(() => {
|
|
|
397
450
|
|
|
398
451
|
<!-- Centered: active from center -->
|
|
399
452
|
<template v-else-if="variant === 'centered'">
|
|
400
|
-
<!-- Active: from center to thumb (
|
|
453
|
+
<!-- Active: from center to thumb (thumb edge uses its clamped position) -->
|
|
401
454
|
<div class="absolute" :style="{
|
|
402
455
|
...(isVertical
|
|
403
|
-
?
|
|
404
|
-
|
|
405
|
-
: { left: 0, right: 0, bottom: `calc(${pctLo}% + ${gap}px)`, height: `calc(${centerPct - pctLo}% - ${gap}px)` }
|
|
406
|
-
: pctLo >= centerPct
|
|
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)` }
|
|
456
|
+
? { left: 0, right: 0, bottom: centeredActiveStart(), height: centeredActiveSize() }
|
|
457
|
+
: { top: 0, bottom: 0, left: centeredActiveStart(), width: centeredActiveSize() }
|
|
409
458
|
),
|
|
410
|
-
borderRadius:
|
|
459
|
+
borderRadius: pillRadiusSquareBoth(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
411
460
|
}" />
|
|
412
461
|
<!-- Inactive: above/right of thumb -->
|
|
413
462
|
<div class="absolute" :style="{
|
|
414
463
|
...(isVertical
|
|
415
|
-
? { left: 0, right: 0, top: 0, height:
|
|
416
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
464
|
+
? { left: 0, right: 0, top: 0, height: centeredFarInactiveSize() }
|
|
465
|
+
: { top: 0, bottom: 0, right: 0, width: centeredFarInactiveSize() }
|
|
417
466
|
),
|
|
418
|
-
borderRadius:
|
|
467
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
419
468
|
}" />
|
|
420
469
|
<!-- Inactive: below/left of thumb -->
|
|
421
470
|
<div class="absolute" :style="{
|
|
422
471
|
...(isVertical
|
|
423
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
424
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
472
|
+
? { left: 0, right: 0, bottom: 0, height: centeredNearInactiveSize() }
|
|
473
|
+
: { top: 0, bottom: 0, left: 0, width: centeredNearInactiveSize() }
|
|
425
474
|
),
|
|
426
|
-
borderRadius:
|
|
475
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
427
476
|
}" />
|
|
428
477
|
</template>
|
|
429
478
|
|
|
430
|
-
<!-- Range: active between thumbs -->
|
|
479
|
+
<!-- Range: active between thumbs (both edges use their clamped position) -->
|
|
431
480
|
<template v-else-if="variant === 'range'">
|
|
432
481
|
<div class="absolute" :style="{
|
|
433
482
|
...(isVertical
|
|
434
|
-
? { left: 0, right: 0, bottom: 0, height:
|
|
435
|
-
: { top: 0, bottom: 0, left: 0, width:
|
|
483
|
+
? { left: 0, right: 0, bottom: 0, height: rangeInactiveBeforeSize() }
|
|
484
|
+
: { top: 0, bottom: 0, left: 0, width: rangeInactiveBeforeSize() }
|
|
436
485
|
),
|
|
437
|
-
borderRadius:
|
|
486
|
+
borderRadius: pillRadiusOuterStart(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
438
487
|
}" />
|
|
439
488
|
<div class="absolute" :style="{
|
|
440
489
|
...(isVertical
|
|
441
|
-
? { left: 0, right: 0, bottom:
|
|
442
|
-
: { top: 0, bottom: 0, left:
|
|
490
|
+
? { left: 0, right: 0, bottom: rangeActiveStart(), height: rangeActiveSize() }
|
|
491
|
+
: { top: 0, bottom: 0, left: rangeActiveStart(), width: rangeActiveSize() }
|
|
443
492
|
),
|
|
444
|
-
borderRadius:
|
|
493
|
+
borderRadius: pillRadiusSquareBoth(), backgroundColor: ct.active, transition: `all ${tr}`,
|
|
445
494
|
}" />
|
|
446
495
|
<div class="absolute" :style="{
|
|
447
496
|
...(isVertical
|
|
448
|
-
? { left: 0, right: 0, top: 0, height:
|
|
449
|
-
: { top: 0, bottom: 0, right: 0, width:
|
|
497
|
+
? { left: 0, right: 0, top: 0, height: rangeInactiveAfterSize() }
|
|
498
|
+
: { top: 0, bottom: 0, right: 0, width: rangeInactiveAfterSize() }
|
|
450
499
|
),
|
|
451
|
-
borderRadius:
|
|
500
|
+
borderRadius: pillRadiusOuterEnd(), backgroundColor: ct.inactive, transition: `all ${tr}`,
|
|
452
501
|
}" />
|
|
453
502
|
</template>
|
|
454
503
|
|