@pisell/utils 1.0.71 → 1.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  2. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
  7. package/es/arrayUtils.d.ts +4 -1
  8. package/es/arrayUtils.js +15 -24
  9. package/es/common/stateHelper.d.ts +6 -2
  10. package/es/common/stateHelper.js +22 -24
  11. package/es/common/types.d.ts +13 -10
  12. package/es/componentStorage.d.ts +27 -25
  13. package/es/componentStorage.js +94 -130
  14. package/es/constants/index.js +7 -9
  15. package/es/date.d.ts +6 -3
  16. package/es/date.js +36 -53
  17. package/es/document.d.ts +6 -3
  18. package/es/document.js +43 -67
  19. package/es/escPosPrinter/EscPosPrinter.js +353 -490
  20. package/es/escPosPrinter/index.d.ts +9 -9
  21. package/es/escPosPrinter/index.js +37 -52
  22. package/es/format.d.ts +12 -11
  23. package/es/format.js +90 -116
  24. package/es/image.d.ts +13 -10
  25. package/es/image.js +48 -60
  26. package/es/index.d.ts +38 -23
  27. package/es/index.js +39 -34
  28. package/es/jsBridge/index.d.ts +8 -4
  29. package/es/jsBridge/index.js +57 -56
  30. package/es/jsBridge/regDeviceApi.js +107 -149
  31. package/es/jsBridge/types.d.ts +95 -115
  32. package/es/locales.d.ts +11 -8
  33. package/es/locales.js +77 -96
  34. package/es/log.d.ts +11 -6
  35. package/es/log.js +37 -59
  36. package/es/miniRedux.d.ts +20 -13
  37. package/es/miniRedux.js +42 -78
  38. package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
  39. package/es/number-input/hooks/useNumberInputState.js +71 -128
  40. package/es/number-input/types.d.ts +88 -88
  41. package/es/number-input/utils/formatter.d.ts +13 -10
  42. package/es/number-input/utils/formatter.js +51 -77
  43. package/es/number-input/utils/validation.d.ts +7 -2
  44. package/es/number-input/utils/validation.js +51 -66
  45. package/es/otherUtils.d.ts +12 -9
  46. package/es/otherUtils.js +71 -129
  47. package/es/platform.d.ts +17 -9
  48. package/es/platform.js +78 -85
  49. package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
  50. package/es/select/hooks/useDebouncedSearch.js +39 -53
  51. package/es/select/hooks/useSelectState.d.ts +7 -7
  52. package/es/select/hooks/useSelectState.js +56 -113
  53. package/es/select/index.d.ts +7 -8
  54. package/es/select/types.d.ts +211 -211
  55. package/es/select/utils/filterOptions.d.ts +7 -6
  56. package/es/select/utils/filterOptions.js +26 -31
  57. package/es/select/utils/helpers.d.ts +10 -9
  58. package/es/select/utils/helpers.js +42 -52
  59. package/es/select/utils/index.d.ts +4 -7
  60. package/es/select/utils/sortOptions.d.ts +6 -5
  61. package/es/select/utils/sortOptions.js +19 -31
  62. package/es/select/utils/tagAggregation.d.ts +6 -6
  63. package/es/select/utils/tagAggregation.js +34 -47
  64. package/es/text-input/hooks/useTextInputState.d.ts +6 -2
  65. package/es/text-input/hooks/useTextInputState.js +69 -126
  66. package/es/text-input/types.d.ts +48 -48
  67. package/es/text-input/utils/validation.d.ts +7 -2
  68. package/es/text-input/utils/validation.js +50 -70
  69. package/es/typeUtils.d.ts +11 -8
  70. package/es/typeUtils.js +61 -84
  71. package/es/walletValidity.d.ts +36 -34
  72. package/es/walletValidity.js +332 -456
  73. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  74. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  75. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  76. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  77. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  78. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
  79. package/lib/_virtual/_rolldown/runtime.js +23 -0
  80. package/lib/arrayUtils.d.ts +4 -1
  81. package/lib/arrayUtils.js +14 -39
  82. package/lib/common/stateHelper.d.ts +6 -2
  83. package/lib/common/stateHelper.js +21 -32
  84. package/lib/common/types.d.ts +13 -10
  85. package/lib/componentStorage.d.ts +27 -25
  86. package/lib/componentStorage.js +96 -126
  87. package/lib/constants/index.js +7 -36
  88. package/lib/date.d.ts +6 -3
  89. package/lib/date.js +43 -65
  90. package/lib/document.d.ts +6 -3
  91. package/lib/document.js +46 -62
  92. package/lib/escPosPrinter/EscPosPrinter.js +327 -403
  93. package/lib/escPosPrinter/index.d.ts +9 -9
  94. package/lib/escPosPrinter/index.js +38 -84
  95. package/lib/format.d.ts +12 -11
  96. package/lib/format.js +91 -99
  97. package/lib/image.d.ts +13 -10
  98. package/lib/image.js +48 -74
  99. package/lib/index.d.ts +38 -23
  100. package/lib/index.js +115 -78
  101. package/lib/jsBridge/index.d.ts +8 -4
  102. package/lib/jsBridge/index.js +58 -77
  103. package/lib/jsBridge/regDeviceApi.js +106 -153
  104. package/lib/jsBridge/types.d.ts +95 -115
  105. package/lib/locales.d.ts +11 -8
  106. package/lib/locales.js +79 -90
  107. package/lib/log.d.ts +11 -6
  108. package/lib/log.js +37 -61
  109. package/lib/miniRedux.d.ts +20 -13
  110. package/lib/miniRedux.js +43 -92
  111. package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
  112. package/lib/number-input/hooks/useNumberInputState.js +71 -81
  113. package/lib/number-input/types.d.ts +88 -88
  114. package/lib/number-input/utils/formatter.d.ts +13 -10
  115. package/lib/number-input/utils/formatter.js +52 -49
  116. package/lib/number-input/utils/validation.d.ts +7 -2
  117. package/lib/number-input/utils/validation.js +50 -52
  118. package/lib/otherUtils.d.ts +12 -9
  119. package/lib/otherUtils.js +86 -98
  120. package/lib/platform.d.ts +17 -9
  121. package/lib/platform.js +85 -122
  122. package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
  123. package/lib/select/hooks/useDebouncedSearch.js +40 -41
  124. package/lib/select/hooks/useSelectState.d.ts +7 -7
  125. package/lib/select/hooks/useSelectState.js +58 -93
  126. package/lib/select/index.d.ts +7 -8
  127. package/lib/select/types.d.ts +211 -211
  128. package/lib/select/utils/filterOptions.d.ts +7 -6
  129. package/lib/select/utils/filterOptions.js +26 -37
  130. package/lib/select/utils/helpers.d.ts +10 -9
  131. package/lib/select/utils/helpers.js +45 -41
  132. package/lib/select/utils/index.d.ts +4 -7
  133. package/lib/select/utils/sortOptions.d.ts +6 -5
  134. package/lib/select/utils/sortOptions.js +18 -39
  135. package/lib/select/utils/tagAggregation.d.ts +6 -6
  136. package/lib/select/utils/tagAggregation.js +33 -41
  137. package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
  138. package/lib/text-input/hooks/useTextInputState.js +69 -79
  139. package/lib/text-input/types.d.ts +48 -48
  140. package/lib/text-input/utils/validation.d.ts +7 -2
  141. package/lib/text-input/utils/validation.js +49 -58
  142. package/lib/typeUtils.d.ts +11 -8
  143. package/lib/typeUtils.js +68 -73
  144. package/lib/walletValidity.d.ts +36 -34
  145. package/lib/walletValidity.js +345 -317
  146. package/package.json +1 -2
  147. package/es/common/index.d.ts +0 -5
  148. package/es/common/index.js +0 -5
  149. package/es/common/types.js +0 -1
  150. package/es/constants/index.d.ts +0 -7
  151. package/es/firebase/config/index.d.ts +0 -13
  152. package/es/firebase/config/index.js +0 -54
  153. package/es/firebase/index.d.ts +0 -28
  154. package/es/firebase/index.js +0 -232
  155. package/es/jsBridge/types.js +0 -1
  156. package/es/number-input/hooks/index.d.ts +0 -4
  157. package/es/number-input/hooks/index.js +0 -5
  158. package/es/number-input/index.d.ts +0 -14
  159. package/es/number-input/index.js +0 -21
  160. package/es/number-input/types.js +0 -1
  161. package/es/number-input/utils/index.d.ts +0 -7
  162. package/es/number-input/utils/index.js +0 -8
  163. package/es/select/hooks/index.d.ts +0 -5
  164. package/es/select/hooks/index.js +0 -6
  165. package/es/select/index.js +0 -13
  166. package/es/select/types.js +0 -1
  167. package/es/select/utils/index.js +0 -8
  168. package/es/text-input/hooks/index.d.ts +0 -4
  169. package/es/text-input/hooks/index.js +0 -5
  170. package/es/text-input/index.d.ts +0 -14
  171. package/es/text-input/index.js +0 -20
  172. package/es/text-input/types.js +0 -1
  173. package/es/text-input/utils/index.d.ts +0 -5
  174. package/es/text-input/utils/index.js +0 -7
  175. package/lib/common/index.d.ts +0 -5
  176. package/lib/common/index.js +0 -29
  177. package/lib/common/types.js +0 -17
  178. package/lib/constants/index.d.ts +0 -7
  179. package/lib/firebase/config/index.d.ts +0 -13
  180. package/lib/firebase/config/index.js +0 -79
  181. package/lib/firebase/index.d.ts +0 -28
  182. package/lib/firebase/index.js +0 -180
  183. package/lib/jsBridge/types.js +0 -17
  184. package/lib/number-input/hooks/index.d.ts +0 -4
  185. package/lib/number-input/hooks/index.js +0 -29
  186. package/lib/number-input/index.d.ts +0 -14
  187. package/lib/number-input/index.js +0 -41
  188. package/lib/number-input/types.js +0 -17
  189. package/lib/number-input/utils/index.d.ts +0 -7
  190. package/lib/number-input/utils/index.js +0 -39
  191. package/lib/select/hooks/index.d.ts +0 -5
  192. package/lib/select/hooks/index.js +0 -34
  193. package/lib/select/index.js +0 -53
  194. package/lib/select/types.js +0 -17
  195. package/lib/select/utils/index.js +0 -48
  196. package/lib/text-input/hooks/index.d.ts +0 -4
  197. package/lib/text-input/hooks/index.js +0 -29
  198. package/lib/text-input/index.d.ts +0 -14
  199. package/lib/text-input/index.js +0 -35
  200. package/lib/text-input/types.js +0 -17
  201. package/lib/text-input/utils/index.d.ts +0 -5
  202. package/lib/text-input/utils/index.js +0 -32
