@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.
Files changed (200) hide show
  1. package/es/arrayUtils.d.ts +23 -26
  2. package/es/arrayUtils.js +157 -97
  3. package/es/common/index.d.ts +5 -0
  4. package/es/common/index.js +5 -0
  5. package/es/common/stateHelper.d.ts +2 -6
  6. package/es/common/stateHelper.js +24 -22
  7. package/es/common/types.d.ts +10 -13
  8. package/es/common/types.js +1 -0
  9. package/es/componentStorage.d.ts +25 -27
  10. package/es/componentStorage.js +130 -94
  11. package/es/constants/index.js +9 -7
  12. package/es/date.js +53 -36
  13. package/es/document.js +67 -43
  14. package/es/escPosPrinter/EscPosPrinter.js +490 -353
  15. package/es/escPosPrinter/index.d.ts +9 -9
  16. package/es/escPosPrinter/index.js +52 -37
  17. package/es/firebase/config/index.js +54 -0
  18. package/es/firebase/index.js +232 -0
  19. package/es/format.d.ts +15 -12
  20. package/es/format.js +156 -89
  21. package/es/image.js +60 -48
  22. package/es/index.d.ts +24 -39
  23. package/es/index.js +35 -40
  24. package/es/jsBridge/index.d.ts +4 -8
  25. package/es/jsBridge/index.js +55 -56
  26. package/es/jsBridge/regDeviceApi.js +126 -87
  27. package/es/jsBridge/types.d.ts +115 -95
  28. package/es/jsBridge/types.js +1 -0
  29. package/es/locales.d.ts +8 -11
  30. package/es/locales.js +96 -77
  31. package/es/log.d.ts +6 -11
  32. package/es/log.js +59 -37
  33. package/es/miniRedux.d.ts +13 -20
  34. package/es/miniRedux.js +76 -42
  35. package/es/number-input/hooks/index.d.ts +4 -0
  36. package/es/number-input/hooks/index.js +5 -0
  37. package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
  38. package/es/number-input/hooks/useNumberInputState.js +128 -71
  39. package/es/number-input/index.d.ts +14 -0
  40. package/es/number-input/index.js +21 -0
  41. package/es/number-input/types.d.ts +88 -88
  42. package/es/number-input/types.js +1 -0
  43. package/es/number-input/utils/formatter.d.ts +10 -13
  44. package/es/number-input/utils/formatter.js +77 -51
  45. package/es/number-input/utils/index.d.ts +7 -0
  46. package/es/number-input/utils/index.js +8 -0
  47. package/es/number-input/utils/validation.d.ts +2 -7
  48. package/es/number-input/utils/validation.js +66 -51
  49. package/es/otherUtils.d.ts +9 -12
  50. package/es/otherUtils.js +129 -71
  51. package/es/platform.d.ts +9 -12
  52. package/es/platform.js +85 -61
  53. package/es/select/hooks/index.d.ts +5 -0
  54. package/es/select/hooks/index.js +6 -0
  55. package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
  56. package/es/select/hooks/useDebouncedSearch.js +53 -39
  57. package/es/select/hooks/useSelectState.d.ts +7 -7
  58. package/es/select/hooks/useSelectState.js +113 -56
  59. package/es/select/index.d.ts +8 -7
  60. package/es/select/index.js +13 -0
  61. package/es/select/types.d.ts +211 -211
  62. package/es/select/types.js +1 -0
  63. package/es/select/utils/filterOptions.d.ts +6 -7
  64. package/es/select/utils/filterOptions.js +31 -26
  65. package/es/select/utils/helpers.d.ts +9 -10
  66. package/es/select/utils/helpers.js +52 -42
  67. package/es/select/utils/index.d.ts +7 -4
  68. package/es/select/utils/index.js +8 -0
  69. package/es/select/utils/sortOptions.d.ts +5 -6
  70. package/es/select/utils/sortOptions.js +31 -19
  71. package/es/select/utils/tagAggregation.d.ts +6 -6
  72. package/es/select/utils/tagAggregation.js +47 -34
  73. package/es/text-input/hooks/index.d.ts +4 -0
  74. package/es/text-input/hooks/index.js +5 -0
  75. package/es/text-input/hooks/useTextInputState.d.ts +2 -6
  76. package/es/text-input/hooks/useTextInputState.js +126 -69
  77. package/es/text-input/index.d.ts +14 -0
  78. package/es/text-input/index.js +20 -0
  79. package/es/text-input/types.d.ts +48 -48
  80. package/es/text-input/types.js +1 -0
  81. package/es/text-input/utils/index.d.ts +5 -0
  82. package/es/text-input/utils/index.js +7 -0
  83. package/es/text-input/utils/validation.d.ts +2 -7
  84. package/es/text-input/utils/validation.js +70 -50
  85. package/es/typeUtils.js +84 -61
  86. package/es/walletValidity.d.ts +42 -44
  87. package/es/walletValidity.js +557 -396
  88. package/es/weighing.d.ts +45 -48
  89. package/es/weighing.js +106 -83
  90. package/lib/arrayUtils.d.ts +23 -26
  91. package/lib/arrayUtils.js +111 -101
  92. package/lib/common/index.d.ts +5 -0
  93. package/lib/common/index.js +29 -0
  94. package/lib/common/stateHelper.d.ts +2 -6
  95. package/lib/common/stateHelper.js +32 -21
  96. package/lib/common/types.d.ts +10 -13
  97. package/lib/common/types.js +17 -0
  98. package/lib/componentStorage.d.ts +25 -27
  99. package/lib/componentStorage.js +126 -96
  100. package/lib/constants/index.js +36 -7
  101. package/lib/date.js +65 -43
  102. package/lib/document.js +62 -46
  103. package/lib/escPosPrinter/EscPosPrinter.js +403 -327
  104. package/lib/escPosPrinter/index.d.ts +9 -9
  105. package/lib/escPosPrinter/index.js +84 -38
  106. package/lib/firebase/config/index.js +79 -0
  107. package/lib/firebase/index.js +180 -0
  108. package/lib/format.d.ts +15 -12
  109. package/lib/format.js +133 -91
  110. package/lib/image.js +74 -48
  111. package/lib/index.d.ts +24 -39
  112. package/lib/index.js +80 -137
  113. package/lib/jsBridge/index.d.ts +4 -8
  114. package/lib/jsBridge/index.js +76 -57
  115. package/lib/jsBridge/regDeviceApi.js +133 -86
  116. package/lib/jsBridge/types.d.ts +115 -95
  117. package/lib/jsBridge/types.js +17 -0
  118. package/lib/locales.d.ts +8 -11
  119. package/lib/locales.js +90 -79
  120. package/lib/log.d.ts +6 -11
  121. package/lib/log.js +61 -37
  122. package/lib/miniRedux.d.ts +13 -20
  123. package/lib/miniRedux.js +89 -43
  124. package/lib/number-input/hooks/index.d.ts +4 -0
  125. package/lib/number-input/hooks/index.js +29 -0
  126. package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
  127. package/lib/number-input/hooks/useNumberInputState.js +81 -71
  128. package/lib/number-input/index.d.ts +14 -0
  129. package/lib/number-input/index.js +41 -0
  130. package/lib/number-input/types.d.ts +88 -88
  131. package/lib/number-input/types.js +17 -0
  132. package/lib/number-input/utils/formatter.d.ts +10 -13
  133. package/lib/number-input/utils/formatter.js +49 -52
  134. package/lib/number-input/utils/index.d.ts +7 -0
  135. package/lib/number-input/utils/index.js +39 -0
  136. package/lib/number-input/utils/validation.d.ts +2 -7
  137. package/lib/number-input/utils/validation.js +52 -50
  138. package/lib/otherUtils.d.ts +9 -12
  139. package/lib/otherUtils.js +98 -86
  140. package/lib/platform.d.ts +9 -12
  141. package/lib/platform.js +123 -68
  142. package/lib/select/hooks/index.d.ts +5 -0
  143. package/lib/select/hooks/index.js +34 -0
  144. package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
  145. package/lib/select/hooks/useDebouncedSearch.js +41 -40
  146. package/lib/select/hooks/useSelectState.d.ts +7 -7
  147. package/lib/select/hooks/useSelectState.js +93 -58
  148. package/lib/select/index.d.ts +8 -7
  149. package/lib/select/index.js +53 -0
  150. package/lib/select/types.d.ts +211 -211
  151. package/lib/select/types.js +17 -0
  152. package/lib/select/utils/filterOptions.d.ts +6 -7
  153. package/lib/select/utils/filterOptions.js +37 -26
  154. package/lib/select/utils/helpers.d.ts +9 -10
  155. package/lib/select/utils/helpers.js +41 -45
  156. package/lib/select/utils/index.d.ts +7 -4
  157. package/lib/select/utils/index.js +48 -0
  158. package/lib/select/utils/sortOptions.d.ts +5 -6
  159. package/lib/select/utils/sortOptions.js +39 -18
  160. package/lib/select/utils/tagAggregation.d.ts +6 -6
  161. package/lib/select/utils/tagAggregation.js +41 -33
  162. package/lib/text-input/hooks/index.d.ts +4 -0
  163. package/lib/text-input/hooks/index.js +29 -0
  164. package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
  165. package/lib/text-input/hooks/useTextInputState.js +79 -69
  166. package/lib/text-input/index.d.ts +14 -0
  167. package/lib/text-input/index.js +35 -0
  168. package/lib/text-input/types.d.ts +48 -48
  169. package/lib/text-input/types.js +17 -0
  170. package/lib/text-input/utils/index.d.ts +5 -0
  171. package/lib/text-input/utils/index.js +32 -0
  172. package/lib/text-input/utils/validation.d.ts +2 -7
  173. package/lib/text-input/utils/validation.js +58 -49
  174. package/lib/typeUtils.js +73 -68
  175. package/lib/walletValidity.d.ts +42 -44
  176. package/lib/walletValidity.js +393 -410
  177. package/lib/weighing.d.ts +45 -48
  178. package/lib/weighing.js +149 -104
  179. package/package.json +1 -1
  180. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  181. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  182. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  183. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  184. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  185. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
  186. package/es/date.d.ts +0 -31
  187. package/es/document.d.ts +0 -16
  188. package/es/image.d.ts +0 -14
  189. package/es/typeUtils.d.ts +0 -45
  190. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  191. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  192. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  193. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  194. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  195. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
  196. package/lib/_virtual/_rolldown/runtime.js +0 -23
  197. package/lib/date.d.ts +0 -31
  198. package/lib/document.d.ts +0 -16
  199. package/lib/image.d.ts +0 -14
  200. package/lib/typeUtils.d.ts +0 -45
package/lib/format.js CHANGED
@@ -1,94 +1,136 @@
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
- }
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
- 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;
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
- * @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
- }
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
- //#endregion
93
- exports.formatAmount = formatAmount;
94
- exports.formatAmountWithOptions = formatAmountWithOptions;
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
- //#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;
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
- * @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
- }
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
- const image = {
47
- ali,
48
- getImageSize
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
- //#endregion
51
- exports.image = image;
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
- 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;
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
- [key: string]: any;
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 };