@solar-taro/core 1.2.0 β 1.2.2
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/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/pipes/number.d.ts +3 -3
- package/pipes/number.js +38 -10
- package/pipes/number.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 1.2.1 (2025-07-26)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for core to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 1.2.0 (2025-07-25)
|
|
6
|
+
|
|
7
|
+
### π Features
|
|
8
|
+
|
|
9
|
+
- **ui-vant/cascader:** add cascader component
|
|
10
|
+
|
|
11
|
+
### β€οΈ Thank You
|
|
12
|
+
|
|
13
|
+
- HyperLife1119
|
|
14
|
+
|
|
1
15
|
## 1.1.13 (2025-07-21)
|
|
2
16
|
|
|
3
17
|
### π©Ή Fixes
|
package/package.json
CHANGED
package/pipes/number.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare function number(value: number): string;
|
|
2
1
|
/**
|
|
3
2
|
* @deprecated {@link number}
|
|
4
3
|
*/
|
|
5
4
|
export declare const amount: typeof number;
|
|
6
|
-
export declare function fixed(value: number,
|
|
7
|
-
export declare function
|
|
5
|
+
export declare function fixed(value: number, fractionDigits?: number): string;
|
|
6
|
+
export declare function number(value: number, fractionDigits?: number): string;
|
|
7
|
+
export declare function currency(value: number, fractionDigits?: number): string;
|
package/pipes/number.js
CHANGED
|
@@ -1,19 +1,47 @@
|
|
|
1
1
|
const FRACTION_DIGITS = 2;
|
|
2
|
-
export function number(value) {
|
|
3
|
-
const fixedValue = +(value || 0).toFixed(FRACTION_DIGITS);
|
|
4
|
-
return fixedValue.toLocaleString('zh-CN', { minimumFractionDigits: FRACTION_DIGITS, maximumFractionDigits: FRACTION_DIGITS });
|
|
5
|
-
}
|
|
6
|
-
;
|
|
7
2
|
/**
|
|
8
3
|
* @deprecated {@link number}
|
|
9
4
|
*/
|
|
10
5
|
export const amount = number;
|
|
11
|
-
export function fixed(value,
|
|
12
|
-
return (value || 0).toFixed(
|
|
6
|
+
export function fixed(value, fractionDigits = FRACTION_DIGITS) {
|
|
7
|
+
return (value || 0).toFixed(fractionDigits);
|
|
13
8
|
}
|
|
14
9
|
;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
// ε°η¨εΊδΈζ―ζ toLocaleString
|
|
11
|
+
// export function number(value: number) {
|
|
12
|
+
// const fixedValue = +(value || 0).toFixed(FRACTION_DIGITS)
|
|
13
|
+
// return fixedValue
|
|
14
|
+
// .toLocaleString('zh-CN', { minimumFractionDigits: FRACTION_DIGITS, maximumFractionDigits: FRACTION_DIGITS });
|
|
15
|
+
// }
|
|
16
|
+
// export function currency(value: number) {
|
|
17
|
+
// const fixedValue = +(value || 0).toFixed(FRACTION_DIGITS)
|
|
18
|
+
// return fixedValue
|
|
19
|
+
// .toLocaleString('zh-CN', { style: 'currency', currency: 'CNY', minimumFractionDigits: FRACTION_DIGITS, maximumFractionDigits: FRACTION_DIGITS })
|
|
20
|
+
// }
|
|
21
|
+
export function number(value, fractionDigits = FRACTION_DIGITS) {
|
|
22
|
+
const num = value || 0;
|
|
23
|
+
const sign = +num.toFixed(fractionDigits) < 0 ? '-' : '';
|
|
24
|
+
const fixedValue = Math.abs(num).toFixed(fractionDigits);
|
|
25
|
+
// eslint-disable-next-line prefer-const
|
|
26
|
+
let [integerPart, decimalPart] = fixedValue.split('.');
|
|
27
|
+
// ζ·»ε εδ½ει符
|
|
28
|
+
const rgx = /(\d+)(\d{3})/;
|
|
29
|
+
while (rgx.test(integerPart)) {
|
|
30
|
+
integerPart = integerPart.replace(rgx, '$1' + ',' + '$2');
|
|
31
|
+
}
|
|
32
|
+
return `${sign}${integerPart}.${decimalPart}`;
|
|
33
|
+
}
|
|
34
|
+
export function currency(value, fractionDigits = FRACTION_DIGITS) {
|
|
35
|
+
const num = value || 0;
|
|
36
|
+
const sign = +num.toFixed(fractionDigits) < 0 ? '-' : '';
|
|
37
|
+
const fixedValue = Math.abs(num).toFixed(fractionDigits);
|
|
38
|
+
// eslint-disable-next-line prefer-const
|
|
39
|
+
let [integerPart, decimalPart] = fixedValue.split('.');
|
|
40
|
+
// ζ·»ε εδ½ει符
|
|
41
|
+
const rgx = /(\d+)(\d{3})/;
|
|
42
|
+
while (rgx.test(integerPart)) {
|
|
43
|
+
integerPart = integerPart.replace(rgx, '$1' + ',' + '$2');
|
|
44
|
+
}
|
|
45
|
+
return `${sign}Β₯${integerPart}.${decimalPart}`;
|
|
18
46
|
}
|
|
19
47
|
//# sourceMappingURL=number.js.map
|
package/pipes/number.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/number.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,CAAC,CAAA;AAEzB,MAAM,
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/number.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,CAAC,CAAA;AAEzB;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC;AAE7B,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,cAAc,GAAG,eAAe;IACnE,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;AAC9C,CAAC;AAAA,CAAC;AAEF,wBAAwB;AACxB,0CAA0C;AAC1C,8DAA8D;AAC9D,sBAAsB;AACtB,oHAAoH;AACpH,IAAI;AACJ,4CAA4C;AAC5C,8DAA8D;AAC9D,sBAAsB;AACtB,uJAAuJ;AACvJ,IAAI;AAEJ,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,cAAc,GAAG,eAAe;IACpE,MAAM,GAAG,GAAG,KA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