@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
@@ -1,58 +1,55 @@
1
- //#region src/number-input/utils/formatter.ts
2
- /**
3
- * 格式化数值
4
- *
5
- * @param value 数值
6
- * @param options 格式化选项
7
- * @returns 格式化后的字符串,null 时返回 null
8
- *
9
- * @example
10
- * formatNumber(1234.567, { precision: 2, useGrouping: true })
11
- * // 返回: "1,234.57"
12
- *
13
- * @example
14
- * formatNumber(1234, { precision: 0, useGrouping: true })
15
- * // 返回: "1,234"
16
- */
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 });
8
+ };
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;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/number-input/utils/formatter.ts
20
+ var formatter_exports = {};
21
+ __export(formatter_exports, {
22
+ addThousandsSeparator: () => addThousandsSeparator,
23
+ formatNumber: () => formatNumber,
24
+ formatPrecision: () => formatPrecision
25
+ });
26
+ module.exports = __toCommonJS(formatter_exports);
17
27
  function formatNumber(value, options = {}) {
18
- if (value === null || value === void 0) return null;
19
- const { precision, useGrouping = false, formatter } = options;
20
- if (formatter) return formatter(value);
21
- if (useGrouping || precision !== void 0) return value.toLocaleString("zh-CN", {
22
- minimumFractionDigits: precision,
23
- maximumFractionDigits: precision,
24
- useGrouping
25
- });
26
- return String(value);
28
+ if (value === null || value === void 0) {
29
+ return null;
30
+ }
31
+ const { precision, useGrouping = false, formatter } = options;
32
+ if (formatter) {
33
+ return formatter(value);
34
+ }
35
+ if (useGrouping || precision !== void 0) {
36
+ return value.toLocaleString("zh-CN", {
37
+ minimumFractionDigits: precision,
38
+ maximumFractionDigits: precision,
39
+ useGrouping
40
+ });
41
+ }
42
+ return String(value);
27
43
  }
28
- /**
29
- * 添加千分位分隔符
30
- *
31
- * @param value 数值
32
- * @returns 添加千分位后的字符串
33
- *
34
- * @example
35
- * addThousandsSeparator(1234567)
36
- * // 返回: "1,234,567"
37
- */
38
44
  function addThousandsSeparator(value) {
39
- return value.toLocaleString("zh-CN", { useGrouping: true });
45
+ return value.toLocaleString("zh-CN", { useGrouping: true });
40
46
  }
41
- /**
42
- * 格式化精度
43
- *
44
- * @param value 数值
45
- * @param precision 小数位数
46
- * @returns 格式化后的数值
47
- *
48
- * @example
49
- * formatPrecision(1.2345, 2)
50
- * // 返回: 1.23
51
- */
52
47
  function formatPrecision(value, precision) {
53
- return Number(value.toFixed(precision));
48
+ return Number(value.toFixed(precision));
54
49
  }
55
- //#endregion
56
- exports.addThousandsSeparator = addThousandsSeparator;
57
- exports.formatNumber = formatNumber;
58
- exports.formatPrecision = formatPrecision;
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ addThousandsSeparator,
53
+ formatNumber,
54
+ formatPrecision
55
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 数值输入工具函数导出
3
+ */
4
+ export { validateValue } from './validation';
5
+ export { getDisplayState } from '../../common';
6
+ export { formatNumber, addThousandsSeparator, formatPrecision } from './formatter';
7
+ export type { NumberFormatOptions } from './formatter';
@@ -0,0 +1,39 @@
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 });
8
+ };
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;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/number-input/utils/index.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ addThousandsSeparator: () => import_formatter.addThousandsSeparator,
23
+ formatNumber: () => import_formatter.formatNumber,
24
+ formatPrecision: () => import_formatter.formatPrecision,
25
+ getDisplayState: () => import_common.getDisplayState,
26
+ validateValue: () => import_validation.validateValue
27
+ });
28
+ module.exports = __toCommonJS(utils_exports);
29
+ var import_validation = require("./validation");
30
+ var import_common = require("../../common");
31
+ var import_formatter = require("./formatter");
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ addThousandsSeparator,
35
+ formatNumber,
36
+ formatPrecision,
37
+ getDisplayState,
38
+ validateValue
39
+ });
@@ -1,7 +1,4 @@
1
- import { ValidationResult } from "../../common/types.js";
2
- import { BaseNumberInputProps } from "../types.js";
3
-
4
- //#region src/number-input/utils/validation.d.ts
1
+ import type { BaseNumberInputProps, ValidationResult } from '../types';
5
2
  /**
6
3
  * 校验数值输入
7
4
  *
@@ -27,6 +24,4 @@ import { BaseNumberInputProps } from "../types.js";
27
24
  * validateValue(150, { min: 0, max: 100 })
28
25
  * // { isValid: false, errors: ['不能大于 100'] }
29
26
  */