@@ -1,9 +1,9 @@
1
- export declare const EscPosPrinter = any;
2
- export declare const ALIGN_LEFT = number;
3
- export declare const ALIGN_CENTER = number;
4
- export declare const ALIGN_RIGHT = number;
5
- export declare const columnWidthWithAlignment = (
6
- width: number,
7
- alignment: number
8
- ) => any;
9
- export declare const preparing = any;
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
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
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
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/escPosPrinter/index.js
30
- var escPosPrinter_exports = {};
31
- __export(escPosPrinter_exports, {
32
- ALIGN_CENTER: () => import_EscPosPrinter.ALIGN_CENTER,
33
- ALIGN_LEFT: () => import_EscPosPrinter.ALIGN_LEFT,
34
- ALIGN_RIGHT: () => import_EscPosPrinter.ALIGN_RIGHT,
35
- EscPosPrinter: () => import_EscPosPrinter.default,
36
- columnWidthWithAlignment: () => import_EscPosPrinter.columnWidthWithAlignment,
37
- preparing: () => preparing
38
- });
39
- module.exports = __toCommonJS(escPosPrinter_exports);
40
- var import_EscPosPrinter = __toESM(require("./EscPosPrinter"));
41
- var dividing = (printer) => {
42
- printer.setAlignment(import_EscPosPrinter.ALIGN_LEFT);
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
- export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
12
- export declare type FormatOptions = {
13
- /** 小数点后位数 默认是小数点后2位 */
14
- precision?: number;
15
- /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
16
- showCurrencySymbol?: boolean;
17
- /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
18
- useThousandsSeparator?: boolean;
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
- export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;
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,102 +1,94 @@
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 });
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
- 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;
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
- 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 = (
34
- //@ts-ignore
35
- Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision)
36
- );
37
- const absoluteAmount = Math.abs(roundedAmount);
38
- const integerPart = Math.floor(absoluteAmount);
39
- const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
40
- let formattedAmount = symbol + integerPart.toString();
41
- if (precision > 0) {
42
- formattedAmount += "." + decimalPart;
43
- if (formattedAmount.indexOf(".00") !== -1) {
44
- formattedAmount = formattedAmount.substring(
45
- 0,
46
- formattedAmount.length - 3
47
- );
48
- }
49
- }
50
- if (roundedAmount < 0) {
51
- formattedAmount = "-" + formattedAmount;
52
- }
53
- return formattedAmount;
54
- } catch (err) {
55
- console.error(err);
56
- return amount;
57
- }
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
+ }
58
91
  };
