@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
package/es/text-input/types.d.ts
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 文本输入组件公共类型定义
|
|
3
|
+
* 供 PisellSingleLineText、PisellLongText、PisellPhone、PisellEmail、PisellUrl 等组件使用
|
|
4
|
+
*/
|
|
5
|
+
export type { DisplayState, ValidationResult } from '../common';
|
|
4
6
|
/**
|
|
5
7
|
* 文本输入状态 Hook 返回值
|
|
6
8
|
*/
|
|
7
|
-
interface TextInputState {
|
|
8
|
-
|
|
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
|
-
|
|
9
|
+
export interface TextInputState {
|
|
10
|
+
/**
|
|
11
|
+
* 当前值
|
|
12
|
+
*/
|
|
13
|
+
value: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* 是否已被触摸(交互过)
|
|
16
|
+
*/
|
|
17
|
+
isTouched: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 是否校验通过
|
|
20
|
+
*/
|
|
21
|
+
isValid: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 错误信息数组
|
|
24
|
+
*/
|
|
25
|
+
errors: string[];
|
|
26
|
+
/**
|
|
27
|
+
* 值变更处理函数
|
|
28
|
+
*/
|
|
29
|
+
handleChange: (value: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* 失焦处理函数
|
|
32
|
+
*/
|
|
33
|
+
handleBlur: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* 聚焦处理函数
|
|
36
|
+
*/
|
|
37
|
+
handleFocus: () => void;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* 基础文本输入 Props(供校验和状态管理使用)
|
|
39
41
|
*/
|
|
40
|
-
interface BaseTextInputProps {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
export interface BaseTextInputProps {
|
|
43
|
+
value?: string;
|
|
44
|
+
defaultValue?: string;
|
|
45
|
+
required?: boolean;
|
|
46
|
+
minLength?: number;
|
|
47
|
+
maxLength?: number;
|
|
48
|
+
pattern?: string | RegExp;
|
|
49
|
+
validator?: (value: string) => boolean | string;
|
|
50
|
+
validateTrigger?: 'onChange' | 'onBlur' | 'both';
|
|
51
|
+
errorMessage?: string;
|
|
52
|
+
onChange?: (value: string) => void;
|
|
53
|
+
onBlur?: (value: string) => void;
|
|
54
|
+
onFocus?: () => void;
|
|
55
|
+
onValidate?: (isValid: boolean, errors: string[]) => void;
|
|
54
56
|
}
|
|
55
|
-
//#endregion
|
|
56
|
-
export { BaseTextInputProps, TextInputState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { ValidationResult } from
|
|
2
|
-
import { BaseTextInputProps } from "../types.js";
|
|
3
|
-
|
|
4
|
-
//#region src/text-input/utils/validation.d.ts
|
|
1
|
+
import type { BaseTextInputProps, ValidationResult } from '../types';
|
|
5
2
|
/**
|
|
6
3
|
* 校验文本输入值
|
|
7
4
|
*
|
|
@@ -23,6 +20,4 @@ import { BaseTextInputProps } from "../types.js";
|
|
|
23
20
|
* validateValue('', { required: true })
|
|
24
21
|
* // { isValid: false, errors: ['此字段为必填项'] }
|
|
25
22
|
*/
|
|
26
|
-
declare function validateValue(value: string, props: BaseTextInputProps): ValidationResult;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { validateValue };
|
|
23
|
+
export declare function validateValue(value: string, props: BaseTextInputProps): ValidationResult;
|
|
@@ -1,51 +1,71 @@
|
|
|
1
|
-
//#region src/text-input/utils/validation.ts
|
|
2
1
|
/**
|
|
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
|
-
*/
|
|
23
|
-
function validateValue(value, props) {
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
2
|
+
* 校验文本输入值
|
|
3
|
+
*
|
|
4
|
+
* 按照优先级执行校验规则:
|
|
5
|
+
* 1. 必填校验(required)
|
|
6
|
+
* 2. 最小长度校验(minLength)
|
|
7
|
+
* 3. 最大长度校验(maxLength)
|
|
8
|
+
* 4. 正则校验(pattern)
|
|
9
|
+
* 5. 自定义校验函数(validator)
|
|
10
|
+
*
|
|
11
|
+
* @param value 待校验的值
|
|
12
|
+
* @param props 校验配置
|
|
13
|
+
* @returns 校验结果对象,包含 isValid 和 errors
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* validateValue('hello', { required: true, minLength: 3 })
|
|
17
|
+
* // { isValid: true, errors: [] }
|
|
18
|
+
*
|
|
19
|
+
* validateValue('', { required: true })
|
|
20
|
+
* // { isValid: false, errors: ['此字段为必填项'] }
|
|
21
|
+
*/
|
|
22
|
+
export function validateValue(value, props) {
|
|
23
|
+
var errors = [];
|
|
24
|
+
|
|
25
|
+
// 1. 必填校验
|
|
26
|
+
if (props.required && !(value !== null && value !== void 0 && value.trim())) {
|
|
27
|
+
errors.push(props.errorMessage || '此字段为必填项');
|
|
28
|
+
return {
|
|
29
|
+
isValid: false,
|
|
30
|
+
errors: errors
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 如果值为空且非必填,直接返回有效
|
|
35
|
+
if (!value) {
|
|
36
|
+
return {
|
|
37
|
+
isValid: true,
|
|
38
|
+
errors: errors
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// 2. 最小长度校验
|
|
43
|
+
if (props.minLength !== undefined && value.length < props.minLength) {
|
|
44
|
+
errors.push("\u6700\u5C11\u9700\u8981 ".concat(props.minLength, " \u4E2A\u5B57\u7B26"));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 3. 最大长度校验(通常在输入时已被 Input 组件限制,这里是兜底校验)
|
|
48
|
+
if (props.maxLength !== undefined && value.length > props.maxLength) {
|
|
49
|
+
errors.push("\u6700\u591A\u5141\u8BB8 ".concat(props.maxLength, " \u4E2A\u5B57\u7B26"));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 4. 正则校验
|
|
53
|
+
if (props.pattern) {
|
|
54
|
+
var regex = typeof props.pattern === 'string' ? new RegExp(props.pattern) : props.pattern;
|
|
55
|
+
if (!regex.test(value)) {
|
|
56
|
+
errors.push(props.errorMessage || '格式不正确');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 5. 自定义校验函数
|
|
61
|
+
if (props.validator) {
|
|
62
|
+
var result = props.validator(value);
|
|
63
|
+
if (result !== true) {
|
|
64
|
+
errors.push(typeof result === 'string' ? result : '校验失败');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
isValid: errors.length === 0,
|
|
69
|
+
errors: errors
|
|
70
|
+
};
|
|
71
|
+
}
|
package/es/typeUtils.js
CHANGED
|
@@ -1,63 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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;
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否是函数
|
|
3
|
+
* @param obj
|
|
4
|
+
*/
|
|
5
|
+
export var isFunction = function isFunction(obj) {
|
|
6
|
+
return typeof obj === 'function';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 判断是否是数组
|
|
11
|
+
* @param obj
|
|
12
|
+
*/
|
|
13
|
+
export var isArr = function isArr(obj) {
|
|
14
|
+
return Array.isArray(obj);
|
|
43
15
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 判断是否是字符串
|
|
19
|
+
* @param obj
|
|
20
|
+
*/
|
|
21
|
+
export var isString = function isString(obj) {
|
|
22
|
+
return typeof obj === 'string';
|
|
61
23
|
};
|
|
62
|
-
|
|
63
|
-
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 判断是否是数字
|
|
27
|
+
* @param obj
|
|
28
|
+
*/
|
|
29
|
+
export var isNumber = function isNumber(obj) {
|
|
30
|
+
return typeof obj === 'number';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 判断是否是undefined
|
|
35
|
+
* @param obj
|
|
36
|
+
*/
|
|
37
|
+
export var isUndefined = function isUndefined(obj) {
|
|
38
|
+
return typeof obj === 'undefined';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 判断是否是boolean
|
|
43
|
+
* @param obj
|
|
44
|
+
*/
|
|
45
|
+
export var isBoolean = function isBoolean(obj) {
|
|
46
|
+
return typeof obj === 'boolean';
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 判断是否是json字符串
|
|
51
|
+
* @param v
|
|
52
|
+
*/
|
|
53
|
+
export var isJson = function isJson(v) {
|
|
54
|
+
if (typeof v === 'string') {
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(v);
|
|
57
|
+
} catch (e) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var getProto = Object.getPrototypeOf;
|
|
65
|
+
var hasOwn = {}.hasOwnProperty;
|
|
66
|
+
var fnToString = hasOwn.toString;
|
|
67
|
+
var ObjectFunctionString = fnToString.call(Object);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @Title: 判断是否为对象
|
|
71
|
+
* @Describe:
|
|
72
|
+
* @Author: Wzw
|
|
73
|
+
* @param {any} obj
|
|
74
|
+
*/
|
|
75
|
+
export var isPlainObject = function isPlainObject(obj) {
|
|
76
|
+
var proto, Ctor;
|
|
77
|
+
if (!obj || toString.call(obj) !== '[object Object]') {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
proto = getProto(obj);
|
|
81
|
+
if (!proto) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
Ctor = hasOwn.call(proto, 'constructor') && proto.constructor;
|
|
85
|
+
return typeof Ctor === 'function' && fnToString.call(Ctor) === ObjectFunctionString;
|
|
86
|
+
};
|
package/es/walletValidity.d.ts
CHANGED
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
type Locale = 'en' | 'zh-CN' | 'zh-HK';
|
|
1
|
+
export declare type Locale = 'en' | 'zh-CN' | 'zh-HK';
|
|
3
2
|
interface ScheduleItem {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
3
|
+
id: number;
|
|
4
|
+
name: string | {
|
|
5
|
+
[key: string]: string;
|
|
17
6
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
type: 'standard' | 'time-slots' | 'designation';
|
|
8
|
+
start_time: string | null;
|
|
9
|
+
end_time: string | null;
|
|
10
|
+
repeat_type: 'none' | 'daily' | 'weekly' | 'monthly' | 'yearly';
|
|
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;
|
|
22
35
|
}>;
|
|
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
|
-
}>;
|
|
37
36
|
}
|
|
38
|
-
interface WalletPassValidity {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
export interface WalletPassValidity {
|
|
38
|
+
start_date?: string | null;
|
|
39
|
+
expire_date?: string | null;
|
|
40
|
+
expire_time?: string | null;
|
|
42
41
|
}
|
|
43
42
|
/** 仅计算展示日期的交集,不修改日程的重复起点或每日使用时段。 */
|
|
44
|
-
declare function getWalletValidityRange(start?: string | null, end?: string | null, validity?: WalletPassValidity): {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
export declare function getWalletValidityRange(start?: string | null, end?: string | null, validity?: WalletPassValidity): {
|
|
44
|
+
startDate: string | null;
|
|
45
|
+
endDate: string | null;
|
|
46
|
+
isEmpty: boolean;
|
|
48
47
|
};
|
|
49
48
|
/**
|
|
50
49
|
* 获取schedule摘要信息
|
|
@@ -52,6 +51,5 @@ declare function getWalletValidityRange(start?: string | null, end?: string | nu
|
|
|
52
51
|
* @param locale 语言设置
|
|
53
52
|
* @returns 摘要文本
|
|
54
53
|
*/
|
|
55
|
-
declare function getScheduleSummary(scheduleList: ScheduleItem[], locale?: Locale, validity?: WalletPassValidity): string;
|
|
56
|
-
|
|
57
|
-
export { Locale, WalletPassValidity, getScheduleSummary, getWalletValidityRange };
|
|
54
|
+
export declare function getScheduleSummary(scheduleList: ScheduleItem[], locale?: Locale, validity?: WalletPassValidity): string;
|
|
55
|
+
export {};
|