@meistrari/tela-build 1.49.2 → 1.50.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.
@@ -5,7 +5,7 @@ import * as AnimatedNumberStories from './animated-number.stories.ts';
5
5
 
6
6
  # TelaAnimatedNumber
7
7
 
8
- An animated number component that smoothly animates number changes with counting effects. Supports currency formatting, decimal precision, and locale customization. Useful for displaying metrics, statistics, or financial data with engaging animations.
8
+ An animated number component that smoothly animates number changes with counting effects. Supports currency formatting, decimal precision, locale customization, and arbitrary prefix/suffix text. Useful for displaying metrics, statistics, or financial data with engaging animations.
9
9
 
10
10
  ## Examples
11
11
 
@@ -84,6 +84,27 @@ const increment = () => {
84
84
  <!-- Output: 123.4568 -->
85
85
  ```
86
86
 
87
+ ### With Prefix & Suffix
88
+
89
+ Wrap the animated value with static text — useful for units or symbols that aren't covered by `currency` (e.g. `%`, `M`, `ms`, `+`).
90
+
91
+ ```vue
92
+ <!-- Suffix -->
93
+ <TelaAnimatedNumber :value="48.2" suffix="M" />
94
+ <!-- Output: 48.2M -->
95
+
96
+ <TelaAnimatedNumber :value="842" suffix="ms" />
97
+ <!-- Output: 842ms -->
98
+
99
+ <!-- Prefix -->
100
+ <TelaAnimatedNumber :value="92" prefix="~" suffix="%" />
101
+ <!-- Output: ~92% -->
102
+
103
+ <!-- Signed delta -->
104
+ <TelaAnimatedNumber :value="8.1" prefix="+" suffix="%" />
105
+ <!-- Output: +8.1% -->
106
+ ```
107
+
87
108
  ### Counter Example
88
109
 
89
110
  ```vue
@@ -188,6 +209,8 @@ type AnimatedNumberProps = {
188
209
  precision?: number
189
210
  currency?: string
190
211
  locales?: string[]
212
+ prefix?: string // static text rendered before the value, e.g. "+", "~"
213
+ suffix?: string // static text rendered after the value, e.g. "%", "M", "ms"
191
214
  }
192
215
  ```
193
216
 
@@ -197,6 +220,7 @@ type AnimatedNumberProps = {
197
220
  - **Currency Formatting**: Support for all currency codes
198
221
  - **Locale Support**: Format according to different locales
199
222
  - **Precision Control**: Set decimal places
223
+ - **Prefix & Suffix**: Wrap the value with static text (units, symbols, signs)
200
224
  - **Performance**: Optimized for rapid updates
201
225
  - **Direction**: Automatically counts up or down
202
226
 
@@ -6,6 +6,8 @@ const props = defineProps<{
6
6
  precision?: number
7
7
  currency?: string
8
8
  locales?: string[]
9
+ prefix?: string
10
+ suffix?: string
9
11
  }>()
10
12
  </script>
11
13
 
@@ -18,6 +20,8 @@ const props = defineProps<{
18
20
  currency: props.currency?.length === 3 ? props.currency : undefined,
19
21
  style: props.currency?.length === 3 ? 'currency' : undefined,
20
22
  }"
23
+ :prefix="props.prefix"
24
+ :suffix="props.suffix"
21
25
  :locales="props.locales"
22
26
  />
23
27
  </template>
@@ -105,10 +105,10 @@ function onFiles(event: Event) {
105
105
 
106
106
  <TelaHomeBody>
107
107
  <TelaHomeMetrics>
108
- <TelaHomeMetricsCard label="Total Cases" value="2,081">
108
+ <TelaHomeMetricsCard label="Total Cases" :value="2081">
109
109
  <div grid grid-cols-2 gap-16px>
110
- <TelaHomeMetricsStat label="Pending" value="273" delta="13.1%" />
111
- <TelaHomeMetricsStat label="Reviewed" value="1,808" delta="86.9%" />
110
+ <TelaHomeMetricsStat label="Pending" :value="273" :delta="13.1" deltaSuffix="%" />
111
+ <TelaHomeMetricsStat label="Reviewed" :value="1808" :delta="86.9" deltaSuffix="%" />
112
112
  </div>
113
113
  </TelaHomeMetricsCard>
114
114
 
@@ -253,7 +253,7 @@ type HomeMetricsProps = {
253
253
  ```typescript
254
254
  type HomeMetricsCardProps = {
255
255
  label?: string // metric label (or use the #label slot)
256
- value?: string | number // optional hero value — omit for a title-only card
256
+ value?: number // optional hero value (animated) — omit for a title-only card
257
257
  class?: HTMLAttributes['class'] // extra classes merged onto the card's inner body wrapper
258
258
  }
259
259
  // default slot — body content (breakdown, list, progress, sparkline)
@@ -266,8 +266,12 @@ When `value` is provided the card leads with a big `heading-h2-semibold` number;
266
266
  ```typescript
267
267
  type HomeMetricsStatProps = {
268
268
  label?: string // stat label (or use the #label slot)
269
- value?: string | number // the value, rendered as h4 (or use the default slot)
270
- delta?: string // optional inline delta, e.g. "13.1%" (or use the #delta slot)
269
+ value?: number // the value (h4), animated via TelaAnimatedNumber (or use the #value slot for non-numeric text)
270
+ valuePrefix?: string // text before the value, e.g. "$"
271
+ valueSuffix?: string // text after the value, e.g. "%", "M", "ms"
272
+ delta?: number // optional inline delta, animated
273
+ deltaPrefix?: string // text before the delta, e.g. "+"
274
+ deltaSuffix?: string // text after the delta, e.g. "%"
271
275
  }
272
276
  ```
273
277
 
@@ -1,22 +1,22 @@
1
1
  <script setup lang="ts">
2
2
  import type { HTMLAttributes } from 'vue'
3
3
 
4
- const props = defineProps<{ label?: string, value?: string | number, class?: HTMLAttributes['class'] }>()
4
+ const props = defineProps<{ label?: string, value?: number, class?: HTMLAttributes['class'] }>()
5
5
 
6
6
  const hasValue = computed(() => props.value !== undefined)
7
7
  </script>
8
8
 
9
9
  <template>
10
- <TelaCard size="xs" class="rounded-0! border-none!">
10
+ <TelaCard size="xs" class="rounded-0! min-w-0">
11
11
  <div flex="~ col" h-full :class="cn(hasValue ? 'gap-[36px]' : 'gap-[20px]', props.class)">
12
- <div flex="~ col" gap-4px>
12
+ <div flex="~ col">
13
13
  <span body-12-regular text-secondary>
14
14
  <slot name="label">
15
15
  {{ label }}
16
16
  </slot>
17
17
  </span>
18
- <h2 v-if="hasValue" heading-h2-semibold text-primary>
19
- {{ value }}
18
+ <h2 v-if="value !== undefined" heading-h2-semibold text-primary>
19
+ <TelaAnimatedNumber :value="value" />
20
20
  </h2>
21
21
  </div>
22
22
  <slot />
@@ -1,22 +1,30 @@
1
1
  <script setup lang="ts">
2
- const props = defineProps<{ label?: string, value?: string | number, delta?: string }>()
3
-
4
- const hasDelta = computed(() => props.delta !== undefined)
2
+ defineProps<{
3
+ label?: string
4
+ value?: number
5
+ valuePrefix?: string
6
+ valueSuffix?: string
7
+ delta?: number
8
+ deltaPrefix?: string
9
+ deltaSuffix?: string
10
+ }>()
5
11
  </script>
6
12
 
7
13
  <template>
8
- <div flex="~ col" gap-4px>
14
+ <div flex="~ col" gap-2px>
9
15
  <span body-12-regular text-secondary>
10
16
  <slot name="label">
11
17
  {{ label }}
12
18
  </slot>
13
19
  </span>
14
20
  <div flex items-baseline gap-4px>
15
- <h4 heading-h4-semibold text-primary>
16
- {{ value }}
21
+ <h4 v-if="$slots.value || value !== undefined" heading-h4-semibold text-primary>
22
+ <slot name="value">
23
+ <TelaAnimatedNumber v-if="value !== undefined" :value="value" :prefix="valuePrefix" :suffix="valueSuffix" />
24
+ </slot>
17
25
  </h4>
18
- <span v-if="hasDelta" body-12-regular text-secondary>
19
- {{ delta }}
26
+ <span v-if="delta !== undefined" body-12-regular text-secondary>
27
+ <TelaAnimatedNumber :value="delta" :prefix="deltaPrefix" :suffix="deltaSuffix" />
20
28
  </span>
21
29
  </div>
22
30
  </div>
@@ -33,7 +33,8 @@ const gridStyle = computed(() => ({
33
33
  <template>
34
34
  <div flex justify-between>
35
35
  <div
36
- grid gap-0.5px bg-border border-0.5px border rounded-12px overflow-hidden
36
+ grid divide-x-0.5px divide-border border-0.5px border rounded-12px overflow-hidden
37
+ class="[&>div]:border-0"
37
38
  :style="gridStyle"
38
39
  >
39
40
  <slot />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-build",
3
- "version": "1.49.2",
3
+ "version": "1.50.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "app.config.ts",