@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,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,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/text-input/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
|
@@ -0,0 +1,32 @@
|
|
|
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/text-input/utils/index.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
getDisplayState: () => import_common.getDisplayState,
|
|
23
|
+
validateValue: () => import_validation.validateValue
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
var import_common = require("../../common");
|
|
27
|
+
var import_validation = require("./validation");
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
getDisplayState,
|
|
31
|
+
validateValue
|
|
32
|
+
});
|
|
@@ -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,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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/text-input/utils/validation.ts
|
|
20
|
+
var validation_exports = {};
|
|
21
|
+
__export(validation_exports, {
|
|
22
|
+
validateValue: () => validateValue
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(validation_exports);
|
|
23
25
|
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
|
-
|
|
26
|
+
const errors = [];
|
|
27
|
+
if (props.required && !(value == null ? void 0 : value.trim())) {
|
|
28
|
+
errors.push(props.errorMessage || "此字段为必填项");
|
|
29
|
+
return { isValid: false, errors };
|
|
30
|
+
}
|
|
31
|
+
if (!value) {
|
|
32
|
+
return { isValid: true, errors };
|
|
33
|
+
}
|
|
34
|
+
if (props.minLength !== void 0 && value.length < props.minLength) {
|
|
35
|
+
errors.push(`最少需要 ${props.minLength} 个字符`);
|
|
36
|
+
}
|
|
37
|
+
if (props.maxLength !== void 0 && value.length > props.maxLength) {
|
|
38
|
+
errors.push(`最多允许 ${props.maxLength} 个字符`);
|
|
39
|
+
}
|
|
40
|
+
if (props.pattern) {
|
|
41
|
+
const regex = typeof props.pattern === "string" ? new RegExp(props.pattern) : props.pattern;
|
|
42
|
+
if (!regex.test(value)) {
|
|
43
|
+
errors.push(props.errorMessage || "格式不正确");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (props.validator) {
|
|
47
|
+
const result = props.validator(value);
|
|
48
|
+
if (result !== true) {
|
|
49
|
+
errors.push(typeof result === "string" ? result : "校验失败");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
isValid: errors.length === 0,
|
|
54
|
+
errors
|
|
55
|
+
};
|
|
49
56
|
}
|
|
50
|
-
|
|
51
|
-
exports
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
validateValue
|
|
60
|
+
});
|
package/lib/typeUtils.js
CHANGED
|
@@ -1,70 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
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 });
|
|
43
8
|
};
|
|
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;
|
|
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;
|
|
61
16
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/typeUtils.ts
|
|
20
|
+
var typeUtils_exports = {};
|
|
21
|
+
__export(typeUtils_exports, {
|
|
22
|
+
isArr: () => isArr,
|
|
23
|
+
isBoolean: () => isBoolean,
|
|
24
|
+
isFunction: () => isFunction,
|
|
25
|
+
isJson: () => isJson,
|
|
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
|
+
});
|
package/lib/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 {};
|