@almadar/ui 4.4.0 → 4.4.1

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.
@@ -7147,7 +7147,8 @@ var init_AnimatedCounter = __esm({
7147
7147
  suffix,
7148
7148
  className
7149
7149
  }) => {
7150
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
7150
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
7151
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
7151
7152
  const [displayValue, setDisplayValue] = React126.useState(value);
7152
7153
  const previousValueRef = React126.useRef(value);
7153
7154
  const animationFrameRef = React126.useRef(null);
package/dist/avl/index.js CHANGED
@@ -7101,7 +7101,8 @@ var init_AnimatedCounter = __esm({
7101
7101
  suffix,
7102
7102
  className
7103
7103
  }) => {
7104
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
7104
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
7105
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
7105
7106
  const [displayValue, setDisplayValue] = useState(value);
7106
7107
  const previousValueRef = useRef(value);
7107
7108
  const animationFrameRef = useRef(null);
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import React from "react";
8
8
  export interface AnimatedCounterProps {
9
- /** The target number to animate to */
10
- value: number;
9
+ /** The target value to animate to. Strings are parsed numerically (e.g. "500", "99.9"). */
10
+ value: number | string;
11
11
  /** Animation duration in milliseconds */
12
12
  duration?: number;
13
13
  /** Text to display before the number */
@@ -3178,7 +3178,8 @@ var init_AnimatedCounter = __esm({
3178
3178
  suffix,
3179
3179
  className
3180
3180
  }) => {
3181
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
3181
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
3182
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
3182
3183
  const [displayValue, setDisplayValue] = React110.useState(value);
3183
3184
  const previousValueRef = React110.useRef(value);
3184
3185
  const animationFrameRef = React110.useRef(null);
@@ -3133,7 +3133,8 @@ var init_AnimatedCounter = __esm({
3133
3133
  suffix,
3134
3134
  className
3135
3135
  }) => {
3136
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
3136
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
3137
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
3137
3138
  const [displayValue, setDisplayValue] = useState(value);
3138
3139
  const previousValueRef = useRef(value);
3139
3140
  const animationFrameRef = useRef(null);
@@ -6,8 +6,8 @@
6
6
  */
7
7
  import React from 'react';
8
8
  export interface AnimatedCounterProps {
9
- /** Target value to count to (e.g. "500+", "99.9%", "3x") */
10
- value: string;
9
+ /** Target value to count to. Strings allow display formats (e.g. "500+", "99.9%", "3x"); numbers are coerced. */
10
+ value: string | number;
11
11
  /** Label displayed below the number */
12
12
  label: string;
13
13
  /** Animation duration in ms */
@@ -4641,7 +4641,7 @@ var PullQuote = ({
4641
4641
  };
4642
4642
  PullQuote.displayName = "PullQuote";
4643
4643
  function parseValue(value) {
4644
- if (!value) return { num: 0, prefix: "", suffix: "", decimals: 0 };
4644
+ if (value === "" || value == null) return { num: 0, prefix: "", suffix: "", decimals: 0 };
4645
4645
  const match = String(value).match(/^([^0-9]*)([0-9]+(?:\.[0-9]+)?)(.*)$/);
4646
4646
  if (!match) {
4647
4647
  return { num: 0, prefix: "", suffix: String(value), decimals: 0 };
@@ -4668,7 +4668,7 @@ var AnimatedCounter = ({
4668
4668
  const animate = React5.useCallback(() => {
4669
4669
  const { num, prefix, suffix, decimals } = parseValue(value);
4670
4670
  if (num === 0) {
4671
- setDisplayValue(value);
4671
+ setDisplayValue(String(value));
4672
4672
  return;
4673
4673
  }
4674
4674
  const startTime = performance.now();
@@ -4681,7 +4681,7 @@ var AnimatedCounter = ({
4681
4681
  if (progress < 1) {
4682
4682
  requestAnimationFrame(tick);
4683
4683
  } else {
4684
- setDisplayValue(value);
4684
+ setDisplayValue(String(value));
4685
4685
  }
4686
4686
  };
4687
4687
  requestAnimationFrame(tick);
@@ -822,8 +822,8 @@ declare const PullQuote: React.FC<PullQuoteProps>;
822
822
  */
823
823
 
824
824
  interface AnimatedCounterProps {
825
- /** Target value to count to (e.g. "500+", "99.9%", "3x") */
826
- value: string;
825
+ /** Target value to count to. Strings allow display formats (e.g. "500+", "99.9%", "3x"); numbers are coerced. */
826
+ value: string | number;
827
827
  /** Label displayed below the number */
828
828
  label: string;
829
829
  /** Animation duration in ms */
@@ -4617,7 +4617,7 @@ var PullQuote = ({
4617
4617
  };
4618
4618
  PullQuote.displayName = "PullQuote";
4619
4619
  function parseValue(value) {
4620
- if (!value) return { num: 0, prefix: "", suffix: "", decimals: 0 };
4620
+ if (value === "" || value == null) return { num: 0, prefix: "", suffix: "", decimals: 0 };
4621
4621
  const match = String(value).match(/^([^0-9]*)([0-9]+(?:\.[0-9]+)?)(.*)$/);
4622
4622
  if (!match) {
4623
4623
  return { num: 0, prefix: "", suffix: String(value), decimals: 0 };
@@ -4644,7 +4644,7 @@ var AnimatedCounter = ({
4644
4644
  const animate = useCallback(() => {
4645
4645
  const { num, prefix, suffix, decimals } = parseValue(value);
4646
4646
  if (num === 0) {
4647
- setDisplayValue(value);
4647
+ setDisplayValue(String(value));
4648
4648
  return;
4649
4649
  }
4650
4650
  const startTime = performance.now();
@@ -4657,7 +4657,7 @@ var AnimatedCounter = ({
4657
4657
  if (progress < 1) {
4658
4658
  requestAnimationFrame(tick);
4659
4659
  } else {
4660
- setDisplayValue(value);
4660
+ setDisplayValue(String(value));
4661
4661
  }
4662
4662
  };
4663
4663
  requestAnimationFrame(tick);
@@ -3681,7 +3681,8 @@ var init_AnimatedCounter = __esm({
3681
3681
  suffix,
3682
3682
  className
3683
3683
  }) => {
3684
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
3684
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
3685
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
3685
3686
  const [displayValue, setDisplayValue] = React115.useState(value);
3686
3687
  const previousValueRef = React115.useRef(value);
3687
3688
  const animationFrameRef = React115.useRef(null);
@@ -3636,7 +3636,8 @@ var init_AnimatedCounter = __esm({
3636
3636
  suffix,
3637
3637
  className
3638
3638
  }) => {
3639
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
3639
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
3640
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
3640
3641
  const [displayValue, setDisplayValue] = useState(value);
3641
3642
  const previousValueRef = useRef(value);
3642
3643
  const animationFrameRef = useRef(null);
@@ -4349,7 +4349,8 @@ var init_AnimatedCounter = __esm({
4349
4349
  suffix,
4350
4350
  className
4351
4351
  }) => {
4352
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
4352
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
4353
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
4353
4354
  const [displayValue, setDisplayValue] = React115.useState(value);
4354
4355
  const previousValueRef = React115.useRef(value);
4355
4356
  const animationFrameRef = React115.useRef(null);
@@ -4304,7 +4304,8 @@ var init_AnimatedCounter = __esm({
4304
4304
  suffix,
4305
4305
  className
4306
4306
  }) => {
4307
- const value = typeof rawValue === "number" && !Number.isNaN(rawValue) ? rawValue : 0;
4307
+ const numericRaw = typeof rawValue === "number" ? rawValue : Number.parseFloat(String(rawValue ?? ""));
4308
+ const value = !Number.isNaN(numericRaw) ? numericRaw : 0;
4308
4309
  const [displayValue, setDisplayValue] = useState(value);
4309
4310
  const previousValueRef = useRef(value);
4310
4311
  const animationFrameRef = useRef(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almadar/ui",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "React UI components, hooks, and providers for Almadar",
5
5
  "type": "module",
6
6
  "main": "./dist/components/index.js",