@pisell/utils 1.0.71 → 1.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +4 -1
- package/es/arrayUtils.js +15 -24
- package/es/common/stateHelper.d.ts +6 -2
- package/es/common/stateHelper.js +22 -24
- package/es/common/types.d.ts +13 -10
- package/es/componentStorage.d.ts +27 -25
- package/es/componentStorage.js +94 -130
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +12 -11
- package/es/format.js +90 -116
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +38 -23
- package/es/index.js +39 -34
- package/es/jsBridge/index.d.ts +8 -4
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +95 -115
- package/es/locales.d.ts +11 -8
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -78
- package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/es/number-input/hooks/useNumberInputState.js +71 -128
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/utils/formatter.d.ts +13 -10
- package/es/number-input/utils/formatter.js +51 -77
- package/es/number-input/utils/validation.d.ts +7 -2
- package/es/number-input/utils/validation.js +51 -66
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +17 -9
- package/es/platform.js +78 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/es/select/hooks/useDebouncedSearch.js +39 -53
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +56 -113
- package/es/select/index.d.ts +7 -8
- package/es/select/types.d.ts +211 -211
- package/es/select/utils/filterOptions.d.ts +7 -6
- package/es/select/utils/filterOptions.js +26 -31
- package/es/select/utils/helpers.d.ts +10 -9
- package/es/select/utils/helpers.js +42 -52
- package/es/select/utils/index.d.ts +4 -7
- package/es/select/utils/sortOptions.d.ts +6 -5
- package/es/select/utils/sortOptions.js +19 -31
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +34 -47
- package/es/text-input/hooks/useTextInputState.d.ts +6 -2
- package/es/text-input/hooks/useTextInputState.js +69 -126
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/utils/validation.d.ts +7 -2
- package/es/text-input/utils/validation.js +50 -70
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +36 -34
- package/es/walletValidity.js +332 -456
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +4 -1
- package/lib/arrayUtils.js +14 -39
- package/lib/common/stateHelper.d.ts +6 -2
- package/lib/common/stateHelper.js +21 -32
- package/lib/common/types.d.ts +13 -10
- package/lib/componentStorage.d.ts +27 -25
- package/lib/componentStorage.js +96 -126
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +12 -11
- package/lib/format.js +91 -99
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +38 -23
- package/lib/index.js +115 -78
- package/lib/jsBridge/index.d.ts +8 -4
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +95 -115
- package/lib/locales.d.ts +11 -8
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -92
- package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/lib/number-input/hooks/useNumberInputState.js +71 -81
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/utils/formatter.d.ts +13 -10
- package/lib/number-input/utils/formatter.js +52 -49
- package/lib/number-input/utils/validation.d.ts +7 -2
- package/lib/number-input/utils/validation.js +50 -52
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +17 -9
- package/lib/platform.js +85 -122
- package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/lib/select/hooks/useDebouncedSearch.js +40 -41
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +58 -93
- package/lib/select/index.d.ts +7 -8
- package/lib/select/types.d.ts +211 -211
- package/lib/select/utils/filterOptions.d.ts +7 -6
- package/lib/select/utils/filterOptions.js +26 -37
- package/lib/select/utils/helpers.d.ts +10 -9
- package/lib/select/utils/helpers.js +45 -41
- package/lib/select/utils/index.d.ts +4 -7
- package/lib/select/utils/sortOptions.d.ts +6 -5
- package/lib/select/utils/sortOptions.js +18 -39
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +33 -41
- package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
- package/lib/text-input/hooks/useTextInputState.js +69 -79
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/utils/validation.d.ts +7 -2
- package/lib/text-input/utils/validation.js +49 -58
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +36 -34
- package/lib/walletValidity.js +345 -317
- package/package.json +1 -2
- package/es/common/index.d.ts +0 -5
- package/es/common/index.js +0 -5
- package/es/common/types.js +0 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/es/jsBridge/types.js +0 -1
- package/es/number-input/hooks/index.d.ts +0 -4
- package/es/number-input/hooks/index.js +0 -5
- package/es/number-input/index.d.ts +0 -14
- package/es/number-input/index.js +0 -21
- package/es/number-input/types.js +0 -1
- package/es/number-input/utils/index.d.ts +0 -7
- package/es/number-input/utils/index.js +0 -8
- package/es/select/hooks/index.d.ts +0 -5
- package/es/select/hooks/index.js +0 -6
- package/es/select/index.js +0 -13
- package/es/select/types.js +0 -1
- package/es/select/utils/index.js +0 -8
- package/es/text-input/hooks/index.d.ts +0 -4
- package/es/text-input/hooks/index.js +0 -5
- package/es/text-input/index.d.ts +0 -14
- package/es/text-input/index.js +0 -20
- package/es/text-input/types.js +0 -1
- package/es/text-input/utils/index.d.ts +0 -5
- package/es/text-input/utils/index.js +0 -7
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.js +0 -29
- package/lib/common/types.js +0 -17
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
- package/lib/jsBridge/types.js +0 -17
- package/lib/number-input/hooks/index.d.ts +0 -4
- package/lib/number-input/hooks/index.js +0 -29
- package/lib/number-input/index.d.ts +0 -14
- package/lib/number-input/index.js +0 -41
- package/lib/number-input/types.js +0 -17
- package/lib/number-input/utils/index.d.ts +0 -7
- package/lib/number-input/utils/index.js +0 -39
- package/lib/select/hooks/index.d.ts +0 -5
- package/lib/select/hooks/index.js +0 -34
- package/lib/select/index.js +0 -53
- package/lib/select/types.js +0 -17
- package/lib/select/utils/index.js +0 -48
- package/lib/text-input/hooks/index.d.ts +0 -4
- package/lib/text-input/hooks/index.js +0 -29
- package/lib/text-input/index.d.ts +0 -14
- package/lib/text-input/index.js +0 -35
- package/lib/text-input/types.js +0 -17
- package/lib/text-input/utils/index.d.ts +0 -5
- package/lib/text-input/utils/index.js +0 -32
|
@@ -1,43 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useDebouncedSearch_exports);
|
|
25
|
-
var import_react = require("react");
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
//#region src/select/hooks/useDebouncedSearch.ts
|
|
4
|
+
/**
|
|
5
|
+
* 防抖搜索 Hook
|
|
6
|
+
* 对用户输入进行防抖处理,避免频繁触发搜索
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 防抖搜索 Hook
|
|
10
|
+
* @template T 值的类型
|
|
11
|
+
* @param initialValue 初始值
|
|
12
|
+
* @param delay 防抖延迟时间(毫秒)
|
|
13
|
+
* @param callback 防抖后的回调函数
|
|
14
|
+
* @returns [防抖后的值, 设置值函数]
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* const [debouncedSearch, setSearchInput] = useDebouncedSearch('', 300, (text) => {
|
|
19
|
+
* console.log('搜索关键词:', text);
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
26
23
|
function useDebouncedSearch(initialValue, delay, callback) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const [value, setValue] = (0, react.useState)(initialValue);
|
|
25
|
+
const [debouncedValue, setDebouncedValue] = (0, react.useState)(initialValue);
|
|
26
|
+
(0, react.useEffect)(() => {
|
|
27
|
+
const timer = setTimeout(() => {
|
|
28
|
+
setDebouncedValue(value);
|
|
29
|
+
callback === null || callback === void 0 || callback(value);
|
|
30
|
+
}, delay);
|
|
31
|
+
return () => {
|
|
32
|
+
clearTimeout(timer);
|
|
33
|
+
};
|
|
34
|
+
}, [
|
|
35
|
+
value,
|
|
36
|
+
delay,
|
|
37
|
+
callback
|
|
38
|
+
]);
|
|
39
|
+
return [debouncedValue, setValue];
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
useDebouncedSearch
|
|
43
|
-
});
|
|
41
|
+
//#endregion
|
|
42
|
+
exports.useDebouncedSearch = useDebouncedSearch;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
import type { UseSelectStateOptions, UseMultipleSelectStateOptions, SelectState, MultipleSelectState } from '../types';
|
|
1
|
+
import { MultipleSelectState, SelectState, UseMultipleSelectStateOptions, UseSelectStateOptions } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/select/hooks/useSelectState.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* 单选状态管理 Hook
|
|
8
6
|
* @template T 值的类型
|
|
9
7
|
* @param options Hook 配置选项
|
|
10
8
|
* @returns 状态管理对象
|
|
11
9
|
*/
|
|
12
|
-
|
|
10
|
+
declare function useSelectState<T = string | number>(options: UseSelectStateOptions<T>): SelectState<T>;
|
|
13
11
|
/**
|
|
14
12
|
* 多选状态管理 Hook
|
|
15
13
|
* @template T 值的类型
|
|
16
14
|
* @param options Hook 配置选项
|
|
17
15
|
* @returns 状态管理对象
|
|
18
16
|
*/
|
|
19
|
-
|
|
17
|
+
declare function useMultipleSelectState<T = string | number>(options: UseMultipleSelectStateOptions<T>): MultipleSelectState<T>;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { useMultipleSelectState, useSelectState };
|
|
@@ -1,97 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/select/hooks/useSelectState.ts
|
|
20
|
-
var useSelectState_exports = {};
|
|
21
|
-
__export(useSelectState_exports, {
|
|
22
|
-
useMultipleSelectState: () => useMultipleSelectState,
|
|
23
|
-
useSelectState: () => useSelectState
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(useSelectState_exports);
|
|
26
|
-
var import_react = require("react");
|
|
1
|
+
require("../../_virtual/_rolldown/runtime.js");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
//#region src/select/hooks/useSelectState.ts
|
|
4
|
+
/**
|
|
5
|
+
* Select 状态管理 Hook
|
|
6
|
+
* 处理受控/非受控模式,适用于单选和多选
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 单选状态管理 Hook
|
|
10
|
+
* @template T 值的类型
|
|
11
|
+
* @param options Hook 配置选项
|
|
12
|
+
* @returns 状态管理对象
|
|
13
|
+
*/
|
|
27
14
|
function useSelectState(options) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const clearValue = (0, import_react.useCallback)(() => {
|
|
44
|
-
setValue(null);
|
|
45
|
-
}, [setValue]);
|
|
46
|
-
return {
|
|
47
|
-
value,
|
|
48
|
-
setValue,
|
|
49
|
-
clearValue
|
|
50
|
-
};
|
|
15
|
+
const { value: controlledValue, defaultValue, onChange } = options;
|
|
16
|
+
const isControlled = controlledValue !== void 0;
|
|
17
|
+
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null);
|
|
18
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
19
|
+
const setValue = (0, react.useCallback)((newValue) => {
|
|
20
|
+
if (!isControlled) setInternalValue(newValue);
|
|
21
|
+
onChange === null || onChange === void 0 || onChange(newValue, null);
|
|
22
|
+
}, [isControlled, onChange]);
|
|
23
|
+
return {
|
|
24
|
+
value,
|
|
25
|
+
setValue,
|
|
26
|
+
clearValue: (0, react.useCallback)(() => {
|
|
27
|
+
setValue(null);
|
|
28
|
+
}, [setValue])
|
|
29
|
+
};
|
|
51
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* 多选状态管理 Hook
|
|
33
|
+
* @template T 值的类型
|
|
34
|
+
* @param options Hook 配置选项
|
|
35
|
+
* @returns 状态管理对象
|
|
36
|
+
*/
|
|
52
37
|
function useMultipleSelectState(options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
);
|
|
75
|
-
const removeValue = (0, import_react.useCallback)(
|
|
76
|
-
(val) => {
|
|
77
|
-
const newValue = value.filter((v) => v !== val);
|
|
78
|
-
setValue(newValue);
|
|
79
|
-
},
|
|
80
|
-
[value, setValue]
|
|
81
|
-
);
|
|
82
|
-
const clearValue = (0, import_react.useCallback)(() => {
|
|
83
|
-
setValue([]);
|
|
84
|
-
}, [setValue]);
|
|
85
|
-
return {
|
|
86
|
-
value,
|
|
87
|
-
setValue,
|
|
88
|
-
addValue,
|
|
89
|
-
removeValue,
|
|
90
|
-
clearValue
|
|
91
|
-
};
|
|
38
|
+
const { value: controlledValue, defaultValue, onChange } = options;
|
|
39
|
+
const isControlled = controlledValue !== void 0;
|
|
40
|
+
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue !== null && defaultValue !== void 0 ? defaultValue : []);
|
|
41
|
+
const value = isControlled ? controlledValue !== null && controlledValue !== void 0 ? controlledValue : [] : internalValue;
|
|
42
|
+
const setValue = (0, react.useCallback)((newValue) => {
|
|
43
|
+
if (!isControlled) setInternalValue(newValue);
|
|
44
|
+
onChange === null || onChange === void 0 || onChange(newValue, []);
|
|
45
|
+
}, [isControlled, onChange]);
|
|
46
|
+
return {
|
|
47
|
+
value,
|
|
48
|
+
setValue,
|
|
49
|
+
addValue: (0, react.useCallback)((val) => {
|
|
50
|
+
setValue([...value, val]);
|
|
51
|
+
}, [value, setValue]),
|
|
52
|
+
removeValue: (0, react.useCallback)((val) => {
|
|
53
|
+
setValue(value.filter((v) => v !== val));
|
|
54
|
+
}, [value, setValue]),
|
|
55
|
+
clearValue: (0, react.useCallback)(() => {
|
|
56
|
+
setValue([]);
|
|
57
|
+
}, [setValue])
|
|
58
|
+
};
|
|
92
59
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
useSelectState
|
|
97
|
-
});
|
|
60
|
+
//#endregion
|
|
61
|
+
exports.useMultipleSelectState = useMultipleSelectState;
|
|
62
|
+
exports.useSelectState = useSelectState;
|
package/lib/select/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export { filterOptions, defaultFilterOption, sortOptions, calculateTagDisplay, findOptionByValue, findOptionsByValues, isOptionSelected, isOptionSelectedInMultiple, generateId, } from './utils';
|
|
1
|
+
import { BaseSelectProps, FilterOptionFunc, MultipleSelectState, SelectOption, SelectState, SortDirection, TagDisplayInfo, UseMultipleSelectStateOptions, UseSelectStateOptions } from "./types.js";
|
|
2
|
+
import { useMultipleSelectState, useSelectState } from "./hooks/useSelectState.js";
|
|
3
|
+
import { useDebouncedSearch } from "./hooks/useDebouncedSearch.js";
|
|
4
|
+
import { calculateTagDisplay } from "./utils/tagAggregation.js";
|
|
5
|
+
import { defaultFilterOption, filterOptions } from "./utils/filterOptions.js";
|
|
6
|
+
import { sortOptions } from "./utils/sortOptions.js";
|
|
7
|
+
import { findOptionByValue, findOptionsByValues, generateId, isOptionSelected, isOptionSelectedInMultiple } from "./utils/helpers.js";
|