@meistrari/tela-build 1.96.0 → 1.97.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  Latest updates and announcements.
4
4
 
5
+ ## October 30, 2026
6
+
7
+ - [Switch](/components/switch) Toggling animates the thumb as a stretching pill: it slides at a near-constant speed while stretching from its trailing edge, squashes as it lands, then springs back to a circle with a slight overshoot over 500ms. The track color crossfades over 300ms. The thumb's small stretch toward the other side (16 → 18px on `sm`, 18 → 20px on `md`) now shows on hover instead of while pressed. Toggling drops it, and it comes back the next time the pointer leaves and hovers the switch again. Toggling again mid-animation reverses from wherever the thumb is instead of jumping to the far end. Switches don't animate on mount, and the animation is skipped under `prefers-reduced-motion`.
8
+ - [Checkbox](/components/checkbox) scales down to 93% while pressed, easing over 200ms. Disabled checkboxes don't scale, and neither do any under `prefers-reduced-motion`.
9
+
5
10
  ## October 29, 2026
6
11
 
7
12
  - [Tooltip Group](/components/tooltip-group) `TelaTooltipGroupTrigger` honors `disabled`: a disabled trigger doesn't open its tooltip, and one that's open closes as soon as it's disabled.
@@ -16,9 +16,9 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
16
16
  <CheckboxRoot
17
17
  v-bind="forwarded"
18
18
  :class="cn(
19
- 'checkbox grid place-content-center peer w-16px h-16px shrink-0 rounded-5px border-[1px] border-strong bg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyan-600',
19
+ 'checkbox grid place-content-center peer size-16px shrink-0 rounded-5px border-[1px] border-strong bg focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyan-600',
20
20
  'hover:data-[state=unchecked]:bg-muted data-[state=checked]:border-transparent data-[state=checked]:bg-btn-primary hover:data-[state=checked]:bg-btn-primary-active',
21
- 'disabled:cursor-not-allowed disabled:bg-muted disabled:border disabled:data-[state=checked]:bg-neutral-300',
21
+ 'disabled:cursor-not-allowed disabled:bg-muted disabled:border disabled:data-[state=checked]:bg-neutral-300 motion-safe:not-disabled:active:scale-93',
22
22
  props.class,
23
23
  )"
24
24
  >
@@ -55,6 +55,6 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits)
55
55
  }
56
56
 
57
57
  .checkbox {
58
- transition: background-color 125ms ease-out, border-color 125ms ease-out;
58
+ transition: background-color 125ms ease-out, border-color 125ms ease-out, transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
59
59
  }
60
60
  </style>
@@ -19,6 +19,42 @@ const delegatedProps = reactiveOmit(props, 'class')
19
19
 
20
20
  const forwarded = useForwardPropsEmits(delegatedProps, emits)
21
21
 
22
+ const hasToggled = ref(false)
23
+ const thumbRef = ref<InstanceType<typeof SwitchThumb>>()
24
+
25
+ const start = ref({ x: 0, shift: 0, scale: 1, reach: 1 })
26
+
27
+ function captureStart() {
28
+ hasToggled.value = true
29
+
30
+ const el: HTMLElement | undefined = thumbRef.value?.$el
31
+
32
+ if (!el)
33
+ return
34
+
35
+ const pillStyle = getComputedStyle(el, '::before')
36
+ const pill = new DOMMatrix(pillStyle.transform)
37
+ const originX = Number.parseFloat(pillStyle.transformOrigin)
38
+ const width = el.offsetWidth
39
+ const left = originX + pill.m41 - originX * pill.a
40
+ const isTurningOn = el.dataset.state !== 'checked'
41
+ const x = new DOMMatrix(getComputedStyle(el).transform).m41
42
+ const track = el.parentElement
43
+ const trackStyle = track ? getComputedStyle(track) : undefined
44
+ const travel = track && trackStyle
45
+ ? track.clientWidth - Number.parseFloat(trackStyle.paddingLeft) - Number.parseFloat(trackStyle.paddingRight) - width
46
+ : 0
47
+
48
+ start.value = {
49
+ x,
50
+ shift: isTurningOn ? left : left - width + width * pill.a,
51
+ scale: pill.a,
52
+ reach: travel > 0 ? Math.min(1, Math.max(0, (isTurningOn ? travel - x : x) / travel)) : 1,
53
+ }
54
+ }
55
+
56
+ watch(() => props.modelValue, captureStart, { flush: 'pre' })
57
+
22
58
  const resolvedSize = computed(() => props.size || 'sm')
