@solar-taro/core 1.1.13 → 1.2.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/CHANGELOG.md +20 -0
- package/package.json +1 -1
- package/pipes/index.d.ts +1 -1
- package/pipes/index.js +1 -1
- package/pipes/index.js.map +1 -1
- package/pipes/number.d.ts +7 -0
- package/pipes/number.js +45 -0
- package/pipes/number.js.map +1 -0
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -1
- package/utils/index.js.map +1 -1
- package/pipes/amount.d.ts +0 -7
- package/pipes/amount.js +0 -24
- package/pipes/amount.js.map +0 -1
- package/utils/math.d.ts +0 -6
- package/utils/math.js +0 -9
- package/utils/math.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 1.2.0 (2025-07-25)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **ui-vant/cascader:** add cascader component
|
|
6
|
+
|
|
7
|
+
### ❤️ Thank You
|
|
8
|
+
|
|
9
|
+
- HyperLife1119
|
|
10
|
+
|
|
11
|
+
## 1.1.13 (2025-07-21)
|
|
12
|
+
|
|
13
|
+
### 🩹 Fixes
|
|
14
|
+
|
|
15
|
+
- **core/pipe:** handle void value on amount function
|
|
16
|
+
|
|
17
|
+
### ❤️ Thank You
|
|
18
|
+
|
|
19
|
+
- HyperLife1119
|
|
20
|
+
|
|
1
21
|
## 1.1.12 (2025-07-21)
|
|
2
22
|
|
|
3
23
|
### 🚀 Features
|
package/package.json
CHANGED
package/pipes/index.d.ts
CHANGED
package/pipes/index.js
CHANGED
package/pipes/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated {@link number}
|
|
3
|
+
*/
|
|
4
|
+
export declare const amount: typeof number;
|
|
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
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const FRACTION_DIGITS = 2;
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated {@link number}
|
|
4
|
+
*/
|
|
5
|
+
export const amount = number;
|
|
6
|
+
export function fixed(value, fractionDigits = FRACTION_DIGITS) {
|
|
7
|
+
return (value || 0).toFixed(fractionDigits);
|
|
8
|
+
}
|
|
9
|
+
;
|
|
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
|
+
let [integerPart, decimalPart] = fixedValue.split('.');
|
|
26
|
+
// 添加千位分隔符
|
|
27
|
+
const rgx = /(\d+)(\d{3})/;
|
|
28
|
+
while (rgx.test(integerPart)) {
|
|
29
|
+
integerPart = integerPart.replace(rgx, '$1' + ',' + '$2');
|
|
30
|
+
}
|
|
31
|
+
return `${sign}${integerPart}.${decimalPart}`;
|
|
32
|
+
}
|
|
33
|
+
export function currency(value, fractionDigits = FRACTION_DIGITS) {
|
|
34
|
+
const num = value || 0;
|
|
35
|
+
const sign = +num.toFixed(fractionDigits) < 0 ? '-' : '';
|
|
36
|
+
const fixedValue = Math.abs(num).toFixed(fractionDigits);
|
|
37
|
+
let [integerPart, decimalPart] = fixedValue.split('.');
|
|
38
|
+
// 添加千位分隔符
|
|
39
|
+
const rgx = /(\d+)(\d{3})/;
|
|
40
|
+
while (rgx.test(integerPart)) {
|
|
41
|
+
integerPart = integerPart.replace(rgx, '$1' + ',' + '$2');
|
|
42
|
+
}
|
|
43
|
+
return `${sign}¥${integerPart}.${decimalPart}`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,E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,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,GAAG,IAAI,IAAI,WAAW,IAAI,WAAW,EAAE,CAAC;AACjD,CAAC"}
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
|
package/pipes/amount.d.ts
DELETED
package/pipes/amount.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 将数字格式化成 1,234 这种带逗号的
|
|
3
|
-
*
|
|
4
|
-
* @param value
|
|
5
|
-
* @param accurate 精准模式,启用后会附加小数点
|
|
6
|
-
*/
|
|
7
|
-
export const amount = (value, accurate = true) => {
|
|
8
|
-
const [integer, decimal] = Math.abs(value || 0).toFixed(2).split('.');
|
|
9
|
-
let str = integer
|
|
10
|
-
.split('')
|
|
11
|
-
.reverse()
|
|
12
|
-
.map((char, index) => char + (index > 0 && index % 3 === 0 ? ',' : '') // 每三个数字就加一逗号
|
|
13
|
-
)
|
|
14
|
-
.reverse()
|
|
15
|
-
.join('');
|
|
16
|
-
if (accurate) {
|
|
17
|
-
str += `.${decimal}`;
|
|
18
|
-
}
|
|
19
|
-
if (value < 0) {
|
|
20
|
-
str = `-${str}`;
|
|
21
|
-
}
|
|
22
|
-
return str;
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=amount.js.map
|
package/pipes/amount.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"amount.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/amount.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,QAAQ,GAAG,IAAI,EAAE,EAAE;IACvD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEtE,IAAI,GAAG,GAAG,OAAO;SACd,KAAK,CAAC,EAAE,CAAC;SACT,OAAO,EAAE;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACnB,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,aAAa;KAC/D;SACA,OAAO,EAAE;SACT,IAAI,CAAC,EAAE,CAAC,CAAC;IAEZ,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC;IACvB,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACd,GAAG,GAAG,IAAI,GAAG,EAAE,CAAA;IACjB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
package/utils/math.d.ts
DELETED
package/utils/math.js
DELETED
package/utils/math.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/math.ts"],"names":[],"mappings":"AACA;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE;IAChD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC"}
|