@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.
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +4 -1
- package/es/arrayUtils.js +15 -24
- package/es/common/stateHelper.d.ts +6 -2
- package/es/common/stateHelper.js +22 -24
- package/es/common/types.d.ts +13 -10
- package/es/componentStorage.d.ts +27 -25
- package/es/componentStorage.js +94 -130
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +12 -11
- package/es/format.js +90 -116
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +38 -23
- package/es/index.js +39 -34
- package/es/jsBridge/index.d.ts +8 -4
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +95 -115
- package/es/locales.d.ts +11 -8
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -78
- package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/es/number-input/hooks/useNumberInputState.js +71 -128
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/utils/formatter.d.ts +13 -10
- package/es/number-input/utils/formatter.js +51 -77
- package/es/number-input/utils/validation.d.ts +7 -2
- package/es/number-input/utils/validation.js +51 -66
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +17 -9
- package/es/platform.js +78 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/es/select/hooks/useDebouncedSearch.js +39 -53
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +56 -113
- package/es/select/index.d.ts +7 -8
- package/es/select/types.d.ts +211 -211
- package/es/select/utils/filterOptions.d.ts +7 -6
- package/es/select/utils/filterOptions.js +26 -31
- package/es/select/utils/helpers.d.ts +10 -9
- package/es/select/utils/helpers.js +42 -52
- package/es/select/utils/index.d.ts +4 -7
- package/es/select/utils/sortOptions.d.ts +6 -5
- package/es/select/utils/sortOptions.js +19 -31
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +34 -47
- package/es/text-input/hooks/useTextInputState.d.ts +6 -2
- package/es/text-input/hooks/useTextInputState.js +69 -126
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/utils/validation.d.ts +7 -2
- package/es/text-input/utils/validation.js +50 -70
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +36 -34
- package/es/walletValidity.js +332 -456
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +4 -1
- package/lib/arrayUtils.js +14 -39
- package/lib/common/stateHelper.d.ts +6 -2
- package/lib/common/stateHelper.js +21 -32
- package/lib/common/types.d.ts +13 -10
- package/lib/componentStorage.d.ts +27 -25
- package/lib/componentStorage.js +96 -126
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +12 -11
- package/lib/format.js +91 -99
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +38 -23
- package/lib/index.js +115 -78
- package/lib/jsBridge/index.d.ts +8 -4
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +95 -115
- package/lib/locales.d.ts +11 -8
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -92
- package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/lib/number-input/hooks/useNumberInputState.js +71 -81
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/utils/formatter.d.ts +13 -10
- package/lib/number-input/utils/formatter.js +52 -49
- package/lib/number-input/utils/validation.d.ts +7 -2
- package/lib/number-input/utils/validation.js +50 -52
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +17 -9
- package/lib/platform.js +85 -122
- package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/lib/select/hooks/useDebouncedSearch.js +40 -41
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +58 -93
- package/lib/select/index.d.ts +7 -8
- package/lib/select/types.d.ts +211 -211
- package/lib/select/utils/filterOptions.d.ts +7 -6
- package/lib/select/utils/filterOptions.js +26 -37
- package/lib/select/utils/helpers.d.ts +10 -9
- package/lib/select/utils/helpers.js +45 -41
- package/lib/select/utils/index.d.ts +4 -7
- package/lib/select/utils/sortOptions.d.ts +6 -5
- package/lib/select/utils/sortOptions.js +18 -39
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +33 -41
- package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
- package/lib/text-input/hooks/useTextInputState.js +69 -79
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/utils/validation.d.ts +7 -2
- package/lib/text-input/utils/validation.js +49 -58
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +36 -34
- package/lib/walletValidity.js +345 -317
- package/package.json +1 -2
- package/es/common/index.d.ts +0 -5
- package/es/common/index.js +0 -5
- package/es/common/types.js +0 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/es/jsBridge/types.js +0 -1
- package/es/number-input/hooks/index.d.ts +0 -4
- package/es/number-input/hooks/index.js +0 -5
- package/es/number-input/index.d.ts +0 -14
- package/es/number-input/index.js +0 -21
- package/es/number-input/types.js +0 -1
- package/es/number-input/utils/index.d.ts +0 -7
- package/es/number-input/utils/index.js +0 -8
- package/es/select/hooks/index.d.ts +0 -5
- package/es/select/hooks/index.js +0 -6
- package/es/select/index.js +0 -13
- package/es/select/types.js +0 -1
- package/es/select/utils/index.js +0 -8
- package/es/text-input/hooks/index.d.ts +0 -4
- package/es/text-input/hooks/index.js +0 -5
- package/es/text-input/index.d.ts +0 -14
- package/es/text-input/index.js +0 -20
- package/es/text-input/types.js +0 -1
- package/es/text-input/utils/index.d.ts +0 -5
- package/es/text-input/utils/index.js +0 -7
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.js +0 -29
- package/lib/common/types.js +0 -17
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
- package/lib/jsBridge/types.js +0 -17
- package/lib/number-input/hooks/index.d.ts +0 -4
- package/lib/number-input/hooks/index.js +0 -29
- package/lib/number-input/index.d.ts +0 -14
- package/lib/number-input/index.js +0 -41
- package/lib/number-input/types.js +0 -17
- package/lib/number-input/utils/index.d.ts +0 -7
- package/lib/number-input/utils/index.js +0 -39
- package/lib/select/hooks/index.d.ts +0 -5
- package/lib/select/hooks/index.js +0 -34
- package/lib/select/index.js +0 -53
- package/lib/select/types.js +0 -17
- package/lib/select/utils/index.js +0 -48
- package/lib/text-input/hooks/index.d.ts +0 -4
- package/lib/text-input/hooks/index.js +0 -29
- package/lib/text-input/index.d.ts +0 -14
- package/lib/text-input/index.js +0 -35
- package/lib/text-input/types.js +0 -17
- package/lib/text-input/utils/index.d.ts +0 -5
- package/lib/text-input/utils/index.js +0 -32
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ValidationResult } from "../../common/types.js";
|
|
2
|
+
import { BaseNumberInputProps } from "../types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/number-input/utils/validation.d.ts
|
|
2
5
|
/**
|
|
3
6
|
* 校验数值输入
|
|
4
7
|
*
|
|
@@ -24,4 +27,6 @@ import type { BaseNumberInputProps, ValidationResult } from '../types';
|
|
|
24
27
|
* validateValue(150, { min: 0, max: 100 })
|
|
25
28
|
* // { isValid: false, errors: ['不能大于 100'] }
|
|
26
29
|
*/
|
|
27
|
-
|
|
30
|
+
declare function validateValue(value: number | null | undefined, props: BaseNumberInputProps): ValidationResult;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { validateValue };
|
|
@@ -1,54 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
*/
|
|
25
27
|
function validateValue(value, props) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
errors
|
|
49
|
-
};
|
|
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
|
+
};
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
validateValue
|
|
54
|
-
});
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.validateValue = validateValue;
|
package/lib/otherUtils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/otherUtils.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* @title: 判断是否无痕模式
|
|
3
4
|
* @description:
|
|
@@ -5,11 +6,11 @@
|
|
|
5
6
|
* @Author: shengjie.zuo
|
|
6
7
|
* @Date: 2024-09-4 09:58:22
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
declare const detectIncognito: () => Promise<{
|
|
10
|
+
isPrivate: boolean;
|
|
11
|
+
browserName: string;
|
|
11
12
|
} | {
|
|
12
|
-
|
|
13
|
+
isPrivate: boolean;
|
|
13
14
|
}>;
|
|
14
15
|
/**
|
|
15
16
|
* @Description: 生成唯一id
|
|
@@ -18,7 +19,7 @@ export declare const detectIncognito: () => Promise<{
|
|
|
18
19
|
* @param {*}
|
|
19
20
|
* @return {*}
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
|
|
22
23
|
/**
|
|
23
24
|
* @title: 对数组进行增|删
|
|
24
25
|
* @description: 用于多选选中和取消选中的处理
|
|
@@ -29,7 +30,7 @@ export declare const getUniqueId: (prefix?: string, maxLength?: number) => strin
|
|
|
29
30
|
* @Author: zhiwei.Wang
|
|
30
31
|
* @Date: 2023-12-19 16:44
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
+
declare const changeArray: <T>(list: T[] | undefined, item: T, key?: string) => T[];
|
|
33
34
|
/**
|
|
34
35
|
* @title: 判断某个字段是否在列表内
|
|
35
36
|
* @description:
|
|
@@ -39,10 +40,12 @@ export declare const changeArray: <T>(list: T[] | undefined, item: T, key?: stri
|
|
|
39
40
|
* @Author: zhiwei.Wang
|
|
40
41
|
* @Date: 2023-12-19 16:54
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
|
|
44
|
+
declare const createArray: (length: number, returnItem: any) => unknown[];
|
|
44
45
|
/**
|
|
45
46
|
* 根据对象内容生成唯一id
|
|
46
47
|
* @param obj
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { changeArray, createArray, detectIncognito, generateUniqueIdByObj, getItemByArray, getUniqueId };
|
package/lib/otherUtils.js
CHANGED
|
@@ -1,103 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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);
|
|
10
39
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
18
61
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
}
|
|
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]);
|
|
57
74
|
};
|
|
58
|
-
|
|
59
|
-
|
|
75
|
+
const createArray = (length, returnItem) => {
|
|
76
|
+
return Array.from(new Array(length)).map(returnItem);
|
|
60
77
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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;
|
|
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);
|
|
80
84
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
});
|
|
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;
|
package/lib/platform.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
//#region src/platform.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* osServer 列表/平面图订阅及其 unsubscribe 仅在 webpos 宿主可用
|
|
4
|
+
*(`appHelper.utils.pisellos` 存在)。低代码 admin、纯 H5 等环境不应发 unsubscribe。
|
|
5
|
+
*/
|
|
6
|
+
declare const isWebposOsServerEnv: () => boolean;
|
|
7
|
+
declare const isIpad: () => boolean;
|
|
8
|
+
declare const isMobile: () => boolean;
|
|
9
|
+
declare const isAndroid: () => boolean;
|
|
10
|
+
declare const isIos: () => boolean;
|
|
11
|
+
declare const checkEnv: () => number;
|
|
12
|
+
declare const isWx: () => boolean;
|
|
13
|
+
declare const isIOS: () => boolean;
|
|
14
|
+
declare const isWxApp: () => boolean;
|
|
15
|
+
declare const isSafari: () => boolean;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { checkEnv, isAndroid, isIOS, isIos, isIpad, isMobile, isSafari, isWebposOsServerEnv, isWx, isWxApp };
|
package/lib/platform.js
CHANGED
|
@@ -1,132 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/platform.ts
|
|
2
|
+
const isBrowser = typeof window != "undefined" && window.document;
|
|
3
|
+
/**
|
|
4
|
+
* osServer 列表/平面图订阅及其 unsubscribe 仅在 webpos 宿主可用
|
|
5
|
+
*(`appHelper.utils.pisellos` 存在)。低代码 admin、纯 H5 等环境不应发 unsubscribe。
|
|
6
|
+
*/
|
|
7
|
+
const isWebposOsServerEnv = () => {
|
|
8
|
+
if (!isBrowser) return false;
|
|
9
|
+
try {
|
|
10
|
+
var _engineCtx$appHelper;
|
|
11
|
+
const w = window;
|
|
12
|
+
const ctx = w.__appContext;
|
|
13
|
+
const injected = w.__injectedContext;
|
|
14
|
+
const engineCtx = ctx != null && Object.keys(ctx).length > 0 ? ctx : injected;
|
|
15
|
+
return Boolean(engineCtx === null || engineCtx === void 0 || (_engineCtx$appHelper = engineCtx.appHelper) === null || _engineCtx$appHelper === void 0 || (_engineCtx$appHelper = _engineCtx$appHelper.utils) === null || _engineCtx$appHelper === void 0 ? void 0 : _engineCtx$appHelper.pisellos);
|
|
16
|
+
} catch (_unused) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
8
19
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
const isIpad = () => {
|
|
21
|
+
var ua = navigator.userAgent;
|
|
22
|
+
var isSafari = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
|
|
23
|
+
var isIphone = ua.indexOf("iPhone") != -1 && ua.indexOf("Version") != -1;
|
|
24
|
+
var isIPad = isSafari && !isIphone && "ontouchend" in document;
|
|
25
|
+
if (!/iphone|ios|ipad|android|mobile/i.test(navigator.userAgent.toLowerCase()) && !isIPad) return false;
|
|
26
|
+
return true;
|
|
16
27
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
isWx: () => isWx,
|
|
30
|
-
isWxApp: () => isWxApp
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(platform_exports);
|
|
33
|
-
var isBrowser = typeof window != "undefined" && window.document;
|
|
34
|
-
var isIpad = () => {
|
|
35
|
-
var ua = navigator.userAgent;
|
|
36
|
-
var isSafari2 = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
|
|
37
|
-
var isIphone = ua.indexOf("iPhone") != -1 && ua.indexOf("Version") != -1;
|
|
38
|
-
var isIPad = isSafari2 && !isIphone && "ontouchend" in document;
|
|
39
|
-
if (!/iphone|ios|ipad|android|mobile/i.test(
|
|
40
|
-
navigator.userAgent.toLowerCase()
|
|
41
|
-
) && !isIPad) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return true;
|
|
28
|
+
const isMobile = () => {
|
|
29
|
+
let sUserAgent = window.navigator.userAgent.toLowerCase();
|
|
30
|
+
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
|
|
31
|
+
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
|
|
32
|
+
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
|
|
33
|
+
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
|
|
34
|
+
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
|
|
35
|
+
let bIsAndroid = sUserAgent.match(/android/i) == "android";
|
|
36
|
+
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
|
|
37
|
+
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
|
|
38
|
+
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) return true;
|
|
39
|
+
else return false;
|
|
45
40
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
|
|
49
|
-
let bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
|
|
50
|
-
let bIsMidp = sUserAgent.match(/midp/i) == "midp";
|
|
51
|
-
let bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
|
|
52
|
-
let bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
|
|
53
|
-
let bIsAndroid = sUserAgent.match(/android/i) == "android";
|
|
54
|
-
let bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
|
|
55
|
-
let bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
|
|
56
|
-
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM || isIpad()) {
|
|
57
|
-
return true;
|
|
58
|
-
} else {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
41
|
+
const isAndroid = () => {
|
|
42
|
+
return navigator.userAgent.toLowerCase().indexOf("android") !== -1;
|
|
61
43
|
};
|
|
62
|
-
|
|
63
|
-
|
|
44
|
+
const isIos = () => {
|
|
45
|
+
return /iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase());
|
|
64
46
|
};
|
|
65
|
-
|
|
66
|
-
|
|
47
|
+
const checkEnv = () => {
|
|
48
|
+
let env = 0;
|
|
49
|
+
let userAgent = window.navigator.userAgent;
|
|
50
|
+
let isOpera = userAgent.indexOf("Opera") > -1 || userAgent.indexOf("OPR") > -1;
|
|
51
|
+
let isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
|
|
52
|
+
let isIE11 = userAgent.indexOf("compatible") === -1 && userAgent.indexOf("Trident") > -1;
|
|
53
|
+
let isEdge = userAgent.indexOf("Edge") > -1;
|
|
54
|
+
let isFF = userAgent.indexOf("Firefox") > -1;
|
|
55
|
+
let isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1;
|
|
56
|
+
let isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("; Win") > -1 && userAgent.indexOf("Safari") > -1;
|
|
57
|
+
if (isOpera || isIE || isIE11 || isEdge || isFF || isSafari || isChrome) env = 0;
|
|
58
|
+
else env = 1;
|
|
59
|
+
return env;
|
|
67
60
|
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
let isSafari2 = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1;
|
|
77
|
-
let isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("; Win") > -1 && userAgent.indexOf("Safari") > -1;
|
|
78
|
-
if (isOpera || isIE || isIE11 || isEdge || isFF || isSafari2 || isChrome) {
|
|
79
|
-
env = 0;
|
|
80
|
-
} else {
|
|
81
|
-
env = 1;
|
|
82
|
-
}
|
|
83
|
-
return env;
|
|
61
|
+
const isWx = () => {
|
|
62
|
+
if (isBrowser) {
|
|
63
|
+
let ua = "";
|
|
64
|
+
if (isBrowser) ua = window.navigator.userAgent.toLowerCase();
|
|
65
|
+
if (ua.match(/MicroMessenger/i) == "micromessenger") return true;
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
84
69
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (isBrowser) {
|
|
89
|
-
ua = window.navigator.userAgent.toLowerCase();
|
|
90
|
-
}
|
|
91
|
-
if (ua.match(/MicroMessenger/i) == "micromessenger") {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
70
|
+
const isIOS = () => {
|
|
71
|
+
if (isBrowser) return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
72
|
+
return false;
|
|
97
73
|
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
|
|
102
|
-
return isiOS;
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
74
|
+
const isWxApp = () => {
|
|
75
|
+
if (isBrowser) return navigator.userAgent.indexOf("miniProgram") !== -1;
|
|
76
|
+
return false;
|
|
105
77
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return false;
|
|
78
|
+
const isSafari = () => {
|
|
79
|
+
if (isBrowser) {
|
|
80
|
+
let userAgent = window.navigator.userAgent;
|
|
81
|
+
return userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") === -1 && userAgent.indexOf("CriOS") === -1 && userAgent.indexOf("ChannelName/Feishu") === -1;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
113
84
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
isIOS,
|
|
126
|
-
isIos,
|
|
127
|
-
isIpad,
|
|
128
|
-
isMobile,
|
|
129
|
-
isSafari,
|
|
130
|
-
isWx,
|
|
131
|
-
isWxApp
|
|
132
|
-
});
|
|
85
|
+
//#endregion
|
|
86
|
+
exports.checkEnv = checkEnv;
|
|
87
|
+
exports.isAndroid = isAndroid;
|
|
88
|
+
exports.isIOS = isIOS;
|
|
89
|
+
exports.isIos = isIos;
|
|
90
|
+
exports.isIpad = isIpad;
|
|
91
|
+
exports.isMobile = isMobile;
|
|
92
|
+
exports.isSafari = isSafari;
|
|
93
|
+
exports.isWebposOsServerEnv = isWebposOsServerEnv;
|
|
94
|
+
exports.isWx = isWx;
|
|
95
|
+
exports.isWxApp = isWxApp;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/select/hooks/useDebouncedSearch.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* 防抖搜索 Hook
|
|
3
4
|
* 对用户输入进行防抖处理,避免频繁触发搜索
|
|
@@ -17,4 +18,6 @@
|
|
|
17
18
|
* });
|
|
18
19
|
* ```
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
declare function useDebouncedSearch<T = string>(initialValue: T, delay: number, callback?: (value: T) => void): [T, (value: T) => void];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { useDebouncedSearch };
|