@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/lib/format.js
CHANGED
|
@@ -1,94 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
}
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
34
8
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return amount;
|
|
43
|
-
}
|
|
44
|
-
if (symbol) return `${symbol}${amount}`;
|
|
45
|
-
return currencyCode ? `${amount} ${currencyCode}` : amount;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
46
16
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
if (roundedAmount < 0) formattedAmount = "-" + formattedAmount;
|
|
86
|
-
return formattedAmount;
|
|
87
|
-
} catch (err) {
|
|
88
|
-
console.error(err);
|
|
89
|
-
return amount;
|
|
90
|
-
}
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/format.ts
|
|
20
|
+
var format_exports = {};
|
|
21
|
+
__export(format_exports, {
|
|
22
|
+
formatAmount: () => formatAmount,
|
|
23
|
+
formatAmountWithOptions: () => formatAmountWithOptions
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(format_exports);
|
|
26
|
+
var import_typeUtils = require("./typeUtils");
|
|
27
|
+
var formatAmount = (amount = 0, precision = 2, symbol = "") => {
|
|
28
|
+
if (!(0, import_typeUtils.isString)(amount) && !(0, import_typeUtils.isNumber)(amount)) {
|
|
29
|
+
console.error("amount is not a number");
|
|
30
|
+
return amount;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
34
|
+
const absoluteAmount = Math.abs(roundedAmount);
|
|
35
|
+
const integerPart = Math.floor(absoluteAmount);
|
|
36
|
+
const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
37
|
+
let formattedAmount = symbol + integerPart.toString();
|
|
38
|
+
if (precision > 0) {
|
|
39
|
+
formattedAmount += "." + decimalPart;
|
|
40
|
+
if (formattedAmount.indexOf(".00") !== -1) {
|
|
41
|
+
formattedAmount = formattedAmount.substring(
|
|
42
|
+
0,
|
|
43
|
+
formattedAmount.length - 3
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (roundedAmount < 0) {
|
|
48
|
+
formattedAmount = "-" + formattedAmount;
|
|
49
|
+
}
|
|
50
|
+
return formattedAmount;
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.error(err);
|
|
53
|
+
return amount;
|
|
54
|
+
}
|
|
91
55
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
56
|
+
var applyCurrencyFormat = (params) => {
|
|
57
|
+
const { amount, symbol, currencyCode, currencyFormat } = params;
|
|
58
|
+
const format = currencyFormat.trim();
|
|
59
|
+
if (format.includes("{{amount}}") || format.includes("{amount}")) {
|
|
60
|
+
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();
|
|
61
|
+
}
|
|
62
|
+
if (format === "symbol_last") {
|
|
63
|
+
if (symbol) return `${amount}${symbol}`;
|
|
64
|
+
if (currencyCode) return `${amount} ${currencyCode}`;
|
|
65
|
+
return amount;
|
|
66
|
+
}
|
|
67
|
+
if (symbol) return `${symbol}${amount}`;
|
|
68
|
+
return currencyCode ? `${amount} ${currencyCode}` : amount;
|
|
69
|
+
};
|
|
70
|
+
var formatAmountWithOptions = (amount = 0, symbol = "", options = {}) => {
|
|
71
|
+
const {
|
|
72
|
+
precision = 2,
|
|
73
|
+
useThousandsSeparator = false,
|
|
74
|
+
showCurrencySymbol = true,
|
|
75
|
+
hideDecimalForWholeNumbers = true,
|
|
76
|
+
currencyCode = "",
|
|
77
|
+
currencyFormat = ""
|
|
78
|
+
} = options;
|
|
79
|
+
if (!(0, import_typeUtils.isString)(amount) && !(0, import_typeUtils.isNumber)(amount)) {
|
|
80
|
+
console.error("amount is not a number");
|
|
81
|
+
return amount;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const roundedAmount = Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision);
|
|
85
|
+
const absoluteAmount = Math.abs(roundedAmount);
|
|
86
|
+
const integerPart = Math.floor(absoluteAmount);
|
|
87
|
+
const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
|
|
88
|
+
if (!currencyCode && !currencyFormat) {
|
|
89
|
+
let legacyFormattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
90
|
+
legacyFormattedAmount = showCurrencySymbol ? symbol + legacyFormattedAmount : legacyFormattedAmount;
|
|
91
|
+
if (precision > 0) {
|
|
92
|
+
legacyFormattedAmount += "." + decimalPart;
|
|
93
|
+
if (hideDecimalForWholeNumbers && legacyFormattedAmount.indexOf(".00") !== -1) {
|
|
94
|
+
legacyFormattedAmount = legacyFormattedAmount.substring(
|
|
95
|
+
0,
|
|
96
|
+
legacyFormattedAmount.length - 3
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (roundedAmount < 0) {
|
|
101
|
+
legacyFormattedAmount = "-" + legacyFormattedAmount;
|
|
102
|
+
}
|
|
103
|
+
return legacyFormattedAmount;
|
|
104
|
+
}
|
|
105
|
+
let formattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
|
|
106
|
+
if (precision > 0) {
|
|
107
|
+
formattedAmount += "." + decimalPart;
|
|
108
|
+
if (hideDecimalForWholeNumbers && Number(decimalPart) === 0) {
|
|
109
|
+
formattedAmount = formattedAmount.substring(
|
|
110
|
+
0,
|
|
111
|
+
formattedAmount.length - precision - 1
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (showCurrencySymbol) {
|
|
116
|
+
formattedAmount = applyCurrencyFormat({
|
|
117
|
+
amount: formattedAmount,
|
|
118
|
+
symbol,
|
|
119
|
+
currencyCode,
|
|
120
|
+
currencyFormat
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (roundedAmount < 0) {
|
|
124
|
+
formattedAmount = "-" + formattedAmount;
|
|
125
|
+
}
|
|
126
|
+
return formattedAmount;
|
|
127
|
+
} catch (err) {
|
|
128
|
+
console.error(err);
|
|
129
|
+
return amount;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
formatAmount,
|
|
135
|
+
formatAmountWithOptions
|
|
136
|
+
});
|
package/lib/image.js
CHANGED
|
@@ -1,51 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
8
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
}
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
45
16
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/image.ts
|
|
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;
|
|
49
41
|
};
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
var getImageSize = (url) => {
|
|
43
|
+
let size = {
|
|
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
|
+
});
|
package/lib/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 };
|