@solar-taro/core 1.1.12 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## 1.1.13 (2025-07-21)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **core/pipe:** handle void value on amount function
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - HyperLife1119
10
+
11
+ ## 1.1.12 (2025-07-21)
12
+
13
+ ### 🚀 Features
14
+
15
+ - **pipes:** move amount and date into pipes
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - HyperLife1119
20
+
1
21
  ## 1.1.11 (2025-07-18)
2
22
 
3
23
  This was a version bump only for core to align it with other projects, there were no code changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solar-taro/core",
3
- "version": "1.1.12",
3
+ "version": "1.2.0",
4
4
  "sideEffects": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
package/pipes/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './amount';
2
1
  export * from './date';
2
+ export * from './number';
package/pipes/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './amount.js';
2
1
  export * from './date.js';
2
+ export * from './number.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/pipes/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA"}
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
+ export declare function number(value: number): string;
2
+ /**
3
+ * @deprecated {@link number}
4
+ */
5
+ export declare const amount: typeof number;
6
+ export declare function fixed(value: number, fixed?: number): string;
7
+ export declare function currency(value: number): string;
@@ -0,0 +1,19 @@
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
+ /**
8
+ * @deprecated {@link number}
9
+ */
10
+ export const amount = number;
11
+ export function fixed(value, fixed = FRACTION_DIGITS) {
12
+ return (value || 0).toFixed(fixed);
13
+ }
14
+ ;
15
+ export function currency(value) {
16
+ const fixedValue = +(value || 0).toFixed(FRACTION_DIGITS);
17
+ return fixedValue.toLocaleString('zh-CN', { style: 'currency', currency: 'CNY', minimumFractionDigits: FRACTION_DIGITS, maximumFractionDigits: FRACTION_DIGITS });
18
+ }
19
+ //# 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,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACzD,OAAO,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC,CAAC;AAChI,CAAC;AAAA,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC;AAE7B,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,KAAK,GAAG,eAAe;IAC1D,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACzD,OAAO,UAAU,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC,CAAA;AACnK,CAAC"}
package/utils/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './array';
2
2
  export * from './helper';
3
- export * from './math';
4
3
  export * from './service';
5
4
  export * from './style';
6
5
  export * from './window';
package/utils/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './array.js';
2
2
  export * from './helper.js';
3
- export * from './math.js';
4
3
  export * from './service.js';
5
4
  export * from './style.js';
6
5
  export * from './window.js';
@@ -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,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA"}
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
@@ -1,7 +0,0 @@
1
- /**
2
- * 将数字格式化成 1,234 这种带逗号的
3
- *
4
- * @param value
5
- * @param accurate 精准模式,启用后会附加小数点
6
- */
7
- export declare const amount: (value: number, accurate?: boolean) => string;
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).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
@@ -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,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEjE,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
@@ -1,6 +0,0 @@
1
- /**
2
- * 固定数字小数位
3
- * @param value
4
- * @param fixed
5
- */
6
- export declare const fixed: (value: number, fixed?: number) => string;
package/utils/math.js DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * 固定数字小数位
3
- * @param value
4
- * @param fixed
5
- */
6
- export const fixed = (value, fixed = 2) => {
7
- return typeof value === 'number' ? value.toFixed(fixed) : '0.' + ('0'.repeat(fixed));
8
- };
9
- //# sourceMappingURL=math.js.map
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"}