@pisell/utils 1.0.72 → 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 +29 -0
- 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 +26 -0
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +12 -0
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +23 -0
- 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 +29 -0
- 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 +26 -0
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +12 -0
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +23 -0
- 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,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";
|
package/lib/select/types.d.ts
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
export type { DisplayState } from '../common';
|
|
1
|
+
import { DisplayState } from "../common/types.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/select/types.d.ts
|
|
7
5
|
/**
|
|
8
6
|
* 选项基础类型
|
|
9
7
|
* @template T 选项值的类型,默认为 string | number
|
|
10
8
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
interface SelectOption<T = string | number> {
|
|
10
|
+
/**
|
|
11
|
+
* 选项值(唯一标识)
|
|
12
|
+
*/
|
|
13
|
+
value: T;
|
|
14
|
+
/**
|
|
15
|
+
* 选项显示文本
|
|
16
|
+
*/
|
|
17
|
+
label: string;
|
|
18
|
+
/**
|
|
19
|
+
* 是否禁用该选项
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 选项图标(可选)
|
|
25
|
+
*/
|
|
26
|
+
icon?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* 标签背景色(多选时用于自定义标签颜色)
|
|
29
|
+
* @example '#61dafb'
|
|
30
|
+
*/
|
|
31
|
+
color?: string;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
34
|
* 选项过滤函数类型
|
|
@@ -39,218 +37,220 @@ export interface SelectOption<T = string | number> {
|
|
|
39
37
|
* @param option 当前选项对象
|
|
40
38
|
* @returns 是否保留该选项
|
|
41
39
|
*/
|
|
42
|
-
|
|
40
|
+
type FilterOptionFunc<T = string | number> = (input: string, option: SelectOption<T>) => boolean;
|
|
43
41
|
/**
|
|
44
42
|
* 排序方向
|
|
45
43
|
*/
|
|
46
|
-
|
|
44
|
+
type SortDirection = 'asc' | 'desc';
|
|
47
45
|
/**
|
|
48
46
|
* Select 状态 Hook 返回值(单选)
|
|
49
47
|
* @template T 值的类型
|
|
50
48
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
interface SelectState<T = string | number> {
|
|
50
|
+
/**
|
|
51
|
+
* 当前选中值
|
|
52
|
+
*/
|
|
53
|
+
value: T | null | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* 设置选中值
|
|
56
|
+
*/
|
|
57
|
+
setValue: (value: T | null) => void;
|
|
58
|
+
/**
|
|
59
|
+
* 清空选中值
|
|
60
|
+
*/
|
|
61
|
+
clearValue: () => void;
|
|
64
62
|
}
|
|
65
63
|
/**
|
|
66
64
|
* Multiple Select 状态 Hook 返回值(多选)
|
|
67
65
|
* @template T 值的类型
|
|
68
66
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
67
|
+
interface MultipleSelectState<T = string | number> {
|
|
68
|
+
/**
|
|
69
|
+
* 当前选中值数组
|
|
70
|
+
*/
|
|
71
|
+
value: T[];
|
|
72
|
+
/**
|
|
73
|
+
* 设置选中值数组
|
|
74
|
+
*/
|
|
75
|
+
setValue: (value: T[]) => void;
|
|
76
|
+
/**
|
|
77
|
+
* 添加一个选中值
|
|
78
|
+
*/
|
|
79
|
+
addValue: (value: T) => void;
|
|
80
|
+
/**
|
|
81
|
+
* 移除一个选中值
|
|
82
|
+
*/
|
|
83
|
+
removeValue: (value: T) => void;
|
|
84
|
+
/**
|
|
85
|
+
* 清空所有选中值
|
|
86
|
+
*/
|
|
87
|
+
clearValue: () => void;
|
|
90
88
|
}
|
|
91
89
|
/**
|
|
92
90
|
* 标签显示信息(多选专用)
|
|
93
91
|
* @template T 选项值的类型
|
|
94
92
|
*/
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
93
|
+
interface TagDisplayInfo<T = string | number> {
|
|
94
|
+
/**
|
|
95
|
+
* 可见的标签列表
|
|
96
|
+
*/
|
|
97
|
+
visibleTags: SelectOption<T>[];
|
|
98
|
+
/**
|
|
99
|
+
* 隐藏的标签列表
|
|
100
|
+
*/
|
|
101
|
+
hiddenTags: SelectOption<T>[];
|
|
102
|
+
/**
|
|
103
|
+
* 隐藏的标签数量
|
|
104
|
+
*/
|
|
105
|
+
hiddenCount: number;
|
|
108
106
|
}
|
|
109
107
|
/**
|
|
110
108
|
* useSelectState Hook 的配置选项(单选)
|
|
111
109
|
* @template T 值的类型
|
|
112
110
|
*/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
111
|
+
interface UseSelectStateOptions<T = string | number> {
|
|
112
|
+
/**
|
|
113
|
+
* 受控模式:当前值
|
|
114
|
+
*/
|
|
115
|
+
value?: T | null;
|
|
116
|
+
/**
|
|
117
|
+
* 非受控模式:默认值
|
|
118
|
+
*/
|
|
119
|
+
defaultValue?: T;
|
|
120
|
+
/**
|
|
121
|
+
* 值变化回调
|
|
122
|
+
*/
|
|
123
|
+
onChange?: (value: T | null, option: SelectOption<T> | null) => void;
|
|
124
|
+
/**
|
|
125
|
+
* 模式(用于类型区分)
|
|
126
|
+
*/
|
|
127
|
+
mode: 'single';
|
|
130
128
|
}
|
|
131
129
|
/**
|
|
132
130
|
* useMultipleSelectState Hook 的配置选项(多选)
|
|
133
131
|
* @template T 值的类型
|
|
134
132
|
*/
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
133
|
+
interface UseMultipleSelectStateOptions<T = string | number> {
|
|
134
|
+
/**
|
|
135
|
+
* 受控模式:当前值数组
|
|
136
|
+
*/
|
|
137
|
+
value?: T[];
|
|
138
|
+
/**
|
|
139
|
+
* 非受控模式:默认值数组
|
|
140
|
+
*/
|
|
141
|
+
defaultValue?: T[];
|
|
142
|
+
/**
|
|
143
|
+
* 值变化回调
|
|
144
|
+
*/
|
|
145
|
+
onChange?: (value: T[], options: SelectOption<T>[]) => void;
|
|
146
|
+
/**
|
|
147
|
+
* 模式(用于类型区分)
|
|
148
|
+
*/
|
|
149
|
+
mode: 'multiple';
|
|
152
150
|
}
|
|
153
151
|
/**
|
|
154
152
|
* 基础 Select Props(公共属性)
|
|
155
153
|
* @template T 值的类型
|
|
156
154
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
155
|
+
interface BaseSelectProps<T = string | number> {
|
|
156
|
+
/**
|
|
157
|
+
* 选项列表(必填)
|
|
158
|
+
*/
|
|
159
|
+
options: SelectOption<T>[];
|
|
160
|
+
/**
|
|
161
|
+
* 占位符文本
|
|
162
|
+
* @default '请选择'
|
|
163
|
+
*/
|
|
164
|
+
placeholder?: string;
|
|
165
|
+
/**
|
|
166
|
+
* 是否显示搜索框
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
showSearch?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* 是否显示清空按钮
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
allowClear?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* 是否禁用
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* 是否只读
|
|
182
|
+
* @default false
|
|
183
|
+
*/
|
|
184
|
+
readOnly?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* 尺寸
|
|
187
|
+
* @default 'middle'
|
|
188
|
+
*/
|
|
189
|
+
size?: 'small' | 'middle' | 'large';
|
|
190
|
+
/**
|
|
191
|
+
* 自定义类名
|
|
192
|
+
*/
|
|
193
|
+
className?: string;
|
|
194
|
+
/**
|
|
195
|
+
* 自定义样式
|
|
196
|
+
*/
|
|
197
|
+
style?: React.CSSProperties;
|
|
198
|
+
/**
|
|
199
|
+
* 标签文本
|
|
200
|
+
*/
|
|
201
|
+
label?: string;
|
|
202
|
+
/**
|
|
203
|
+
* 辅助提示文本
|
|
204
|
+
*/
|
|
205
|
+
helperText?: string;
|
|
206
|
+
/**
|
|
207
|
+
* 是否必填
|
|
208
|
+
* @default false
|
|
209
|
+
*/
|
|
210
|
+
required?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* 是否显示错误状态
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
error?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* 错误提示文本
|
|
218
|
+
*/
|
|
219
|
+
errorText?: string;
|
|
220
|
+
/**
|
|
221
|
+
* 是否启用过滤
|
|
222
|
+
* @default false
|
|
223
|
+
*/
|
|
224
|
+
filterable?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* 自定义过滤函数
|
|
227
|
+
*/
|
|
228
|
+
filterOption?: FilterOptionFunc<T>;
|
|
229
|
+
/**
|
|
230
|
+
* 是否启用排序
|
|
231
|
+
* @default false
|
|
232
|
+
*/
|
|
233
|
+
sortable?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* 排序方向
|
|
236
|
+
*/
|
|
237
|
+
sortDirection?: SortDirection;
|
|
238
|
+
/**
|
|
239
|
+
* 搜索输入回调
|
|
240
|
+
*/
|
|
241
|
+
onSearch?: (value: string) => void;
|
|
242
|
+
/**
|
|
243
|
+
* 获得焦点回调
|
|
244
|
+
*/
|
|
245
|
+
onFocus?: (event: React.FocusEvent) => void;
|
|
246
|
+
/**
|
|
247
|
+
* 失去焦点回调
|
|
248
|
+
*/
|
|
249
|
+
onBlur?: (event: React.FocusEvent) => void;
|
|
250
|
+
/**
|
|
251
|
+
* 下拉框显隐回调
|
|
252
|
+
*/
|
|
253
|
+
onDropdownVisibleChange?: (visible: boolean) => void;
|
|
256
254
|
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { BaseSelectProps, FilterOptionFunc, MultipleSelectState, SelectOption, SelectState, SortDirection, TagDisplayInfo, UseMultipleSelectStateOptions, UseSelectStateOptions };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import type { SelectOption, FilterOptionFunc } from '../types';
|
|
1
|
+
import { FilterOptionFunc, SelectOption } from "../types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/select/utils/filterOptions.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* 默认的选项过滤函数
|
|
7
6
|
* 根据 label 进行模糊匹配(不区分大小写)
|
|
@@ -10,7 +9,7 @@ import type { SelectOption, FilterOptionFunc } from '../types';
|
|
|
10
9
|
* @param option 选项对象
|
|
11
10
|
* @returns 是否保留该选项
|
|
12
11
|
*/
|
|
13
|
-
|
|
12
|
+
declare function defaultFilterOption<T = string | number>(input: string, option: SelectOption<T>): boolean;
|
|
14
13
|
/**
|
|
15
14
|
* 过滤选项列表
|
|
16
15
|
* @template T 选项值的类型
|
|
@@ -19,4 +18,6 @@ export declare function defaultFilterOption<T = string | number>(input: string,
|
|
|
19
18
|
* @param filterFunc 自定义过滤函数(可选)
|
|
20
19
|
* @returns 过滤后的选项列表
|
|
21
20
|
*/
|
|
22
|
-
|
|
21
|
+
declare function filterOptions<T = string | number>(options: SelectOption<T>[], searchText: string, filterFunc?: FilterOptionFunc<T>): SelectOption<T>[];
|
|
22
|
+
//#endregion
|
|
23
|
+
export { defaultFilterOption, filterOptions };
|