@pisell/utils 3.0.5 → 3.0.6
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 +76 -1
- package/es/arrayUtils.js +103 -24
- package/es/common/stateHelper.d.ts +22 -0
- package/es/common/stateHelper.js +23 -0
- package/es/common/types.d.ts +31 -0
- package/es/componentStorage.d.ts +38 -0
- package/es/componentStorage.js +106 -0
- 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 -112
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +39 -18
- package/es/index.js +40 -29
- package/es/jsBridge/index.d.ts +14 -106
- package/es/jsBridge/index.js +57 -40
- package/es/jsBridge/regDeviceApi.js +87 -126
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +11 -11
- package/es/locales.js +79 -69
- 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 -71
- package/es/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/es/number-input/hooks/useNumberInputState.js +72 -0
- package/es/number-input/types.d.ts +96 -0
- package/es/number-input/utils/formatter.d.ts +56 -0
- package/es/number-input/utils/formatter.js +56 -0
- package/es/number-input/utils/validation.d.ts +32 -0
- package/es/number-input/utils/validation.js +52 -0
- package/es/otherUtils.d.ts +51 -0
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +12 -9
- package/es/platform.js +61 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/es/select/hooks/useDebouncedSearch.js +41 -0
- package/es/select/hooks/useSelectState.d.ts +19 -0
- package/es/select/hooks/useSelectState.js +60 -0
- package/es/select/index.d.ts +7 -0
- package/es/select/types.d.ts +256 -0
- package/es/select/utils/filterOptions.d.ts +23 -0
- package/es/select/utils/filterOptions.js +29 -0
- package/es/select/utils/helpers.d.ts +43 -0
- package/es/select/utils/helpers.js +51 -0
- package/es/select/utils/index.d.ts +4 -0
- package/es/select/utils/sortOptions.d.ts +13 -0
- package/es/select/utils/sortOptions.js +20 -0
- package/es/select/utils/tagAggregation.d.ts +25 -0
- package/es/select/utils/tagAggregation.js +35 -0
- package/es/text-input/hooks/useTextInputState.d.ts +28 -0
- package/es/text-input/hooks/useTextInputState.js +70 -0
- package/es/text-input/types.d.ts +56 -0
- package/es/text-input/utils/validation.d.ts +28 -0
- package/es/text-input/utils/validation.js +51 -0
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +57 -0
- package/es/walletValidity.js +404 -460
- package/es/weighing.d.ts +65 -0
- package/es/weighing.js +96 -0
- 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 +76 -1
- package/lib/arrayUtils.js +102 -37
- package/lib/common/stateHelper.d.ts +22 -0
- package/lib/common/stateHelper.js +23 -0
- package/lib/common/types.d.ts +31 -0
- package/lib/componentStorage.d.ts +38 -0
- package/lib/componentStorage.js +114 -0
- 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 -93
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +39 -18
- package/lib/index.js +137 -68
- package/lib/jsBridge/index.d.ts +14 -106
- package/lib/jsBridge/index.js +60 -60
- package/lib/jsBridge/regDeviceApi.js +86 -133
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +11 -11
- package/lib/locales.js +79 -63
- 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 -91
- package/lib/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/lib/number-input/hooks/useNumberInputState.js +73 -0
- package/lib/number-input/types.d.ts +96 -0
- package/lib/number-input/utils/formatter.d.ts +56 -0
- package/lib/number-input/utils/formatter.js +58 -0
- package/lib/number-input/utils/validation.d.ts +32 -0
- package/lib/number-input/utils/validation.js +52 -0
- package/lib/otherUtils.d.ts +51 -0
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +12 -9
- package/lib/platform.js +68 -123
- package/lib/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/lib/select/hooks/useDebouncedSearch.js +42 -0
- package/lib/select/hooks/useSelectState.d.ts +19 -0
- package/lib/select/hooks/useSelectState.js +62 -0
- package/lib/select/index.d.ts +7 -0
- package/lib/select/types.d.ts +256 -0
- package/lib/select/utils/filterOptions.d.ts +23 -0
- package/lib/select/utils/filterOptions.js +30 -0
- package/lib/select/utils/helpers.d.ts +43 -0
- package/lib/select/utils/helpers.js +55 -0
- package/lib/select/utils/index.d.ts +4 -0
- package/lib/select/utils/sortOptions.d.ts +13 -0
- package/lib/select/utils/sortOptions.js +20 -0
- package/lib/select/utils/tagAggregation.d.ts +25 -0
- package/lib/select/utils/tagAggregation.js +35 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +28 -0
- package/lib/text-input/hooks/useTextInputState.js +71 -0
- package/lib/text-input/types.d.ts +56 -0
- package/lib/text-input/utils/validation.d.ts +28 -0
- package/lib/text-input/utils/validation.js +51 -0
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +57 -0
- package/lib/walletValidity.js +420 -323
- package/lib/weighing.d.ts +65 -0
- package/lib/weighing.js +114 -0
- package/package.json +1 -1
- 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/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
|
@@ -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,85 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
1
|
+
const require_asyncToGenerator = require("../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
const require_EscPosPrinter = require("./EscPosPrinter.js");
|
|
3
|
+
//#region src/escPosPrinter/index.js
|
|
4
|
+
const dividing = (printer) => {
|
|
5
|
+
printer.setAlignment(0);
|
|
6
|
+
printer.appendText("------------------------------------------------\n");
|
|
10
7
|
};
|
|
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
|
-
printer.appendText("------------------------------------------------\n");
|
|
44
|
-
};
|
|
45
|
-
var preparing = async (ip, sn, params) => {
|
|
46
|
-
const printer = new import_EscPosPrinter.default(576);
|
|
47
|
-
const { title } = params;
|
|
48
|
-
printer.clear();
|
|
49
|
-
printer.lineFeed(1);
|
|
50
|
-
printer.setPrintModes(false, false, false);
|
|
51
|
-
printer.setAlignment(import_EscPosPrinter.ALIGN_CENTER);
|
|
52
|
-
printer.appendText("打印测试\n");
|
|
53
|
-
dividing(printer);
|
|
54
|
-
printer.setAlignment(import_EscPosPrinter.ALIGN_LEFT);
|
|
55
|
-
printer.appendText("Order time: 2023-10-19 14:15:50\n");
|
|
56
|
-
printer.appendText("Order number\n");
|
|
57
|
-
printer.appendText("D3012");
|
|
58
|
-
dividing(printer);
|
|
59
|
-
printer.setColumnWidths(
|
|
60
|
-
(0, import_EscPosPrinter.columnWidthWithAlignment)(150, import_EscPosPrinter.ALIGN_LEFT),
|
|
61
|
-
(0, import_EscPosPrinter.columnWidthWithAlignment)(426, import_EscPosPrinter.ALIGN_LEFT)
|
|
62
|
-
);
|
|
63
|
-
printer.printInColumns("Number", "Name");
|
|
64
|
-
printer.setPrintModes(true, true, true);
|
|
65
|
-
printer.printInColumns(
|
|
66
|
-
"1 x",
|
|
67
|
-
"我是很长的商品名称我是很长的商品名称我是很长的商品名称我是很长的商品名称"
|
|
68
|
-
);
|
|
69
|
-
printer.setPrintModes(false, false, false);
|
|
70
|
-
dividing(printer);
|
|
71
|
-
printer.lineFeed(4);
|
|
72
|
-
printer.cutPaper(false);
|
|
73
|
-
printer.printAndExitPageMode();
|
|
74
|
-
const result = await printer.print(ip, sn, 1);
|
|
75
|
-
return result;
|
|
76
|
-
};
|
|
77
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
-
0 && (module.exports = {
|
|
79
|
-
ALIGN_CENTER,
|
|
80
|
-
ALIGN_LEFT,
|
|
81
|
-
ALIGN_RIGHT,
|
|
82
|
-
EscPosPrinter,
|
|
83
|
-
columnWidthWithAlignment,
|
|
84
|
-
preparing
|
|
85
|
-
});
|
|
8
|
+
const preparing = function() {
|
|
9
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (ip, sn, params) {
|
|
10
|
+
const printer = new require_EscPosPrinter.default(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(require_EscPosPrinter.columnWidthWithAlignment(150, 0), require_EscPosPrinter.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
|
+
};
|
|
37
|
+
}();
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.preparing = preparing;
|
package/lib/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/lib/format.js
CHANGED
|
@@ -1,96 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const require_typeUtils = require("./typeUtils.js");
|
|
2
|
+
//#region src/format.ts
|
|
3
|
+
/**
|
|
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 (!require_typeUtils.isString(amount) && !require_typeUtils.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
|
+
}
|
|
8
34
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
46
|
};
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
/**
|
|
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 (!require_typeUtils.isString(amount) && !require_typeUtils.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
|
+
}
|
|
55
91
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
useThousandsSeparator = false,
|
|
60
|
-
showCurrencySymbol = true,
|
|
61
|
-
hideDecimalForWholeNumbers = true
|
|
62
|
-
} = options;
|
|
63
|
-
if (!(0, import_typeUtils.isString)(amount) && !(0, import_typeUtils.isNumber)(amount)) {
|
|
64
|
-
console.error("amount is not a number");
|
|
65
|
-
return amount;
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
69
|
-
const absoluteAmount = Math.abs(roundedAmount);
|
|
70
|
-
const integerPart = Math.floor(absoluteAmount);
|
|
71
|
-
const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
72
|
-
let formattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
73
|
-
formattedAmount = showCurrencySymbol ? symbol + formattedAmount : formattedAmount;
|
|
74
|
-
if (precision > 0) {
|
|
75
|
-
formattedAmount += "." + decimalPart;
|
|
76
|
-
if (hideDecimalForWholeNumbers && formattedAmount.indexOf(".00") !== -1) {
|
|
77
|
-
formattedAmount = formattedAmount.substring(
|
|
78
|
-
0,
|
|
79
|
-
formattedAmount.length - 3
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (roundedAmount < 0) {
|
|
84
|
-
formattedAmount = "-" + formattedAmount;
|
|
85
|
-
}
|
|
86
|
-
return formattedAmount;
|
|
87
|
-
} catch (err) {
|
|
88
|
-
console.error(err);
|
|
89
|
-
return amount;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
93
|
-
0 && (module.exports = {
|
|
94
|
-
formatAmount,
|
|
95
|
-
formatAmountWithOptions
|
|
96
|
-
});
|
|
92
|
+
//#endregion
|
|
93
|
+
exports.formatAmount = formatAmount;
|
|
94
|
+
exports.formatAmountWithOptions = formatAmountWithOptions;
|
package/lib/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/lib/image.js
CHANGED
|
@@ -1,77 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/**
|
|
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
|
+
}
|
|
16
45
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var image_exports = {};
|
|
21
|
-
__export(image_exports, {
|
|
22
|
-
image: () => image
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(image_exports);
|
|
25
|
-
var ali = (url, w) => {
|
|
26
|
-
if (!url || /^\s+$/.test(url)) {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
if (/x-oss-process=/.test(url)) {
|
|
30
|
-
return url;
|
|
31
|
-
}
|
|
32
|
-
let dpr = 2;
|
|
33
|
-
w = w || 750;
|
|
34
|
-
if (url.indexOf("?") > -1) {
|
|
35
|
-
url += "&";
|
|
36
|
-
} else {
|
|
37
|
-
url += "?";
|
|
38
|
-
}
|
|
39
|
-
url += "x-oss-process=image/resize,w_" + parseInt(w * dpr + "") + ",image/format,webp/interlace,1,image/quality,Q_60/sharpen,90";
|
|
40
|
-
return url;
|
|
46
|
+
const image = {
|
|
47
|
+
ali,
|
|
48
|
+
getImageSize
|
|
41
49
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
width: 375,
|
|
45
|
-
height: 375,
|
|
46
|
-
ratio: 1,
|
|
47
|
-
widthRatio: 1,
|
|
48
|
-
success: false,
|
|
49
|
-
originRatio: 1
|
|
50
|
-
};
|
|
51
|
-
if (typeof url !== "string") return size;
|
|
52
|
-
try {
|
|
53
|
-
let arr = url.split("__");
|
|
54
|
-
if (arr[1]) {
|
|
55
|
-
let sizeArr = arr[1].split("_");
|
|
56
|
-
let _width = Number(sizeArr[0]) || 375;
|
|
57
|
-
let _height = Number(sizeArr[1]) || 375;
|
|
58
|
-
size.width = _width;
|
|
59
|
-
size.height = _height;
|
|
60
|
-
size.success = true;
|
|
61
|
-
size.ratio = Number(_height / _width);
|
|
62
|
-
size.widthRatio = Number((_width / _height).toFixed(2));
|
|
63
|
-
size.originRatio = Number(_height / _width);
|
|
64
|
-
}
|
|
65
|
-
return size;
|
|
66
|
-
} catch (err) {
|
|
67
|
-
return size;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
var image = {
|
|
71
|
-
ali,
|
|
72
|
-
getImageSize
|
|
73
|
-
};
|
|
74
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
-
0 && (module.exports = {
|
|
76
|
-
image
|
|
77
|
-
});
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.image = image;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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, 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 { GroupByOptions, GroupBySpec, GroupKey, GroupResult, getByPath, groupBy, uniqueByKey } from "./arrayUtils.js";
|
|
15
|
+
import { Locale, WalletPassValidity, getScheduleSummary, getWalletValidityRange } from "./walletValidity.js";
|
|
16
|
+
import { INVALID_SCALE_READING_STATUSES, MAX_RETAIL_SCALE_WEIGHT_KG, STANDARD_WEIGHT_UNIT, STANDARD_WEIGHT_UNIT_SYMBOL, ScaleReadingStatus, UNIT_PRICE_PRECISION, WEIGHT_PRECISION, WEIGHT_UNIT_GRAMS, WEIGHT_UNIT_NAMES, WEIGHT_UNIT_SYMBOLS, WeighingSnapshot, WeightUnit, WeightUnitName, WeightUnitSymbol, formatUnitPriceValue, formatWeightValue, getUsableScaleWeight, getWeightUnitGrams, getWeightUnitPriceConversionFactor, getWeightUnitSymbol, isInvalidScaleReadingStatus, isSupportedWeightUnit, normalizeWeightUnit, resolveWeighingSnapshot } from "./weighing.js";
|
|
17
|
+
import { DisplayState, ValidationResult } from "./common/types.js";
|
|
18
|
+
import { getDisplayState } from "./common/stateHelper.js";
|
|
19
|
+
import { BaseTextInputProps, TextInputState } from "./text-input/types.js";
|
|
20
|
+
import { useTextInputState } from "./text-input/hooks/useTextInputState.js";
|
|
21
|
+
import { validateValue as validateValue$1 } from "./text-input/utils/validation.js";
|
|
22
|
+
import { BaseNumberInputProps, NumberInputState } from "./number-input/types.js";
|
|
23
|
+
import { useNumberInputState } from "./number-input/hooks/useNumberInputState.js";
|
|
24
|
+
import { validateValue } from "./number-input/utils/validation.js";
|
|
25
|
+
import { NumberFormatOptions, addThousandsSeparator, formatNumber, formatPrecision } from "./number-input/utils/formatter.js";
|
|
26
|
+
import { BaseSelectProps, FilterOptionFunc, MultipleSelectState, SelectOption, SelectState, SortDirection, TagDisplayInfo, UseMultipleSelectStateOptions, UseSelectStateOptions } from "./select/types.js";
|
|
27
|
+
import { useMultipleSelectState, useSelectState } from "./select/hooks/useSelectState.js";
|
|
28
|
+
import { useDebouncedSearch } from "./select/hooks/useDebouncedSearch.js";
|
|
29
|
+
import { calculateTagDisplay } from "./select/utils/tagAggregation.js";
|
|
30
|
+
import { defaultFilterOption, filterOptions } from "./select/utils/filterOptions.js";
|
|
31
|
+
import { sortOptions } from "./select/utils/sortOptions.js";
|
|
32
|
+
import { findOptionByValue, findOptionsByValues, generateId, isOptionSelected, isOptionSelectedInMultiple } from "./select/utils/helpers.js";
|
|
33
|
+
//#region src/index.d.ts
|
|
34
|
+
declare const setPisellUtilsConfig: (config: {
|
|
35
|
+
[key: string]: any;
|
|
17
36
|
}) => void;
|
|
18
|
-
|
|
19
|
-
|
|
37
|
+
declare const getPisellUtilsConfig: () => {
|
|
38
|
+
[key: string]: any;
|
|
20
39
|
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, BaseNumberInputProps, BaseSelectProps, BaseTextInputProps, ColumnSettingStorageItem, DisplayState, EscPosPrinter, FilterOptionFunc, FormatOptions, GroupByOptions, GroupBySpec, GroupKey, GroupResult, INVALID_SCALE_READING_STATUSES, Locale, MAX_RETAIL_SCALE_WEIGHT_KG, MultipleSelectState, NumberFormatOptions, NumberInputState, STANDARD_WEIGHT_UNIT, STANDARD_WEIGHT_UNIT_SYMBOL, ScaleReadingStatus, SelectOption, SelectState, SortDirection, TagDisplayInfo, TextInputState, UNIT_PRICE_PRECISION, UseMultipleSelectStateOptions, UseSelectStateOptions, ValidationResult, WEIGHT_PRECISION, WEIGHT_UNIT_GRAMS, WEIGHT_UNIT_NAMES, WEIGHT_UNIT_SYMBOLS, WalletPassValidity, WeighingSnapshot, WeightUnit, WeightUnitName, WeightUnitSymbol, addThousandsSeparator, calculateTagDisplay, changeArray, checkEnv, clearColumnSettingFromLocal, clearColumnVisibilityFromLocal, columnWidthWithAlignment, copyToClipboard, createArray, dataManager, defaultFilterOption, detectIncognito, excelDateToJSDate, filterOptions, findOptionByValue, findOptionsByValues, formatAmount, formatAmountWithOptions, formatDate, formatNumber, formatPrecision, formatUnitPriceValue, formatWeightValue, generateId, generateUniqueIdByObj, getByPath, getColumnSettingFromLocal, getColumnVisibilityFromLocal, getComponentStorageKey, getDisplayState, getItemByArray, getPisellUtilsConfig, getRecordBoardColumnSettingFromLocal, getScheduleSummary, getStorageKeySuffix, getUniqueId, getUsableScaleWeight, getWalletValidityRange, getWeightUnitGrams, getWeightUnitPriceConversionFactor, getWeightUnitSymbol, groupBy, image, isAndroid, isArr, isBoolean, isFunction, isIOS, isInvalidScaleReadingStatus, isIos, isIpad, isJson, isMobile, isNumber, isOptionSelected, isOptionSelectedInMultiple, isPlainObject, isSafari, isString, isSupportedWeightUnit, isUndefined, isWx, isWxApp, jsDateToExcelDate, locales, miniRedux, normalizeWeightUnit, preparing, resolveWeighingSnapshot, saveColumnSettingToLocal, saveColumnVisibilityToLocal, sendWarningLog, setPisellUtilsConfig, setTheme, sortOptions, uniqueByKey, useDebouncedSearch, useMultipleSelectState, useNumberInputState, useSelectState, useTextInputState, validateValue as validateNumberValue, validateValue$1 as validateTextValue, webPayment, webPrint };
|