@pisell/utils 1.0.70 → 1.0.72

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 (129) hide show
  1. package/README.md +2 -2
  2. package/es/arrayUtils.d.ts +1 -1
  3. package/es/common/index.d.ts +5 -5
  4. package/es/common/index.js +2 -2
  5. package/es/common/stateHelper.d.ts +18 -18
  6. package/es/common/stateHelper.js +15 -15
  7. package/es/common/types.d.ts +28 -28
  8. package/es/componentStorage.d.ts +36 -36
  9. package/es/componentStorage.js +7 -7
  10. package/es/constants/index.d.ts +7 -7
  11. package/es/date.d.ts +28 -28
  12. package/es/date.js +22 -22
  13. package/es/document.d.ts +13 -13
  14. package/es/document.js +7 -7
  15. package/es/escPosPrinter/index.d.ts +9 -9
  16. package/es/firebase/config/index.d.ts +13 -13
  17. package/es/firebase/index.d.ts +28 -28
  18. package/es/format.js +14 -14
  19. package/es/image.d.ts +11 -11
  20. package/es/image.js +5 -5
  21. package/es/index.d.ts +25 -25
  22. package/es/jsBridge/index.js +15 -15
  23. package/es/jsBridge/regDeviceApi.d.ts +15 -15
  24. package/es/jsBridge/regDeviceApi.js +3 -3
  25. package/es/locales.js +15 -15
  26. package/es/log.d.ts +10 -10
  27. package/es/number-input/hooks/index.d.ts +4 -4
  28. package/es/number-input/hooks/index.js +2 -2
  29. package/es/number-input/hooks/useNumberInputState.d.ts +25 -25
  30. package/es/number-input/hooks/useNumberInputState.js +39 -39
  31. package/es/number-input/index.d.ts +14 -14
  32. package/es/number-input/index.js +8 -8
  33. package/es/number-input/types.d.ts +96 -96
  34. package/es/number-input/utils/formatter.d.ts +53 -53
  35. package/es/number-input/utils/formatter.js +37 -37
  36. package/es/number-input/utils/index.d.ts +7 -7
  37. package/es/number-input/utils/index.js +2 -2
  38. package/es/number-input/utils/validation.d.ts +27 -27
  39. package/es/number-input/utils/validation.js +24 -24
  40. package/es/otherUtils.d.ts +48 -48
  41. package/es/otherUtils.js +32 -32
  42. package/es/platform.d.ts +9 -9
  43. package/es/select/hooks/index.d.ts +5 -5
  44. package/es/select/hooks/index.js +2 -2
  45. package/es/select/hooks/useDebouncedSearch.d.ts +20 -20
  46. package/es/select/hooks/useDebouncedSearch.js +17 -17
  47. package/es/select/hooks/useSelectState.d.ts +19 -19
  48. package/es/select/hooks/useSelectState.js +13 -13
  49. package/es/select/index.d.ts +8 -8
  50. package/es/select/index.js +3 -3
  51. package/es/select/types.d.ts +256 -256
  52. package/es/select/utils/filterOptions.d.ts +22 -22
  53. package/es/select/utils/filterOptions.js +16 -16
  54. package/es/select/utils/helpers.d.ts +42 -42
  55. package/es/select/utils/helpers.js +30 -30
  56. package/es/select/utils/index.d.ts +7 -7
  57. package/es/select/utils/index.js +2 -2
  58. package/es/select/utils/sortOptions.d.ts +12 -12
  59. package/es/select/utils/sortOptions.js +8 -8
  60. package/es/select/utils/tagAggregation.d.ts +25 -25
  61. package/es/select/utils/tagAggregation.js +21 -21
  62. package/es/text-input/hooks/index.d.ts +4 -4
  63. package/es/text-input/hooks/index.js +2 -2
  64. package/es/text-input/hooks/useTextInputState.d.ts +24 -24
  65. package/es/text-input/hooks/useTextInputState.js +38 -38
  66. package/es/text-input/index.d.ts +14 -14
  67. package/es/text-input/index.js +9 -9
  68. package/es/text-input/types.d.ts +56 -56
  69. package/es/text-input/utils/index.d.ts +5 -5
  70. package/es/text-input/utils/index.js +2 -2
  71. package/es/text-input/utils/validation.d.ts +23 -23
  72. package/es/text-input/utils/validation.js +20 -20
  73. package/es/typeUtils.d.ts +42 -42
  74. package/es/typeUtils.js +26 -26
  75. package/es/walletValidity.d.ts +44 -44
  76. package/es/walletValidity.js +85 -85
  77. package/lib/arrayUtils.d.ts +1 -1
  78. package/lib/common/index.d.ts +5 -5
  79. package/lib/common/stateHelper.d.ts +18 -18
  80. package/lib/common/types.d.ts +28 -28
  81. package/lib/componentStorage.d.ts +36 -36
  82. package/lib/constants/index.d.ts +7 -7
  83. package/lib/date.d.ts +28 -28
  84. package/lib/document.d.ts +13 -13
  85. package/lib/escPosPrinter/index.d.ts +9 -9
  86. package/lib/firebase/config/index.d.ts +13 -13
  87. package/lib/firebase/index.d.ts +28 -28
  88. package/lib/image.d.ts +11 -11
  89. package/lib/index.d.ts +25 -25
  90. package/lib/jsBridge/regDeviceApi.d.ts +15 -15
  91. package/lib/log.d.ts +10 -10
  92. package/lib/number-input/hooks/index.d.ts +4 -4
  93. package/lib/number-input/hooks/useNumberInputState.d.ts +25 -25
  94. package/lib/number-input/index.d.ts +14 -14
  95. package/lib/number-input/types.d.ts +96 -96
  96. package/lib/number-input/utils/formatter.d.ts +53 -53
  97. package/lib/number-input/utils/index.d.ts +7 -7
  98. package/lib/number-input/utils/validation.d.ts +27 -27
  99. package/lib/otherUtils.d.ts +48 -48
  100. package/lib/platform.d.ts +9 -9
  101. package/lib/select/hooks/index.d.ts +5 -5
  102. package/lib/select/hooks/useDebouncedSearch.d.ts +20 -20
  103. package/lib/select/hooks/useSelectState.d.ts +19 -19
  104. package/lib/select/index.d.ts +8 -8
  105. package/lib/select/types.d.ts +256 -256
  106. package/lib/select/utils/filterOptions.d.ts +22 -22
  107. package/lib/select/utils/helpers.d.ts +42 -42
  108. package/lib/select/utils/index.d.ts +7 -7
  109. package/lib/select/utils/sortOptions.d.ts +12 -12
  110. package/lib/select/utils/tagAggregation.d.ts +25 -25
  111. package/lib/text-input/hooks/index.d.ts +4 -4
  112. package/lib/text-input/hooks/useTextInputState.d.ts +24 -24
  113. package/lib/text-input/index.d.ts +14 -14
  114. package/lib/text-input/types.d.ts +56 -56
  115. package/lib/text-input/utils/index.d.ts +5 -5
  116. package/lib/text-input/utils/validation.d.ts +23 -23
  117. package/lib/typeUtils.d.ts +42 -42
  118. package/lib/walletValidity.d.ts +44 -44
  119. package/package.json +1 -1
  120. package/es/format.d.ts +0 -28
  121. package/es/jsBridge/index.d.ts +0 -22
  122. package/es/jsBridge/types.d.ts +0 -149
  123. package/es/locales.d.ts +0 -9
  124. package/es/miniRedux.d.ts +0 -16
  125. package/lib/format.d.ts +0 -28
  126. package/lib/jsBridge/index.d.ts +0 -22
  127. package/lib/jsBridge/types.d.ts +0 -149
  128. package/lib/locales.d.ts +0 -9
  129. package/lib/miniRedux.d.ts +0 -16