30
- declare function validateValue(value: number | null | undefined, props: BaseNumberInputProps): ValidationResult;
31
- //#endregion
32
- export { validateValue };
27
+ export declare function validateValue(value: number | null | undefined, props: BaseNumberInputProps): ValidationResult;
@@ -1,52 +1,54 @@
1
- //#region src/number-input/utils/validation.ts
2
- /**
3
- * 校验数值输入
4
- *
5
- * 按照优先级执行校验规则:
6
- * 1. 必填校验(required)
7
- * 2. 最小值校验(min)
8
- * 3. 最大值校验(max)
9
- * 4. 自定义校验函数(validator)
10
- *
11
- * @param value 待校验的值
12
- * @param props 校验配置
13
- * @returns 校验结果对象,包含 isValid 和 errors
14
- *
15
- * @example
16
- * validateValue(10, { required: true, min: 0, max: 100 })
17
- * // { isValid: true, errors: [] }
18
- *
19
- * @example
20
- * validateValue(null, { required: true })
21
- * // { isValid: false, errors: ['此字段为必填项'] }
22
- *
23
- * @example
24
- * validateValue(150, { min: 0, max: 100 })
25
- * // { isValid: false, errors: ['不能大于 100'] }
26
- */
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 });
8
+ };
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;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/number-input/utils/validation.ts
20
+ var validation_exports = {};
21
+ __export(validation_exports, {
22
+ validateValue: () => validateValue
23
+ });
24
+ module.exports = __toCommonJS(validation_exports);
27
25
  function validateValue(value, props) {
28
- const errors = [];
29
- if (props.required && (value === null || value === void 0)) {
30
- errors.push(props.errorMessage || "此字段为必填项");
31
- return {
32
- isValid: false,
33
- errors
34
- };
35
- }
36
- if (value === null || value === void 0) return {
37
- isValid: true,
38
- errors
39
- };
40
- if (props.min !== void 0 && value < props.min) errors.push(`不能小于 ${props.min}`);
41
- if (props.max !== void 0 && value > props.max) errors.push(`不能大于 ${props.max}`);
42
- if (props.validator) {
43
- const result = props.validator(value);
44
- if (result !== true) errors.push(typeof result === "string" ? result : "校验失败");
45
- }
46
- return {
47
- isValid: errors.length === 0,
48
- errors
49
- };
26
+ const errors = [];
27
+ if (props.required && (value === null || value === void 0)) {
28
+ errors.push(props.errorMessage || "此字段为必填项");
29
+ return { isValid: false, errors };
30
+ }
31
+ if (value === null || value === void 0) {
32
+ return { isValid: true, errors };
33
+ }
34
+ if (props.min !== void 0 && value < props.min) {
35
+ errors.push(`不能小于 ${props.min}`);
36
+ }
37
+ if (props.max !== void 0 && value > props.max) {
38
+ errors.push(`不能大于 ${props.max}`);
39
+ }
40
+ if (props.validator) {
41
+ const result = props.validator(value);
42
+ if (result !== true) {
43
+ errors.push(typeof result === "string" ? result : "校验失败");
44
+ }
45
+ }
46
+ return {
47
+ isValid: errors.length === 0,
48
+ errors
49
+ };
50
50
  }
51
- //#endregion
52
- exports.validateValue = validateValue;
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ validateValue
54
+ });
@@ -1,4 +1,3 @@
1
- //#region src/otherUtils.d.ts
2
1
  /**
3
2
  * @title: 判断是否无痕模式
4
3
  * @description:
@@ -6,11 +5,11 @@
6
5
  * @Author: shengjie.zuo
7
6
  * @Date: 2024-09-4 09:58:22
8
7
  */
