@seakoi/native-ui 1.2.0 → 1.3.0
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/CHANGELOG.md +35 -0
- package/dist/commonjs/components/base/index.js +33 -11
- package/dist/commonjs/components/base/input/base-input.js +4 -2
- package/dist/commonjs/components/base/overflow/all-mode-overflow.js +49 -0
- package/dist/commonjs/components/base/overflow/fixed-count-overflow.js +70 -0
- package/dist/commonjs/components/base/overflow/index.js +16 -0
- package/dist/commonjs/components/base/overflow/overflow.js +72 -0
- package/dist/commonjs/components/base/overflow/responsive-overflow.js +280 -0
- package/dist/commonjs/components/base/overflow/style/index.js +39 -0
- package/dist/commonjs/components/base/overflow/types.js +5 -0
- package/dist/commonjs/components/base/picker/picker-content.js +16 -12
- package/dist/commonjs/components/base/picker/picker-field.js +9 -7
- package/dist/commonjs/components/base/picker/picker.js +6 -1
- package/dist/commonjs/components/base/picker/style/index.js +7 -1
- package/dist/commonjs/components/base/portal/portal-host.js +5 -3
- package/dist/commonjs/components/base/select/hooks/use-select-actions.js +155 -0
- package/dist/commonjs/components/base/select/hooks/use-select-options.js +169 -0
- package/dist/commonjs/components/base/select/hooks/use-selector.js +104 -0
- package/dist/commonjs/components/base/select/index.js +16 -0
- package/dist/commonjs/components/base/select/select-multiple-content.js +182 -0
- package/dist/commonjs/components/base/select/select-popup.js +233 -0
- package/dist/commonjs/components/base/select/select-single-content.js +100 -0
- package/dist/commonjs/components/base/select/select-suffix.js +67 -0
- package/dist/commonjs/components/base/select/select.js +285 -0
- package/dist/commonjs/components/base/select/style/index.js +40 -0
- package/dist/commonjs/components/base/select/style/select-multiple-content-styles.js +46 -0
- package/dist/commonjs/components/base/select/style/select-popup-styles.js +67 -0
- package/dist/commonjs/components/base/select/style/select-single-content-styles.js +28 -0
- package/dist/commonjs/components/base/select/style/select-styles.js +46 -0
- package/dist/commonjs/components/base/select/style/select-suffix-styles.js +21 -0
- package/dist/commonjs/components/base/select/types.js +5 -0
- package/dist/commonjs/components/base/tabs/style/index.js +37 -0
- package/dist/commonjs/components/base/tabs/tabs.js +90 -45
- package/dist/commonjs/native-provider/native-provider.js +5 -5
- package/dist/commonjs/shared/utils/index.js +11 -0
- package/dist/commonjs/shared/utils/object.js +39 -0
- package/dist/module/components/base/index.js +2 -0
- package/dist/module/components/base/input/base-input.js +4 -2
- package/dist/module/components/base/overflow/all-mode-overflow.js +43 -0
- package/dist/module/components/base/overflow/fixed-count-overflow.js +64 -0
- package/dist/module/components/base/overflow/index.js +3 -0
- package/dist/module/components/base/overflow/overflow.js +66 -0
- package/dist/module/components/base/overflow/responsive-overflow.js +274 -0
- package/dist/module/components/base/overflow/style/index.js +36 -0
- package/dist/module/components/base/overflow/types.js +3 -0
- package/dist/module/components/base/picker/picker-content.js +16 -12
- package/dist/module/components/base/picker/picker-field.js +9 -7
- package/dist/module/components/base/picker/picker.js +6 -1
- package/dist/module/components/base/picker/style/index.js +6 -0
- package/dist/module/components/base/portal/portal-host.js +4 -3
- package/dist/module/components/base/select/hooks/use-select-actions.js +151 -0
- package/dist/module/components/base/select/hooks/use-select-options.js +162 -0
- package/dist/module/components/base/select/hooks/use-selector.js +100 -0
- package/dist/module/components/base/select/index.js +3 -0
- package/dist/module/components/base/select/select-multiple-content.js +176 -0
- package/dist/module/components/base/select/select-popup.js +227 -0
- package/dist/module/components/base/select/select-single-content.js +94 -0
- package/dist/module/components/base/select/select-suffix.js +61 -0
- package/dist/module/components/base/select/select.js +279 -0
- package/dist/module/components/base/select/style/index.js +7 -0
- package/dist/module/components/base/select/style/select-multiple-content-styles.js +43 -0
- package/dist/module/components/base/select/style/select-popup-styles.js +64 -0
- package/dist/module/components/base/select/style/select-single-content-styles.js +25 -0
- package/dist/module/components/base/select/style/select-styles.js +43 -0
- package/dist/module/components/base/select/style/select-suffix-styles.js +18 -0
- package/dist/module/components/base/select/types.js +3 -0
- package/dist/module/components/base/tabs/style/index.js +33 -0
- package/dist/module/components/base/tabs/tabs.js +92 -47
- package/dist/module/native-provider/native-provider.js +5 -5
- package/dist/module/shared/utils/index.js +2 -1
- package/dist/module/shared/utils/object.js +35 -0
- package/dist/typescript/components/base/index.d.ts +2 -0
- package/dist/typescript/components/base/index.d.ts.map +1 -1
- package/dist/typescript/components/base/input/base-input.d.ts.map +1 -1
- package/dist/typescript/components/base/overflow/all-mode-overflow.d.ts +11 -0
- package/dist/typescript/components/base/overflow/all-mode-overflow.d.ts.map +1 -0
- package/dist/typescript/components/base/overflow/fixed-count-overflow.d.ts +11 -0
- package/dist/typescript/components/base/overflow/fixed-count-overflow.d.ts.map +1 -0
- package/dist/typescript/components/base/overflow/index.d.ts +3 -0
- package/dist/typescript/components/base/overflow/index.d.ts.map +1 -0
- package/dist/typescript/components/base/overflow/overflow.d.ts +13 -0
- package/dist/typescript/components/base/overflow/overflow.d.ts.map +1 -0
- package/dist/typescript/components/base/overflow/responsive-overflow.d.ts +12 -0
- package/dist/typescript/components/base/overflow/responsive-overflow.d.ts.map +1 -0
- package/dist/typescript/components/base/overflow/style/index.d.ts +31 -0
- package/dist/typescript/components/base/overflow/style/index.d.ts.map +1 -0
- package/dist/typescript/components/base/overflow/types.d.ts +77 -0
- package/dist/typescript/components/base/overflow/types.d.ts.map +1 -0
- package/dist/typescript/components/base/picker/picker-content.d.ts +12 -0
- package/dist/typescript/components/base/picker/picker-content.d.ts.map +1 -1
- package/dist/typescript/components/base/picker/picker-field.d.ts.map +1 -1
- package/dist/typescript/components/base/picker/picker.d.ts +9 -0
- package/dist/typescript/components/base/picker/picker.d.ts.map +1 -1
- package/dist/typescript/components/base/picker/style/index.d.ts +6 -0
- package/dist/typescript/components/base/picker/style/index.d.ts.map +1 -1
- package/dist/typescript/components/base/portal/portal-host.d.ts +1 -0
- package/dist/typescript/components/base/portal/portal-host.d.ts.map +1 -1
- package/dist/typescript/components/base/portal/types.d.ts +2 -0
- package/dist/typescript/components/base/portal/types.d.ts.map +1 -1
- package/dist/typescript/components/base/select/hooks/use-select-actions.d.ts +144 -0
- package/dist/typescript/components/base/select/hooks/use-select-actions.d.ts.map +1 -0
- package/dist/typescript/components/base/select/hooks/use-select-options.d.ts +91 -0
- package/dist/typescript/components/base/select/hooks/use-select-options.d.ts.map +1 -0
- package/dist/typescript/components/base/select/hooks/use-selector.d.ts +90 -0
- package/dist/typescript/components/base/select/hooks/use-selector.d.ts.map +1 -0
- package/dist/typescript/components/base/select/index.d.ts +3 -0
- package/dist/typescript/components/base/select/index.d.ts.map +1 -0
- package/dist/typescript/components/base/select/select-multiple-content.d.ts +51 -0
- package/dist/typescript/components/base/select/select-multiple-content.d.ts.map +1 -0
- package/dist/typescript/components/base/select/select-popup.d.ts +107 -0
- package/dist/typescript/components/base/select/select-popup.d.ts.map +1 -0
- package/dist/typescript/components/base/select/select-single-content.d.ts +48 -0
- package/dist/typescript/components/base/select/select-single-content.d.ts.map +1 -0
- package/dist/typescript/components/base/select/select-suffix.d.ts +43 -0
- package/dist/typescript/components/base/select/select-suffix.d.ts.map +1 -0
- package/dist/typescript/components/base/select/select.d.ts +40 -0
- package/dist/typescript/components/base/select/select.d.ts.map +1 -0
- package/dist/typescript/components/base/select/style/index.d.ts +6 -0
- package/dist/typescript/components/base/select/style/index.d.ts.map +1 -0
- package/dist/typescript/components/base/select/style/select-multiple-content-styles.d.ts +40 -0
- package/dist/typescript/components/base/select/style/select-multiple-content-styles.d.ts.map +1 -0
- package/dist/typescript/components/base/select/style/select-popup-styles.d.ts +61 -0
- package/dist/typescript/components/base/select/style/select-popup-styles.d.ts.map +1 -0
- package/dist/typescript/components/base/select/style/select-single-content-styles.d.ts +22 -0
- package/dist/typescript/components/base/select/style/select-single-content-styles.d.ts.map +1 -0
- package/dist/typescript/components/base/select/style/select-styles.d.ts +40 -0
- package/dist/typescript/components/base/select/style/select-styles.d.ts.map +1 -0
- package/dist/typescript/components/base/select/style/select-suffix-styles.d.ts +15 -0
- package/dist/typescript/components/base/select/style/select-suffix-styles.d.ts.map +1 -0
- package/dist/typescript/components/base/select/types.d.ts +206 -0
- package/dist/typescript/components/base/select/types.d.ts.map +1 -0
- package/dist/typescript/components/base/tabs/style/index.d.ts +29 -0
- package/dist/typescript/components/base/tabs/style/index.d.ts.map +1 -0
- package/dist/typescript/components/base/tabs/tabs.d.ts +26 -5
- package/dist/typescript/components/base/tabs/tabs.d.ts.map +1 -1
- package/dist/typescript/native-provider/native-provider.d.ts +2 -0
- package/dist/typescript/native-provider/native-provider.d.ts.map +1 -1
- package/dist/typescript/shared/utils/index.d.ts +1 -0
- package/dist/typescript/shared/utils/index.d.ts.map +1 -1
- package/dist/typescript/shared/utils/object.d.ts +21 -0
- package/dist/typescript/shared/utils/object.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/base/index.ts +2 -0
- package/src/components/base/input/base-input.tsx +4 -2
- package/src/components/base/overflow/all-mode-overflow.tsx +49 -0
- package/src/components/base/overflow/fixed-count-overflow.tsx +71 -0
- package/src/components/base/overflow/index.ts +2 -0
- package/src/components/base/overflow/overflow.tsx +60 -0
- package/src/components/base/overflow/responsive-overflow.tsx +349 -0
- package/src/components/base/overflow/style/index.ts +32 -0
- package/src/components/base/overflow/types.ts +75 -0
- package/src/components/base/picker/picker-content.tsx +24 -9
- package/src/components/base/picker/picker-field.tsx +19 -13
- package/src/components/base/picker/picker.tsx +10 -1
- package/src/components/base/picker/style/index.ts +4 -0
- package/src/components/base/portal/portal-host.tsx +13 -3
- package/src/components/base/portal/types.ts +2 -0
- package/src/components/base/select/hooks/use-select-actions.ts +263 -0
- package/src/components/base/select/hooks/use-select-options.ts +250 -0
- package/src/components/base/select/hooks/use-selector.ts +155 -0
- package/src/components/base/select/index.ts +2 -0
- package/src/components/base/select/select-multiple-content.tsx +292 -0
- package/src/components/base/select/select-popup.tsx +384 -0
- package/src/components/base/select/select-single-content.tsx +127 -0
- package/src/components/base/select/select-suffix.tsx +100 -0
- package/src/components/base/select/select.tsx +302 -0
- package/src/components/base/select/style/index.ts +5 -0
- package/src/components/base/select/style/select-multiple-content-styles.ts +41 -0
- package/src/components/base/select/style/select-popup-styles.ts +62 -0
- package/src/components/base/select/style/select-single-content-styles.ts +23 -0
- package/src/components/base/select/style/select-styles.ts +41 -0
- package/src/components/base/select/style/select-suffix-styles.ts +16 -0
- package/src/components/base/select/types.ts +261 -0
- package/src/components/base/tabs/style/index.ts +32 -0
- package/src/components/base/tabs/tabs.tsx +146 -55
- package/src/native-provider/native-provider.tsx +4 -4
- package/src/shared/utils/index.ts +1 -0
- package/src/shared/utils/object.ts +37 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { GestureResponderEvent } from 'react-native';
|
|
2
|
+
import type { SelectMode, SelectOption } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* 选项操作 Hook 参数
|
|
5
|
+
*
|
|
6
|
+
* @template ValueType - 选项值的类型
|
|
7
|
+
*/
|
|
8
|
+
export interface UseSelectActionsParams<ValueType = unknown, RealValueType = unknown> {
|
|
9
|
+
/**
|
|
10
|
+
* 当前值
|
|
11
|
+
*/
|
|
12
|
+
value: RealValueType;
|
|
13
|
+
/**
|
|
14
|
+
* 选择模式
|
|
15
|
+
*/
|
|
16
|
+
mode?: SelectMode;
|
|
17
|
+
/**
|
|
18
|
+
* 是否禁用
|
|
19
|
+
*/
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 最大选择数量
|
|
23
|
+
*/
|
|
24
|
+
maxCount?: number;
|
|
25
|
+
/**
|
|
26
|
+
* 自动清空搜索
|
|
27
|
+
*/
|
|
28
|
+
autoClearSearchValue?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* 设置值
|
|
31
|
+
*/
|
|
32
|
+
setValue: (value: RealValueType) => void;
|
|
33
|
+
/**
|
|
34
|
+
* 清空搜索
|
|
35
|
+
*/
|
|
36
|
+
clearSearch: () => void;
|
|
37
|
+
/**
|
|
38
|
+
* 关闭下拉框
|
|
39
|
+
*/
|
|
40
|
+
closePopup: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* 判断选项是否被选中
|
|
43
|
+
*/
|
|
44
|
+
isOptionSelected: (option: SelectOption<ValueType>) => boolean;
|
|
45
|
+
/**
|
|
46
|
+
* 激活回调
|
|
47
|
+
*/
|
|
48
|
+
onActive?: (value: ValueType) => void;
|
|
49
|
+
/**
|
|
50
|
+
* 选择回调
|
|
51
|
+
*/
|
|
52
|
+
onSelect?: (value: ValueType, option: SelectOption<ValueType>) => void;
|
|
53
|
+
/**
|
|
54
|
+
* 取消选择回调
|
|
55
|
+
*/
|
|
56
|
+
onDeselect?: (value: ValueType) => void;
|
|
57
|
+
/**
|
|
58
|
+
* 清除回调
|
|
59
|
+
*/
|
|
60
|
+
onClear?: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* 创建选项回调
|
|
63
|
+
*/
|
|
64
|
+
onCreateOption?: (inputValue: string) => SelectOption<ValueType> | void | undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 选项操作 Hook 返回值
|
|
68
|
+
*/
|
|
69
|
+
export interface UseSelectActionsResult<ValueType = unknown> {
|
|
70
|
+
/**
|
|
71
|
+
* 处理选项点击
|
|
72
|
+
*/
|
|
73
|
+
handleOptionPress: (option: SelectOption<ValueType>) => void;
|
|
74
|
+
/**
|
|
75
|
+
* 处理标签移除
|
|
76
|
+
*/
|
|
77
|
+
handleTagClose: (option: SelectOption<ValueType>) => void;
|
|
78
|
+
/**
|
|
79
|
+
* 处理清除
|
|
80
|
+
*/
|
|
81
|
+
handleClear: (e: GestureResponderEvent) => void;
|
|
82
|
+
/**
|
|
83
|
+
* 处理创建新选项
|
|
84
|
+
*/
|
|
85
|
+
handleCreateOption: (searchValue: string) => void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 选项操作 Hook
|
|
89
|
+
*
|
|
90
|
+
* 封装 Select 组件中与选项操作相关的逻辑,包括:
|
|
91
|
+
* - 选项点击处理
|
|
92
|
+
* - 标签移除处理
|
|
93
|
+
* - 清除操作处理
|
|
94
|
+
* - 创建新选项处理
|
|
95
|
+
*
|
|
96
|
+
* @template ValueType - 选项值的类型
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const {
|
|
100
|
+
* handleOptionPress,
|
|
101
|
+
* handleTagClose,
|
|
102
|
+
* handleClear,
|
|
103
|
+
* handleCreateOption
|
|
104
|
+
* } = useSelectActions({
|
|
105
|
+
* value,
|
|
106
|
+
* mode,
|
|
107
|
+
* disabled,
|
|
108
|
+
* maxCount,
|
|
109
|
+
* autoClearSearchValue,
|
|
110
|
+
* setValue,
|
|
111
|
+
* clearSearch,
|
|
112
|
+
* closePopup,
|
|
113
|
+
* isOptionSelected,
|
|
114
|
+
* onSelect,
|
|
115
|
+
* onDeselect,
|
|
116
|
+
* onClear
|
|
117
|
+
* });
|
|
118
|
+
*/
|
|
119
|
+
export declare const useSelectActions: <ValueType = unknown, RealValueType = unknown>(params: UseSelectActionsParams<ValueType, RealValueType>) => UseSelectActionsResult<ValueType>;
|
|
120
|
+
/**
|
|
121
|
+
* 搜索配置
|
|
122
|
+
*
|
|
123
|
+
* @template OptionType - 选项类型
|
|
124
|
+
*/
|
|
125
|
+
export interface SelectSearchConfig<OptionType extends SelectOption = SelectOption> {
|
|
126
|
+
/**
|
|
127
|
+
* 是否在选中项后清空搜索框(仅 multiple/tags 模式)
|
|
128
|
+
* @default true
|
|
129
|
+
*/
|
|
130
|
+
autoClearSearchValue?: boolean;
|
|
131
|
+
/** 是否根据输入项进行筛选 */
|
|
132
|
+
filterOption?: boolean | ((inputValue: string, option: OptionType) => boolean);
|
|
133
|
+
/** 搜索时对筛选结果排序 */
|
|
134
|
+
filterSort?: (optionA: OptionType, optionB: OptionType, info: {
|
|
135
|
+
searchValue: string;
|
|
136
|
+
}) => number;
|
|
137
|
+
/** 搜索时过滤对应的 option 属性 */
|
|
138
|
+
optionFilterProp?: string | string[];
|
|
139
|
+
/** 控制搜索文本 */
|
|
140
|
+
searchValue?: string;
|
|
141
|
+
/** 文本框值变化时回调 */
|
|
142
|
+
onSearch?: (value: string) => void;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=use-select-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-select-actions.d.ts","sourceRoot":"","sources":["../../../../../../src/components/base/select/hooks/use-select-actions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB,CACrC,SAAS,GAAG,OAAO,EACnB,aAAa,GAAG,OAAO;IAEvB;;OAEG;IACH,KAAK,EAAE,aAAa,CAAC;IACrB;;OAEG;IACH,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB;;OAEG;IACH,gBAAgB,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,KAAK,OAAO,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACtC;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACvE;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;I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B,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACrC,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { SelectSearchConfig } from '#components/base/select/hooks/use-select-actions';
|
|
2
|
+
import type { SelectMode, SelectOption, SelectOptionGroup } from '../types';
|
|
3
|
+
export interface SelectFlattenedGroupOption extends Pick<SelectOptionGroup, 'label' | 'key'> {
|
|
4
|
+
/** 是否为分组标题 */
|
|
5
|
+
isGroup?: boolean;
|
|
6
|
+
/** 分组 key */
|
|
7
|
+
groupKey?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 判断选项是否为分组
|
|
11
|
+
*
|
|
12
|
+
* @template ValueType - 选项值的类型
|
|
13
|
+
*/
|
|
14
|
+
export declare const isSelectOptionGroup: <ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>>(item: SelectOption<ValueType> | SelectOptionGroup<OptionType>) => item is SelectOptionGroup<OptionType>;
|
|
15
|
+
export declare function isSelectFlattenedGroupOption<OptionType extends SelectOption>(v: SelectFlattenedGroupOption | OptionType): v is SelectFlattenedGroupOption;
|
|
16
|
+
/**
|
|
17
|
+
* Select 选项处理 Hook 参数
|
|
18
|
+
*
|
|
19
|
+
* @template ValueType - 选项值的类型
|
|
20
|
+
* @template OptionType - 选项类型
|
|
21
|
+
* @template M - 选择模式
|
|
22
|
+
* @template RealValueType - 实际值类型
|
|
23
|
+
*/
|
|
24
|
+
export interface UseSelectOptionsParams<ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>, M extends SelectMode | undefined = undefined, RealValueType = unknown> extends SelectSearchConfig<OptionType> {
|
|
25
|
+
/**
|
|
26
|
+
* 选项列表
|
|
27
|
+
*/
|
|
28
|
+
options: (OptionType | SelectOptionGroup<OptionType>)[];
|
|
29
|
+
/**
|
|
30
|
+
* 当前选中的值
|
|
31
|
+
*/
|
|
32
|
+
value: RealValueType;
|
|
33
|
+
/**
|
|
34
|
+
* 选择模式
|
|
35
|
+
*/
|
|
36
|
+
mode?: M;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Select 选项处理 Hook 返回值
|
|
40
|
+
*
|
|
41
|
+
* @template ValueType - 选项值的类型
|
|
42
|
+
* @template OptionType - 选项类型
|
|
43
|
+
*/
|
|
44
|
+
export interface UseSelectOptionsResult<ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>> {
|
|
45
|
+
/**
|
|
46
|
+
* 扁平化后的选项列表(包含分组标题)
|
|
47
|
+
*/
|
|
48
|
+
flattenedOptions: (OptionType | SelectFlattenedGroupOption)[];
|
|
49
|
+
/**
|
|
50
|
+
* 所有可选项(不包含分组标题)
|
|
51
|
+
*/
|
|
52
|
+
allOptions: SelectOption<ValueType>[];
|
|
53
|
+
/**
|
|
54
|
+
* 过滤后的选项列表
|
|
55
|
+
*/
|
|
56
|
+
filteredOptions: (OptionType | SelectFlattenedGroupOption)[];
|
|
57
|
+
/**
|
|
58
|
+
* 当前选中的选项
|
|
59
|
+
*/
|
|
60
|
+
selectedOptions: OptionType[];
|
|
61
|
+
/**
|
|
62
|
+
* 判断选项是否被选中
|
|
63
|
+
*/
|
|
64
|
+
isOptionSelected: (option: OptionType) => boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Select 选项处理 Hook
|
|
68
|
+
*
|
|
69
|
+
* 封装 Select 组件中与选项相关的逻辑,包括:
|
|
70
|
+
* - 扁平化选项列表
|
|
71
|
+
* - 过滤选项
|
|
72
|
+
* - 获取选中的选项
|
|
73
|
+
* - 判断选项是否被选中
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const {
|
|
77
|
+
* allOptions,
|
|
78
|
+
* filteredOptions,
|
|
79
|
+
* selectedOptions,
|
|
80
|
+
* isOptionSelected
|
|
81
|
+
* } = useSelectOptions({
|
|
82
|
+
* options,
|
|
83
|
+
* value,
|
|
84
|
+
* mode,
|
|
85
|
+
* searchValue,
|
|
86
|
+
* filterOption: true,
|
|
87
|
+
* optionFilterProp: 'label'
|
|
88
|
+
* });
|
|
89
|
+
*/
|
|
90
|
+
export declare const useSelectOptions: <ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>, M extends SelectMode | undefined = undefined, RealValueType = unknown>(params: UseSelectOptionsParams<ValueType, OptionType, M, RealValueType>) => UseSelectOptionsResult<ValueType>;
|
|
91
|
+
//# sourceMappingURL=use-select-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-select-options.d.ts","sourceRoot":"","sources":["../../../../../../src/components/base/select/hooks/use-select-options.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AAE3F,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE5E,MAAM,WAAW,0BACf,SAAQ,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,KAAK,CAAC;IAChD,cAAc;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,SAAS,GAAG,OAAO,EACnB,UAAU,SAAS,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,EAEpE,MAAM,YAAY,CAAC,SAAS,CAAC,GAAG,iBAAiB,CAAC,UAAU,CAAC,KAC5D,IAAI,IAAI,iBAAiB,CAAC,UAAU,CAEtC,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,UAAU,SAAS,YAAY,EAC1E,CAAC,EAAE,0BAA0B,GAAG,UAAU,GACzC,CA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AAU,EAAE,CAAC,EAAE,aAAa,CAAC,KACtE,sBAAsB,CAAC,SAAS,CAqHlC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import { type LayoutRectangle, type View } from 'react-native';
|
|
3
|
+
/**
|
|
4
|
+
* 选择器 Hook 参数
|
|
5
|
+
*/
|
|
6
|
+
export interface UseSelectorParams {
|
|
7
|
+
/**
|
|
8
|
+
* 默认打开状态
|
|
9
|
+
*/
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* 受控的打开状态
|
|
13
|
+
*/
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 是否禁用
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* 打开状态变化回调
|
|
21
|
+
*/
|
|
22
|
+
onOpenChange?: (open: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 选择器 Hook 返回值
|
|
26
|
+
*/
|
|
27
|
+
export interface UseSelectorResult {
|
|
28
|
+
/**
|
|
29
|
+
* 选择器 ref
|
|
30
|
+
*/
|
|
31
|
+
selectorRef: RefObject<View | null>;
|
|
32
|
+
/**
|
|
33
|
+
* 是否打开
|
|
34
|
+
*/
|
|
35
|
+
open: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 选择器布局信息
|
|
38
|
+
*/
|
|
39
|
+
selectorLayout: LayoutRectangle | null;
|
|
40
|
+
/**
|
|
41
|
+
* 是否聚焦
|
|
42
|
+
*/
|
|
43
|
+
isFocused: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* 设置打开状态
|
|
46
|
+
*/
|
|
47
|
+
setOpen: (open: boolean) => void;
|
|
48
|
+
/**
|
|
49
|
+
* 更新选择器位置
|
|
50
|
+
*/
|
|
51
|
+
updateSelectorLayout: () => void;
|
|
52
|
+
/**
|
|
53
|
+
* 处理选择器点击
|
|
54
|
+
*/
|
|
55
|
+
handleSelectorPress: () => void;
|
|
56
|
+
/**
|
|
57
|
+
* 处理选择器布局变化
|
|
58
|
+
*/
|
|
59
|
+
handleSelectorLayout: () => void;
|
|
60
|
+
/**
|
|
61
|
+
* 关闭下拉框
|
|
62
|
+
*/
|
|
63
|
+
closePopup: () => void;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 选择器 Hook
|
|
67
|
+
*
|
|
68
|
+
* 封装 Select 组件中与选择器相关的逻辑,包括:
|
|
69
|
+
* - 选择器 ref 管理
|
|
70
|
+
* - 打开/关闭状态管理
|
|
71
|
+
* - 选择器位置获取
|
|
72
|
+
* - 焦点状态管理
|
|
73
|
+
* - 选择器点击处理
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const {
|
|
77
|
+
* selectorRef,
|
|
78
|
+
* open,
|
|
79
|
+
* selectorLayout,
|
|
80
|
+
* isFocused,
|
|
81
|
+
* handleSelectorPress,
|
|
82
|
+
* handleSelectorLayout
|
|
83
|
+
* } = useSelector({
|
|
84
|
+
* defaultOpen: false,
|
|
85
|
+
* disabled: false,
|
|
86
|
+
* onOpenChange
|
|
87
|
+
* });
|
|
88
|
+
*/
|
|
89
|
+
export declare const useSelector: (params: UseSelectorParams) => UseSelectorResult;
|
|
90
|
+
//# sourceMappingURL=use-selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-selector.d.ts","sourceRoot":"","sources":["../../../../../../src/components/base/select/hooks/use-selector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,EAAE,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACpC;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,cAAc,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACjC;;OAEG;IACH,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;IAChC;;OAEG;IACH,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,iBAAiB,KAAG,iBA8DvD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/base/select/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,mBAAmB,SAAS,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { SelectMode, SelectOption, SelectProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Select 多选内容组件的 Props
|
|
6
|
+
*/
|
|
7
|
+
export interface SelectMultipleContentProps<ValueType> extends Pick<SelectProps<ValueType>, 'maxTagCount' | 'maxTagPlaceholder' | 'maxTagTextLength' | 'tagRender'> {
|
|
8
|
+
/** 选中的选项列表 */
|
|
9
|
+
selectedOptions: SelectOption<ValueType>[];
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
/** 自定义标签渲染 */
|
|
13
|
+
labelRender?: SelectProps<ValueType>['labelRender'];
|
|
14
|
+
/** 占位符样式 */
|
|
15
|
+
placeholderStyle?: StyleProp<TextStyle>;
|
|
16
|
+
/** 输入框样式 */
|
|
17
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
18
|
+
/** 标签项容器样式 */
|
|
19
|
+
tagItemStyle?: StyleProp<ViewStyle>;
|
|
20
|
+
/** 标签文本内容样式 */
|
|
21
|
+
tagContentStyle?: StyleProp<TextStyle>;
|
|
22
|
+
/** 标签删除按钮样式 */
|
|
23
|
+
tagRemoveStyle?: StyleProp<ViewStyle>;
|
|
24
|
+
/** 标签整体容器样式 */
|
|
25
|
+
tagContainerStyle?: StyleProp<ViewStyle>;
|
|
26
|
+
/** 标签关闭事件 */
|
|
27
|
+
onTagClose: (option: SelectOption<ValueType>) => void;
|
|
28
|
+
/** 是否显示搜索输入框 */
|
|
29
|
+
showSearchInput?: boolean;
|
|
30
|
+
/** 搜索值 */
|
|
31
|
+
searchValue?: string;
|
|
32
|
+
/** 搜索值变化回调 */
|
|
33
|
+
onSearchChange?: (value: string) => void;
|
|
34
|
+
/** 占位符文本 */
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
/** 选择模式 */
|
|
37
|
+
mode?: SelectMode;
|
|
38
|
+
/** 创建选项回调 */
|
|
39
|
+
onCreateOption?: (value: string) => void;
|
|
40
|
+
/** 下拉框是否打开 */
|
|
41
|
+
open: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Select 多选内容组件
|
|
45
|
+
*
|
|
46
|
+
* 负责渲染多选模式下的标签列表,包括标签的显示、关闭按钮等功能。
|
|
47
|
+
*
|
|
48
|
+
* @template ValueType - 选项值的类型
|
|
49
|
+
*/
|
|
50
|
+
export declare const SelectMultipleContent: <ValueType = unknown>({ selectedOptions, disabled, maxTagCount, maxTagTextLength, maxTagPlaceholder, tagRender, labelRender, placeholderStyle, inputStyle, tagItemStyle, tagContentStyle, tagRemoveStyle, tagContainerStyle, onTagClose, showSearchInput, searchValue, onSearchChange, placeholder, mode, onCreateOption, open, }: SelectMultipleContentProps<ValueType>) => React.JSX.Element;
|
|
51
|
+
//# sourceMappingURL=select-multiple-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-multiple-content.d.ts","sourceRoot":"","sources":["../../../../../src/components/base/select/select-multiple-content.tsx"],"names":[],"mappings":"AACA,OAAO,KAMN,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,KAAK,SAAS,EACd,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAIrE;;GAEG;AACH,MAAM,WAAW,0BAA0B,CAAC,SAAS,CACnD,SAAQ,IAAI,CACV,WAAW,CAAC,SAAS,CAAC,EACtB,aAAa,GAAG,mBAAmB,GAAG,kBAAkB,GAAG,WAAW,CACvE;IACD,cAAc;IACd,eAAe,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;IAC3C,WAAW;IACX,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc;IACd,WAAW,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC;IACpD,YAAY;IACZ,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,YAAY;IACZ,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC,cAAc;IACd,YAAY,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACpC,eAAe;IACf,eAAe,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACvC,eAAe;IACf,cAAc,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACtC,eAAe;IACf,iBAAiB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACzC,aAAa;IACb,UAAU,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IACtD,gBAAgB;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU;IACV,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc;IACd,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,YAAY;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,aAAa;IACb,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,cAAc;IACd,IAAI,EAAE,OAAO,CAAC;CACf;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,GAAG,OAAO,EAAG,6SAsBzD,0BAA0B,CAAC,SAAS,CAAC,sBAgMvC,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type LayoutRectangle, type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
3
|
+
import { type UseSelectOptionsResult } from '#components/base/select/hooks/use-select-options';
|
|
4
|
+
import type { SelectOption } from './types';
|
|
5
|
+
/** 下拉菜单默认最大高度 */
|
|
6
|
+
export declare const DEFAULT_POPUP_MAX_HEIGHT: 256;
|
|
7
|
+
/**
|
|
8
|
+
* SelectPopup 组件的属性
|
|
9
|
+
*
|
|
10
|
+
* @template ValueType - 选项值的类型
|
|
11
|
+
*/
|
|
12
|
+
export interface SelectPopupProps<ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>> {
|
|
13
|
+
/**
|
|
14
|
+
* 是否展开
|
|
15
|
+
*/
|
|
16
|
+
open: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 选择器布局信息
|
|
19
|
+
*/
|
|
20
|
+
selectorLayout: LayoutRectangle;
|
|
21
|
+
/**
|
|
22
|
+
* 下拉菜单和选择器同宽
|
|
23
|
+
*/
|
|
24
|
+
matchWidth?: boolean | number;
|
|
25
|
+
/**
|
|
26
|
+
* 下拉菜单位置,不指定时自动计算
|
|
27
|
+
*/
|
|
28
|
+
placement?: 'top' | 'bottom';
|
|
29
|
+
/**
|
|
30
|
+
* 加载中状态
|
|
31
|
+
*/
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 下拉列表为空时显示的内容
|
|
35
|
+
*/
|
|
36
|
+
notFoundContent?: React.ReactNode;
|
|
37
|
+
/**
|
|
38
|
+
* 自定义选中项图标
|
|
39
|
+
*/
|
|
40
|
+
selectedIcon?: React.ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* 自定义渲染下拉选项
|
|
43
|
+
*/
|
|
44
|
+
optionRender?: (option: OptionType, info: {
|
|
45
|
+
index: number;
|
|
46
|
+
selected: boolean;
|
|
47
|
+
}) => React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* 下拉菜单最大高度
|
|
50
|
+
* @default {@link DEFAULT_POPUP_MAX_HEIGHT}
|
|
51
|
+
*/
|
|
52
|
+
popupMaxHeight?: number;
|
|
53
|
+
/**
|
|
54
|
+
* 过滤后的选项列表
|
|
55
|
+
*/
|
|
56
|
+
filteredOptions: UseSelectOptionsResult<ValueType, OptionType>['filteredOptions'];
|
|
57
|
+
/**
|
|
58
|
+
* 搜索值
|
|
59
|
+
*/
|
|
60
|
+
searchValue: string;
|
|
61
|
+
/**
|
|
62
|
+
* 选择模式
|
|
63
|
+
*/
|
|
64
|
+
mode?: 'multiple' | 'tags';
|
|
65
|
+
/**
|
|
66
|
+
* 自定义样式
|
|
67
|
+
*/
|
|
68
|
+
popupRootStyle?: StyleProp<ViewStyle>;
|
|
69
|
+
/**
|
|
70
|
+
* 弹出菜单列表样式
|
|
71
|
+
*/
|
|
72
|
+
popupListStyle?: StyleProp<ViewStyle>;
|
|
73
|
+
/**
|
|
74
|
+
* 弹出菜单条目样式
|
|
75
|
+
*/
|
|
76
|
+
popupListItemStyle?: StyleProp<ViewStyle>;
|
|
77
|
+
/**
|
|
78
|
+
* 分组标签样式
|
|
79
|
+
*/
|
|
80
|
+
popupGroupLabelStyle?: StyleProp<TextStyle>;
|
|
81
|
+
/**
|
|
82
|
+
* 自定义下拉框内容
|
|
83
|
+
*/
|
|
84
|
+
popupRender?: (originNode: React.ReactNode) => React.ReactNode;
|
|
85
|
+
/**
|
|
86
|
+
* 判断选项是否被选中
|
|
87
|
+
*/
|
|
88
|
+
isOptionSelected: (option: OptionType) => boolean;
|
|
89
|
+
/**
|
|
90
|
+
* 关闭回调
|
|
91
|
+
*/
|
|
92
|
+
onClose: () => void;
|
|
93
|
+
/**
|
|
94
|
+
* 选项点击回调
|
|
95
|
+
*/
|
|
96
|
+
onOptionPress: (option: OptionType) => void;
|
|
97
|
+
/**
|
|
98
|
+
* 创建选项回调
|
|
99
|
+
*/
|
|
100
|
+
onCreateOption: () => void;
|
|
101
|
+
/**
|
|
102
|
+
* 下拉列表滚动时回调
|
|
103
|
+
*/
|
|
104
|
+
onPopupScroll?: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
|
|
105
|
+
}
|
|
106
|
+
export declare const SelectPopup: <ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>>({ open, selectorLayout, matchWidth, placement: forcedPlacement, popupMaxHeight, loading, filteredOptions, notFoundContent, searchValue, mode, popupRootStyle, popupListStyle, popupListItemStyle, popupGroupLabelStyle, selectedIcon, optionRender, popupRender, isOptionSelected, onClose, onOptionPress, onCreateOption, onPopupScroll, }: SelectPopupProps<ValueType, OptionType>) => React.JSX.Element | null;
|
|
107
|
+
//# sourceMappingURL=select-popup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-popup.d.ts","sourceRoot":"","sources":["../../../../../src/components/base/select/select-popup.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAKL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAEzB,KAAK,SAAS,EACd,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,kDAAkD,CAAC;AAI1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,iBAAiB;AACjB,eAAO,MAAM,wBAAwB,EAAG,GAAY,CAAC;AAErD;;;;GAIG;AACH,MAAM,WAAW,gBAAgB,CAC/B,SAAS,GAAG,OAAO,EACnB,UAAU,SAAS,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC;IAEpE;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,cAAc,EAAE,eAAe,CAAC;IAChC;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B;;OAEG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC;;OAEG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC/B;;OAEG;IACH,YAAY,CAAC,EAAE,CACb,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,KACvC,KAAK,CAAC,SAAS,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MA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electProps } from '#components/base';
|
|
4
|
+
import type { SelectMode, SelectOption } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Select 单选内容组件的 Props
|
|
7
|
+
*
|
|
8
|
+
* @template ValueType - 选项值的类型
|
|
9
|
+
*/
|
|
10
|
+
export interface SelectSingleContentProps<ValueType> {
|
|
11
|
+
/** 选中的选项 */
|
|
12
|
+
selectedOption?: SelectOption<ValueType>;
|
|
13
|
+
/** 自定义标签渲染函数 */
|
|
14
|
+
labelRender?: SelectProps<ValueType>['labelRender'];
|
|
15
|
+
/** 是否显示搜索输入框 */
|
|
16
|
+
showSearchInput?: boolean;
|
|
17
|
+
/** 当前搜索值 */
|
|
18
|
+
searchValue?: string;
|
|
19
|
+
/** 搜索值变化回调函数 */
|
|
20
|
+
onSearchChange?: (value: string) => void;
|
|
21
|
+
/** 占位符文本 */
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
/** 选择模式 */
|
|
24
|
+
mode?: SelectMode;
|
|
25
|
+
/** 创建新选项的回调函数 */
|
|
26
|
+
onCreateOption?: (value: string) => void;
|
|
27
|
+
/** 占位符样式 */
|
|
28
|
+
placeholderStyle?: StyleProp<TextStyle>;
|
|
29
|
+
/** 输入框样式 */
|
|
30
|
+
inputStyle?: StyleProp<TextStyle>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Select 单选内容组件
|
|
34
|
+
*
|
|
35
|
+
* 负责渲染单选模式下的选中值显示,支持占位符、自定义渲染和搜索输入。
|
|
36
|
+
*
|
|
37
|
+
* @template ValueType - 选项值的类型
|
|
38
|
+
* @param props - 组件属性
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* <SelectSingleContent
|
|
42
|
+
* selectedOption={{ label: '选项1', value: 1 }}
|
|
43
|
+
* placeholder="请选择"
|
|
44
|
+
* styles={styles}
|
|
45
|
+
* />
|
|
46
|
+
*/
|
|
47
|
+
export declare const SelectSingleContent: <ValueType = unknown>({ selectedOption, labelRender, showSearchInput, searchValue, onSearchChange, placeholder, mode, onCreateOption, placeholderStyle, inputStyle, }: SelectSingleContentProps<ValueType>) => React.JSX.Element;
|
|
48
|
+
//# sourceMappingURL=select-single-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-single-content.d.ts","sourceRoot":"","sources":["../../../../../src/components/base/select/select-single-content.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAS,KAAK,WAAW,EAAQ,MAAM,kBAAkB,CAAC;AAIjE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,wBAAwB,CAAC,SAAS;IACjD,YAAY;IACZ,cAAc,CAAC,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACzC,gBAAgB;IAChB,WAAW,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAC;IACpD,gBAAgB;IAChB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB;IAChB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,YAAY;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW;IACX,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,iBAAiB;IACjB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,YAAY;IACZ,gBAAgB,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACxC,YAAY;IACZ,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,GAAI,SAAS,GAAG,OAAO,EAAG,iJAWvD,wBAAwB,CAAC,SAAS,CAAC,sBA+DrC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type GestureResponderEvent, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import type { SelectProps } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* SelectSuffix 组件的属性
|
|
6
|
+
*/
|
|
7
|
+
export interface SelectSuffixProps {
|
|
8
|
+
/**
|
|
9
|
+
* 是否显示清除按钮
|
|
10
|
+
*/
|
|
11
|
+
showClearButton: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 是否允许清除
|
|
14
|
+
*/
|
|
15
|
+
allowClear?: SelectProps['allowClear'];
|
|
16
|
+
/**
|
|
17
|
+
* 是否打开下拉框
|
|
18
|
+
*/
|
|
19
|
+
open: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* 自定义后缀图标
|
|
22
|
+
*/
|
|
23
|
+
suffixIcon?: SelectProps['suffixIcon'];
|
|
24
|
+
/**
|
|
25
|
+
* 后缀元素样式
|
|
26
|
+
*/
|
|
27
|
+
suffixStyle?: StyleProp<ViewStyle>;
|
|
28
|
+
/**
|
|
29
|
+
* 清除按钮样式
|
|
30
|
+
*/
|
|
31
|
+
clearStyle?: StyleProp<ViewStyle>;
|
|
32
|
+
/**
|
|
33
|
+
* 清除按钮点击回调
|
|
34
|
+
*/
|
|
35
|
+
onClear: (e: GestureResponderEvent) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Select 后缀区域组件
|
|
39
|
+
*
|
|
40
|
+
* 包含清除按钮和下拉箭头图标
|
|
41
|
+
*/
|
|
42
|
+
export declare const SelectSuffix: React.FC<SelectSuffixProps>;
|
|
43
|
+
//# sourceMappingURL=select-suffix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-suffix.d.ts","sourceRoot":"","sources":["../../../../../src/components/base/select/select-suffix.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,KAAK,qBAAqB,EAE1B,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACvC;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACvC;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnC;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClC;;OAEG;IACH,OAAO,EAAE,CAAC,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAC7C;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA6CpD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { SelectMode, SelectOption, SelectProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Select 选择器组件
|
|
5
|
+
*
|
|
6
|
+
* 支持单选、多选和标签模式,提供搜索、清除、自定义渲染等功能。
|
|
7
|
+
*
|
|
8
|
+
* @template ValueType - 选项值的类型
|
|
9
|
+
* @template M - 选择模式,可以是 'multiple' | 'tags' | undefined
|
|
10
|
+
*
|
|
11
|
+
* @param props - 组件属性
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // 单选模式
|
|
15
|
+
* <Select
|
|
16
|
+
* options={[{ label: '选项1', value: 1 }]}
|
|
17
|
+
* placeholder="请选择"
|
|
18
|
+
* onChange={value => console.log(value)}
|
|
19
|
+
* />
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // 多选模式
|
|
23
|
+
* <Select
|
|
24
|
+
* mode="multiple"
|
|
25
|
+
* options={options}
|
|
26
|
+
* value={[1, 2]}
|
|
27
|
+
* onChange={values => console.log(values)}
|
|
28
|
+
* />
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* // 标签模式(支持创建新选项)
|
|
32
|
+
* <Select
|
|
33
|
+
* mode="tags"
|
|
34
|
+
* options={options}
|
|
35
|
+
* showSearch
|
|
36
|
+
* onChange={values => console.log(values)}
|
|
37
|
+
* />
|
|
38
|
+
*/
|
|
39
|
+
export declare const Select: <ValueType = unknown, OptionType extends SelectOption<ValueType> = SelectOption<ValueType>, M extends SelectMode | undefined = undefined, RealValueType extends M extends SelectMode ? ValueType[] : ValueType = M extends SelectMode ? ValueType[] : ValueType>(props: SelectProps<ValueType, OptionType, M, RealValueType>) => React.JSX.Element;
|
|
40
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../../src/components/base/select/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,eAAO,MAAM,MAAM,GACjB,SAAS,GAAG,OAAO,EACnB,UAAU,SAAS,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,EACpE,CAAC,SAAS,UAAU,GAAG,SAAS,GAAG,SAAS,EAC5C,aAAa,SAAS,CAAC,SAAS,UAAU,GACtC,SAAS,EAAE,GACX,SAAS,GAAG,CAAC,SAAS,UAAU,GAAG,SAAS,EAAE,GAAG,SAAS,EAE9D,OAAO,WAAW,CAAC,SAAS,EAAE,UAAU,EAAE,CAAC,EAAE,aAAa,CAAC,sBAkP5D,CAAC"}
|