@pisell/utils 3.0.6 → 3.0.7
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/arrayUtils.d.ts +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
package/es/format.js
CHANGED
|
@@ -1,93 +1,160 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { isString, isNumber } from "./typeUtils";
|
|
2
|
+
|
|
3
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
export var formatAmount = function formatAmount() {
|
|
14
|
+
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
15
|
+
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
16
|
+
var symbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
17
|
+
// 校验格式
|
|
18
|
+
if (!isString(amount) && !isNumber(amount)) {
|
|
19
|
+
console.error('amount is not a number');
|
|
20
|
+
return amount;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
// 四舍五入
|
|
24
|
+
var roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
25
|
+
// 处理负数情况
|
|
26
|
+
var absoluteAmount = Math.abs(roundedAmount);
|
|
27
|
+
// 截取整数
|
|
28
|
+
var integerPart = Math.floor(absoluteAmount);
|
|
29
|
+
// 截取小数部分并补零
|
|
30
|
+
var decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
31
|
+
|
|
32
|
+
// 拼接货币符号
|
|
33
|
+
var formattedAmount = symbol + integerPart.toString();
|
|
34
|
+
|
|
35
|
+
// 添加小数点
|
|
36
|
+
if (precision > 0) {
|
|
37
|
+
formattedAmount += '.' + decimalPart;
|
|
38
|
+
|
|
39
|
+
// 如果小数位是 .00的话 抹去
|
|
40
|
+
if (formattedAmount.indexOf('.00') !== -1) {
|
|
41
|
+
formattedAmount = formattedAmount.substring(0, formattedAmount.length - 3);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 添加负号
|
|
46
|
+
if (roundedAmount < 0) {
|
|
47
|
+
formattedAmount = '-' + formattedAmount;
|
|
48
|
+
}
|
|
49
|
+
return formattedAmount;
|
|
50
|
+
} catch (err) {
|
|
51
|
+
// 计算错误则返回原金额
|
|
52
|
+
console.error(err);
|
|
53
|
+
return amount;
|
|
54
|
+
}
|
|
34
55
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
56
|
+
var applyCurrencyFormat = function applyCurrencyFormat(params) {
|
|
57
|
+
var amount = params.amount,
|
|
58
|
+
symbol = params.symbol,
|
|
59
|
+
currencyCode = params.currencyCode,
|
|
60
|
+
currencyFormat = params.currencyFormat;
|
|
61
|
+
var format = currencyFormat.trim();
|
|
62
|
+
if (format.includes('{{amount}}') || format.includes('{amount}')) {
|
|
63
|
+
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();
|
|
64
|
+
}
|
|
65
|
+
if (format === 'symbol_last') {
|
|
66
|
+
if (symbol) return "".concat(amount).concat(symbol);
|
|
67
|
+
if (currencyCode) return "".concat(amount, " ").concat(currencyCode);
|
|
68
|
+
return amount;
|
|
69
|
+
}
|
|
70
|
+
if (symbol) return "".concat(symbol).concat(amount);
|
|
71
|
+
return currencyCode ? "".concat(amount, " ").concat(currencyCode) : amount;
|
|
46
72
|
};
|
|
73
|
+
|
|
47
74
|
/**
|
|
48
|
-
* 根据配置格式化金额
|
|
49
|
-
* @param amount
|
|
50
|
-
* @param symbol
|
|
51
|
-
* @param options
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
75
|
+
* 根据配置格式化金额
|
|
76
|
+
* @param amount
|
|
77
|
+
* @param symbol
|
|
78
|
+
* @param options
|
|
79
|
+
*/
|
|
80
|
+
export var formatAmountWithOptions = function formatAmountWithOptions() {
|
|
81
|
+
var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
82
|
+
var symbol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
83
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
84
|
+
var _options$precision = options.precision,
|
|
85
|
+
precision = _options$precision === void 0 ? 2 : _options$precision,
|
|
86
|
+
_options$useThousands = options.useThousandsSeparator,
|
|
87
|
+
useThousandsSeparator = _options$useThousands === void 0 ? false : _options$useThousands,
|
|
88
|
+
_options$showCurrency = options.showCurrencySymbol,
|
|
89
|
+
showCurrencySymbol = _options$showCurrency === void 0 ? true : _options$showCurrency,
|
|
90
|
+
_options$hideDecimalF = options.hideDecimalForWholeNumbers,
|
|
91
|
+
hideDecimalForWholeNumbers = _options$hideDecimalF === void 0 ? true : _options$hideDecimalF,
|
|
92
|
+
_options$currencyCode = options.currencyCode,
|
|
93
|
+
currencyCode = _options$currencyCode === void 0 ? '' : _options$currencyCode,
|
|
94
|
+
_options$currencyForm = options.currencyFormat,
|
|
95
|
+
currencyFormat = _options$currencyForm === void 0 ? '' : _options$currencyForm;
|
|
96
|
+
// 校验格式
|
|
97
|
+
if (!isString(amount) && !isNumber(amount)) {
|
|
98
|
+
console.error('amount is not a number');
|
|
99
|
+
return amount;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
// 四舍五入
|
|
103
|
+
var roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
104
|
+
// 处理负数情况
|
|
105
|
+
var absoluteAmount = Math.abs(roundedAmount);
|
|
106
|
+
// 截取整数
|
|
107
|
+
var integerPart = Math.floor(absoluteAmount);
|
|
108
|
+
// 截取小数部分并补零
|
|
109
|
+
var decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
110
|
+
|
|
111
|
+
// 新配置缺省时完整保留历史逻辑,避免影响现有调用方。
|
|
112
|
+
if (!currencyCode && !currencyFormat) {
|
|
113
|
+
var legacyFormattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
114
|
+
legacyFormattedAmount = showCurrencySymbol ? symbol + legacyFormattedAmount : legacyFormattedAmount;
|
|
115
|
+
if (precision > 0) {
|
|
116
|
+
legacyFormattedAmount += '.' + decimalPart;
|
|
117
|
+
if (hideDecimalForWholeNumbers && legacyFormattedAmount.indexOf('.00') !== -1) {
|
|
118
|
+
legacyFormattedAmount = legacyFormattedAmount.substring(0, legacyFormattedAmount.length - 3);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (roundedAmount < 0) {
|
|
122
|
+
legacyFormattedAmount = '-' + legacyFormattedAmount;
|
|
123
|
+
}
|
|
124
|
+
return legacyFormattedAmount;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// 增加千分位分隔符
|
|
128
|
+
var formattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
129
|
+
|
|
130
|
+
// 添加小数点
|
|
131
|
+
if (precision > 0) {
|
|
132
|
+
formattedAmount += '.' + decimalPart;
|
|
133
|
+
|
|
134
|
+
// 整数按配置隐藏全部小数位
|
|
135
|
+
if (hideDecimalForWholeNumbers && Number(decimalPart) === 0) {
|
|
136
|
+
formattedAmount = formattedAmount.substring(0, formattedAmount.length - precision - 1);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 数值精度与币种排版分开处理,便于共享法币和虚拟币规则
|
|
141
|
+
if (showCurrencySymbol) {
|
|
142
|
+
formattedAmount = applyCurrencyFormat({
|
|
143
|
+
amount: formattedAmount,
|
|
144
|
+
symbol: symbol,
|
|
145
|
+
currencyCode: currencyCode,
|
|
146
|
+
currencyFormat: currencyFormat
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 添加负号
|
|
151
|
+
if (roundedAmount < 0) {
|
|
152
|
+
formattedAmount = '-' + formattedAmount;
|
|
153
|
+
}
|
|
154
|
+
return formattedAmount;
|
|
155
|
+
} catch (err) {
|
|
156
|
+
// 计算错误则返回原金额
|
|
157
|
+
console.error(err);
|
|
158
|
+
return amount;
|
|
159
|
+
}
|
|
160
|
+
};
|
package/es/image.js
CHANGED
|
@@ -1,51 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
var ali = function ali(url, w) {
|
|
2
|
+
if (!url || /^\s+$/.test(url)) {
|
|
3
|
+
return '';
|
|
4
|
+
}
|
|
5
|
+
// 如果图片链接中已经包含了过滤参数,则直接跳过
|
|
6
|
+
if (/x-oss-process=/.test(url)) {
|
|
7
|
+
return url;
|
|
8
|
+
}
|
|
9
|
+
var dpr = 2;
|
|
10
|
+
w = w || 750;
|
|
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;
|
|
11
18
|
};
|
|
19
|
+
|
|
12
20
|
/**
|
|
13
|
-
* @Title: 获取图片尺寸
|
|
14
|
-
* @Describe: 通过 __ 进行分割
|
|
15
|
-
* @Author: Wzw
|
|
16
|
-
* @param {string} url
|
|
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
|
-
|
|
21
|
+
* @Title: 获取图片尺寸
|
|
22
|
+
* @Describe: 通过 __ 进行分割
|
|
23
|
+
* @Author: Wzw
|
|
24
|
+
* @param {string} url
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
var getImageSize = function getImageSize(url) {
|
|
28
|
+
var size = {
|
|
29
|
+
width: 375,
|
|
30
|
+
height: 375,
|
|
31
|
+
ratio: 1,
|
|
32
|
+
widthRatio: 1,
|
|
33
|
+
success: false,
|
|
34
|
+
originRatio: 1
|
|
35
|
+
};
|
|
36
|
+
if (typeof url !== 'string') return size;
|
|
37
|
+
// https://file.mypisel.dev/boxlocal/image/9c4e5a0afdbefadc78e3eab27c9ca3202021_07_23_16_05_00_916_02868331878656287__2160_976__.jpeg
|
|
38
|
+
// 根据 __ 分割url
|
|
39
|
+
try {
|
|
40
|
+
var arr = url.split('__');
|
|
41
|
+
// 根据规则, 第二个下标为图片的宽高
|
|
42
|
+
if (arr[1]) {
|
|
43
|
+
// 分割宽高, 第一个值是宽 第二个值是高
|
|
44
|
+
var sizeArr = arr[1].split('_');
|
|
45
|
+
// 如果没取到则默认为375
|
|
46
|
+
var _width = Number(sizeArr[0]) || 375;
|
|
47
|
+
var _height = Number(sizeArr[1]) || 375;
|
|
48
|
+
size.width = _width;
|
|
49
|
+
size.height = _height;
|
|
50
|
+
size.success = true;
|
|
51
|
+
size.ratio = Number(_height / _width);
|
|
52
|
+
size.widthRatio = Number((_width / _height).toFixed(2));
|
|
53
|
+
size.originRatio = Number(_height / _width);
|
|
54
|
+
}
|
|
55
|
+
return size;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
return size;
|
|
58
|
+
}
|
|
45
59
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
//#endregion
|
|
51
|
-
export { image };
|
|
60
|
+
export var image = {
|
|
61
|
+
ali: ali,
|
|
62
|
+
getImageSize: getImageSize
|
|
63
|
+
};
|
package/es/index.d.ts
CHANGED
|
@@ -1,41 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
|
1
|
+
export * from './otherUtils';
|
|
2
|
+
export * from './typeUtils';
|
|
3
|
+
export * from './componentStorage';
|
|
4
|
+
export * from './document';
|
|
5
|
+
export * from './date';
|
|
6
|
+
export * from './platform';
|
|
7
|
+
export * from './log';
|
|
8
|
+
export * from './format';
|
|
9
|
+
export * from './escPosPrinter';
|
|
10
|
+
export * from './miniRedux';
|
|
11
|
+
export * from './jsBridge';
|
|
12
|
+
export * from './image';
|
|
13
|
+
export * from './locales';
|
|
14
|
+
export * from './arrayUtils';
|
|
15
|
+
export * from './walletValidity';
|
|
16
|
+
export * from './weighing';
|
|
17
|
+
export * from './common';
|
|
18
|
+
export * from './text-input';
|
|
19
|
+
export * from './number-input';
|
|
20
|
+
export * from './select';
|
|
21
|
+
export declare const setPisellUtilsConfig: (config: {
|
|
22
|
+
[key: string]: any;
|
|
36
23
|
}) => void;
|
|
37
|
-
declare const getPisellUtilsConfig: () => {
|
|
38
|
-
|
|
24
|
+
export declare const getPisellUtilsConfig: () => {
|
|
25
|
+
[key: string]: any;
|
|
39
26
|
};
|
|
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 };
|
package/es/index.js
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
const setPisellUtilsConfig = (config) => {
|
|
33
|
-
globalThis.pisellUtilsConfig = _objectSpread2(_objectSpread2({}, globalThis.pisellUtilsConfig || {}), config || {});
|
|
34
|
-
console.log("PisellUtilsConfig_set>>>>", config, globalThis);
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
export * from "./otherUtils";
|
|
8
|
+
export * from "./typeUtils";
|
|
9
|
+
export * from "./componentStorage";
|
|
10
|
+
export * from "./document";
|
|
11
|
+
export * from "./date";
|
|
12
|
+
export * from "./platform";
|
|
13
|
+
export * from "./log";
|
|
14
|
+
export * from "./format";
|
|
15
|
+
export * from "./escPosPrinter";
|
|
16
|
+
export * from "./miniRedux";
|
|
17
|
+
export * from "./jsBridge";
|
|
18
|
+
export * from "./image";
|
|
19
|
+
export * from "./locales";
|
|
20
|
+
export * from "./arrayUtils";
|
|
21
|
+
export * from "./walletValidity";
|
|
22
|
+
export * from "./weighing";
|
|
23
|
+
export * from "./common";
|
|
24
|
+
export * from "./text-input";
|
|
25
|
+
export * from "./number-input";
|
|
26
|
+
export * from "./select";
|
|
27
|
+
// export { default as firebase } from './firebase';
|
|
28
|
+
|
|
29
|
+
export var setPisellUtilsConfig = function setPisellUtilsConfig(config) {
|
|
30
|
+
globalThis.pisellUtilsConfig = _objectSpread(_objectSpread({}, globalThis.pisellUtilsConfig || {}), config || {});
|
|
31
|
+
console.log('PisellUtilsConfig_set>>>>', config, globalThis);
|
|
35
32
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, EscPosPrinter, INVALID_SCALE_READING_STATUSES, MAX_RETAIL_SCALE_WEIGHT_KG, STANDARD_WEIGHT_UNIT, STANDARD_WEIGHT_UNIT_SYMBOL, UNIT_PRICE_PRECISION, WEIGHT_PRECISION, WEIGHT_UNIT_GRAMS, WEIGHT_UNIT_NAMES, WEIGHT_UNIT_SYMBOLS, 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 };
|
|
33
|
+
export var getPisellUtilsConfig = function getPisellUtilsConfig() {
|
|
34
|
+
console.log('PisellUtilsConfig_get>>>>', globalThis);
|
|
35
|
+
return globalThis.pisellUtilsConfig || {};
|
|
36
|
+
};
|
package/es/jsBridge/index.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { DataManagerParams, WebPaymentParams
|
|
2
|
-
|
|
3
|
-
//#region src/jsBridge/index.d.ts
|
|
1
|
+
import { WebPrintParams, DataManagerParams, WebPaymentParams } from './types';
|
|
4
2
|
/**
|
|
5
3
|
* webView页面中调用打印机打印
|
|
6
4
|
* 此api暂时只支持native app平台下ios手机
|
|
7
5
|
* @param params
|
|
8
6
|
* @param callback
|
|
9
7
|
*/
|
|
10
|
-
declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
8
|
+
export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
11
9
|
/**
|
|
12
10
|
* webView页面中调用APP内的数据
|
|
13
11
|
* 此api暂时只支持native app平台下ios手机
|
|
14
12
|
* @param params
|
|
15
13
|
* @param callback
|
|
16
14
|
*/
|
|
17
|
-
declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
|
|
15
|
+
export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
|
|
18
16
|
/**
|
|
19
17
|
* webView页面中调用APP内的支付
|
|
20
18
|
* 此api暂时只支持native app平台下ios
|
|
21
19
|
* @param params
|
|
22
20
|
* @param callback
|
|
23
21
|
*/
|
|
24
|
-
declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { dataManager, webPayment, webPrint };
|
|
22
|
+
export declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|