9
- declare const detectIncognito: () => Promise<{
10
- isPrivate: boolean;
11
- browserName: string;
8
+ export declare const detectIncognito: () => Promise<{
9
+ isPrivate: boolean;
10
+ browserName: string;
12
11
  } | {
13
- isPrivate: boolean;
12
+ isPrivate: boolean;
14
13
  }>;
15
14
  /**
16
15
  * @Description: 生成唯一id
@@ -19,7 +18,7 @@ declare const detectIncognito: () => Promise<{
19
18
  * @param {*}
20
19
  * @return {*}
21
20
  */
22
- declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
21
+ export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
23
22
  /**
24
23
  * @title: 对数组进行增|删
25
24
  * @description: 用于多选选中和取消选中的处理
@@ -30,7 +29,7 @@ declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
30
29
  * @Author: zhiwei.Wang
31
30
  * @Date: 2023-12-19 16:44
32
31
  */
33
- declare const changeArray: <T>(list: T[] | undefined, item: T, key?: string) => T[];
32
+ export declare const changeArray: <T>(list: T[] | undefined, item: T, key?: string) => T[];
34
33
  /**
35
34
  * @title: 判断某个字段是否在列表内
36
35
  * @description:
@@ -40,12 +39,10 @@ declare const changeArray: <T>(list: T[] | undefined, item: T, key?: string) =>
40
39
  * @Author: zhiwei.Wang
41
40
  * @Date: 2023-12-19 16:54
42
41
  */
43
- declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
44
- declare const createArray: (length: number, returnItem: any) => unknown[];
42
+ export declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
43
+ export declare const createArray: (length: number, returnItem: any) => unknown[];
45
44
  /**
46
45
  * 根据对象内容生成唯一id
47
46
  * @param obj
48
47
  */
49
- declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
50
- //#endregion
51
- export { changeArray, createArray, detectIncognito, generateUniqueIdByObj, getItemByArray, getUniqueId };
48
+ export declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
package/lib/otherUtils.js CHANGED
@@ -1,91 +1,103 @@
1
- const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
- const require_asyncToGenerator = require("./_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
3
- let crypto_js_md5 = require("crypto-js/md5");
4
- crypto_js_md5 = require_runtime.__toESM(crypto_js_md5);
5
- let crypto_js_enc_hex = require("crypto-js/enc-hex");
6
- crypto_js_enc_hex = require_runtime.__toESM(crypto_js_enc_hex);
7
- let detectincognitojs = require("detectincognitojs");
8
- //#region src/otherUtils.ts
9
- /**
10
- * @title: 判断是否无痕模式
11
- * @description:
12
- * @return: *
13
- * @Author: shengjie.zuo
14
- * @Date: 2024-09-4 09:58:22
15
- */
16
- const detectIncognito = function() {
17
- var _ref = require_asyncToGenerator._asyncToGenerator(function* () {
18
- try {
19
- if (navigator.userAgent.toLowerCase().includes("honor")) return { isPrivate: false };
20
- return yield (0, detectincognitojs.detectIncognito)();
21
- } catch (error) {
22
- console.warn("detectIncognito failed:", error);
23
- return { isPrivate: false };
24
- }
25
- });
26
- return function detectIncognito() {
27
- return _ref.apply(this, arguments);
28
- };
29
- }();
30
- /**
31
- * @Description: 生成唯一id
32
- * @Author: wzw
33
- * @Date: 2020-12-01 14:20:29
34
- * @param {*}
35
- * @return {*}
36
- */
37
- const getUniqueId = (prefix = "", maxLength = 11) => {
38
- return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
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 });
39
10
  };
40
- /**
41
- * @title: 对数组进行增|删
42
- * @description: 用于多选选中和取消选中的处理
43
- * @param {any} list
44
- * @param {any} item
45
- * @param {string} key
46
- * @return {*}
47
- * @Author: zhiwei.Wang
48
- * @Date: 2023-12-19 16:44
49
- */
50
- const changeArray = (list = [], item, key = "this") => {
51
- let _list = JSON.parse(JSON.stringify(list));
52
- let isSome = false;
53
- if (key === "this") isSome = _list.includes(item);
54
- else isSome = _list.some((d) => d[key] === item[key]);
55
- if (isSome) _list = _list.filter((d) => {
56
- if (key === "this") return d !== item;
57
- return d[key] !== item[key];
58
- });
59
- else _list.push(item);
60
- return _list;
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;
61
18
  };
