@number-flow/react 0.5.12 → 0.5.13
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/{NumberFlow-client-48rw3j0J.mjs → NumberFlow-client-BTpPLmzo.mjs} +10 -3
- package/dist/{NumberFlow-client-8ThZK4QG.js → NumberFlow-client-CN4TfYrs.js} +10 -3
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -2
- package/package.json +2 -2
|
@@ -22,7 +22,10 @@ define('number-flow-react', NumberFlowElement);
|
|
|
22
22
|
// Serialize to strings b/c React:
|
|
23
23
|
const formatters = {};
|
|
24
24
|
// Tiny workaround to support React 19 until it's released:
|
|
25
|
-
|
|
25
|
+
function identity(v) {
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
28
|
+
const serialize = isReact19 ? identity : JSON.stringify;
|
|
26
29
|
function splitProps(props) {
|
|
27
30
|
const { transformTiming, spinTiming, opacityTiming, animated, respectMotionPreference, trend, plugins, ...rest } = props;
|
|
28
31
|
return [
|
|
@@ -85,16 +88,20 @@ class NumberFlowImpl extends React.Component {
|
|
|
85
88
|
this.el = el;
|
|
86
89
|
}
|
|
87
90
|
render() {
|
|
88
|
-
const [_, { innerRef, className, data, willChange, isolate, group, digits, onAnimationsStart, onAnimationsFinish, ...rest }] = splitProps(this.props);
|
|
91
|
+
const [_, { innerRef, className, data, nonce, willChange, isolate, group, digits, onAnimationsStart, onAnimationsFinish, ...rest }] = splitProps(this.props);
|
|
89
92
|
return(// @ts-expect-error missing types
|
|
90
93
|
/*#__PURE__*/ React.createElement("number-flow-react", {
|
|
91
94
|
ref: this.handleRef,
|
|
92
95
|
"data-will-change": willChange ? '' : undefined,
|
|
93
96
|
// Have to rename this:
|
|
94
97
|
class: className,
|
|
98
|
+
nonce: nonce,
|
|
95
99
|
...rest,
|
|
96
100
|
dangerouslySetInnerHTML: {
|
|
97
|
-
__html: BROWSER ? '' : renderInnerHTML(data
|
|
101
|
+
__html: BROWSER ? '' : renderInnerHTML(data, {
|
|
102
|
+
nonce,
|
|
103
|
+
elementSuffix: '-react'
|
|
104
|
+
})
|
|
98
105
|
},
|
|
99
106
|
suppressHydrationWarning: true,
|
|
100
107
|
digits: serialize(digits),
|
|
@@ -45,7 +45,10 @@ NumberFlowLite.define('number-flow-react', NumberFlowElement);
|
|
|
45
45
|
// Serialize to strings b/c React:
|
|
46
46
|
const formatters = {};
|
|
47
47
|
// Tiny workaround to support React 19 until it's released:
|
|
48
|
-
|
|
48
|
+
function identity(v) {
|
|
49
|
+
return v;
|
|
50
|
+
}
|
|
51
|
+
const serialize = isReact19 ? identity : JSON.stringify;
|
|
49
52
|
function splitProps(props) {
|
|
50
53
|
const { transformTiming, spinTiming, opacityTiming, animated, respectMotionPreference, trend, plugins, ...rest } = props;
|
|
51
54
|
return [
|
|
@@ -108,16 +111,20 @@ class NumberFlowImpl extends React__namespace.Component {
|
|
|
108
111
|
this.el = el;
|
|
109
112
|
}
|
|
110
113
|
render() {
|
|
111
|
-
const [_, { innerRef, className, data, willChange, isolate, group, digits, onAnimationsStart, onAnimationsFinish, ...rest }] = splitProps(this.props);
|
|
114
|
+
const [_, { innerRef, className, data, nonce, willChange, isolate, group, digits, onAnimationsStart, onAnimationsFinish, ...rest }] = splitProps(this.props);
|
|
112
115
|
return(// @ts-expect-error missing types
|
|
113
116
|
/*#__PURE__*/ React__namespace.createElement("number-flow-react", {
|
|
114
117
|
ref: this.handleRef,
|
|
115
118
|
"data-will-change": willChange ? '' : undefined,
|
|
116
119
|
// Have to rename this:
|
|
117
120
|
class: className,
|
|
121
|
+
nonce: nonce,
|
|
118
122
|
...rest,
|
|
119
123
|
dangerouslySetInnerHTML: {
|
|
120
|
-
__html: esmEnv.BROWSER ? '' : NumberFlowLite.renderInnerHTML(data
|
|
124
|
+
__html: esmEnv.BROWSER ? '' : NumberFlowLite.renderInnerHTML(data, {
|
|
125
|
+
nonce,
|
|
126
|
+
elementSuffix: '-react'
|
|
127
|
+
})
|
|
121
128
|
},
|
|
122
129
|
suppressHydrationWarning: true,
|
|
123
130
|
digits: serialize(digits),
|
package/dist/index.d.mts
CHANGED
|
@@ -39,10 +39,12 @@ declare function NumberFlowGroup({ children }: {
|
|
|
39
39
|
children: React.ReactNode;
|
|
40
40
|
}): React.JSX.Element;
|
|
41
41
|
|
|
42
|
+
declare const styles: readonly [string, string, string];
|
|
43
|
+
|
|
42
44
|
declare const useIsSupported: () => boolean;
|
|
43
45
|
declare const usePrefersReducedMotion: () => boolean;
|
|
44
46
|
declare function useCanAnimate({ respectMotionPreference }?: {
|
|
45
47
|
respectMotionPreference?: boolean | undefined;
|
|
46
48
|
}): boolean;
|
|
47
49
|
|
|
48
|
-
export { NumberFlowElement, NumberFlowGroup, type NumberFlowProps, NumberFlow as default, useCanAnimate, useIsSupported, usePrefersReducedMotion };
|
|
50
|
+
export { NumberFlowElement, NumberFlowGroup, type NumberFlowProps, NumberFlow as default, styles, useCanAnimate, useIsSupported, usePrefersReducedMotion };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,10 +39,12 @@ declare function NumberFlowGroup({ children }: {
|
|
|
39
39
|
children: React.ReactNode;
|
|
40
40
|
}): React.JSX.Element;
|
|
41
41
|
|
|
42
|
+
declare const styles: readonly [string, string, string];
|
|
43
|
+
|
|
42
44
|
declare const useIsSupported: () => boolean;
|
|
43
45
|
declare const usePrefersReducedMotion: () => boolean;
|
|
44
46
|
declare function useCanAnimate({ respectMotionPreference }?: {
|
|
45
47
|
respectMotionPreference?: boolean | undefined;
|
|
46
48
|
}): boolean;
|
|
47
49
|
|
|
48
|
-
export { NumberFlowElement, NumberFlowGroup, type NumberFlowProps, NumberFlow as default, useCanAnimate, useIsSupported, usePrefersReducedMotion };
|
|
50
|
+
export { NumberFlowElement, NumberFlowGroup, type NumberFlowProps, NumberFlow as default, styles, useCanAnimate, useIsSupported, usePrefersReducedMotion };
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var NumberFlowLite = require('number-flow/lite');
|
|
5
|
+
var csp = require('number-flow/csp');
|
|
5
6
|
var plugins = require('number-flow/plugins');
|
|
6
|
-
var NumberFlowClient = require('./NumberFlow-client-
|
|
7
|
+
var NumberFlowClient = require('./NumberFlow-client-CN4TfYrs.js');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
@@ -25,6 +26,7 @@ function _interopNamespace(e) {
|
|
|
25
26
|
|
|
26
27
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
28
|
|
|
29
|
+
const styles = csp.buildStyles('-react');
|
|
28
30
|
const useIsSupported = ()=>React__namespace.useSyncExternalStore(()=>()=>{}, ()=>NumberFlowLite.canAnimate, ()=>false);
|
|
29
31
|
const usePrefersReducedMotion = ()=>React__namespace.useSyncExternalStore((cb)=>{
|
|
30
32
|
NumberFlowLite.prefersReducedMotion?.addEventListener('change', cb);
|
|
@@ -39,6 +41,7 @@ function useCanAnimate({ respectMotionPreference = true } = {}) {
|
|
|
39
41
|
exports.NumberFlowElement = NumberFlowClient.NumberFlowElement;
|
|
40
42
|
exports.NumberFlowGroup = NumberFlowClient.NumberFlowGroup;
|
|
41
43
|
exports.default = NumberFlowClient.NumberFlow;
|
|
44
|
+
exports.styles = styles;
|
|
42
45
|
exports.useCanAnimate = useCanAnimate;
|
|
43
46
|
exports.useIsSupported = useIsSupported;
|
|
44
47
|
exports.usePrefersReducedMotion = usePrefersReducedMotion;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { canAnimate, prefersReducedMotion } from 'number-flow/lite';
|
|
3
|
+
import { buildStyles } from 'number-flow/csp';
|
|
3
4
|
export * from 'number-flow/plugins';
|
|
4
|
-
export { a as NumberFlowElement, b as NumberFlowGroup, N as default } from './NumberFlow-client-
|
|
5
|
+
export { a as NumberFlowElement, b as NumberFlowGroup, N as default } from './NumberFlow-client-BTpPLmzo.mjs';
|
|
5
6
|
|
|
7
|
+
const styles = buildStyles('-react');
|
|
6
8
|
const useIsSupported = ()=>React.useSyncExternalStore(()=>()=>{}, ()=>canAnimate, ()=>false);
|
|
7
9
|
const usePrefersReducedMotion = ()=>React.useSyncExternalStore((cb)=>{
|
|
8
10
|
prefersReducedMotion?.addEventListener('change', cb);
|
|
@@ -14,4 +16,4 @@ function useCanAnimate({ respectMotionPreference = true } = {}) {
|
|
|
14
16
|
return isSupported && (!respectMotionPreference || !reducedMotion);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export { useCanAnimate, useIsSupported, usePrefersReducedMotion };
|
|
19
|
+
export { styles, useCanAnimate, useIsSupported, usePrefersReducedMotion };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.5.
|
|
6
|
+
"version": "0.5.13",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Maxwell Barvian",
|
|
9
9
|
"email": "max@barvian.me",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"esm-env": "^1.1.4",
|
|
52
|
-
"number-flow": "0.5.
|
|
52
|
+
"number-flow": "0.5.11"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@playwright/test": "^1.48.0",
|