@numeric-text/react 0.1.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.
- package/README.md +3 -0
- package/dist/NumericText-12s-c2pBkv0T.js +38 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +2 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { BROWSER } from '@numeric-text/core';
|
|
4
|
+
import { useRef, useLayoutEffect } from 'react';
|
|
5
|
+
|
|
6
|
+
const NumericText = ({ value, trend, transition, respectMotionPreference, animated = true, ...rest })=>{
|
|
7
|
+
const ref = useRef(null);
|
|
8
|
+
const isMounted = useRef(false);
|
|
9
|
+
useLayoutEffect(()=>{
|
|
10
|
+
if (ref.current) ref.current.update(value, isMounted.current && animated);
|
|
11
|
+
if (!isMounted.current) isMounted.current = true;
|
|
12
|
+
}, [
|
|
13
|
+
value
|
|
14
|
+
]);
|
|
15
|
+
useLayoutEffect(()=>{
|
|
16
|
+
if (ref.current) ref.current.setOptions({
|
|
17
|
+
trend,
|
|
18
|
+
transition,
|
|
19
|
+
respectMotionPreference
|
|
20
|
+
});
|
|
21
|
+
}, [
|
|
22
|
+
trend,
|
|
23
|
+
transition,
|
|
24
|
+
respectMotionPreference
|
|
25
|
+
]);
|
|
26
|
+
return /*#__PURE__*/ jsx("numeric-text", {
|
|
27
|
+
ref: ref,
|
|
28
|
+
role: "img",
|
|
29
|
+
"aria-label": value + '',
|
|
30
|
+
...rest,
|
|
31
|
+
suppressHydrationWarning: true,
|
|
32
|
+
dangerouslySetInnerHTML: {
|
|
33
|
+
__html: BROWSER ? '' : value
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { NumericText as N };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { NumericTextProps } from '@numeric-text/core';
|
|
3
|
+
export * from '@numeric-text/core';
|
|
4
|
+
import { HTMLAttributes } from 'react';
|
|
5
|
+
|
|
6
|
+
type Props = NumericTextProps & HTMLAttributes<HTMLElement>;
|
|
7
|
+
declare const NumericText: ({ value, trend, transition, respectMotionPreference, animated, ...rest }: Props) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
namespace React {
|
|
11
|
+
namespace JSX {
|
|
12
|
+
interface IntrinsicElements {
|
|
13
|
+
'numeric-text': React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { NumericText as default };
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@numeric-text/react",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "React wrapper for @numeric-text/core",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/shizukushq/numeric-text.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/shizukushq/numeric-text/issues"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "bunchee",
|
|
31
|
+
"dev": "bunchee --watch"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^18 || ^19"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@numeric-text/core": "workspace:*"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/react": "^19.2.9",
|
|
41
|
+
"bunchee": "^6.9.4",
|
|
42
|
+
"react": "^19.2.3",
|
|
43
|
+
"typescript": "^5.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|