62
- /**
63
- * @title: 判断某个字段是否在列表内
64
- * @description:
65
- * @param {*} T
66
- * @param {boolean} param2
67
- * @return {*}
68
- * @Author: zhiwei.Wang
69
- * @Date: 2023-12-19 16:54
70
- */
71
- const getItemByArray = (list = [], item, key = "this") => {
72
- if (key === "this") return list.includes(item);
73
- return list.some((d) => d[key] === item[key]);
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/otherUtils.ts
30
+ var otherUtils_exports = {};
31
+ __export(otherUtils_exports, {
32
+ changeArray: () => changeArray,
33
+ createArray: () => createArray,
34
+ detectIncognito: () => detectIncognito,
35
+ generateUniqueIdByObj: () => generateUniqueIdByObj,
36
+ getItemByArray: () => getItemByArray,
37
+ getUniqueId: () => getUniqueId
38
+ });
39
+ module.exports = __toCommonJS(otherUtils_exports);
40
+ var import_md5 = __toESM(require("crypto-js/md5"));
41
+ var import_enc_hex = __toESM(require("crypto-js/enc-hex"));
42
+ var import_detectincognitojs = require("detectincognitojs");
43
+ var detectIncognito = async () => {
44
+ try {
45
+ if (navigator.userAgent.toLowerCase().includes("honor")) {
46
+ return {
47
+ isPrivate: false
48
+ };
49
+ }
50
+ return await (0, import_detectincognitojs.detectIncognito)();
51
+ } catch (error) {
52
+ console.warn("detectIncognito failed:", error);
53
+ return {
54
+ isPrivate: false
55
+ };
56
+ }
74
57
  };
75
- const createArray = (length, returnItem) => {
76
- return Array.from(new Array(length)).map(returnItem);
58
+ var getUniqueId = (prefix = "", maxLength = 11) => {
59
+ return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
77
60
  };
78
- /**
79
- * 根据对象内容生成唯一id
80
- * @param obj
81
- */
82
- const generateUniqueIdByObj = (obj) => {
83
- return (0, crypto_js_md5.default)(JSON.stringify(obj)).toString(crypto_js_enc_hex.default.Hex);
61
+ var changeArray = (list = [], item, key = "this") => {
62
+ let _list = JSON.parse(JSON.stringify(list));
63
+ let isSome = false;
64
+ if (key === "this") {
65
+ isSome = _list.includes(item);
66
+ } else {
67
+ isSome = _list.some((d) => d[key] === item[key]);
68
+ }
69
+ if (isSome) {
70
+ _list = _list.filter((d) => {
71
+ if (key === "this") {
72
+ return d !== item;
73
+ }
74
+ return d[key] !== item[key];
75
+ });
76
+ } else {
77
+ _list.push(item);
78
+ }
79
+ return _list;
84
80
  };
85
- //#endregion
86
- exports.changeArray = changeArray;
87
- exports.createArray = createArray;
88
- exports.detectIncognito = detectIncognito;
89
- exports.generateUniqueIdByObj = generateUniqueIdByObj;
90
- exports.getItemByArray = getItemByArray;
91
- exports.getUniqueId = getUniqueId;
81
+ var getItemByArray = (list = [], item, key = "this") => {
82
+ if (key === "this") {
83
+ return list.includes(item);
84
+ }
85
+ return list.some((d) => d[key] === item[key]);
86
+ };
87
+ var createArray = (length, returnItem) => {
88
+ return Array.from(new Array(length)).map(returnItem);
89
+ };
90
+ var generateUniqueIdByObj = (obj) => {
91
+ const jsonString = JSON.stringify(obj);
92
+ const hash = (0, import_md5.default)(jsonString);
93
+ return hash.toString(import_enc_hex.default.Hex);
94
+ };
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ changeArray,
98
+ createArray,
99
+ detectIncognito,
100
+ generateUniqueIdByObj,
101
+ getItemByArray,
102
+ getUniqueId
103
+ });
package/lib/platform.d.ts CHANGED
@@ -1,12 +1,9 @@
1
- //#region src/platform.d.ts
2
- declare const isIpad: () => boolean;
3
- declare const isMobile: () => boolean;
4
- declare const isAndroid: () => boolean;
5
- declare const isIos: () => boolean;
6
- declare const checkEnv: () => number;
7
- declare const isWx: () => boolean;
8
- declare const isIOS: () => boolean;
9
- declare const isWxApp: () => boolean;
10
- declare const isSafari: () => boolean;
11
- //#endregion
12
- export { checkEnv, isAndroid, isIOS, isIos, isIpad, isMobile, isSafari, isWx, isWxApp };
1
+ export declare const isIpad: () => boolean;
2
+ export declare const isMobile: () => boolean;
3
+ export declare const isAndroid: () => boolean;
4
+ export declare const isIos: () => boolean;
5
+ export declare const checkEnv: () => number;
6
+ export declare const isWx: () => boolean;
7
+ export declare const isIOS: () => boolean;
8
+ export declare const isWxApp: () => boolean;
9
+ export declare const isSafari: () => boolean;