@number-flow/react 0.2.6 → 0.3.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.
package/dist/index.d.mts CHANGED
@@ -5,26 +5,25 @@ export { Format, Trend, Value } from 'number-flow';
5
5
  declare const OBSERVED_ATTRIBUTES: readonly ["parts"];
6
6
  type ObservedAttribute = (typeof OBSERVED_ATTRIBUTES)[number];
7
7
  declare class NumberFlowElement extends NumberFlowLite {
8
- static observedAttributes: readonly ["parts"];
8
+ static observedAttributes: readonly ["parts"] | never[];
9
9
  attributeChangedCallback(attr: ObservedAttribute, _oldValue: string, newValue: string): void;
10
10
  }
11
- type NonPartsProps = Omit<Props, 'manual'>;
12
- type BaseProps = React.HTMLAttributes<NumberFlowElement> & Partial<NonPartsProps> & {
11
+ type BaseProps = React.HTMLAttributes<NumberFlowElement> & Partial<Props> & {
13
12
  isolate?: boolean;
14
13
  willChange?: boolean;
15
- onAnimationsStart?: () => void;
16
- onAnimationsFinish?: () => void;
14
+ onAnimationsStart?: (e: CustomEvent<undefined>) => void;
15
+ onAnimationsFinish?: (e: CustomEvent<undefined>) => void;
17
16
  };
18
17
  type NumberFlowProps = BaseProps & {
19
18
  value: Value;
20
19
  locales?: Intl.LocalesArgument;
21
20
  format?: Format;
22
21
  };
23
- declare const NumberFlow: React.ForwardRefExoticComponent<React.HTMLAttributes<NumberFlowElement> & Partial<NonPartsProps> & {
22
+ declare const NumberFlow: React.ForwardRefExoticComponent<React.HTMLAttributes<NumberFlowElement> & Partial<Props> & {
24
23
  isolate?: boolean;
25
24
  willChange?: boolean;
26
- onAnimationsStart?: () => void;
27
- onAnimationsFinish?: () => void;
25
+ onAnimationsStart?: (e: CustomEvent<undefined>) => void;
26
+ onAnimationsFinish?: (e: CustomEvent<undefined>) => void;
28
27
  } & {
29
28
  value: Value;
30
29
  locales?: Intl.LocalesArgument;
package/dist/index.d.ts CHANGED
@@ -5,26 +5,25 @@ export { Format, Trend, Value } from 'number-flow';
5
5
  declare const OBSERVED_ATTRIBUTES: readonly ["parts"];
6
6
  type ObservedAttribute = (typeof OBSERVED_ATTRIBUTES)[number];
7
7
  declare class NumberFlowElement extends NumberFlowLite {
8
- static observedAttributes: readonly ["parts"];
8
+ static observedAttributes: readonly ["parts"] | never[];
9
9
  attributeChangedCallback(attr: ObservedAttribute, _oldValue: string, newValue: string): void;
10
10
  }
11
- type NonPartsProps = Omit<Props, 'manual'>;
12
- type BaseProps = React.HTMLAttributes<NumberFlowElement> & Partial<NonPartsProps> & {
11
+ type BaseProps = React.HTMLAttributes<NumberFlowElement> & Partial<Props> & {
13
12
  isolate?: boolean;
14
13
  willChange?: boolean;
15
- onAnimationsStart?: () => void;
16
- onAnimationsFinish?: () => void;
14
+ onAnimationsStart?: (e: CustomEvent<undefined>) => void;
15
+ onAnimationsFinish?: (e: CustomEvent<undefined>) => void;
17
16
  };
18
17
  type NumberFlowProps = BaseProps & {
19
18
  value: Value;
20
19
  locales?: Intl.LocalesArgument;
21
20
  format?: Format;
22
21
  };
23
- declare const NumberFlow: React.ForwardRefExoticComponent<React.HTMLAttributes<NumberFlowElement> & Partial<NonPartsProps> & {
22
+ declare const NumberFlow: React.ForwardRefExoticComponent<React.HTMLAttributes<NumberFlowElement> & Partial<Props> & {
24
23
  isolate?: boolean;
25
24
  willChange?: boolean;
26
- onAnimationsStart?: () => void;
27
- onAnimationsFinish?: () => void;
25
+ onAnimationsStart?: (e: CustomEvent<undefined>) => void;
26
+ onAnimationsFinish?: (e: CustomEvent<undefined>) => void;
28
27
  } & {
29
28
  value: Value;
30
29
  locales?: Intl.LocalesArgument;
package/dist/index.js CHANGED
@@ -45,15 +45,16 @@ __export(src_exports, {
45
45
  module.exports = __toCommonJS(src_exports);
46
46
  var React = __toESM(require("react"));
47
47
  var import_number_flow = require("number-flow");
48
- var isReact19 = React.version.startsWith("19.");
48
+ var REACT_MAJOR = parseInt(React.version.match(/^(\d+)\./)?.[1]);
49
+ var isReact19 = REACT_MAJOR >= 19;
49
50
  var OBSERVED_ATTRIBUTES = ["parts"];
50
51
  var NumberFlowElement = class extends import_number_flow.NumberFlowLite {
51
52
  attributeChangedCallback(attr, _oldValue, newValue) {
52
53
  this[attr] = JSON.parse(newValue);
53
54
  }
54
55
  };
55
- NumberFlowElement.observedAttributes = OBSERVED_ATTRIBUTES;
56
- NumberFlowElement.define();
56
+ NumberFlowElement.observedAttributes = isReact19 ? [] : OBSERVED_ATTRIBUTES;
57
+ (0, import_number_flow.define)("number-flow-react", NumberFlowElement);
57
58
  var formatters = {};
58
59
  var serializeParts = isReact19 ? (p) => p : JSON.stringify;
59
60
  function splitProps(props) {
@@ -102,7 +103,10 @@ var NumberFlowImpl = class extends React.Component {
102
103
  if (this.props.onAnimationsStart)
103
104
  __privateGet(this, _el).addEventListener("animationsstart", this.props.onAnimationsStart);
104
105
  if (prevProps?.onAnimationsFinish)
105
- __privateGet(this, _el).removeEventListener("animationsfinish", prevProps.onAnimationsFinish);
106
+ __privateGet(this, _el).removeEventListener(
107
+ "animationsfinish",
108
+ prevProps.onAnimationsFinish
109
+ );
106
110
  if (this.props.onAnimationsFinish)
107
111
  __privateGet(this, _el).addEventListener("animationsfinish", this.props.onAnimationsFinish);
108
112
  }
@@ -131,7 +135,7 @@ var NumberFlowImpl = class extends React.Component {
131
135
  return (
132
136
  // @ts-expect-error missing types
133
137
  /* @__PURE__ */ React.createElement(
134
- "number-flow",
138
+ "number-flow-react",
135
139
  {
136
140
  ref: this.handleRef,
137
141
  "data-will-change": willChange ? "" : void 0,
package/dist/index.mjs CHANGED
@@ -14,17 +14,19 @@ import {
14
14
  partitionParts,
15
15
  NumberFlowLite,
16
16
  prefersReducedMotion,
17
- canAnimate as _canAnimate
17
+ canAnimate as _canAnimate,
18
+ define
18
19
  } from "number-flow";
19
- var isReact19 = React.version.startsWith("19.");
20
+ var REACT_MAJOR = parseInt(React.version.match(/^(\d+)\./)?.[1]);
21
+ var isReact19 = REACT_MAJOR >= 19;
20
22
  var OBSERVED_ATTRIBUTES = ["parts"];
21
23
  var NumberFlowElement = class extends NumberFlowLite {
22
24
  attributeChangedCallback(attr, _oldValue, newValue) {
23
25
  this[attr] = JSON.parse(newValue);
24
26
  }
25
27
  };
26
- NumberFlowElement.observedAttributes = OBSERVED_ATTRIBUTES;
27
- NumberFlowElement.define();
28
+ NumberFlowElement.observedAttributes = isReact19 ? [] : OBSERVED_ATTRIBUTES;
29
+ define("number-flow-react", NumberFlowElement);
28
30
  var formatters = {};
29
31
  var serializeParts = isReact19 ? (p) => p : JSON.stringify;
30
32
  function splitProps(props) {
@@ -73,7 +75,10 @@ var NumberFlowImpl = class extends React.Component {
73
75
  if (this.props.onAnimationsStart)
74
76
  __privateGet(this, _el).addEventListener("animationsstart", this.props.onAnimationsStart);
75
77
  if (prevProps?.onAnimationsFinish)
76
- __privateGet(this, _el).removeEventListener("animationsfinish", prevProps.onAnimationsFinish);
78
+ __privateGet(this, _el).removeEventListener(
79
+ "animationsfinish",
80
+ prevProps.onAnimationsFinish
81
+ );
77
82
  if (this.props.onAnimationsFinish)
78
83
  __privateGet(this, _el).addEventListener("animationsfinish", this.props.onAnimationsFinish);
79
84
  }
@@ -102,7 +107,7 @@ var NumberFlowImpl = class extends React.Component {
102
107
  return (
103
108
  // @ts-expect-error missing types
104
109
  /* @__PURE__ */ React.createElement(
105
- "number-flow",
110
+ "number-flow-react",
106
111
  {
107
112
  ref: this.handleRef,
108
113
  "data-will-change": willChange ? "" : void 0,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.2.6",
6
+ "version": "0.3.1",
7
7
  "author": {
8
8
  "name": "Maxwell Barvian",
9
9
  "email": "max@barvian.me",
@@ -48,7 +48,7 @@
48
48
  }
49
49
  },
50
50
  "dependencies": {
51
- "number-flow": "0.3.4"
51
+ "number-flow": "0.3.6"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@playwright/test": "^1.48.0",