@pisell/utils 1.0.71 → 1.0.73
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/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +4 -1
- package/es/arrayUtils.js +15 -24
- package/es/common/stateHelper.d.ts +6 -2
- package/es/common/stateHelper.js +22 -24
- package/es/common/types.d.ts +13 -10
- package/es/componentStorage.d.ts +27 -25
- package/es/componentStorage.js +94 -130
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +12 -11
- package/es/format.js +90 -116
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +38 -23
- package/es/index.js +39 -34
- package/es/jsBridge/index.d.ts +8 -4
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +95 -115
- package/es/locales.d.ts +11 -8
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -78
- package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/es/number-input/hooks/useNumberInputState.js +71 -128
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/utils/formatter.d.ts +13 -10
- package/es/number-input/utils/formatter.js +51 -77
- package/es/number-input/utils/validation.d.ts +7 -2
- package/es/number-input/utils/validation.js +51 -66
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +17 -9
- package/es/platform.js +78 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/es/select/hooks/useDebouncedSearch.js +39 -53
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +56 -113
- package/es/select/index.d.ts +7 -8
- package/es/select/types.d.ts +211 -211
- package/es/select/utils/filterOptions.d.ts +7 -6
- package/es/select/utils/filterOptions.js +26 -31
- package/es/select/utils/helpers.d.ts +10 -9
- package/es/select/utils/helpers.js +42 -52
- package/es/select/utils/index.d.ts +4 -7
- package/es/select/utils/sortOptions.d.ts +6 -5
- package/es/select/utils/sortOptions.js +19 -31
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +34 -47
- package/es/text-input/hooks/useTextInputState.d.ts +6 -2
- package/es/text-input/hooks/useTextInputState.js +69 -126
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/utils/validation.d.ts +7 -2
- package/es/text-input/utils/validation.js +50 -70
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +36 -34
- package/es/walletValidity.js +332 -456
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +4 -1
- package/lib/arrayUtils.js +14 -39
- package/lib/common/stateHelper.d.ts +6 -2
- package/lib/common/stateHelper.js +21 -32
- package/lib/common/types.d.ts +13 -10
- package/lib/componentStorage.d.ts +27 -25
- package/lib/componentStorage.js +96 -126
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +12 -11
- package/lib/format.js +91 -99
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +38 -23
- package/lib/index.js +115 -78
- package/lib/jsBridge/index.d.ts +8 -4
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +95 -115
- package/lib/locales.d.ts +11 -8
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -92
- package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/lib/number-input/hooks/useNumberInputState.js +71 -81
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/utils/formatter.d.ts +13 -10
- package/lib/number-input/utils/formatter.js +52 -49
- package/lib/number-input/utils/validation.d.ts +7 -2
- package/lib/number-input/utils/validation.js +50 -52
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +17 -9
- package/lib/platform.js +85 -122
- package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/lib/select/hooks/useDebouncedSearch.js +40 -41
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +58 -93
- package/lib/select/index.d.ts +7 -8
- package/lib/select/types.d.ts +211 -211
- package/lib/select/utils/filterOptions.d.ts +7 -6
- package/lib/select/utils/filterOptions.js +26 -37
- package/lib/select/utils/helpers.d.ts +10 -9
- package/lib/select/utils/helpers.js +45 -41
- package/lib/select/utils/index.d.ts +4 -7
- package/lib/select/utils/sortOptions.d.ts +6 -5
- package/lib/select/utils/sortOptions.js +18 -39
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +33 -41
- package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
- package/lib/text-input/hooks/useTextInputState.js +69 -79
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/utils/validation.d.ts +7 -2
- package/lib/text-input/utils/validation.js +49 -58
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +36 -34
- package/lib/walletValidity.js +345 -317
- package/package.json +1 -2
- package/es/common/index.d.ts +0 -5
- package/es/common/index.js +0 -5
- package/es/common/types.js +0 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/es/jsBridge/types.js +0 -1
- package/es/number-input/hooks/index.d.ts +0 -4
- package/es/number-input/hooks/index.js +0 -5
- package/es/number-input/index.d.ts +0 -14
- package/es/number-input/index.js +0 -21
- package/es/number-input/types.js +0 -1
- package/es/number-input/utils/index.d.ts +0 -7
- package/es/number-input/utils/index.js +0 -8
- package/es/select/hooks/index.d.ts +0 -5
- package/es/select/hooks/index.js +0 -6
- package/es/select/index.js +0 -13
- package/es/select/types.js +0 -1
- package/es/select/utils/index.js +0 -8
- package/es/text-input/hooks/index.d.ts +0 -4
- package/es/text-input/hooks/index.js +0 -5
- package/es/text-input/index.d.ts +0 -14
- package/es/text-input/index.js +0 -20
- package/es/text-input/types.js +0 -1
- package/es/text-input/utils/index.d.ts +0 -5
- package/es/text-input/utils/index.js +0 -7
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.js +0 -29
- package/lib/common/types.js +0 -17
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
- package/lib/jsBridge/types.js +0 -17
- package/lib/number-input/hooks/index.d.ts +0 -4
- package/lib/number-input/hooks/index.js +0 -29
- package/lib/number-input/index.d.ts +0 -14
- package/lib/number-input/index.js +0 -41
- package/lib/number-input/types.js +0 -17
- package/lib/number-input/utils/index.d.ts +0 -7
- package/lib/number-input/utils/index.js +0 -39
- package/lib/select/hooks/index.d.ts +0 -5
- package/lib/select/hooks/index.js +0 -34
- package/lib/select/index.js +0 -53
- package/lib/select/types.js +0 -17
- package/lib/select/utils/index.js +0 -48
- package/lib/text-input/hooks/index.d.ts +0 -4
- package/lib/text-input/hooks/index.js +0 -29
- package/lib/text-input/index.d.ts +0 -14
- package/lib/text-input/index.js +0 -35
- package/lib/text-input/types.js +0 -17
- package/lib/text-input/utils/index.d.ts +0 -5
- package/lib/text-input/utils/index.js +0 -32
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
1
|
+
//#region src/escPosPrinter/index.d.ts
|
|
2
|
+
declare const EscPosPrinter = any;
|
|
3
|
+
declare const ALIGN_LEFT = number;
|
|
4
|
+
declare const ALIGN_CENTER = number;
|
|
5
|
+
declare const ALIGN_RIGHT = number;
|
|
6
|
+
declare const columnWidthWithAlignment = (width: number, alignment: number) => any;
|
|
7
|
+
declare const preparing = any;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, EscPosPrinter, columnWidthWithAlignment, preparing };
|
|
@@ -1,54 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
printer.setAlignment(ALIGN_LEFT);
|
|
8
|
-
printer.appendText("------------------------------------------------\n");
|
|
1
|
+
import { _asyncToGenerator } from "../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
|
|
2
|
+
import EscPosPrinter, { columnWidthWithAlignment } from "./EscPosPrinter.js";
|
|
3
|
+
//#region src/escPosPrinter/index.js
|
|
4
|
+
const dividing = (printer) => {
|
|
5
|
+
printer.setAlignment(0);
|
|
6
|
+
printer.appendText("------------------------------------------------\n");
|
|
9
7
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
_context.next = 24;
|
|
40
|
-
return printer.print(ip, sn, 1);
|
|
41
|
-
case 24:
|
|
42
|
-
result = _context.sent;
|
|
43
|
-
return _context.abrupt("return", result);
|
|
44
|
-
case 26:
|
|
45
|
-
case "end":
|
|
46
|
-
return _context.stop();
|
|
47
|
-
}
|
|
48
|
-
}, _callee);
|
|
49
|
-
}));
|
|
50
|
-
return function preparing(_x, _x2, _x3) {
|
|
51
|
-
return _ref.apply(this, arguments);
|
|
52
|
-
};
|
|
8
|
+
const preparing = function() {
|
|
9
|
+
var _ref = _asyncToGenerator(function* (ip, sn, params) {
|
|
10
|
+
const printer = new EscPosPrinter(576);
|
|
11
|
+
const { title } = params;
|
|
12
|
+
printer.clear();
|
|
13
|
+
printer.lineFeed(1);
|
|
14
|
+
printer.setPrintModes(false, false, false);
|
|
15
|
+
printer.setAlignment(1);
|
|
16
|
+
printer.appendText("打印测试\n");
|
|
17
|
+
dividing(printer);
|
|
18
|
+
printer.setAlignment(0);
|
|
19
|
+
printer.appendText("Order time: 2023-10-19 14:15:50\n");
|
|
20
|
+
printer.appendText("Order number\n");
|
|
21
|
+
printer.appendText("D3012");
|
|
22
|
+
dividing(printer);
|
|
23
|
+
printer.setColumnWidths(columnWidthWithAlignment(150, 0), columnWidthWithAlignment(426, 0));
|
|
24
|
+
printer.printInColumns("Number", "Name");
|
|
25
|
+
printer.setPrintModes(true, true, true);
|
|
26
|
+
printer.printInColumns("1 x", "我是很长的商品名称我是很长的商品名称我是很长的商品名称我是很长的商品名称");
|
|
27
|
+
printer.setPrintModes(false, false, false);
|
|
28
|
+
dividing(printer);
|
|
29
|
+
printer.lineFeed(4);
|
|
30
|
+
printer.cutPaper(false);
|
|
31
|
+
printer.printAndExitPageMode();
|
|
32
|
+
return yield printer.print(ip, sn, 1);
|
|
33
|
+
});
|
|
34
|
+
return function preparing(_x, _x2, _x3) {
|
|
35
|
+
return _ref.apply(this, arguments);
|
|
36
|
+
};
|
|
53
37
|
}();
|
|
54
|
-
|
|
38
|
+
//#endregion
|
|
39
|
+
export { preparing };
|
package/es/format.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/format.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* @title: 格式化金额
|
|
3
4
|
* @description:
|
|
@@ -8,16 +9,14 @@
|
|
|
8
9
|
* @Author: zhiwei.Wang
|
|
9
10
|
* @Date: 2023-11-06 16:51
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
|
|
20
|
-
hideDecimalForWholeNumbers?: boolean;
|
|
12
|
+
declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
|
|
13
|
+
type FormatOptions = {
|
|
14
|
+
/** 小数点后位数 默认是小数点后2位 */precision?: number; /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
|
|
15
|
+
showCurrencySymbol?: boolean; /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
|
|
16
|
+
useThousandsSeparator?: boolean; /** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
|
|
17
|
+
hideDecimalForWholeNumbers?: boolean; /** 货币代码或虚拟币单位后缀 */
|
|
18
|
+
currencyCode?: string; /** 货币展示格式,支持预置值和金额模板 */
|
|
19
|
+
currencyFormat?: string;
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
23
22
|
* 根据配置格式化金额
|
|
@@ -25,4 +24,6 @@ export declare type FormatOptions = {
|
|
|
25
24
|
* @param symbol
|
|
26
25
|
* @param options
|
|
27
26
|
*/
|
|
28
|
-
|
|
27
|
+
declare const formatAmountWithOptions: (amount?: number | string, symbol?: string, options?: FormatOptions) => string | number;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FormatOptions, formatAmount, formatAmountWithOptions };
|
package/es/format.js
CHANGED
|
@@ -1,119 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { isNumber, isString } from "./typeUtils.js";
|
|
2
|
+
//#region src/format.ts
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// 添加负号
|
|
48
|
-
if (roundedAmount < 0) {
|
|
49
|
-
formattedAmount = '-' + formattedAmount;
|
|
50
|
-
}
|
|
51
|
-
return formattedAmount;
|
|
52
|
-
} catch (err) {
|
|
53
|
-
// 计算错误则返回原金额
|
|
54
|
-
console.error(err);
|
|
55
|
-
return amount;
|
|
56
|
-
}
|
|
4
|
+
* @title: 格式化金额
|
|
5
|
+
* @description:
|
|
6
|
+
* @param {number} amount 原金额
|
|
7
|
+
* @param {number} precision 小数位数
|
|
8
|
+
* @param {string} symbol 货币符号
|
|
9
|
+
* @return {*}
|
|
10
|
+
* @Author: zhiwei.Wang
|
|
11
|
+
* @Date: 2023-11-06 16:51
|
|
12
|
+
*/
|
|
13
|
+
const formatAmount = (amount = 0, precision = 2, symbol = "") => {
|
|
14
|
+
if (!isString(amount) && !isNumber(amount)) {
|
|
15
|
+
console.error("amount is not a number");
|
|
16
|
+
return amount;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
20
|
+
const absoluteAmount = Math.abs(roundedAmount);
|
|
21
|
+
const integerPart = Math.floor(absoluteAmount);
|
|
22
|
+
const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
23
|
+
let formattedAmount = symbol + integerPart.toString();
|
|
24
|
+
if (precision > 0) {
|
|
25
|
+
formattedAmount += "." + decimalPart;
|
|
26
|
+
if (formattedAmount.indexOf(".00") !== -1) formattedAmount = formattedAmount.substring(0, formattedAmount.length - 3);
|
|
27
|
+
}
|
|
28
|
+
if (roundedAmount < 0) formattedAmount = "-" + formattedAmount;
|
|
29
|
+
return formattedAmount;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
console.error(err);
|
|
32
|
+
return amount;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const applyCurrencyFormat = (params) => {
|
|
36
|
+
const { amount, symbol, currencyCode, currencyFormat } = params;
|
|
37
|
+
const format = currencyFormat.trim();
|
|
38
|
+
if (format.includes("{{amount}}") || format.includes("{amount}")) return format.split("{{amount}}").join(amount).split("{{sym}}").join(symbol).split("{{unit}}").join(currencyCode).split("{{symbol}}").join(symbol).split("{{unit_label}}").join(currencyCode).split("{{currency_code}}").join(currencyCode).split("{amount}").join(amount).split("{sym}").join(symbol).split("{unit}").join(currencyCode).split("{symbol}").join(symbol).split("{unit_label}").join(currencyCode).split("{currency_code}").join(currencyCode).trim();
|
|
39
|
+
if (format === "symbol_last") {
|
|
40
|
+
if (symbol) return `${amount}${symbol}`;
|
|
41
|
+
if (currencyCode) return `${amount} ${currencyCode}`;
|
|
42
|
+
return amount;
|
|
43
|
+
}
|
|
44
|
+
if (symbol) return `${symbol}${amount}`;
|
|
45
|
+
return currencyCode ? `${amount} ${currencyCode}` : amount;
|
|
57
46
|
};
|
|
58
47
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
formattedAmount = formattedAmount.substring(0, formattedAmount.length - 3);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// 添加负号
|
|
110
|
-
if (roundedAmount < 0) {
|
|
111
|
-
formattedAmount = '-' + formattedAmount;
|
|
112
|
-
}
|
|
113
|
-
return formattedAmount;
|
|
114
|
-
} catch (err) {
|
|
115
|
-
// 计算错误则返回原金额
|
|
116
|
-
console.error(err);
|
|
117
|
-
return amount;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
48
|
+
* 根据配置格式化金额
|
|
49
|
+
* @param amount
|
|
50
|
+
* @param symbol
|
|
51
|
+
* @param options
|
|
52
|
+
*/
|
|
53
|
+
const formatAmountWithOptions = (amount = 0, symbol = "", options = {}) => {
|
|
54
|
+
const { precision = 2, useThousandsSeparator = false, showCurrencySymbol = true, hideDecimalForWholeNumbers = true, currencyCode = "", currencyFormat = "" } = options;
|
|
55
|
+
if (!isString(amount) && !isNumber(amount)) {
|
|
56
|
+
console.error("amount is not a number");
|
|
57
|
+
return amount;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
61
|
+
const absoluteAmount = Math.abs(roundedAmount);
|
|
62
|
+
const integerPart = Math.floor(absoluteAmount);
|
|
63
|
+
const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
64
|
+
if (!currencyCode && !currencyFormat) {
|
|
65
|
+
let legacyFormattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
66
|
+
legacyFormattedAmount = showCurrencySymbol ? symbol + legacyFormattedAmount : legacyFormattedAmount;
|
|
67
|
+
if (precision > 0) {
|
|
68
|
+
legacyFormattedAmount += "." + decimalPart;
|
|
69
|
+
if (hideDecimalForWholeNumbers && legacyFormattedAmount.indexOf(".00") !== -1) legacyFormattedAmount = legacyFormattedAmount.substring(0, legacyFormattedAmount.length - 3);
|
|
70
|
+
}
|
|
71
|
+
if (roundedAmount < 0) legacyFormattedAmount = "-" + legacyFormattedAmount;
|
|
72
|
+
return legacyFormattedAmount;
|
|
73
|
+
}
|
|
74
|
+
let formattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
75
|
+
if (precision > 0) {
|
|
76
|
+
formattedAmount += "." + decimalPart;
|
|
77
|
+
if (hideDecimalForWholeNumbers && Number(decimalPart) === 0) formattedAmount = formattedAmount.substring(0, formattedAmount.length - precision - 1);
|
|
78
|
+
}
|
|
79
|
+
if (showCurrencySymbol) formattedAmount = applyCurrencyFormat({
|
|
80
|
+
amount: formattedAmount,
|
|
81
|
+
symbol,
|
|
82
|
+
currencyCode,
|
|
83
|
+
currencyFormat
|
|
84
|
+
});
|
|
85
|
+
if (roundedAmount < 0) formattedAmount = "-" + formattedAmount;
|
|
86
|
+
return formattedAmount;
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error(err);
|
|
89
|
+
return amount;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { formatAmount, formatAmountWithOptions };
|
package/es/image.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
//#region src/image.d.ts
|
|
2
|
+
declare const image: {
|
|
3
|
+
ali: (url: string, w: number) => string;
|
|
4
|
+
getImageSize: (url: string) => {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
ratio: number;
|
|
8
|
+
success: boolean;
|
|
9
|
+
widthRatio: number;
|
|
10
|
+
originRatio: number;
|
|
11
|
+
};
|
|
11
12
|
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { image };
|
package/es/image.js
CHANGED
|
@@ -1,63 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (url.indexOf('?') > -1) {
|
|
12
|
-
url += '&';
|
|
13
|
-
} else {
|
|
14
|
-
url += '?';
|
|
15
|
-
}
|
|
16
|
-
url += 'x-oss-process=image/resize,w_' + parseInt(w * dpr + '') + ',image/format,webp/interlace,1,image/quality,Q_60/sharpen,90';
|
|
17
|
-
return url;
|
|
1
|
+
//#region src/image.ts
|
|
2
|
+
const ali = (url, w) => {
|
|
3
|
+
if (!url || /^\s+$/.test(url)) return "";
|
|
4
|
+
if (/x-oss-process=/.test(url)) return url;
|
|
5
|
+
let dpr = 2;
|
|
6
|
+
w = w || 750;
|
|
7
|
+
if (url.indexOf("?") > -1) url += "&";
|
|
8
|
+
else url += "?";
|
|
9
|
+
url += "x-oss-process=image/resize,w_" + parseInt(w * dpr + "") + ",image/format,webp/interlace,1,image/quality,Q_60/sharpen,90";
|
|
10
|
+
return url;
|
|
18
11
|
};
|
|
19
|
-
|
|
20
12
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
size.originRatio = Number(_height / _width);
|
|
54
|
-
}
|
|
55
|
-
return size;
|
|
56
|
-
} catch (err) {
|
|
57
|
-
return size;
|
|
58
|
-
}
|
|
13
|
+
* @Title: 获取图片尺寸
|
|
14
|
+
* @Describe: 通过 __ 进行分割
|
|
15
|
+
* @Author: Wzw
|
|
16
|
+
* @param {string} url
|
|
17
|
+
*/
|
|
18
|
+
const getImageSize = (url) => {
|
|
19
|
+
let size = {
|
|
20
|
+
width: 375,
|
|
21
|
+
height: 375,
|
|
22
|
+
ratio: 1,
|
|
23
|
+
widthRatio: 1,
|
|
24
|
+
success: false,
|
|
25
|
+
originRatio: 1
|
|
26
|
+
};
|
|
27
|
+
if (typeof url !== "string") return size;
|
|
28
|
+
try {
|
|
29
|
+
let arr = url.split("__");
|
|
30
|
+
if (arr[1]) {
|
|
31
|
+
let sizeArr = arr[1].split("_");
|
|
32
|
+
let _width = Number(sizeArr[0]) || 375;
|
|
33
|
+
let _height = Number(sizeArr[1]) || 375;
|
|
34
|
+
size.width = _width;
|
|
35
|
+
size.height = _height;
|
|
36
|
+
size.success = true;
|
|
37
|
+
size.ratio = Number(_height / _width);
|
|
38
|
+
size.widthRatio = Number((_width / _height).toFixed(2));
|
|
39
|
+
size.originRatio = Number(_height / _width);
|
|
40
|
+
}
|
|
41
|
+
return size;
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return size;
|
|
44
|
+
}
|
|
59
45
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
46
|
+
const image = {
|
|
47
|
+
ali,
|
|
48
|
+
getImageSize
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { image };
|
package/es/index.d.ts
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { changeArray, createArray, detectIncognito, generateUniqueIdByObj, getItemByArray, getUniqueId } from "./otherUtils.js";
|
|
2
|
+
import { isArr, isBoolean, isFunction, isJson, isNumber, isPlainObject, isString, isUndefined } from "./typeUtils.js";
|
|
3
|
+
import { ColumnSettingStorageItem, clearColumnSettingFromLocal, clearColumnVisibilityFromLocal, getColumnSettingFromLocal, getColumnVisibilityFromLocal, getComponentStorageKey, getRecordBoardColumnSettingFromLocal, getStorageKeySuffix, saveColumnSettingToLocal, saveColumnVisibilityToLocal } from "./componentStorage.js";
|
|
4
|
+
import { copyToClipboard, setTheme } from "./document.js";
|
|
5
|
+
import { excelDateToJSDate, formatDate, jsDateToExcelDate } from "./date.js";
|
|
6
|
+
import { checkEnv, isAndroid, isIOS, isIos, isIpad, isMobile, isSafari, isWebposOsServerEnv, isWx, isWxApp } from "./platform.js";
|
|
7
|
+
import { sendWarningLog } from "./log.js";
|
|
8
|
+
import { FormatOptions, formatAmount, formatAmountWithOptions } from "./format.js";
|
|
9
|
+
import { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, EscPosPrinter, columnWidthWithAlignment, preparing } from "./escPosPrinter/index.js";
|
|
10
|
+
import { miniRedux } from "./miniRedux.js";
|
|
11
|
+
import { dataManager, webPayment, webPrint } from "./jsBridge/index.js";
|
|
12
|
+
import { image } from "./image.js";
|
|
13
|
+
import { locales } from "./locales.js";
|
|
14
|
+
import { uniqueByKey } from "./arrayUtils.js";
|
|
15
|
+
import { Locale, getScheduleSummary } from "./walletValidity.js";
|
|
16
|
+
import { DisplayState, ValidationResult } from "./common/types.js";
|
|
17
|
+
import { getDisplayState } from "./common/stateHelper.js";
|
|
18
|
+
import { BaseTextInputProps, TextInputState } from "./text-input/types.js";
|
|
19
|
+
import { useTextInputState } from "./text-input/hooks/useTextInputState.js";
|
|
20
|
+
import { validateValue as validateValue$1 } from "./text-input/utils/validation.js";
|
|
21
|
+
import { BaseNumberInputProps, NumberInputState } from "./number-input/types.js";
|
|
22
|
+
import { useNumberInputState } from "./number-input/hooks/useNumberInputState.js";
|
|
23
|
+
import { validateValue } from "./number-input/utils/validation.js";
|
|
24
|
+
import { NumberFormatOptions, addThousandsSeparator, formatNumber, formatPrecision } from "./number-input/utils/formatter.js";
|
|
25
|
+
import { BaseSelectProps, FilterOptionFunc, MultipleSelectState, SelectOption, SelectState, SortDirection, TagDisplayInfo, UseMultipleSelectStateOptions, UseSelectStateOptions } from "./select/types.js";
|
|
26
|
+
import { useMultipleSelectState, useSelectState } from "./select/hooks/useSelectState.js";
|
|
27
|
+
import { useDebouncedSearch } from "./select/hooks/useDebouncedSearch.js";
|
|
28
|
+
import { calculateTagDisplay } from "./select/utils/tagAggregation.js";
|
|
29
|
+
import { defaultFilterOption, filterOptions } from "./select/utils/filterOptions.js";
|
|
30
|
+
import { sortOptions } from "./select/utils/sortOptions.js";
|
|
31
|
+
import { findOptionByValue, findOptionsByValues, generateId, isOptionSelected, isOptionSelectedInMultiple } from "./select/utils/helpers.js";
|
|
32
|
+
//#region src/index.d.ts
|
|
33
|
+
declare const setPisellUtilsConfig: (config: {
|
|
34
|
+
[key: string]: any;
|
|
22
35
|
}) => void;
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
declare const getPisellUtilsConfig: () => {
|
|
37
|
+
[key: string]: any;
|
|
25
38
|
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, BaseNumberInputProps, BaseSelectProps, BaseTextInputProps, ColumnSettingStorageItem, DisplayState, EscPosPrinter, FilterOptionFunc, FormatOptions, Locale, MultipleSelectState, NumberFormatOptions, NumberInputState, SelectOption, SelectState, SortDirection, TagDisplayInfo, TextInputState, UseMultipleSelectStateOptions, UseSelectStateOptions, ValidationResult, addThousandsSeparator, calculateTagDisplay, changeArray, checkEnv, clearColumnSettingFromLocal, clearColumnVisibilityFromLocal, columnWidthWithAlignment, copyToClipboard, createArray, dataManager, defaultFilterOption, detectIncognito, excelDateToJSDate, filterOptions, findOptionByValue, findOptionsByValues, formatAmount, formatAmountWithOptions, formatDate, formatNumber, formatPrecision, generateId, generateUniqueIdByObj, getColumnSettingFromLocal, getColumnVisibilityFromLocal, getComponentStorageKey, getDisplayState, getItemByArray, getPisellUtilsConfig, getRecordBoardColumnSettingFromLocal, getScheduleSummary, getStorageKeySuffix, getUniqueId, image, isAndroid, isArr, isBoolean, isFunction, isIOS, isIos, isIpad, isJson, isMobile, isNumber, isOptionSelected, isOptionSelectedInMultiple, isPlainObject, isSafari, isString, isUndefined, isWebposOsServerEnv, isWx, isWxApp, jsDateToExcelDate, locales, miniRedux, preparing, saveColumnSettingToLocal, saveColumnVisibilityToLocal, sendWarningLog, setPisellUtilsConfig, setTheme, sortOptions, uniqueByKey, useDebouncedSearch, useMultipleSelectState, useNumberInputState, useSelectState, useTextInputState, validateValue as validateNumberValue, validateValue$1 as validateTextValue, webPayment, webPrint };
|