@pisell/utils 3.0.6 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/arrayUtils.d.ts +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
|
@@ -1,58 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
48
|
+
return Number(value.toFixed(precision));
|
|
54
49
|
}
|
|
55
|
-
|
|
56
|
-
exports
|
|
57
|
-
|
|
58
|
-
|
|
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,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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
52
|
-
exports
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
validateValue
|
|
54
|
+
});
|
package/lib/otherUtils.d.ts
CHANGED
|
@@ -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
|
-
|
|
11
|
-
|
|
8
|
+
export declare const detectIncognito: () => Promise<{
|
|
9
|
+
isPrivate: boolean;
|
|
10
|
+
browserName: string;
|
|
12
11
|
} | {
|
|
13
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
76
|
-
|
|
58
|
+
var getUniqueId = (prefix = "", maxLength = 11) => {
|
|
59
|
+
return prefix + (Math.random() + "").replace(/\D/g, "").substring(0, maxLength);
|
|
77
60
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
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;
|