@pisell/utils 1.0.72 → 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 +29 -0
- 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 +26 -0
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +12 -0
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +23 -0
- 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 +29 -0
- 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 +26 -0
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +12 -0
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +23 -0
- 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,56 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
export type { DisplayState, ValidationResult } from '../common';
|
|
1
|
+
import { DisplayState, ValidationResult } from "../common/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/text-input/types.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* 文本输入状态 Hook 返回值
|
|
8
6
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
7
|
+
interface TextInputState {
|
|
8
|
+
/**
|
|
9
|
+
* 当前值
|
|
10
|
+
*/
|
|
11
|
+
value: string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* 是否已被触摸(交互过)
|
|
14
|
+
*/
|
|
15
|
+
isTouched: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* 是否校验通过
|
|
18
|
+
*/
|
|
19
|
+
isValid: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 错误信息数组
|
|
22
|
+
*/
|
|
23
|
+
errors: string[];
|
|
24
|
+
/**
|
|
25
|
+
* 值变更处理函数
|
|
26
|
+
*/
|
|
27
|
+
handleChange: (value: string) => void;
|
|
28
|
+
/**
|
|
29
|
+
* 失焦处理函数
|
|
30
|
+
*/
|
|
31
|
+
handleBlur: () => void;
|
|
32
|
+
/**
|
|
33
|
+
* 聚焦处理函数
|
|
34
|
+
*/
|
|
35
|
+
handleFocus: () => void;
|
|
38
36
|
}
|
|
39
37
|
/**
|
|
40
38
|
* 基础文本输入 Props(供校验和状态管理使用)
|
|
41
39
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
interface BaseTextInputProps {
|
|
41
|
+
value?: string;
|
|
42
|
+
defaultValue?: string;
|
|
43
|
+
required?: boolean;
|
|
44
|
+
minLength?: number;
|
|
45
|
+
maxLength?: number;
|
|
46
|
+
pattern?: string | RegExp;
|
|
47
|
+
validator?: (value: string) => boolean | string;
|
|
48
|
+
validateTrigger?: 'onChange' | 'onBlur' | 'both';
|
|
49
|
+
errorMessage?: string;
|
|
50
|
+
onChange?: (value: string) => void;
|
|
51
|
+
onBlur?: (value: string) => void;
|
|
52
|
+
onFocus?: () => void;
|
|
53
|
+
onValidate?: (isValid: boolean, errors: string[]) => void;
|
|
56
54
|
}
|
|
55
|
+
//#endregion
|
|
56
|
+
export { BaseTextInputProps, TextInputState };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ValidationResult } from "../../common/types.js";
|
|
2
|
+
import { BaseTextInputProps } from "../types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/text-input/utils/validation.d.ts
|
|
2
5
|
/**
|
|
3
6
|
* 校验文本输入值
|
|
4
7
|
*
|
|
@@ -20,4 +23,6 @@ import type { BaseTextInputProps, ValidationResult } from '../types';
|
|
|
20
23
|
* validateValue('', { required: true })
|
|
21
24
|
* // { isValid: false, errors: ['此字段为必填项'] }
|
|
22
25
|
*/
|
|
23
|
-
|
|
26
|
+
declare function validateValue(value: string, props: BaseTextInputProps): ValidationResult;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { validateValue };
|
|
@@ -1,60 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(validation_exports);
|
|
1
|
+
//#region src/text-input/utils/validation.ts
|
|
2
|
+
/**
|
|
3
|
+
* 校验文本输入值
|
|
4
|
+
*
|
|
5
|
+
* 按照优先级执行校验规则:
|
|
6
|
+
* 1. 必填校验(required)
|
|
7
|
+
* 2. 最小长度校验(minLength)
|
|
8
|
+
* 3. 最大长度校验(maxLength)
|
|
9
|
+
* 4. 正则校验(pattern)
|
|
10
|
+
* 5. 自定义校验函数(validator)
|
|
11
|
+
*
|
|
12
|
+
* @param value 待校验的值
|
|
13
|
+
* @param props 校验配置
|
|
14
|
+
* @returns 校验结果对象,包含 isValid 和 errors
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* validateValue('hello', { required: true, minLength: 3 })
|
|
18
|
+
* // { isValid: true, errors: [] }
|
|
19
|
+
*
|
|
20
|
+
* validateValue('', { required: true })
|
|
21
|
+
* // { isValid: false, errors: ['此字段为必填项'] }
|
|
22
|
+
*/
|
|
25
23
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
isValid: errors.length === 0,
|
|
54
|
-
errors
|
|
55
|
-
};
|
|
24
|
+
const errors = [];
|
|
25
|
+
if (props.required && !(value === null || value === void 0 ? void 0 : value.trim())) {
|
|
26
|
+
errors.push(props.errorMessage || "此字段为必填项");
|
|
27
|
+
return {
|
|
28
|
+
isValid: false,
|
|
29
|
+
errors
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (!value) return {
|
|
33
|
+
isValid: true,
|
|
34
|
+
errors
|
|
35
|
+
};
|
|
36
|
+
if (props.minLength !== void 0 && value.length < props.minLength) errors.push(`最少需要 ${props.minLength} 个字符`);
|
|
37
|
+
if (props.maxLength !== void 0 && value.length > props.maxLength) errors.push(`最多允许 ${props.maxLength} 个字符`);
|
|
38
|
+
if (props.pattern) {
|
|
39
|
+
if (!(typeof props.pattern === "string" ? new RegExp(props.pattern) : props.pattern).test(value)) errors.push(props.errorMessage || "格式不正确");
|
|
40
|
+
}
|
|
41
|
+
if (props.validator) {
|
|
42
|
+
const result = props.validator(value);
|
|
43
|
+
if (result !== true) errors.push(typeof result === "string" ? result : "校验失败");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
isValid: errors.length === 0,
|
|
47
|
+
errors
|
|
48
|
+
};
|
|
56
49
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
validateValue
|
|
60
|
-
});
|
|
50
|
+
//#endregion
|
|
51
|
+
exports.validateValue = validateValue;
|
package/lib/typeUtils.d.ts
CHANGED
|
@@ -1,42 +1,45 @@
|
|
|
1
|
+
//#region src/typeUtils.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* 判断是否是函数
|
|
3
4
|
* @param obj
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
declare const isFunction: (obj: any) => obj is Function;
|
|
6
7
|
/**
|
|
7
8
|
* 判断是否是数组
|
|
8
9
|
* @param obj
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
declare const isArr: (obj: any) => obj is any[];
|
|
11
12
|
/**
|
|
12
13
|
* 判断是否是字符串
|
|
13
14
|
* @param obj
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
declare const isString: (obj: any) => obj is string;
|
|
16
17
|
/**
|
|
17
18
|
* 判断是否是数字
|
|
18
19
|
* @param obj
|
|
19
20
|
*/
|
|
20
|
-
|
|
21
|
+
declare const isNumber: (obj: any) => obj is number;
|
|
21
22
|
/**
|
|
22
23
|
* 判断是否是undefined
|
|
23
24
|
* @param obj
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
+
declare const isUndefined: (obj: any) => obj is undefined;
|
|
26
27
|
/**
|
|
27
28
|
* 判断是否是boolean
|
|
28
29
|
* @param obj
|
|
29
30
|
*/
|
|
30
|
-
|
|
31
|
+
declare const isBoolean: (obj: any) => obj is boolean;
|
|
31
32
|
/**
|
|
32
33
|
* 判断是否是json字符串
|
|
33
34
|
* @param v
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
+
declare const isJson: (v: any) => boolean;
|
|
36
37
|
/**
|
|
37
38
|
* @Title: 判断是否为对象
|
|
38
39
|
* @Describe:
|
|
39
40
|
* @Author: Wzw
|
|
40
41
|
* @param {any} obj
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
declare const isPlainObject: (obj: any) => boolean;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { isArr, isBoolean, isFunction, isJson, isNumber, isPlainObject, isString, isUndefined };
|
package/lib/typeUtils.js
CHANGED
|
@@ -1,75 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
//#region src/typeUtils.ts
|
|
2
|
+
/**
|
|
3
|
+
* 判断是否是函数
|
|
4
|
+
* @param obj
|
|
5
|
+
*/
|
|
6
|
+
const isFunction = (obj) => typeof obj === "function";
|
|
7
|
+
/**
|
|
8
|
+
* 判断是否是数组
|
|
9
|
+
* @param obj
|
|
10
|
+
*/
|
|
11
|
+
const isArr = (obj) => Array.isArray(obj);
|
|
12
|
+
/**
|
|
13
|
+
* 判断是否是字符串
|
|
14
|
+
* @param obj
|
|
15
|
+
*/
|
|
16
|
+
const isString = (obj) => typeof obj === "string";
|
|
17
|
+
/**
|
|
18
|
+
* 判断是否是数字
|
|
19
|
+
* @param obj
|
|
20
|
+
*/
|
|
21
|
+
const isNumber = (obj) => typeof obj === "number";
|
|
22
|
+
/**
|
|
23
|
+
* 判断是否是undefined
|
|
24
|
+
* @param obj
|
|
25
|
+
*/
|
|
26
|
+
const isUndefined = (obj) => typeof obj === "undefined";
|
|
27
|
+
/**
|
|
28
|
+
* 判断是否是boolean
|
|
29
|
+
* @param obj
|
|
30
|
+
*/
|
|
31
|
+
const isBoolean = (obj) => typeof obj === "boolean";
|
|
32
|
+
/**
|
|
33
|
+
* 判断是否是json字符串
|
|
34
|
+
* @param v
|
|
35
|
+
*/
|
|
36
|
+
const isJson = (v) => {
|
|
37
|
+
if (typeof v === "string") try {
|
|
38
|
+
return JSON.parse(v);
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
else return false;
|
|
8
43
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
44
|
+
const getProto = Object.getPrototypeOf;
|
|
45
|
+
const hasOwn = {}.hasOwnProperty;
|
|
46
|
+
const fnToString = hasOwn.toString;
|
|
47
|
+
const ObjectFunctionString = fnToString.call(Object);
|
|
48
|
+
/**
|
|
49
|
+
* @Title: 判断是否为对象
|
|
50
|
+
* @Describe:
|
|
51
|
+
* @Author: Wzw
|
|
52
|
+
* @param {any} obj
|
|
53
|
+
*/
|
|
54
|
+
const isPlainObject = (obj) => {
|
|
55
|
+
var proto, Ctor;
|
|
56
|
+
if (!obj || toString.call(obj) !== "[object Object]") return false;
|
|
57
|
+
proto = getProto(obj);
|
|
58
|
+
if (!proto) return true;
|
|
59
|
+
Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
|
|
60
|
+
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
|
|
16
61
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
isNumber: () => isNumber,
|
|
27
|
-
isPlainObject: () => isPlainObject,
|
|
28
|
-
isString: () => isString,
|
|
29
|
-
isUndefined: () => isUndefined
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(typeUtils_exports);
|
|
32
|
-
var isFunction = (obj) => typeof obj === "function";
|
|
33
|
-
var isArr = (obj) => Array.isArray(obj);
|
|
34
|
-
var isString = (obj) => typeof obj === "string";
|
|
35
|
-
var isNumber = (obj) => typeof obj === "number";
|
|
36
|
-
var isUndefined = (obj) => typeof obj === "undefined";
|
|
37
|
-
var isBoolean = (obj) => typeof obj === "boolean";
|
|
38
|
-
var isJson = (v) => {
|
|
39
|
-
if (typeof v === "string") {
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(v);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var getProto = Object.getPrototypeOf;
|
|
50
|
-
var hasOwn = {}.hasOwnProperty;
|
|
51
|
-
var fnToString = hasOwn.toString;
|
|
52
|
-
var ObjectFunctionString = fnToString.call(Object);
|
|
53
|
-
var isPlainObject = (obj) => {
|
|
54
|
-
var proto, Ctor;
|
|
55
|
-
if (!obj || toString.call(obj) !== "[object Object]") {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
proto = getProto(obj);
|
|
59
|
-
if (!proto) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
|
|
63
|
-
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
|
|
64
|
-
};
|
|
65
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
-
0 && (module.exports = {
|
|
67
|
-
isArr,
|
|
68
|
-
isBoolean,
|
|
69
|
-
isFunction,
|
|
70
|
-
isJson,
|
|
71
|
-
isNumber,
|
|
72
|
-
isPlainObject,
|
|
73
|
-
isString,
|
|
74
|
-
isUndefined
|
|
75
|
-
});
|
|
62
|
+
//#endregion
|
|
63
|
+
exports.isArr = isArr;
|
|
64
|
+
exports.isBoolean = isBoolean;
|
|
65
|
+
exports.isFunction = isFunction;
|
|
66
|
+
exports.isJson = isJson;
|
|
67
|
+
exports.isNumber = isNumber;
|
|
68
|
+
exports.isPlainObject = isPlainObject;
|
|
69
|
+
exports.isString = isString;
|
|
70
|
+
exports.isUndefined = isUndefined;
|
package/lib/walletValidity.d.ts
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/walletValidity.d.ts
|
|
2
|
+
type Locale = 'en' | 'zh-CN' | 'zh-HK';
|
|
2
3
|
interface ScheduleItem {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
id: number;
|
|
5
|
+
name: string | {
|
|
6
|
+
[key: string]: string;
|
|
7
|
+
};
|
|
8
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
9
|
+
start_time: string | null;
|
|
10
|
+
end_time: string | null;
|
|
11
|
+
repeat_type: 'none' | 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
12
|
+
repeat_rule: {
|
|
13
|
+
end: {
|
|
14
|
+
type: 'never' | 'date' | 'occurrence';
|
|
15
|
+
end_date: string | null;
|
|
16
|
+
occurrence: number | null;
|
|
6
17
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
repeat_rule: {
|
|
12
|
-
end: {
|
|
13
|
-
type: 'never' | 'date' | 'occurrence';
|
|
14
|
-
end_date: string | null;
|
|
15
|
-
occurrence: number | null;
|
|
16
|
-
};
|
|
17
|
-
frequency: number;
|
|
18
|
-
excluded_date: Array<{
|
|
19
|
-
start: string;
|
|
20
|
-
end: string;
|
|
21
|
-
}>;
|
|
22
|
-
included_date: any[];
|
|
23
|
-
frequency_date: number[];
|
|
24
|
-
} | null;
|
|
25
|
-
designation: Array<{
|
|
26
|
-
start_date: string;
|
|
27
|
-
start_time: string;
|
|
28
|
-
end_date: string;
|
|
29
|
-
end_time: string;
|
|
30
|
-
}> | null;
|
|
31
|
-
is_all: number;
|
|
32
|
-
time_slot: Array<{
|
|
33
|
-
start_time: string;
|
|
34
|
-
end_time: string;
|
|
18
|
+
frequency: number;
|
|
19
|
+
excluded_date: Array<{
|
|
20
|
+
start: string;
|
|
21
|
+
end: string;
|
|
35
22
|
}>;
|
|
23
|
+
included_date: any[];
|
|
24
|
+
frequency_date: number[];
|
|
25
|
+
} | null;
|
|
26
|
+
designation: Array<{
|
|
27
|
+
start_date: string;
|
|
28
|
+
start_time: string;
|
|
29
|
+
end_date: string;
|
|
30
|
+
end_time: string;
|
|
31
|
+
}> | null;
|
|
32
|
+
is_all: number;
|
|
33
|
+
time_slot: Array<{
|
|
34
|
+
start_time: string;
|
|
35
|
+
end_time: string;
|
|
36
|
+
}>;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* 获取schedule摘要信息
|
|
@@ -40,5 +41,6 @@ interface ScheduleItem {
|
|
|
40
41
|
* @param locale 语言设置
|
|
41
42
|
* @returns 摘要文本
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
declare function getScheduleSummary(scheduleList: ScheduleItem[], locale?: Locale): string;
|
|
45
|
+
//#endregion
|
|
46
|
+
export { Locale, getScheduleSummary };
|