@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.
Files changed (200) hide show
  1. package/es/arrayUtils.d.ts +23 -26
  2. package/es/arrayUtils.js +157 -97
  3. package/es/common/index.d.ts +5 -0
  4. package/es/common/index.js +5 -0
  5. package/es/common/stateHelper.d.ts +2 -6
  6. package/es/common/stateHelper.js +24 -22
  7. package/es/common/types.d.ts +10 -13
  8. package/es/common/types.js +1 -0
  9. package/es/componentStorage.d.ts +25 -27
  10. package/es/componentStorage.js +130 -94
  11. package/es/constants/index.js +9 -7
  12. package/es/date.js +53 -36
  13. package/es/document.js +67 -43
  14. package/es/escPosPrinter/EscPosPrinter.js +490 -353
  15. package/es/escPosPrinter/index.d.ts +9 -9
  16. package/es/escPosPrinter/index.js +52 -37
  17. package/es/firebase/config/index.js +54 -0
  18. package/es/firebase/index.js +232 -0
  19. package/es/format.d.ts +15 -12
  20. package/es/format.js +156 -89
  21. package/es/image.js +60 -48
  22. package/es/index.d.ts +24 -39
  23. package/es/index.js +35 -40
  24. package/es/jsBridge/index.d.ts +4 -8
  25. package/es/jsBridge/index.js +55 -56
  26. package/es/jsBridge/regDeviceApi.js +126 -87
  27. package/es/jsBridge/types.d.ts +115 -95
  28. package/es/jsBridge/types.js +1 -0
  29. package/es/locales.d.ts +8 -11
  30. package/es/locales.js +96 -77
  31. package/es/log.d.ts +6 -11
  32. package/es/log.js +59 -37
  33. package/es/miniRedux.d.ts +13 -20
  34. package/es/miniRedux.js +76 -42
  35. package/es/number-input/hooks/index.d.ts +4 -0
  36. package/es/number-input/hooks/index.js +5 -0
  37. package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
  38. package/es/number-input/hooks/useNumberInputState.js +128 -71
  39. package/es/number-input/index.d.ts +14 -0
  40. package/es/number-input/index.js +21 -0
  41. package/es/number-input/types.d.ts +88 -88
  42. package/es/number-input/types.js +1 -0
  43. package/es/number-input/utils/formatter.d.ts +10 -13
  44. package/es/number-input/utils/formatter.js +77 -51
  45. package/es/number-input/utils/index.d.ts +7 -0
  46. package/es/number-input/utils/index.js +8 -0
  47. package/es/number-input/utils/validation.d.ts +2 -7
  48. package/es/number-input/utils/validation.js +66 -51
  49. package/es/otherUtils.d.ts +9 -12
  50. package/es/otherUtils.js +129 -71
  51. package/es/platform.d.ts +9 -12
  52. package/es/platform.js +85 -61
  53. package/es/select/hooks/index.d.ts +5 -0
  54. package/es/select/hooks/index.js +6 -0
  55. package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
  56. package/es/select/hooks/useDebouncedSearch.js +53 -39
  57. package/es/select/hooks/useSelectState.d.ts +7 -7
  58. package/es/select/hooks/useSelectState.js +113 -56
  59. package/es/select/index.d.ts +8 -7
  60. package/es/select/index.js +13 -0
  61. package/es/select/types.d.ts +211 -211
  62. package/es/select/types.js +1 -0
  63. package/es/select/utils/filterOptions.d.ts +6 -7
  64. package/es/select/utils/filterOptions.js +31 -26
  65. package/es/select/utils/helpers.d.ts +9 -10
  66. package/es/select/utils/helpers.js +52 -42
  67. package/es/select/utils/index.d.ts +7 -4
  68. package/es/select/utils/index.js +8 -0
  69. package/es/select/utils/sortOptions.d.ts +5 -6
  70. package/es/select/utils/sortOptions.js +31 -19
  71. package/es/select/utils/tagAggregation.d.ts +6 -6
  72. package/es/select/utils/tagAggregation.js +47 -34
  73. package/es/text-input/hooks/index.d.ts +4 -0
  74. package/es/text-input/hooks/index.js +5 -0
  75. package/es/text-input/hooks/useTextInputState.d.ts +2 -6
  76. package/es/text-input/hooks/useTextInputState.js +126 -69
  77. package/es/text-input/index.d.ts +14 -0
  78. package/es/text-input/index.js +20 -0
  79. package/es/text-input/types.d.ts +48 -48
  80. package/es/text-input/types.js +1 -0
  81. package/es/text-input/utils/index.d.ts +5 -0
  82. package/es/text-input/utils/index.js +7 -0
  83. package/es/text-input/utils/validation.d.ts +2 -7
  84. package/es/text-input/utils/validation.js +70 -50
  85. package/es/typeUtils.js +84 -61
  86. package/es/walletValidity.d.ts +42 -44
  87. package/es/walletValidity.js +557 -396
  88. package/es/weighing.d.ts +45 -48
  89. package/es/weighing.js +106 -83
  90. package/lib/arrayUtils.d.ts +23 -26
  91. package/lib/arrayUtils.js +111 -101
  92. package/lib/common/index.d.ts +5 -0
  93. package/lib/common/index.js +29 -0
  94. package/lib/common/stateHelper.d.ts +2 -6
  95. package/lib/common/stateHelper.js +32 -21
  96. package/lib/common/types.d.ts +10 -13
  97. package/lib/common/types.js +17 -0
  98. package/lib/componentStorage.d.ts +25 -27
  99. package/lib/componentStorage.js +126 -96
  100. package/lib/constants/index.js +36 -7
  101. package/lib/date.js +65 -43
  102. package/lib/document.js +62 -46
  103. package/lib/escPosPrinter/EscPosPrinter.js +403 -327
  104. package/lib/escPosPrinter/index.d.ts +9 -9
  105. package/lib/escPosPrinter/index.js +84 -38
  106. package/lib/firebase/config/index.js +79 -0
  107. package/lib/firebase/index.js +180 -0
  108. package/lib/format.d.ts +15 -12
  109. package/lib/format.js +133 -91
  110. package/lib/image.js +74 -48
  111. package/lib/index.d.ts +24 -39
  112. package/lib/index.js +80 -137
  113. package/lib/jsBridge/index.d.ts +4 -8
  114. package/lib/jsBridge/index.js +76 -57
  115. package/lib/jsBridge/regDeviceApi.js +133 -86
  116. package/lib/jsBridge/types.d.ts +115 -95
  117. package/lib/jsBridge/types.js +17 -0
  118. package/lib/locales.d.ts +8 -11
  119. package/lib/locales.js +90 -79
  120. package/lib/log.d.ts +6 -11
  121. package/lib/log.js +61 -37
  122. package/lib/miniRedux.d.ts +13 -20
  123. package/lib/miniRedux.js +89 -43
  124. package/lib/number-input/hooks/index.d.ts +4 -0
  125. package/lib/number-input/hooks/index.js +29 -0
  126. package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
  127. package/lib/number-input/hooks/useNumberInputState.js +81 -71
  128. package/lib/number-input/index.d.ts +14 -0
  129. package/lib/number-input/index.js +41 -0
  130. package/lib/number-input/types.d.ts +88 -88
  131. package/lib/number-input/types.js +17 -0
  132. package/lib/number-input/utils/formatter.d.ts +10 -13
  133. package/lib/number-input/utils/formatter.js +49 -52
  134. package/lib/number-input/utils/index.d.ts +7 -0
  135. package/lib/number-input/utils/index.js +39 -0
  136. package/lib/number-input/utils/validation.d.ts +2 -7
  137. package/lib/number-input/utils/validation.js +52 -50
  138. package/lib/otherUtils.d.ts +9 -12
  139. package/lib/otherUtils.js +98 -86
  140. package/lib/platform.d.ts +9 -12
  141. package/lib/platform.js +123 -68
  142. package/lib/select/hooks/index.d.ts +5 -0
  143. package/lib/select/hooks/index.js +34 -0
  144. package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
  145. package/lib/select/hooks/useDebouncedSearch.js +41 -40
  146. package/lib/select/hooks/useSelectState.d.ts +7 -7
  147. package/lib/select/hooks/useSelectState.js +93 -58
  148. package/lib/select/index.d.ts +8 -7
  149. package/lib/select/index.js +53 -0
  150. package/lib/select/types.d.ts +211 -211
  151. package/lib/select/types.js +17 -0
  152. package/lib/select/utils/filterOptions.d.ts +6 -7
  153. package/lib/select/utils/filterOptions.js +37 -26
  154. package/lib/select/utils/helpers.d.ts +9 -10
  155. package/lib/select/utils/helpers.js +41 -45
  156. package/lib/select/utils/index.d.ts +7 -4
  157. package/lib/select/utils/index.js +48 -0
  158. package/lib/select/utils/sortOptions.d.ts +5 -6
  159. package/lib/select/utils/sortOptions.js +39 -18
  160. package/lib/select/utils/tagAggregation.d.ts +6 -6
  161. package/lib/select/utils/tagAggregation.js +41 -33
  162. package/lib/text-input/hooks/index.d.ts +4 -0
  163. package/lib/text-input/hooks/index.js +29 -0
  164. package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
  165. package/lib/text-input/hooks/useTextInputState.js +79 -69
  166. package/lib/text-input/index.d.ts +14 -0
  167. package/lib/text-input/index.js +35 -0
  168. package/lib/text-input/types.d.ts +48 -48
  169. package/lib/text-input/types.js +17 -0
  170. package/lib/text-input/utils/index.d.ts +5 -0
  171. package/lib/text-input/utils/index.js +32 -0
  172. package/lib/text-input/utils/validation.d.ts +2 -7
  173. package/lib/text-input/utils/validation.js +58 -49
  174. package/lib/typeUtils.js +73 -68
  175. package/lib/walletValidity.d.ts +42 -44
  176. package/lib/walletValidity.js +393 -410
  177. package/lib/weighing.d.ts +45 -48
  178. package/lib/weighing.js +149 -104
  179. package/package.json +1 -1
  180. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  181. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  182. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  183. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  184. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  185. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
  186. package/es/date.d.ts +0 -31
  187. package/es/document.d.ts +0 -16
  188. package/es/image.d.ts +0 -14
  189. package/es/typeUtils.d.ts +0 -45
  190. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  191. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  192. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  193. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  194. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  195. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
  196. package/lib/_virtual/_rolldown/runtime.js +0 -23
  197. package/lib/date.d.ts +0 -31
  198. package/lib/document.d.ts +0 -16
  199. package/lib/image.d.ts +0 -14
  200. package/lib/typeUtils.d.ts +0 -45
