@akinon/ui-select 0.5.0 → 1.0.1
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/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +52 -1
- package/dist/cjs/types.d.ts +187 -1
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +53 -2
- package/dist/esm/types.d.ts +187 -1
- package/package.json +5 -4
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { SelectProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Select component for Akinon UI.
|
|
5
|
+
*
|
|
6
|
+
* This component provides a versatile dropdown input for selecting options.
|
|
7
|
+
* It supports single or multiple selection modes, search functionality,
|
|
8
|
+
* custom rendering for options and labels, and advanced accessibility features.
|
|
9
|
+
*
|
|
10
|
+
* The Select component adheres to the Akinon design system, ensuring consistent
|
|
11
|
+
* styling and behavior. It is highly customizable and suitable for use in forms,
|
|
12
|
+
* filters, and other selection scenarios.
|
|
13
|
+
*/
|
|
3
14
|
export declare const Select: ({ ...restSelectProps }: SelectProps) => React.JSX.Element;
|
|
4
15
|
export type * from './types';
|
|
5
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,MAAM,2BAA4B,WAAW,sBA0DzD,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,10 +12,61 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Select = void 0;
|
|
15
|
+
const ui_theme_1 = require("@akinon/ui-theme");
|
|
16
|
+
const cssinjs_1 = require("@ant-design/cssinjs");
|
|
15
17
|
const antd_1 = require("antd");
|
|
16
18
|
const React = require("react");
|
|
19
|
+
/**
|
|
20
|
+
* Select component for Akinon UI.
|
|
21
|
+
*
|
|
22
|
+
* This component provides a versatile dropdown input for selecting options.
|
|
23
|
+
* It supports single or multiple selection modes, search functionality,
|
|
24
|
+
* custom rendering for options and labels, and advanced accessibility features.
|
|
25
|
+
*
|
|
26
|
+
* The Select component adheres to the Akinon design system, ensuring consistent
|
|
27
|
+
* styling and behavior. It is highly customizable and suitable for use in forms,
|
|
28
|
+
* filters, and other selection scenarios.
|
|
29
|
+
*/
|
|
17
30
|
const Select = (_a) => {
|
|
18
31
|
var restSelectProps = __rest(_a, []);
|
|
19
|
-
|
|
32
|
+
const { getPrefixCls, theme } = React.useContext(antd_1.ConfigProvider.ConfigContext);
|
|
33
|
+
const { token, hashId } = (0, ui_theme_1.useToken)();
|
|
34
|
+
const selectToken = token.Select;
|
|
35
|
+
const selectPrefixCls = `${getPrefixCls()}-select`;
|
|
36
|
+
const dropdownPrefixCls = `${selectPrefixCls}-dropdown`;
|
|
37
|
+
const dropdownPrefixClsWithHash = `:where(.${hashId}).${dropdownPrefixCls}`;
|
|
38
|
+
const useStyle = (0, cssinjs_1.useStyleRegister)({
|
|
39
|
+
token: token,
|
|
40
|
+
path: ['Select'],
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
theme: theme
|
|
43
|
+
}, () => {
|
|
44
|
+
return {
|
|
45
|
+
[`${dropdownPrefixClsWithHash}`]: {
|
|
46
|
+
'&.akinon-select-dropdown': {
|
|
47
|
+
[`.${selectPrefixCls}-item`]: {
|
|
48
|
+
boxShadow: `inset 0 -1px 0 0 ${selectToken.selectItemBorderShadowColor}, inset 0 1px 0 0 ${selectToken.selectItemBorderShadowColor}`,
|
|
49
|
+
'&:nth-child(even)': {
|
|
50
|
+
backgroundColor: selectToken.selectItemBgColor,
|
|
51
|
+
[`&.${selectPrefixCls}-item-option-selected`]: {
|
|
52
|
+
backgroundColor: selectToken === null || selectToken === void 0 ? void 0 : selectToken.optionActiveBg
|
|
53
|
+
},
|
|
54
|
+
'&:hover': {
|
|
55
|
+
backgroundColor: selectToken.selectItemHoverBgColor
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
[`.${selectPrefixCls}-item-option-selected`]: {
|
|
60
|
+
backgroundColor: selectToken === null || selectToken === void 0 ? void 0 : selectToken.optionActiveBg,
|
|
61
|
+
color: selectToken.selectedOptionColor,
|
|
62
|
+
'&:hover': {
|
|
63
|
+
backgroundColor: selectToken === null || selectToken === void 0 ? void 0 : selectToken.optionActiveBg
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
return useStyle(React.createElement(antd_1.Select, Object.assign({ size: "large", popupMatchSelectWidth: true }, restSelectProps)));
|
|
20
71
|
};
|
|
21
72
|
exports.Select = Select;
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -1,67 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base option type for Select components.
|
|
3
|
+
*/
|
|
1
4
|
export interface BaseOptionType {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the option is disabled.
|
|
7
|
+
*/
|
|
2
8
|
disabled?: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Additional CSS class for the option.
|
|
12
|
+
*/
|
|
3
13
|
className?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Descriptive title for the option.
|
|
17
|
+
*/
|
|
4
18
|
title?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Additional custom properties for the option.
|
|
22
|
+
*/
|
|
5
23
|
[name: string]: unknown;
|
|
6
24
|
}
|
|
7
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Default option type with additional attributes.
|
|
28
|
+
*/
|
|
8
29
|
export interface DefaultOptionType extends BaseOptionType {
|
|
30
|
+
/**
|
|
31
|
+
* The label displayed for the option.
|
|
32
|
+
*/
|
|
9
33
|
label?: React.ReactNode;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The value associated with the option.
|
|
37
|
+
*/
|
|
10
38
|
value?: string | number | null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Nested child options for hierarchical structures.
|
|
42
|
+
*/
|
|
11
43
|
children?: Omit<DefaultOptionType, 'children'>[];
|
|
12
44
|
}
|
|
13
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Generic handler type for select events.
|
|
48
|
+
* @param value - The selected value.
|
|
49
|
+
* @param option - The corresponding option.
|
|
50
|
+
*/
|
|
14
51
|
export type SelectHandler<ValueType, OptionType> = (
|
|
15
52
|
value: ValueType,
|
|
16
53
|
option: OptionType
|
|
17
54
|
) => void;
|
|
18
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Extracts the element type from an array type.
|
|
58
|
+
*/
|
|
19
59
|
export type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
|
20
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Props for the Select component.
|
|
63
|
+
*/
|
|
21
64
|
export interface SelectProps<
|
|
22
65
|
ValueType = string | number | boolean,
|
|
23
66
|
OptionType extends BaseOptionType = DefaultOptionType
|
|
24
67
|
> extends BaseSelectPropsWithoutPrivate {
|
|
68
|
+
/**
|
|
69
|
+
* Placeholder text displayed when no value is selected.
|
|
70
|
+
*/
|
|
25
71
|
placeholder?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether to show a clear button to remove the selection.
|
|
75
|
+
*/
|
|
26
76
|
allowClear?: boolean;
|
|
27
|
-
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Unique identifier for the select component.
|
|
80
|
+
*/
|
|
28
81
|
id?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Custom field names for options.
|
|
85
|
+
*/
|
|
29
86
|
fieldNames?: FieldNames;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Current search value for the options.
|
|
90
|
+
*/
|
|
30
91
|
searchValue?: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Callback triggered when the search value changes.
|
|
95
|
+
* @param value - The current search value.
|
|
96
|
+
*/
|
|
31
97
|
onSearch?: (value: string) => void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether to clear the search value after selection.
|
|
101
|
+
*/
|
|
32
102
|
autoClearSearchValue?: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether the popup width matches the select width.
|
|
106
|
+
*/
|
|
107
|
+
popupMatchSelectWidth?: boolean | number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Callback triggered when an option is selected.
|
|
111
|
+
*/
|
|
33
112
|
onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Callback triggered when an option is deselected.
|
|
116
|
+
*/
|
|
34
117
|
onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Custom filter function for options.
|
|
121
|
+
*/
|
|
35
122
|
filterOption?: boolean | FilterFunc<OptionType>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Custom sorting function for options.
|
|
126
|
+
*/
|
|
36
127
|
filterSort?: (optionA: OptionType, optionB: OptionType) => number;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The property used for option filtering.
|
|
131
|
+
*/
|
|
37
132
|
optionFilterProp?: string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The property used for option labeling.
|
|
136
|
+
*/
|
|
38
137
|
optionLabelProp?: string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Size of the select input.
|
|
141
|
+
*/
|
|
39
142
|
size?: 'small' | 'middle' | 'large';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether the select is in a loading state.
|
|
146
|
+
*/
|
|
147
|
+
loading?: boolean;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* List of options for the select component.
|
|
151
|
+
*/
|
|
40
152
|
options?: OptionType[];
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Custom render function for options.
|
|
156
|
+
*/
|
|
41
157
|
optionRender?: (
|
|
42
158
|
oriOption: FlattenOptionData<BaseOptionType>,
|
|
43
159
|
info: {
|
|
44
160
|
index: number;
|
|
45
161
|
}
|
|
46
162
|
) => React.ReactNode;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Whether to make the first option active by default.
|
|
166
|
+
*/
|
|
47
167
|
defaultActiveFirstOption?: boolean;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Whether to enable virtual scrolling for options.
|
|
171
|
+
*/
|
|
48
172
|
virtual?: boolean;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Text direction of the select component.
|
|
176
|
+
*/
|
|
49
177
|
direction?: 'ltr' | 'rtl';
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Height of the options list.
|
|
181
|
+
*/
|
|
50
182
|
listHeight?: number;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Height of individual list items.
|
|
186
|
+
*/
|
|
51
187
|
listItemHeight?: number;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Custom render function for the selected label.
|
|
191
|
+
*/
|
|
52
192
|
labelRender?: (props: LabelInValueType) => React.ReactNode;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Custom icon for selected menu items.
|
|
196
|
+
*/
|
|
53
197
|
menuItemSelectedIcon?: RenderNode;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The mode of the select component (e.g., combobox, multiple, or tags).
|
|
201
|
+
*/
|
|
54
202
|
mode?: 'combobox' | 'multiple' | 'tags';
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Whether the value includes label information.
|
|
206
|
+
*/
|
|
55
207
|
labelInValue?: boolean;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The current value of the select component.
|
|
211
|
+
*/
|
|
56
212
|
value?: ValueType | null;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The default value of the select component.
|
|
216
|
+
*/
|
|
57
217
|
defaultValue?: ValueType | null;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Maximum number of selected items.
|
|
221
|
+
*/
|
|
58
222
|
maxCount?: number;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Callback triggered when the value changes.
|
|
226
|
+
*/
|
|
59
227
|
onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Additional CSS class for the root element.
|
|
231
|
+
*/
|
|
60
232
|
rootClassName?: string;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Icon displayed as the suffix for the select input.
|
|
236
|
+
*/
|
|
61
237
|
suffixIcon?: React.ReactNode;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Whether the select is disabled.
|
|
241
|
+
*/
|
|
62
242
|
disabled?: boolean;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Whether to show the dropdown arrow.
|
|
246
|
+
*/
|
|
63
247
|
showArrow?: boolean;
|
|
248
|
+
|
|
64
249
|
/**
|
|
250
|
+
* Style variant of the select component.
|
|
65
251
|
* @default "outlined"
|
|
66
252
|
*/
|
|
67
253
|
variant?: 'outlined' | 'borderless' | 'filled';
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { SelectProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Select component for Akinon UI.
|
|
5
|
+
*
|
|
6
|
+
* This component provides a versatile dropdown input for selecting options.
|
|
7
|
+
* It supports single or multiple selection modes, search functionality,
|
|
8
|
+
* custom rendering for options and labels, and advanced accessibility features.
|
|
9
|
+
*
|
|
10
|
+
* The Select component adheres to the Akinon design system, ensuring consistent
|
|
11
|
+
* styling and behavior. It is highly customizable and suitable for use in forms,
|
|
12
|
+
* filters, and other selection scenarios.
|
|
13
|
+
*/
|
|
3
14
|
export declare const Select: ({ ...restSelectProps }: SelectProps) => React.JSX.Element;
|
|
4
15
|
export type * from './types';
|
|
5
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,MAAM,2BAA4B,WAAW,sBA0DzD,CAAC;AAEF,mBAAmB,SAAS,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -9,9 +9,60 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import {
|
|
12
|
+
import { useToken } from '@akinon/ui-theme';
|
|
13
|
+
import { useStyleRegister } from '@ant-design/cssinjs';
|
|
14
|
+
import { ConfigProvider, Select as AntSelect } from 'antd';
|
|
13
15
|
import * as React from 'react';
|
|
16
|
+
/**
|
|
17
|
+
* Select component for Akinon UI.
|
|
18
|
+
*
|
|
19
|
+
* This component provides a versatile dropdown input for selecting options.
|
|
20
|
+
* It supports single or multiple selection modes, search functionality,
|
|
21
|
+
* custom rendering for options and labels, and advanced accessibility features.
|
|
22
|
+
*
|
|
23
|
+
* The Select component adheres to the Akinon design system, ensuring consistent
|
|
24
|
+
* styling and behavior. It is highly customizable and suitable for use in forms,
|
|
25
|
+
* filters, and other selection scenarios.
|
|
26
|
+
*/
|
|
14
27
|
export const Select = (_a) => {
|
|
15
28
|
var restSelectProps = __rest(_a, []);
|
|
16
|
-
|
|
29
|
+
const { getPrefixCls, theme } = React.useContext(ConfigProvider.ConfigContext);
|
|
30
|
+
const { token, hashId } = useToken();
|
|
31
|
+
const selectToken = token.Select;
|
|
32
|
+
const selectPrefixCls = `${getPrefixCls()}-select`;
|
|
33
|
+
const dropdownPrefixCls = `${selectPrefixCls}-dropdown`;
|
|
34
|
+
const dropdownPrefixClsWithHash = `:where(.${hashId}).${dropdownPrefixCls}`;
|
|
35
|
+
const useStyle = useStyleRegister({
|
|
36
|
+
token: token,
|
|
37
|
+
path: ['Select'],
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
theme: theme
|
|
40
|
+
}, () => {
|
|
41
|
+
return {
|
|
42
|
+
[`${dropdownPrefixClsWithHash}`]: {
|
|
43
|
+
'&.akinon-select-dropdown': {
|
|
44
|
+
[`.${selectPrefixCls}-item`]: {
|
|
45
|
+
boxShadow: `inset 0 -1px 0 0 ${selectToken.selectItemBorderShadowColor}, inset 0 1px 0 0 ${selectToken.selectItemBorderShadowColor}`,
|
|
46
|
+
'&:nth-child(even)': {
|
|
47
|
+
backgroundColor: selectToken.selectItemBgColor,
|
|
48
|
+
[`&.${selectPrefixCls}-item-option-selected`]: {
|
|
49
|
+
backgroundColor: selectToken === null || selectToken === void 0 ? void 0 : selectToken.optionActiveBg
|
|
50
|
+
},
|
|
51
|
+
'&:hover': {
|
|
52
|
+
backgroundColor: selectToken.selectItemHoverBgColor
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
[`.${selectPrefixCls}-item-option-selected`]: {
|
|
57
|
+
backgroundColor: selectToken === null || selectToken === void 0 ? void 0 : selectToken.optionActiveBg,
|
|
58
|
+
color: selectToken.selectedOptionColor,
|
|
59
|
+
'&:hover': {
|
|
60
|
+
backgroundColor: selectToken === null || selectToken === void 0 ? void 0 : selectToken.optionActiveBg
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
return useStyle(React.createElement(AntSelect, Object.assign({ size: "large", popupMatchSelectWidth: true }, restSelectProps)));
|
|
17
68
|
};
|
package/dist/esm/types.d.ts
CHANGED
|
@@ -1,67 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base option type for Select components.
|
|
3
|
+
*/
|
|
1
4
|
export interface BaseOptionType {
|
|
5
|
+
/**
|
|
6
|
+
* Whether the option is disabled.
|
|
7
|
+
*/
|
|
2
8
|
disabled?: boolean;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Additional CSS class for the option.
|
|
12
|
+
*/
|
|
3
13
|
className?: string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Descriptive title for the option.
|
|
17
|
+
*/
|
|
4
18
|
title?: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Additional custom properties for the option.
|
|
22
|
+
*/
|
|
5
23
|
[name: string]: unknown;
|
|
6
24
|
}
|
|
7
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Default option type with additional attributes.
|
|
28
|
+
*/
|
|
8
29
|
export interface DefaultOptionType extends BaseOptionType {
|
|
30
|
+
/**
|
|
31
|
+
* The label displayed for the option.
|
|
32
|
+
*/
|
|
9
33
|
label?: React.ReactNode;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The value associated with the option.
|
|
37
|
+
*/
|
|
10
38
|
value?: string | number | null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Nested child options for hierarchical structures.
|
|
42
|
+
*/
|
|
11
43
|
children?: Omit<DefaultOptionType, 'children'>[];
|
|
12
44
|
}
|
|
13
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Generic handler type for select events.
|
|
48
|
+
* @param value - The selected value.
|
|
49
|
+
* @param option - The corresponding option.
|
|
50
|
+
*/
|
|
14
51
|
export type SelectHandler<ValueType, OptionType> = (
|
|
15
52
|
value: ValueType,
|
|
16
53
|
option: OptionType
|
|
17
54
|
) => void;
|
|
18
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Extracts the element type from an array type.
|
|
58
|
+
*/
|
|
19
59
|
export type ArrayElementType<T> = T extends (infer E)[] ? E : T;
|
|
20
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Props for the Select component.
|
|
63
|
+
*/
|
|
21
64
|
export interface SelectProps<
|
|
22
65
|
ValueType = string | number | boolean,
|
|
23
66
|
OptionType extends BaseOptionType = DefaultOptionType
|
|
24
67
|
> extends BaseSelectPropsWithoutPrivate {
|
|
68
|
+
/**
|
|
69
|
+
* Placeholder text displayed when no value is selected.
|
|
70
|
+
*/
|
|
25
71
|
placeholder?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether to show a clear button to remove the selection.
|
|
75
|
+
*/
|
|
26
76
|
allowClear?: boolean;
|
|
27
|
-
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Unique identifier for the select component.
|
|
80
|
+
*/
|
|
28
81
|
id?: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Custom field names for options.
|
|
85
|
+
*/
|
|
29
86
|
fieldNames?: FieldNames;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Current search value for the options.
|
|
90
|
+
*/
|
|
30
91
|
searchValue?: string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Callback triggered when the search value changes.
|
|
95
|
+
* @param value - The current search value.
|
|
96
|
+
*/
|
|
31
97
|
onSearch?: (value: string) => void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether to clear the search value after selection.
|
|
101
|
+
*/
|
|
32
102
|
autoClearSearchValue?: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Whether the popup width matches the select width.
|
|
106
|
+
*/
|
|
107
|
+
popupMatchSelectWidth?: boolean | number;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Callback triggered when an option is selected.
|
|
111
|
+
*/
|
|
33
112
|
onSelect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Callback triggered when an option is deselected.
|
|
116
|
+
*/
|
|
34
117
|
onDeselect?: SelectHandler<ArrayElementType<ValueType>, OptionType>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Custom filter function for options.
|
|
121
|
+
*/
|
|
35
122
|
filterOption?: boolean | FilterFunc<OptionType>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Custom sorting function for options.
|
|
126
|
+
*/
|
|
36
127
|
filterSort?: (optionA: OptionType, optionB: OptionType) => number;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The property used for option filtering.
|
|
131
|
+
*/
|
|
37
132
|
optionFilterProp?: string;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The property used for option labeling.
|
|
136
|
+
*/
|
|
38
137
|
optionLabelProp?: string;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Size of the select input.
|
|
141
|
+
*/
|
|
39
142
|
size?: 'small' | 'middle' | 'large';
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether the select is in a loading state.
|
|
146
|
+
*/
|
|
147
|
+
loading?: boolean;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* List of options for the select component.
|
|
151
|
+
*/
|
|
40
152
|
options?: OptionType[];
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Custom render function for options.
|
|
156
|
+
*/
|
|
41
157
|
optionRender?: (
|
|
42
158
|
oriOption: FlattenOptionData<BaseOptionType>,
|
|
43
159
|
info: {
|
|
44
160
|
index: number;
|
|
45
161
|
}
|
|
46
162
|
) => React.ReactNode;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Whether to make the first option active by default.
|
|
166
|
+
*/
|
|
47
167
|
defaultActiveFirstOption?: boolean;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Whether to enable virtual scrolling for options.
|
|
171
|
+
*/
|
|
48
172
|
virtual?: boolean;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Text direction of the select component.
|
|
176
|
+
*/
|
|
49
177
|
direction?: 'ltr' | 'rtl';
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Height of the options list.
|
|
181
|
+
*/
|
|
50
182
|
listHeight?: number;
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Height of individual list items.
|
|
186
|
+
*/
|
|
51
187
|
listItemHeight?: number;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Custom render function for the selected label.
|
|
191
|
+
*/
|
|
52
192
|
labelRender?: (props: LabelInValueType) => React.ReactNode;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Custom icon for selected menu items.
|
|
196
|
+
*/
|
|
53
197
|
menuItemSelectedIcon?: RenderNode;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* The mode of the select component (e.g., combobox, multiple, or tags).
|
|
201
|
+
*/
|
|
54
202
|
mode?: 'combobox' | 'multiple' | 'tags';
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Whether the value includes label information.
|
|
206
|
+
*/
|
|
55
207
|
labelInValue?: boolean;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* The current value of the select component.
|
|
211
|
+
*/
|
|
56
212
|
value?: ValueType | null;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The default value of the select component.
|
|
216
|
+
*/
|
|
57
217
|
defaultValue?: ValueType | null;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Maximum number of selected items.
|
|
221
|
+
*/
|
|
58
222
|
maxCount?: number;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Callback triggered when the value changes.
|
|
226
|
+
*/
|
|
59
227
|
onChange?: (value: ValueType, option?: OptionType | OptionType[]) => void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Additional CSS class for the root element.
|
|
231
|
+
*/
|
|
60
232
|
rootClassName?: string;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Icon displayed as the suffix for the select input.
|
|
236
|
+
*/
|
|
61
237
|
suffixIcon?: React.ReactNode;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Whether the select is disabled.
|
|
241
|
+
*/
|
|
62
242
|
disabled?: boolean;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Whether to show the dropdown arrow.
|
|
246
|
+
*/
|
|
63
247
|
showArrow?: boolean;
|
|
248
|
+
|
|
64
249
|
/**
|
|
250
|
+
* Style variant of the select component.
|
|
65
251
|
* @default "outlined"
|
|
66
252
|
*/
|
|
67
253
|
variant?: 'outlined' | 'borderless' | 'filled';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/ui-select",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
@@ -9,14 +9,15 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"antd": "5.
|
|
12
|
+
"antd": "5.22.6"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"clean-package": "2.2.0",
|
|
16
16
|
"copyfiles": "^2.4.1",
|
|
17
17
|
"rimraf": "^5.0.5",
|
|
18
|
-
"typescript": "
|
|
19
|
-
"@akinon/typescript-config": "0.
|
|
18
|
+
"typescript": "*",
|
|
19
|
+
"@akinon/typescript-config": "1.0.1",
|
|
20
|
+
"@akinon/ui-theme": "1.0.1"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"react": ">=18",
|