package/es/image.js CHANGED
@@ -17,11 +17,11 @@ var ali = function ali(url, w) {
17
17
  return url;
18
18
  };
19
19
 
20
- /**
21
- * @Title: 获取图片尺寸
22
- * @Describe: 通过 __ 进行分割
23
- * @Author: Wzw
24
- * @param {string} url
20
+ /**
21
+ * @Title: 获取图片尺寸
22
+ * @Describe: 通过 __ 进行分割
23
+ * @Author: Wzw
24
+ * @param {string} url
25
25
  */
26
26
 
27
27
  var getImageSize = function getImageSize(url) {
package/es/index.d.ts CHANGED
@@ -1,25 +1,25 @@
1
- export * from './otherUtils';
2
- export * from './typeUtils';
3
- export * from './componentStorage';
4
- export * from './document';
5
- export * from './date';
6
- export * from './platform';
7
- export * from './log';
8
- export * from './format';
9
- export * from './escPosPrinter';
10
- export * from './miniRedux';
11
- export * from './jsBridge';
12
- export * from './image';
13
- export * from './locales';
14
- export * from './arrayUtils';
15
- export * from './walletValidity';
16
- export * from './common';
17
- export * from './text-input';
18
- export * from './number-input';
19
- export * from './select';
20
- export declare const setPisellUtilsConfig: (config: {
21
- [key: string]: any;
22
- }) => void;
23
- export declare const getPisellUtilsConfig: () => {
24
- [key: string]: any;
25
- };
1
+ export * from './otherUtils';
2
+ export * from './typeUtils';
3
+ export * from './componentStorage';
4
+ export * from './document';
5
+ export * from './date';
6
+ export * from './platform';
7
+ export * from './log';
8
+ export * from './format';
9
+ export * from './escPosPrinter';
10
+ export * from './miniRedux';
11
+ export * from './jsBridge';
12
+ export * from './image';
13
+ export * from './locales';
14
+ export * from './arrayUtils';
15
+ export * from './walletValidity';
16
+ export * from './common';
17
+ export * from './text-input';
18
+ export * from './number-input';
19
+ export * from './select';
20
+ export declare const setPisellUtilsConfig: (config: {
21
+ [key: string]: any;
22
+ }) => void;
23
+ export declare const getPisellUtilsConfig: () => {
24
+ [key: string]: any;
25
+ };
@@ -1,9 +1,9 @@
1
1
  import regDeviceApi from "./regDeviceApi";
2
- /**
3
- * webView页面中调用打印机打印
4
- * 此api暂时只支持native app平台下ios手机
5
- * @param params
6
- * @param callback
2
+ /**
3
+ * webView页面中调用打印机打印
4
+ * 此api暂时只支持native app平台下ios手机
5
+ * @param params
6
+ * @param callback
7
7
  */
8
8
  export function webPrint(params, _callback, onError) {
9
9
  regDeviceApi().then(function (jsBridge) {
@@ -20,11 +20,11 @@ export function webPrint(params, _callback, onError) {
20
20
  });
21
21
  }
22
22
 
23
- /**
24
- * webView页面中调用APP内的数据
25
- * 此api暂时只支持native app平台下ios手机
26
- * @param params
27
- * @param callback
23
+ /**
24
+ * webView页面中调用APP内的数据
25
+ * 此api暂时只支持native app平台下ios手机
26
+ * @param params
27
+ * @param callback
28
28
  */
29
29
  export function dataManager(params, _callback2, onError) {
30
30
  regDeviceApi().then(function (jsBridge) {
@@ -39,11 +39,11 @@ export function dataManager(params, _callback2, onError) {
39
39
  }).catch(onError);
40
40
  }
41
41
 
42
- /**
43
- * webView页面中调用APP内的支付
44
- * 此api暂时只支持native app平台下ios
45
- * @param params
46
- * @param callback
42
+ /**
43
+ * webView页面中调用APP内的支付
44
+ * 此api暂时只支持native app平台下ios
45
+ * @param params
46
+ * @param callback
47
47
  */
48
48
  export function webPayment(params, _callback3, onError) {
49
49
  regDeviceApi().then(function (jsBridge) {
@@ -1,15 +1,15 @@
1
- type ComposedJSBridge = {
2
- // eslint-disable-next-line camelcase
3
- callDeviceApi: (a: {
4
- apiName: string;
5
- callback: Functon;
6
- onError?: (e: any) => void;
7
- params?: any;
8
- key_events?: string[];
9
- }) => void;
10
- calledByDevice: (a: { apiName: string; callback: Functon }) => void;
11
- };
12
-
13
- const regDeviceApi: (isWebPrint?: boolean) => Promise<ComposedJSBridge>;
14
-
15
- export default regDeviceApi;
1
+ type ComposedJSBridge = {
2
+ // eslint-disable-next-line camelcase
3
+ callDeviceApi: (a: {
4
+ apiName: string;
5
+ callback: Functon;
6
+ onError?: (e: any) => void;
7
+ params?: any;
8
+ key_events?: string[];
9
+ }) => void;
10
+ calledByDevice: (a: { apiName: string; callback: Functon }) => void;
11
+ };
12
+
13
+ const regDeviceApi: (isWebPrint?: boolean) => Promise<ComposedJSBridge>;
14
+
15
+ export default regDeviceApi;
@@ -51,9 +51,9 @@ function checkApiName(apiNames, apiName) {
51
51
  return _apiNames.includes(apiName);
52
52
  }
53
53
 
54
- /**
55
- * 通用jsBridge
56
- * @param deviceType
54
+ /**
55
+ * 通用jsBridge
56
+ * @param deviceType
57
57
  */
58
58
  function getComposedBridge(deviceType) {
59
59
  if (composedBridge) {
package/es/locales.js CHANGED
@@ -52,14 +52,14 @@ var formatLocale = function formatLocale(_locale) {
52
52
  return 'en';
53
53
  };
54
54
 
55
- /**
56
- * @title: 初始化多语言
57
- * @description:
58
- * @param {any} _localeMaps
59
- * @param {string} _locale
60
- * @return {*}
61
- * @Author: zhiwei.Wang
62
- * @Date: 2024-01-17 21:38
55
+ /**
56
+ * @title: 初始化多语言
57
+ * @description:
58
+ * @param {any} _localeMaps
59
+ * @param {string} _locale
60
+ * @return {*}
61
+ * @Author: zhiwei.Wang
62
+ * @Date: 2024-01-17 21:38
63
63
  */
64
64
  var init = function init(_localeMaps, _locale) {
65
65
  // 设置语言
@@ -76,13 +76,13 @@ var init = function init(_localeMaps, _locale) {
76
76
  localeMap = localeMaps[locale];
77
77
  };
78
78
 
79
- /**
80
- * @title: 获取语言
81
- * @description:
82
- * @param {string} id
83
- * @return {*}
84
- * @Author: zhiwei.Wang
85
- * @Date: 2024-01-17 21:39
79
+ /**
80
+ * @title: 获取语言
81
+ * @description:
82
+ * @param {string} id
83
+ * @return {*}
84
+ * @Author: zhiwei.Wang
85
+ * @Date: 2024-01-17 21:39
86
86
  */
87
87
  var getText = function getText(id) {
88
88
  var _localeMaps2;
package/es/log.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- interface contentItem {
2
- key: string;
3
- value: string;
4
- }
5
- interface sendWebhookProps {
6
- title: string;
7
- content: contentItem[];
8
- }
9
- export declare const sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
10
- export {};
1
+ interface contentItem {
2
+ key: string;
3
+ value: string;
4
+ }
5
+ interface sendWebhookProps {
6
+ title: string;
7
+ content: contentItem[];
8
+ }
9
+ export declare const sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
10
+ export {};
@@ -1,4 +1,4 @@
1
- /**
2
- * 数值输入 Hooks 导出
3
- */
4
- export { useNumberInputState } from './useNumberInputState';
1
+ /**
2
+ * 数值输入 Hooks 导出
3
+ */
4
+ export { useNumberInputState } from './useNumberInputState';
@@ -1,5 +1,5 @@
1
- /**
2
- * 数值输入 Hooks 导出
1
+ /**
2
+ * 数值输入 Hooks 导出
3
3
  */
4
4
 
5
5
  export { useNumberInputState } from "./useNumberInputState";
@@ -1,25 +1,25 @@
1
- import type { BaseNumberInputProps, NumberInputState } from '../types';
2
- /**
3
- * 数值输入状态管理 Hook
4
- *
5
- * 管理组件的内部状态,包括:
6
- * - 值管理(受控/非受控模式)
7
- * - 校验状态管理
8
- * - 事件处理函数封装
9
- *
10
- * 支持受控和非受控两种模式:
11
- * - 受控模式:value 由外部传入,组件不维护内部状态
12
- * - 非受控模式:使用 defaultValue,组件维护内部状态
13
- *
14
- * @param props 组件 Props(包含校验配置)
15
- * @returns 数值输入状态对象
16
- *
17
- * @example
18
- * // 受控模式
19
- * const state = useNumberInputState({ value: 10, onChange: (v) => console.log(v) });
20
- *
21
- * @example
22
- * // 非受控模式
23
- * const state = useNumberInputState({ defaultValue: 10, min: 0, max: 100 });
24
- */
25
- export declare function useNumberInputState(props: BaseNumberInputProps): NumberInputState;
1
+ import type { BaseNumberInputProps, NumberInputState } from '../types';
2
+ /**
3
+ * 数值输入状态管理 Hook
4
+ *
5
+ * 管理组件的内部状态,包括:
6
+ * - 值管理(受控/非受控模式)
7
+ * - 校验状态管理
8
+ * - 事件处理函数封装
9
+ *
10
+ * 支持受控和非受控两种模式:
11
+ * - 受控模式:value 由外部传入,组件不维护内部状态
12
+ * - 非受控模式:使用 defaultValue,组件维护内部状态
13
+ *
14
+ * @param props 组件 Props(包含校验配置)
15
+ * @returns 数值输入状态对象
16
+ *
17
+ * @example
18
+ * // 受控模式
19
+ * const state = useNumberInputState({ value: 10, onChange: (v) => console.log(v) });
20
+ *
21
+ * @example
22
+ * // 非受控模式
23
+ * const state = useNumberInputState({ defaultValue: 10, min: 0, max: 100 });
24
+ */
25
+ export declare function useNumberInputState(props: BaseNumberInputProps): NumberInputState;
@@ -6,28 +6,28 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { useState, useCallback } from 'react';
8
8
  import { validateValue } from "../utils/validation";
9
- /**
10
- * 数值输入状态管理 Hook
11
- *
12
- * 管理组件的内部状态,包括:
13
- * - 值管理(受控/非受控模式)
14
- * - 校验状态管理
15
- * - 事件处理函数封装
16
- *
17
- * 支持受控和非受控两种模式:
18
- * - 受控模式:value 由外部传入,组件不维护内部状态
19
- * - 非受控模式:使用 defaultValue,组件维护内部状态
20
- *
21
- * @param props 组件 Props(包含校验配置)
22
- * @returns 数值输入状态对象
23
- *
24
- * @example
25
- * // 受控模式
26
- * const state = useNumberInputState({ value: 10, onChange: (v) => console.log(v) });
27
- *
28
- * @example
29
- * // 非受控模式
30
- * const state = useNumberInputState({ defaultValue: 10, min: 0, max: 100 });
9
+ /**
10
+ * 数值输入状态管理 Hook
11
+ *
12
+ * 管理组件的内部状态,包括:
13
+ * - 值管理(受控/非受控模式)
14
+ * - 校验状态管理
15
+ * - 事件处理函数封装
16
+ *
17
+ * 支持受控和非受控两种模式:
18
+ * - 受控模式:value 由外部传入,组件不维护内部状态
19
+ * - 非受控模式:使用 defaultValue,组件维护内部状态
20
+ *
21
+ * @param props 组件 Props(包含校验配置)
22
+ * @returns 数值输入状态对象
23
+ *
24
+ * @example
25
+ * // 受控模式
26
+ * const state = useNumberInputState({ value: 10, onChange: (v) => console.log(v) });
27
+ *
28
+ * @example
29
+ * // 非受控模式
30
+ * const state = useNumberInputState({ defaultValue: 10, min: 0, max: 100 });
31
31
  */
32
32
  export function useNumberInputState(props) {
33
33
  var _props$defaultValue;
@@ -55,12 +55,12 @@ export function useNumberInputState(props) {
55
55
  // 当前值(受控模式优先使用 props.value)
56
56
  var currentValue = isControlled ? props.value : innerValue;
57
57
 
58
- /**
59
- * 值变更处理函数
60
- *
61
- * 1. 更新内部状态(非受控模式)
62
- * 2. 根据 validateTrigger 决定是否立即校验
63
- * 3. 触发外部 onChange 回调
58
+ /**
59
+ * 值变更处理函数
60
+ *
61
+ * 1. 更新内部状态(非受控模式)
62
+ * 2. 根据 validateTrigger 决定是否立即校验
63
+ * 3. 触发外部 onChange 回调
64
64
  */
65
65
  var handleChange = useCallback(function (newValue) {
66
66
  var _props$onChange;
@@ -83,12 +83,12 @@ export function useNumberInputState(props) {
83
83
  (_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, newValue);
84
84
  }, [isControlled, props]);
85
85
 
86
- /**
87
- * 失焦处理函数
88
- *
89
- * 1. 标记为已触摸
90
- * 2. 执行失焦时的校验(根据 validateTrigger)
91
- * 3. 触发外部 onBlur 回调
86
+ /**
87
+ * 失焦处理函数
88
+ *
89
+ * 1. 标记为已触摸
90
+ * 2. 执行失焦时的校验(根据 validateTrigger)
91
+ * 3. 触发外部 onBlur 回调
92
92
  */
93
93
  var handleBlur = useCallback(function () {
94
94
  var _props$onBlur;
@@ -106,11 +106,11 @@ export function useNumberInputState(props) {
106
106
  (_props$onBlur = props.onBlur) === null || _props$onBlur === void 0 || _props$onBlur.call(props, currentValue !== null && currentValue !== void 0 ? currentValue : null);
107
107
  }, [currentValue, props]);
108
108
 
109
- /**
110
- * 聚焦处理函数
111
- *
112
- * 1. 标记为已触摸
113
- * 2. 触发外部 onFocus 回调
109
+ /**
110
+ * 聚焦处理函数
111
+ *
112
+ * 1. 标记为已触摸
113
+ * 2. 触发外部 onFocus 回调
114
114
  */
115
115
  var handleFocus = useCallback(function () {
116
116
  var _props$onFocus;
@@ -1,14 +1,14 @@
1
- /**
2
- * 数值输入组件公共逻辑导出
3
- *
4
- * 供以下组件使用:
5
- * - PisellNumber
6
- * - PisellCurrency
7
- * - PisellPercent
8
- * - 其他数值输入组件
9
- */
10
- export type { DisplayState, ValidationResult, NumberInputState, BaseNumberInputProps, } from './types';
11
- export { useNumberInputState } from './hooks';
12
- export { getDisplayState, formatNumber, addThousandsSeparator, formatPrecision, } from './utils';
13
- export { validateValue as validateNumberValue } from './utils';
14
- export type { NumberFormatOptions } from './utils';
1
+ /**
2
+ * 数值输入组件公共逻辑导出
3
+ *
4
+ * 供以下组件使用:
5
+ * - PisellNumber
6
+ * - PisellCurrency
7
+ * - PisellPercent
8
+ * - 其他数值输入组件
9
+ */
10
+ export type { DisplayState, ValidationResult, NumberInputState, BaseNumberInputProps, } from './types';
11
+ export { useNumberInputState } from './hooks';
12
+ export { getDisplayState, formatNumber, addThousandsSeparator, formatPrecision, } from './utils';
13
+ export { validateValue as validateNumberValue } from './utils';
14
+ export type { NumberFormatOptions } from './utils';
@@ -1,11 +1,11 @@
1
- /**
2
- * 数值输入组件公共逻辑导出
3
- *
4
- * 供以下组件使用:
5
- * - PisellNumber
6
- * - PisellCurrency
7
- * - PisellPercent
8
- * - 其他数值输入组件
1
+ /**
2
+ * 数值输入组件公共逻辑导出
3
+ *
4
+ * 供以下组件使用:
5
+ * - PisellNumber
6
+ * - PisellCurrency
7
+ * - PisellPercent
8
+ * - 其他数值输入组件
9
9
  */
10
10
 
11
11
  // 类型
@@ -1,96 +1,96 @@
1
- /**
2
- * 数值输入组件公共类型定义
3
- * 供 PisellNumber、PisellCurrency、PisellPercent 等组件使用
4
- */
5
- export type { DisplayState, ValidationResult } from '../common';
6
- /**
7
- * 数值输入状态 Hook 返回值
8
- */
9
- export interface NumberInputState {
10
- /**
11
- * 当前值
12
- */
13
- value: number | null | 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: number | null) => void;
30
- /**
31
- * 失焦处理函数
32
- */
33
- handleBlur: () => void;
34
- /**
35
- * 聚焦处理函数
36
- */
37
- handleFocus: () => void;
38
- }
39
- /**
40
- * 基础数值输入 Props(供校验和状态管理使用)
41
- */
42
- export interface BaseNumberInputProps {
43
- /**
44
- * 当前值(受控)
45
- */
46
- value?: number | null;
47
- /**
48
- * 默认值(非受控)
49
- */
50
- defaultValue?: number | null;
51
- /**
52
- * 是否必填
53
- */
54
- required?: boolean;
55
- /**
56
- * 最小值
57
- */
58
- min?: number;
59
- /**
60
- * 最大值
61
- */
62
- max?: number;
63
- /**
64
- * 自定义校验函数
65
- * @param value 当前值
66
- * @returns true 表示通过,false 或错误信息字符串表示不通过
67
- */
68
- validator?: (value: number | null) => boolean | string;
69
- /**
70
- * 校验触发时机
71
- * - onChange: 输入时即时校验
72
- * - onBlur: 失焦时校验
73
- * - both: 输入和失焦时都校验
74
- */
75
- validateTrigger?: 'onChange' | 'onBlur' | 'both';
76
- /**
77
- * 自定义错误提示信息
78
- */
79
- errorMessage?: string;
80
- /**
81
- * 值变更回调
82
- */
83
- onChange?: (value: number | null) => void;
84
- /**
85
- * 失焦回调
86
- */
87
- onBlur?: (value: number | null) => void;
88
- /**
89
- * 聚焦回调
90
- */
91
- onFocus?: () => void;
92
- /**
93
- * 校验回调
94
- */
95
- onValidate?: (isValid: boolean, errors: string[]) => void;
96
- }
1
+ /**
2
+ * 数值输入组件公共类型定义
3
+ * 供 PisellNumber、PisellCurrency、PisellPercent 等组件使用
4
+ */
5
+ export type { DisplayState, ValidationResult } from '../common';
6
+ /**
7
+ * 数值输入状态 Hook 返回值
8
+ */
9
+ export interface NumberInputState {
10
+ /**
11
+ * 当前值
12
+ */
13
+ value: number | null | 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: number | null) => void;
30
+ /**
31
+ * 失焦处理函数
32
+ */
33
+ handleBlur: () => void;
34
+ /**
35
+ * 聚焦处理函数
36
+ */
37
+ handleFocus: () => void;
38
+ }
39
+ /**
40
+ * 基础数值输入 Props(供校验和状态管理使用)
41
+ */
42
+ export interface BaseNumberInputProps {
43
+ /**
44
+ * 当前值(受控)
45
+ */
46
+ value?: number | null;
47
+ /**
48
+ * 默认值(非受控)
49
+ */
50
+ defaultValue?: number | null;
51
+ /**
52
+ * 是否必填
53
+ */
54
+ required?: boolean;
55
+ /**
56
+ * 最小值
57
+ */
58
+ min?: number;
59
+ /**
60
+ * 最大值
61
+ */
62
+ max?: number;
63
+ /**
64
+ * 自定义校验函数
65
+ * @param value 当前值
66
+ * @returns true 表示通过,false 或错误信息字符串表示不通过
67
+ */
68
+ validator?: (value: number | null) => boolean | string;
69
+ /**
70
+ * 校验触发时机
71
+ * - onChange: 输入时即时校验
72
+ * - onBlur: 失焦时校验
73
+ * - both: 输入和失焦时都校验
74
+ */
75
+ validateTrigger?: 'onChange' | 'onBlur' | 'both';
76
+ /**
77
+ * 自定义错误提示信息
78
+ */
79
+ errorMessage?: string;
80
+ /**
81
+ * 值变更回调
82
+ */
83
+ onChange?: (value: number | null) => void;
84
+ /**
85
+ * 失焦回调
86
+ */
87
+ onBlur?: (value: number | null) => void;
88
+ /**
89
+ * 聚焦回调
90
+ */
91
+ onFocus?: () => void;
92
+ /**
93
+ * 校验回调
94
+ */
95
+ onValidate?: (isValid: boolean, errors: string[]) => void;
96
+ }