@0xchain/number-like 0.0.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/README.md +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/package.json +31 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface INumberLikeProps extends Intl.NumberFormatOptions {
|
|
2
|
+
number?: string | number;
|
|
3
|
+
addonBefore?: React.ReactNode;
|
|
4
|
+
addonAfter?: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
wrapClassName?: string;
|
|
7
|
+
limit?: number;
|
|
8
|
+
}
|
|
9
|
+
export default function NumberLike({ number, addonBefore, addonAfter, className, wrapClassName, limit, ...options }: INumberLikeProps): "--" | import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,mBAAmB;IAChE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACb,KAAK,EACL,GAAG,OAAO,EACX,EAAE,gBAAgB,kDAwClB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs as d, jsx as a } from "react/jsx-runtime";
|
|
3
|
+
import { twMerge as c } from "tailwind-merge";
|
|
4
|
+
function p({
|
|
5
|
+
number: e,
|
|
6
|
+
addonBefore: n,
|
|
7
|
+
addonAfter: s,
|
|
8
|
+
className: l,
|
|
9
|
+
wrapClassName: f,
|
|
10
|
+
limit: t,
|
|
11
|
+
...i
|
|
12
|
+
}) {
|
|
13
|
+
if (e === null || e === "null" || (typeof e == "number" && (e = String(e)), !e || e === "undefined" || typeof e > "u"))
|
|
14
|
+
return "--";
|
|
15
|
+
const o = e;
|
|
16
|
+
let r;
|
|
17
|
+
try {
|
|
18
|
+
r = new Intl.NumberFormat("en-US", {
|
|
19
|
+
maximumFractionDigits: 20,
|
|
20
|
+
minimumFractionDigits: 0,
|
|
21
|
+
...i
|
|
22
|
+
}).format(o);
|
|
23
|
+
} catch (m) {
|
|
24
|
+
console.error(m), r = e;
|
|
25
|
+
}
|
|
26
|
+
return t && Math.abs(Number(e)) < t && Math.abs(Number(e)) > 0 && (r = `< ${i.currency === "USD" ? "$" : ""}${t}`), Number(e) === 0 && (r = `${i.currency === "USD" ? "$" : ""}0`), /* @__PURE__ */ d("div", { className: c(
|
|
27
|
+
"inline-flex items-center flex-nowrap",
|
|
28
|
+
f
|
|
29
|
+
), "data-testid": "number-like", children: [
|
|
30
|
+
n && /* @__PURE__ */ a("span", { children: n }),
|
|
31
|
+
/* @__PURE__ */ a("span", { className: c("pr-1 shrink-0", l), children: r }),
|
|
32
|
+
s && /* @__PURE__ */ a("span", { className: "flex-shrink-0", children: s })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
p as default
|
|
37
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@0xchain/number-like",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"!**/*.tsbuildinfo"
|
|
19
|
+
],
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"rollup-plugin-preserve-use-client": "3.0.1"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"react": "19.1.1",
|
|
25
|
+
"react-dom": "19.1.1",
|
|
26
|
+
"tailwind-merge": "3.3.1"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
}
|
|
31
|
+
}
|