23
59
 
24
60
  const sizeStyle = computed(() => (({
@@ -27,30 +63,90 @@ const sizeStyle = computed(() => (({
27
63
  }) as Record<SwitchSize, string>)[resolvedSize.value] ?? '')
28
64
 
29
65
  const thumbSizeStyle = computed(() => (({
30
- sm: 'w-16px h-16px data-[state=checked]:translate-x-3 group-enabled:group-active:before:scale-x-[1.125]',
31
- md: 'w-18px h-18px data-[state=checked]:translate-x-4 group-enabled:group-active:before:scale-x-[1.111]',
66
+ sm: 'w-16px h-16px [--switch-width:16px] [--switch-travel:0.75rem] [--switch-stretch:0.75] data-[state=checked]:translate-x-3',
67
+ md: 'w-18px h-18px [--switch-width:18px] [--switch-travel:1rem] [--switch-stretch:0.889] data-[state=checked]:translate-x-4',
32
68
  }) as Record<SwitchSize, string>)[resolvedSize.value] ?? '')
69
+
70
+ const isHovered = ref(false)
71
+ const isStretchArmed = ref(true)
72
+
73
+ function onPointerLeave() {
74
+ isHovered.value = false
75
+ isStretchArmed.value = true
76
+ }
77
+
78
+ function onToggle() {
79
+ captureStart()
80
+ isStretchArmed.value = false
81
+ }
82
+
83
+ const hoverStretch = computed(() => resolvedSize.value === 'md' ? 1.111 : 1.125)
84
+
85
+ const thumbStyle = computed(() => ({
86
+ '--switch-rest': isHovered.value && isStretchArmed.value && !props.disabled ? hoverStretch.value : 1,
87
+ '--switch-start': `${start.value.x}px`,
88
+ '--switch-shift': `${start.value.shift}px`,
89
+ '--switch-from': start.value.scale,
90
+ '--switch-reach': start.value.reach,
91
+ }))
33
92
  </script>
34
93
 
35
94
  <template>
36
95
  <SwitchRoot
37
96
  v-bind="forwarded"
38
97
  :class="cn(
39
- 'group peer inline-flex w-32px h-20px shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyan-600 disabled:cursor-not-allowed disabled:opacity-50',
98
+ 'group peer inline-flex w-32px h-20px shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors duration-300 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-cyan-600 disabled:cursor-not-allowed disabled:opacity-50',
40
99
  'data-[state=unchecked]:bg-neutral-200 not-disabled:data-[state=unchecked]:hover:bg-neutral-300 data-[state=checked]:bg-green-500 not-disabled:data-[state=checked]:hover:bg-green-600',
41
100
  sizeStyle,
42
101
  props.class,
43
102
  )"
103
+ @update:model-value="onToggle"
104
+ @pointerenter="isHovered = true"
105
+ @pointerleave="onPointerLeave"
44
106
  >
45
107
  <SwitchThumb
108
+ ref="thumbRef"
46
109
  :class="cn(
47
110
  'relative isolate flex items-center justify-center rounded-full ring-0 transition-[transform,filter] duration-350 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none data-[state=checked]:drop-shadow-md',
48
- 'before:content-empty before:absolute before:inset-0 before:-z-1 before:rounded-full before:bg before:origin-left data-[state=checked]:before:origin-right',
49
- 'before:transition-[transform,background-color] before:duration-350 before:ease-[cubic-bezier(0.22,1,0.36,1)] group-enabled:group-active:before:duration-160 group-enabled:group-active:before:ease-out motion-reduce:before:transition-none hover:before:bg-muted',
111
+ 'before:content-empty before:absolute before:inset-0 before:-z-1 before:rounded-full before:bg before:scale-x-[var(--switch-rest)] before:origin-left data-[state=checked]:before:origin-right',
112
+ 'before:transition-[transform,background-color] before:duration-160 before:ease-out motion-reduce:before:transition-none hover:before:bg-muted',
113
+ hasToggled && [
114
+ 'motion-safe:data-[state=checked]:animate-[switchThumbOn_0.5s_linear] motion-safe:data-[state=checked]:before:animate-[switchPillOn_0.5s_linear]',
115
+ 'motion-safe:data-[state=unchecked]:animate-[switchThumbOff_0.5s_linear] motion-safe:data-[state=unchecked]:before:animate-[switchPillOff_0.5s_linear]',
116
+ ],
50
117
  thumbSizeStyle,
51
118
  )"
119
+ :style="thumbStyle"
52
120
  >
53
121
  <slot name="thumb" />
54
122
  </SwitchThumb>
55
123
  </SwitchRoot>
56
124
  </template>
125
+
126
+ <style>
127
+ @keyframes switchThumbOn {
128
+ 0% { transform: translateX(var(--switch-start)); }
129
+ 51%, 100% { transform: translateX(var(--switch-travel)); }
130
+ }
131
+
132
+ @keyframes switchThumbOff {
133
+ 0% { transform: translateX(var(--switch-start)); }
134
+ 51%, 100% { transform: translateX(0); }
135
+ }
136
+
137
+ @keyframes switchPillOn {
138
+ 0% { transform-origin: left center; transform: translateX(var(--switch-shift)) scaleX(var(--switch-from)); }
139
+ 24% { transform: translateX(0) scaleX(calc(1 + var(--switch-stretch) * var(--switch-reach) * 0.46)); }
140
+ 51% { transform: translateX(calc(var(--switch-width) * (1 - var(--switch-rest)))) scaleX(calc(var(--switch-rest) - var(--switch-stretch) * 0.08)); animation-timing-function: ease-out; }
141
+ 66% { transform: translateX(calc(var(--switch-width) * (1 - var(--switch-rest)))) scaleX(calc(var(--switch-rest) + var(--switch-stretch) * 0.02)); animation-timing-function: ease-in-out; }
142
+ 100% { transform-origin: left center; transform: translateX(calc(var(--switch-width) * (1 - var(--switch-rest)))) scaleX(var(--switch-rest)); }
143
+ }
144
+
145
+ @keyframes switchPillOff {
146
+ 0% { transform-origin: right center; transform: translateX(var(--switch-shift)) scaleX(var(--switch-from)); }
147
+ 24% { transform: translateX(0) scaleX(calc(1 + var(--switch-stretch) * var(--switch-reach) * 0.46)); }
148
+ 51% { transform: translateX(calc(var(--switch-width) * (var(--switch-rest) - 1))) scaleX(calc(var(--switch-rest) - var(--switch-stretch) * 0.08)); animation-timing-function: ease-out; }
149
+ 66% { transform: translateX(calc(var(--switch-width) * (var(--switch-rest) - 1))) scaleX(calc(var(--switch-rest) + var(--switch-stretch) * 0.02)); animation-timing-function: ease-in-out; }
150
+ 100% { transform-origin: right center; transform: translateX(calc(var(--switch-width) * (var(--switch-rest) - 1))) scaleX(var(--switch-rest)); }
151
+ }
152
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-build",
3
- "version": "1.96.0",
3
+ "version": "1.97.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "app.config.ts",