59
- var formatAmountWithOptions = (amount = 0, symbol = "", options) => {
60
- const {
61
- precision = 2,
62
- useThousandsSeparator = false,
63
- showCurrencySymbol = true,
64
- hideDecimalForWholeNumbers = true
65
- } = options;
66
- if (!(0, import_typeUtils.isString)(amount) && !(0, import_typeUtils.isNumber)(amount)) {
67
- console.error("amount is not a number");
68
- return amount;
69
- }
70
- try {
71
- const roundedAmount = (
72
- //@ts-ignore
73
- Math.round(amount * Math.pow(10, precision)) / Math.pow(10, precision)
74
- );
75
- const absoluteAmount = Math.abs(roundedAmount);
76
- const integerPart = Math.floor(absoluteAmount);
77
- const decimalPart = (absoluteAmount - integerPart).toFixed(precision).substring(2);
78
- let formattedAmount = useThousandsSeparator ? integerPart.toLocaleString() : integerPart.toString();
79
- formattedAmount = showCurrencySymbol ? symbol + formattedAmount : formattedAmount;
80
- if (precision > 0) {
81
- formattedAmount += "." + decimalPart;
82
- if (hideDecimalForWholeNumbers && formattedAmount.indexOf(".00") !== -1) {
83
- formattedAmount = formattedAmount.substring(
84
- 0,
85
- formattedAmount.length - 3
86
- );
87
- }
88
- }
89
- if (roundedAmount < 0) {
90
- formattedAmount = "-" + formattedAmount;
91
- }
92
- return formattedAmount;
93
- } catch (err) {
94
- console.error(err);
95
- return amount;
96
- }
97
- };
98
- // Annotate the CommonJS export names for ESM import in node:
99
- 0 && (module.exports = {
100
- formatAmount,
101
- formatAmountWithOptions
102
- });
92
+ //#endregion
93
+ exports.formatAmount = formatAmount;
94
+ exports.formatAmountWithOptions = formatAmountWithOptions;
package/lib/image.d.ts CHANGED
@@ -1,11 +1,14 @@
1
- export declare const image: {
2
- ali: (url: string, w: number) => string;
3
- getImageSize: (url: string) => {
4
- width: number;
5
- height: number;
6
- ratio: number;
7
- success: boolean;
8
- widthRatio: number;
9
- originRatio: number;
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
- 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 });
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
- 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;
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
- 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;
46
+ const image = {
47
+ ali,
48
+ getImageSize
41
49
  };
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
- });
50
+ //#endregion
51
+ exports.image = image;
package/lib/index.d.ts CHANGED
@@ -1,25 +1,40 @@
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 './common';
17
- export * from './text-input';
18
- export * from './number-input';
19
- export * from './select';
20
- export declare const setPisellUtilsConfig: (config: {
21
- [key: string]: any;
1
+ import { changeArray, createArray, detectIncognito, generateUniqueIdByObj, getItemByArray, getUniqueId } from "./otherUtils.js";
2
+ import { isArr, isBoolean, isFunction, isJson, isNumber, isPlainObject, isString, isUndefined } from "./typeUtils.js";
3
+ import { ColumnSettingStorageItem, clearColumnSettingFromLocal, clearColumnVisibilityFromLocal, getColumnSettingFromLocal, getColumnVisibilityFromLocal, getComponentStorageKey, getRecordBoardColumnSettingFromLocal, getStorageKeySuffix, saveColumnSettingToLocal, saveColumnVisibilityToLocal } from "./componentStorage.js";
4
+ import { copyToClipboard, setTheme } from "./document.js";
5
+ import { excelDateToJSDate, formatDate, jsDateToExcelDate } from "./date.js";
6
+ import { checkEnv, isAndroid, isIOS, isIos, isIpad, isMobile, isSafari, isWebposOsServerEnv, isWx, isWxApp } from "./platform.js";
7
+ import { sendWarningLog } from "./log.js";
8
+ import { FormatOptions, formatAmount, formatAmountWithOptions } from "./format.js";
9
+ import { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, EscPosPrinter, columnWidthWithAlignment, preparing } from "./escPosPrinter/index.js";
10
+ import { miniRedux } from "./miniRedux.js";
11
+ import { dataManager, webPayment, webPrint } from "./jsBridge/index.js";
12
+ import { image } from "./image.js";
13
+ import { locales } from "./locales.js";
14
+ import { uniqueByKey } from "./arrayUtils.js";
15
+ import { Locale, getScheduleSummary } from "./walletValidity.js";
16
+ import { DisplayState, ValidationResult } from "./common/types.js";
17
+ import { getDisplayState } from "./common/stateHelper.js";
18
+ import { BaseTextInputProps, TextInputState } from "./text-input/types.js";
19
+ import { useTextInputState } from "./text-input/hooks/useTextInputState.js";
20
+ import { validateValue as validateValue$1 } from "./text-input/utils/validation.js";
21
+ import { BaseNumberInputProps, NumberInputState } from "./number-input/types.js";
22
+ import { useNumberInputState } from "./number-input/hooks/useNumberInputState.js";
23
+ import { validateValue } from "./number-input/utils/validation.js";
24
+ import { NumberFormatOptions, addThousandsSeparator, formatNumber, formatPrecision } from "./number-input/utils/formatter.js";
25
+ import { BaseSelectProps, FilterOptionFunc, MultipleSelectState, SelectOption, SelectState, SortDirection, TagDisplayInfo, UseMultipleSelectStateOptions, UseSelectStateOptions } from "./select/types.js";
26
+ import { useMultipleSelectState, useSelectState } from "./select/hooks/useSelectState.js";
27
+ import { useDebouncedSearch } from "./select/hooks/useDebouncedSearch.js";
28
+ import { calculateTagDisplay } from "./select/utils/tagAggregation.js";
29
+ import { defaultFilterOption, filterOptions } from "./select/utils/filterOptions.js";
30
+ import { sortOptions } from "./select/utils/sortOptions.js";
31
+ import { findOptionByValue, findOptionsByValues, generateId, isOptionSelected, isOptionSelectedInMultiple } from "./select/utils/helpers.js";
32
+ //#region src/index.d.ts
33
+ declare const setPisellUtilsConfig: (config: {
34
+ [key: string]: any;
22
35
  }) => void;
23
- export declare const getPisellUtilsConfig: () => {
24
- [key: string]: any;
36
+ declare const getPisellUtilsConfig: () => {
37
+ [key: string]: any;
25
38
  };
39
+ //#endregion
40
+ export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, BaseNumberInputProps, BaseSelectProps, BaseTextInputProps, ColumnSettingStorageItem, DisplayState, EscPosPrinter, FilterOptionFunc, FormatOptions, Locale, MultipleSelectState, NumberFormatOptions, NumberInputState, SelectOption, SelectState, SortDirection, TagDisplayInfo, TextInputState, UseMultipleSelectStateOptions, UseSelectStateOptions, ValidationResult, addThousandsSeparator, calculateTagDisplay, changeArray, checkEnv, clearColumnSettingFromLocal, clearColumnVisibilityFromLocal, columnWidthWithAlignment, copyToClipboard, createArray, dataManager, defaultFilterOption, detectIncognito, excelDateToJSDate, filterOptions, findOptionByValue, findOptionsByValues, formatAmount, formatAmountWithOptions, formatDate, formatNumber, formatPrecision, generateId, generateUniqueIdByObj, getColumnSettingFromLocal, getColumnVisibilityFromLocal, getComponentStorageKey, getDisplayState, getItemByArray, getPisellUtilsConfig, getRecordBoardColumnSettingFromLocal, getScheduleSummary, getStorageKeySuffix, getUniqueId, image, isAndroid, isArr, isBoolean, isFunction, isIOS, isIos, isIpad, isJson, isMobile, isNumber, isOptionSelected, isOptionSelectedInMultiple, isPlainObject, isSafari, isString, isUndefined, isWebposOsServerEnv, isWx, isWxApp, jsDateToExcelDate, locales, miniRedux, preparing, saveColumnSettingToLocal, saveColumnVisibilityToLocal, sendWarningLog, setPisellUtilsConfig, setTheme, sortOptions, uniqueByKey, useDebouncedSearch, useMultipleSelectState, useNumberInputState, useSelectState, useTextInputState, validateValue as validateNumberValue, validateValue$1 as validateTextValue, webPayment, webPrint };