@@ -1,56 +1,56 @@
1
- import { DisplayState, ValidationResult } from "../common/types.js";
2
-
3
- //#region src/text-input/types.d.ts
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
- 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;
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
- 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;
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 {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 文本输入工具函数导出
3
+ */
4
+ export { getDisplayState } from '../../common';
5
+ export { validateValue } from './validation';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 文本输入工具函数导出
3
+ */
4
+
5
+ // getDisplayState 已移到公共模块,从 common 重新导出
6
+ export { getDisplayState } from "../../common";
7
+ export { validateValue } from "./validation";
@@ -1,7 +1,4 @@
1
- import { ValidationResult } from "../../common/types.js";
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
- 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
- };
49
- }
50
- //#endregion
51
- export { validateValue };
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
- //#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;
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
- 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
+
17
+ /**
18
+ * 判断是否是字符串
19
+ * @param obj
20
+ */
21
+ export var isString = function isString(obj) {
22
+ return typeof obj === 'string';
61
23
  };
62
- //#endregion
63
- export { isArr, isBoolean, isFunction, isJson, isNumber, isPlainObject, isString, isUndefined };
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
+ };
@@ -1,50 +1,49 @@
1
- //#region src/walletValidity.d.ts
2
- type Locale = 'en' | 'zh-CN' | 'zh-HK';
1
+ export declare type Locale = 'en' | 'zh-CN' | 'zh-HK';
3
2
  interface ScheduleItem {
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;
3
+ id: number;
4
+ name: string | {
5
+ [key: string]: string;
17
6
  };
18
- frequency: number;
19
- excluded_date: Array<{
20
- start: string;
21
- end: string;
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
- start_date?: string | null;
40
- expire_date?: string | null;
41
- expire_time?: string | null;
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
- startDate: string | null;
46
- endDate: string | null;
47
- isEmpty: boolean;
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
- //#endregion
57
- export { Locale, WalletPassValidity, getScheduleSummary, getWalletValidityRange };
54
+ export declare function getScheduleSummary(scheduleList: ScheduleItem[], locale?: Locale, validity?: WalletPassValidity): string;
55
+ export {};