Skip to content

Commit b8022e1

Browse files
authored
fix(SelectInput): improve TSelectInputProps and TSelectFieldProps types (#3073)
* fix: wrong TSelectInputProps types * fix: wrong TSelectFieldProps types * chore: add changeset
1 parent 38e22cb commit b8022e1

File tree

3 files changed

+60
-61
lines changed

3 files changed

+60
-61
lines changed

.changeset/twenty-dots-kiss.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@commercetools-uikit/select-field': patch
3+
'@commercetools-uikit/select-input': patch
4+
---
5+
6+
Improve TSelectInputProps and TSelectFieldProps types

packages/components/fields/select-field/src/select-field.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export type TOptionObject = {
3131
export type TOptions = TOption[] | TOptionObject[];
3232
export type TCustomEvent = {
3333
target: {
34-
id?: ReactSelectProps['inputId'];
35-
name?: ReactSelectProps['name'];
34+
id?: ReactSelectProps<TOption>['inputId'];
35+
name?: ReactSelectProps<TOption>['name'];
3636
value?: string | string[] | null;
3737
};
3838
persist: () => void;
@@ -111,13 +111,13 @@ export type TSelectFieldProps = {
111111
* <br/>
112112
* [Props from React select was used](https://react-select.com/props)
113113
*/
114-
'aria-label'?: ReactSelectProps['aria-label'];
114+
'aria-label'?: ReactSelectProps<TOption>['aria-label'];
115115
/**
116116
* HTML ID of an element that should be used as the label (for assistive tech)
117117
* <br/>
118118
* [Props from React select was used](https://react-select.com/props)
119119
*/
120-
'aria-labelledby'?: ReactSelectProps['aria-labelledby'];
120+
'aria-labelledby'?: ReactSelectProps<TOption>['aria-labelledby'];
121121
/**
122122
* Focus the control when it is mounted
123123
*/
@@ -131,19 +131,19 @@ export type TSelectFieldProps = {
131131
* <br/>
132132
* [Props from React select was used](https://react-select.com/props)
133133
*/
134-
components?: ReactSelectProps['components'];
134+
components?: ReactSelectProps<TOption>['components'];
135135
/**
136136
* Control whether the selected values should be rendered in the control
137137
* <br>
138138
* [Props from React select was used](https://react-select.com/props)
139139
*/
140-
controlShouldRenderValue?: ReactSelectProps['controlShouldRenderValue'];
140+
controlShouldRenderValue?: ReactSelectProps<TOption>['controlShouldRenderValue'];
141141
/**
142142
* Custom method to filter whether an option should be displayed in the menu
143143
* <br/>
144144
* [Props from React select was used](https://react-select.com/props)
145145
*/
146-
filterOption?: ReactSelectProps['filterOption'];
146+
filterOption?: ReactSelectProps<TOption>['filterOption'];
147147
/**
148148
* The id to set on the SelectContainer component
149149
*/
@@ -169,7 +169,7 @@ export type TSelectFieldProps = {
169169
* <br/>
170170
* [Props from React select was used](https://react-select.com/props)
171171
*/
172-
isOptionDisabled?: ReactSelectProps['isOptionDisabled'];
172+
isOptionDisabled?: ReactSelectProps<TOption>['isOptionDisabled'];
173173
/**
174174
* Support multiple selected options
175175
*/
@@ -187,7 +187,7 @@ export type TSelectFieldProps = {
187187
* <br/>
188188
* [Props from React select was used](https://react-select.com/props)
189189
*/
190-
menuPortalTarget?: ReactSelectProps['menuPortalTarget'];
190+
menuPortalTarget?: ReactSelectProps<TOption>['menuPortalTarget'];
191191
/**
192192
* z-index value for the menu portal
193193
* <br>
@@ -209,7 +209,7 @@ export type TSelectFieldProps = {
209209
* <br/>
210210
* [Props from React select was used](https://react-select.com/props)
211211
*/
212-
noOptionsMessage?: ReactSelectProps['noOptionsMessage'];
212+
noOptionsMessage?: ReactSelectProps<TOption>['noOptionsMessage'];
213213
/**
214214
* Handle blur events on the control
215215
*/
@@ -225,13 +225,13 @@ export type TSelectFieldProps = {
225225
* <br/>
226226
* [Props from React select was used](https://react-select.com/props)
227227
*/
228-
onFocus?: ReactSelectProps['onFocus'];
228+
onFocus?: ReactSelectProps<TOption>['onFocus'];
229229
/**
230230
* Handle change events on the input
231231
* <br/>
232232
* [Props from React select was used](https://react-select.com/props)
233233
*/
234-
onInputChange?: ReactSelectProps['onInputChange'];
234+
onInputChange?: ReactSelectProps<TOption>['onInputChange'];
235235
/**
236236
* Array of options that populate the select menu
237237
*/
@@ -246,17 +246,15 @@ export type TSelectFieldProps = {
246246
* <br/>
247247
* [Props from React select was used](https://react-select.com/props)
248248
*/
249-
tabIndex?: ReactSelectProps['tabIndex'];
249+
tabIndex?: ReactSelectProps<TOption>['tabIndex'];
250250
/**
251251
* Select the currently focused option when the user presses tab
252252
*/
253253
tabSelectsValue?: boolean;
254254
/**
255255
* The value of the select; reflected by the selected option
256-
* <br/>
257-
* [Props from React select was used](https://react-select.com/props)
258256
*/
259-
value?: ReactSelectProps['value'];
257+
value?: string | string[] | null;
260258

261259
// LabelField
262260
/**
@@ -303,7 +301,7 @@ export type TSelectFieldProps = {
303301
* <br/>
304302
* [Props from React select was used](https://react-select.com/props)
305303
*/
306-
inputValue?: ReactSelectProps['inputValue'];
304+
inputValue?: ReactSelectProps<TOption>['inputValue'];
307305
};
308306

309307
type TFieldState = Pick<TSelectFieldProps, 'id'>;

0 commit comments

Comments
 (0)