@blocklet/payment-react 1.13.205 → 1.13.207
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/es/util.d.ts +2 -2
- package/es/util.js +4 -4
- package/lib/util.d.ts +2 -2
- package/lib/util.js +4 -4
- package/package.json +3 -3
- package/src/util.ts +4 -4
package/es/util.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare function formatDateTime(date: Date | string | number, locale?: st
|
|
|
9
9
|
export declare const formatLocale: (locale?: string) => string;
|
|
10
10
|
export declare const formatPrettyMsLocale: (locale: string) => "zh_CN" | "en_US";
|
|
11
11
|
export declare const formatError: (err: any) => any;
|
|
12
|
-
export declare function formatBNStr(str?: string, decimals?: number, precision?: number): any;
|
|
13
|
-
export declare function formatNumber(n: number | string, precision?: number): any;
|
|
12
|
+
export declare function formatBNStr(str?: string, decimals?: number, precision?: number, trim?: boolean): any;
|
|
13
|
+
export declare function formatNumber(n: number | string, precision?: number, trim?: boolean): any;
|
|
14
14
|
export declare const formatPrice: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean, locale?: string) => string;
|
|
15
15
|
export declare const formatPriceAmount: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean) => string;
|
|
16
16
|
export declare function getStatementDescriptor(items: any[]): any;
|
package/es/util.js
CHANGED
|
@@ -63,10 +63,10 @@ export const formatError = (err) => {
|
|
|
63
63
|
}
|
|
64
64
|
return err.message;
|
|
65
65
|
};
|
|
66
|
-
export function formatBNStr(str = "", decimals = 18, precision = 6) {
|
|
67
|
-
return formatNumber(fromUnitToToken(str, decimals), precision);
|
|
66
|
+
export function formatBNStr(str = "", decimals = 18, precision = 6, trim = true) {
|
|
67
|
+
return formatNumber(fromUnitToToken(str, decimals), precision, trim);
|
|
68
68
|
}
|
|
69
|
-
export function formatNumber(n, precision = 6) {
|
|
69
|
+
export function formatNumber(n, precision = 6, trim = true) {
|
|
70
70
|
if (!n || n === "0") {
|
|
71
71
|
return "0";
|
|
72
72
|
}
|
|
@@ -75,7 +75,7 @@ export function formatNumber(n, precision = 6) {
|
|
|
75
75
|
thousandSeparated: true,
|
|
76
76
|
...(precision || precision === 0) && { mantissa: precision }
|
|
77
77
|
};
|
|
78
|
-
return trimEnd(num.format(options), "0.");
|
|
78
|
+
return trim ? trimEnd(num.format(options), "0.") : num.format(options);
|
|
79
79
|
}
|
|
80
80
|
export const formatPrice = (price, currency, unit_label, quantity = 1, bn = true, locale = "en") => {
|
|
81
81
|
const unit = getPriceUintAmountByCurrency(price, currency);
|
package/lib/util.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare function formatDateTime(date: Date | string | number, locale?: st
|
|
|
9
9
|
export declare const formatLocale: (locale?: string) => string;
|
|
10
10
|
export declare const formatPrettyMsLocale: (locale: string) => "zh_CN" | "en_US";
|
|
11
11
|
export declare const formatError: (err: any) => any;
|
|
12
|
-
export declare function formatBNStr(str?: string, decimals?: number, precision?: number): any;
|
|
13
|
-
export declare function formatNumber(n: number | string, precision?: number): any;
|
|
12
|
+
export declare function formatBNStr(str?: string, decimals?: number, precision?: number, trim?: boolean): any;
|
|
13
|
+
export declare function formatNumber(n: number | string, precision?: number, trim?: boolean): any;
|
|
14
14
|
export declare const formatPrice: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean, locale?: string) => string;
|
|
15
15
|
export declare const formatPriceAmount: (price: TPrice, currency: TPaymentCurrency, unit_label?: string, quantity?: number, bn?: boolean) => string;
|
|
16
16
|
export declare function getStatementDescriptor(items: any[]): any;
|
package/lib/util.js
CHANGED
|
@@ -112,10 +112,10 @@ const formatError = err => {
|
|
|
112
112
|
return err.message;
|
|
113
113
|
};
|
|
114
114
|
exports.formatError = formatError;
|
|
115
|
-
function formatBNStr(str = "", decimals = 18, precision = 6) {
|
|
116
|
-
return formatNumber((0, _util.fromUnitToToken)(str, decimals), precision);
|
|
115
|
+
function formatBNStr(str = "", decimals = 18, precision = 6, trim = true) {
|
|
116
|
+
return formatNumber((0, _util.fromUnitToToken)(str, decimals), precision, trim);
|
|
117
117
|
}
|
|
118
|
-
function formatNumber(n, precision = 6) {
|
|
118
|
+
function formatNumber(n, precision = 6, trim = true) {
|
|
119
119
|
if (!n || n === "0") {
|
|
120
120
|
return "0";
|
|
121
121
|
}
|
|
@@ -126,7 +126,7 @@ function formatNumber(n, precision = 6) {
|
|
|
126
126
|
mantissa: precision
|
|
127
127
|
})
|
|
128
128
|
};
|
|
129
|
-
return (0, _trimEnd.default)(num.format(options), "0.");
|
|
129
|
+
return trim ? (0, _trimEnd.default)(num.format(options), "0.") : num.format(options);
|
|
130
130
|
}
|
|
131
131
|
const formatPrice = (price, currency, unit_label, quantity = 1, bn = true, locale = "en") => {
|
|
132
132
|
const unit = getPriceUintAmountByCurrency(price, currency);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/payment-react",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.207",
|
|
4
4
|
"description": "Reusable react components for payment kit v2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@babel/core": "^7.23.9",
|
|
91
91
|
"@babel/preset-env": "^7.23.9",
|
|
92
92
|
"@babel/preset-react": "^7.23.3",
|
|
93
|
-
"@blocklet/payment-types": "1.13.
|
|
93
|
+
"@blocklet/payment-types": "1.13.207",
|
|
94
94
|
"@storybook/addon-essentials": "^7.6.13",
|
|
95
95
|
"@storybook/addon-interactions": "^7.6.13",
|
|
96
96
|
"@storybook/addon-links": "^7.6.13",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"vite-plugin-babel": "^1.2.0",
|
|
120
120
|
"vite-plugin-node-polyfills": "^0.19.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "7b4918ac7bb09317df0b2a78e337312cc4b50b67"
|
|
123
123
|
}
|
package/src/util.ts
CHANGED
|
@@ -101,11 +101,11 @@ export const formatError = (err: any) => {
|
|
|
101
101
|
return err.message;
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
export function formatBNStr(str: string = '', decimals: number = 18, precision: number = 6) {
|
|
105
|
-
return formatNumber(fromUnitToToken(str, decimals), precision);
|
|
104
|
+
export function formatBNStr(str: string = '', decimals: number = 18, precision: number = 6, trim: boolean = true) {
|
|
105
|
+
return formatNumber(fromUnitToToken(str, decimals), precision, trim);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export function formatNumber(n: number | string, precision: number = 6) {
|
|
108
|
+
export function formatNumber(n: number | string, precision: number = 6, trim: boolean = true) {
|
|
109
109
|
if (!n || n === '0') {
|
|
110
110
|
return '0';
|
|
111
111
|
}
|
|
@@ -114,7 +114,7 @@ export function formatNumber(n: number | string, precision: number = 6) {
|
|
|
114
114
|
thousandSeparated: true,
|
|
115
115
|
...((precision || precision === 0) && { mantissa: precision }),
|
|
116
116
|
};
|
|
117
|
-
return trimEnd(num.format(options), '0.');
|
|
117
|
+
return trim ? trimEnd(num.format(options), '0.') : num.format(options);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export const formatPrice = (
|