@meistrari/tela-build 1.98.0 → 1.98.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/CHANGELOG.md +4 -0
- package/components/tela/animated/animated-number.vue +186 -14
- package/nuxt.config.ts +0 -1
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Latest updates and announcements.
|
|
4
4
|
|
|
5
|
+
## November 3, 2026
|
|
6
|
+
|
|
7
|
+
- [Animated Number](/components/animated-number) has a new animation, now handmade instead of `@number-flow/vue`: a changed digit rolls upward while its replacement comes in from below, blurring, fading and scaling down as they cross, over 280ms. Only the digits that changed animate, so adding a trailing digit (`123` to `1,231`) leaves the others in place, while separators and neighboring digits slide to their new positions. Each digit keeps its natural shape but is padded with margins to the width of the widest digit, measured with the digits' own font features such as `tabular-nums`, so changing digits don't push their neighbors around. Props and number formatting are unchanged, and the animation is skipped under `prefers-reduced-motion`.
|
|
8
|
+
|
|
5
9
|
## October 30, 2026
|
|
6
10
|
|
|
7
11
|
- [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`.
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import NumberFlow from '@number-flow/vue'
|
|
3
|
-
|
|
4
2
|
const props = defineProps<{
|
|
5
3
|
value: number
|
|
6
4
|
precision?: number
|
|
@@ -9,19 +7,193 @@ const props = defineProps<{
|
|
|
9
7
|
prefix?: string
|
|
10
8
|
suffix?: string
|
|
11
9
|
}>()
|
|
10
|
+
|
|
11
|
+
const ENTER_ACTIVE = 'transition-[transform,opacity,filter] duration-[280ms] ease-[cubic-bezier(0.33,1,0.68,1)]'
|
|
12
|
+
const ENTER_FROM = 'opacity-0 [filter:blur(0.12em)] [transform:translateY(0.45em)_scale(0.8)]'
|
|
13
|
+
const LEAVE_ACTIVE = '!absolute left-0 top-0 pointer-events-none transition-[transform,opacity,filter] duration-[200ms] ease-[cubic-bezier(0.33,1,0.68,1)]'
|
|
14
|
+
const LEAVE_TO = 'opacity-0 [filter:blur(0.12em)] [transform:translateY(-0.45em)_scale(0.8)]'
|
|
15
|
+
const MOVE = 'transition-[transform,opacity,filter] duration-[280ms] ease-[cubic-bezier(0.22,1,0.36,1)]'
|
|
16
|
+
const WIDTH_ANIMATION = { duration: 280, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' }
|
|
17
|
+
const DIGITS = [...'0123456789']
|
|
18
|
+
const DIGIT_TIGHTENING = 0.01
|
|
19
|
+
const DIGIT_PROBE = 'absolute invisible'
|
|
20
|
+
|
|
21
|
+
const root = ref<HTMLElement | null>(null)
|
|
22
|
+
const reducedMotion = ref(false)
|
|
23
|
+
const digitMargins = ref<Record<string, string>>({})
|
|
24
|
+
let widthAnimation: Animation | undefined
|
|
25
|
+
let integerDigits: { id: number, text: string }[] = []
|
|
26
|
+
let nextDigitId = 0
|
|
27
|
+
|
|
28
|
+
const formatter = computed(() => new Intl.NumberFormat(props.locales, {
|
|
29
|
+
roundingMode: 'expand',
|
|
30
|
+
maximumFractionDigits: props.precision,
|
|
31
|
+
currency: props.currency?.length === 3 ? props.currency : undefined,
|
|
32
|
+
style: props.currency?.length === 3 ? 'currency' : undefined,
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
const text = computed(() => `${props.prefix ?? ''}${formatter.value.format(props.value)}${props.suffix ?? ''}`)
|
|
36
|
+
|
|
37
|
+
function alignIntegerDigits(next: string) {
|
|
38
|
+
const previous = integerDigits.map(digit => digit.text).join('')
|
|
39
|
+
const offset = next.startsWith(previous) || previous.startsWith(next) ? 0 : previous.length - next.length
|
|
40
|
+
|
|
41
|
+
integerDigits = [...next].map((digit, index) => ({
|
|
42
|
+
id: integerDigits[index + offset]?.id ?? nextDigitId++,
|
|
43
|
+
text: digit,
|
|
44
|
+
}))
|
|
45
|
+
|
|
46
|
+
return integerDigits
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const cells = computed(() => {
|
|
50
|
+
const parts = formatter.value.formatToParts(props.value)
|
|
51
|
+
const digits = alignIntegerDigits(parts.filter(part => part.type === 'integer').map(part => part.value).join(''))
|
|
52
|
+
|
|
53
|
+
let digitIndex = 0
|
|
54
|
+
let groupIndex = 0
|
|
55
|
+
let fractionIndex = 0
|
|
56
|
+
let before = props.prefix ?? ''
|
|
57
|
+
let after = ''
|
|
58
|
+
|
|
59
|
+
const numberCells: { key: string, text: string, isDigit?: boolean }[] = []
|
|
60
|
+
|
|
61
|
+
for (const part of parts) {
|
|
62
|
+
if (part.type === 'integer') {
|
|
63
|
+
for (const _ of part.value) {
|
|
64
|
+
const digit = digits[digitIndex++]
|
|
65
|
+
|
|
66
|
+
if (digit)
|
|
67
|
+
numberCells.push({ key: `integer-${digit.id}`, text: digit.text, isDigit: true })
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (part.type === 'fraction') {
|
|
71
|
+
for (const digit of part.value)
|
|
72
|
+
numberCells.push({ key: `fraction-${fractionIndex++}`, text: digit, isDigit: true })
|
|
73
|
+
}
|
|
74
|
+
else if (part.type === 'group') {
|
|
75
|
+
numberCells.push({ key: `group-${groupIndex++}`, text: part.value })
|
|
76
|
+
}
|
|
77
|
+
else if (part.type === 'decimal') {
|
|
78
|
+
numberCells.push({ key: 'decimal', text: part.value })
|
|
79
|
+
}
|
|
80
|
+
else if (numberCells.length === 0) {
|
|
81
|
+
before += part.value
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
after += part.value
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
after += props.suffix ?? ''
|
|
89
|
+
|
|
90
|
+
return [
|
|
91
|
+
...(before ? [{ key: 'before', text: before }] : []),
|
|
92
|
+
...numberCells,
|
|
93
|
+
...(after ? [{ key: 'after', text: after }] : []),
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
function measureDigits() {
|
|
98
|
+
const element = root.value
|
|
99
|
+
|
|
100
|
+
if (!element)
|
|
101
|
+
return
|
|
102
|
+
|
|
103
|
+
const probes = DIGITS.map((digit) => {
|
|
104
|
+
const probe = document.createElement('span')
|
|
105
|
+
|
|
106
|
+
probe.className = DIGIT_PROBE
|
|
107
|
+
probe.textContent = digit
|
|
108
|
+
|
|
109
|
+
return probe
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
element.append(...probes)
|
|
113
|
+
|
|
114
|
+
const widths = probes.map(probe => Number.parseFloat(getComputedStyle(probe).width))
|
|
115
|
+
|
|
116
|
+
const fontSize = Number.parseFloat(getComputedStyle(element).fontSize)
|
|
117
|
+
|
|
118
|
+
for (const probe of probes)
|
|
119
|
+
probe.remove()
|
|
120
|
+
|
|
121
|
+
const widest = Math.max(...widths)
|
|
122
|
+
|
|
123
|
+
if (!(widest > 0) || !(fontSize > 0))
|
|
124
|
+
return
|
|
125
|
+
|
|
126
|
+
digitMargins.value = Object.fromEntries(DIGITS.map((digit, index) => [digit, `${(widest - (widths[index] ?? widest)) / 2 / fontSize - DIGIT_TIGHTENING}em`]))
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
onMounted(() => {
|
|
130
|
+
measureDigits()
|
|
131
|
+
document.fonts?.ready.then(measureDigits)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
watch(text, async () => {
|
|
135
|
+
measureDigits()
|
|
136
|
+
|
|
137
|
+
reducedMotion.value = window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
138
|
+
|
|
139
|
+
const element = root.value
|
|
140
|
+
|
|
141
|
+
if (!element || reducedMotion.value)
|
|
142
|
+
return
|
|
143
|
+
|
|
144
|
+
const from = element.getBoundingClientRect().width
|
|
145
|
+
|
|
146
|
+
widthAnimation?.cancel()
|
|
147
|
+
await nextTick()
|
|
148
|
+
|
|
149
|
+
const to = element.getBoundingClientRect().width
|
|
150
|
+
|
|
151
|
+
if (Math.abs(from - to) > 0.5)
|
|
152
|
+
widthAnimation = element.animate({ width: [`${from}px`, `${to}px`] }, WIDTH_ANIMATION)
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
function pinLeavingCell(element: Element) {
|
|
156
|
+
if (!(element instanceof HTMLElement))
|
|
157
|
+
return
|
|
158
|
+
|
|
159
|
+
element.style.left = `${element.offsetLeft}px`
|
|
160
|
+
element.style.top = `${element.offsetTop}px`
|
|
161
|
+
}
|
|
12
162
|
</script>
|
|
13
163
|
|
|
14
164
|
<template>
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
165
|
+
<span
|
|
166
|
+
ref="root"
|
|
167
|
+
role="img"
|
|
168
|
+
:aria-label="text"
|
|
169
|
+
class="relative inline-block whitespace-pre"
|
|
170
|
+
>
|
|
171
|
+
<TransitionGroup
|
|
172
|
+
tag="span"
|
|
173
|
+
aria-hidden="true"
|
|
174
|
+
:css="!reducedMotion"
|
|
175
|
+
:enter-active-class="ENTER_ACTIVE"
|
|
176
|
+
:enter-from-class="ENTER_FROM"
|
|
177
|
+
:leave-active-class="LEAVE_ACTIVE"
|
|
178
|
+
:leave-to-class="LEAVE_TO"
|
|
179
|
+
:move-class="reducedMotion ? undefined : MOVE"
|
|
180
|
+
@before-leave="pinLeavingCell"
|
|
181
|
+
>
|
|
182
|
+
<span v-for="cell in cells" :key="cell.key" class="relative inline-block">
|
|
183
|
+
<Transition
|
|
184
|
+
:css="!reducedMotion"
|
|
185
|
+
:enter-active-class="ENTER_ACTIVE"
|
|
186
|
+
:enter-from-class="ENTER_FROM"
|
|
187
|
+
:leave-active-class="LEAVE_ACTIVE"
|
|
188
|
+
:leave-to-class="LEAVE_TO"
|
|
189
|
+
>
|
|
190
|
+
<span
|
|
191
|
+
:key="cell.text"
|
|
192
|
+
class="inline-block"
|
|
193
|
+
:style="cell.isDigit ? { marginInline: digitMargins[cell.text] } : undefined"
|
|
194
|
+
>{{ cell.text }}</span>
|
|
195
|
+
</Transition>
|
|
196
|
+
</span>
|
|
197
|
+
</TransitionGroup>
|
|
198
|
+
</span>
|
|
27
199
|
</template>
|
package/nuxt.config.ts
CHANGED
|
@@ -108,7 +108,6 @@ export default defineNuxtConfig({
|
|
|
108
108
|
// components makes Vite discover the dep mid-session, re-optimize, and
|
|
109
109
|
// hard-reload the browser. Prebundling them up front keeps dev stable.
|
|
110
110
|
include: [
|
|
111
|
-
'@number-flow/vue',
|
|
112
111
|
'clsx',
|
|
113
112
|
'date-fns',
|
|
114
113
|
'radix-vue',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meistrari/tela-build",
|
|
3
|
-
"version": "1.98.
|
|
3
|
+
"version": "1.98.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"app.config.ts",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"@iconify-json/ph": "1.2.2",
|
|
34
34
|
"@internationalized/date": "3.6.0",
|
|
35
35
|
"@meistrari/auth-core": "^1.42.0",
|
|
36
|
-
"@number-flow/vue": "^0.3.2",
|
|
37
36
|
"@types/mdast": "4.0.4",
|
|
38
37
|
"@unocss/nuxt": "66.5.12",
|
|
39
38
|
"@unocss/transformer-directives": "66.5.12",
|
|
@@ -80,7 +79,7 @@
|
|
|
80
79
|
"@nuxt/kit": "4.6.2",
|
|
81
80
|
"@types/node": "22.19.0",
|
|
82
81
|
"gray-matter": "4.0.3",
|
|
83
|
-
"nuxt": "4.6.
|
|
82
|
+
"nuxt": "4.6.3",
|
|
84
83
|
"vue": "3.5.42",
|
|
85
84
|
"vitest": "4.1.11",
|
|
86
85
|
"vue-tsc": "3.3.11",
|