@commercetools-uikit/select-input 20.3.0 → 20.3.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.
@@ -51,7 +51,7 @@ const customizedComponents = {
51
51
  ClearIndicator: selectUtils.ClearIndicator,
52
52
  MultiValueRemove: selectUtils.TagRemove
53
53
  };
54
- const isOptionObject = option => option.options !== undefined;
54
+ const isOptionObject = option => 'options' in option && !!option.options;
55
55
  const SelectInput = _ref => {
56
56
  var _context, _context2;
57
57
  let _ref$appearance = _ref.appearance,
@@ -267,7 +267,7 @@ SelectInput.ValueContainer = Select.components.ValueContainer;
267
267
  var SelectInput$1 = SelectInput;
268
268
 
269
269
  // NOTE: This string will be replaced on build time with the package version.
270
- var version = "20.3.0";
270
+ var version = "20.3.1";
271
271
 
272
272
  exports["default"] = SelectInput$1;
273
273
  exports.version = version;
@@ -51,7 +51,7 @@ const customizedComponents = {
51
51
  ClearIndicator: selectUtils.ClearIndicator,
52
52
  MultiValueRemove: selectUtils.TagRemove
53
53
  };
54
- const isOptionObject = option => option.options !== undefined;
54
+ const isOptionObject = option => 'options' in option && !!option.options;
55
55
  const SelectInput = _ref => {
56
56
  var _context, _context2;
57
57
  let _ref$appearance = _ref.appearance,
@@ -267,7 +267,7 @@ SelectInput.ValueContainer = Select.components.ValueContainer;
267
267
  var SelectInput$1 = SelectInput;
268
268
 
269
269
  // NOTE: This string will be replaced on build time with the package version.
270
- var version = "20.3.0";
270
+ var version = "20.3.1";
271
271
 
272
272
  exports["default"] = SelectInput$1;
273
273
  exports.version = version;
@@ -29,7 +29,7 @@ const customizedComponents = {
29
29
  ClearIndicator,
30
30
  MultiValueRemove: TagRemove
31
31
  };
32
- const isOptionObject = option => option.options !== undefined;
32
+ const isOptionObject = option => 'options' in option && !!option.options;
33
33
  const SelectInput = _ref => {
34
34
  var _context, _context2;
35
35
  let _ref$appearance = _ref.appearance,
@@ -245,6 +245,6 @@ SelectInput.ValueContainer = components.ValueContainer;
245
245
  var SelectInput$1 = SelectInput;
246
246
 
247
247
  // NOTE: This string will be replaced on build time with the package version.
248
- var version = "20.3.0";
248
+ var version = "20.3.1";
249
249
 
250
250
  export { SelectInput$1 as default, version };
@@ -5,10 +5,10 @@ export type TOption = {
5
5
  label?: ReactNode;
6
6
  isDisabled?: boolean;
7
7
  };
8
- export type TOptionObject = {
9
- options: TOption[];
8
+ export type TOptionObject<T extends TOption = TOption> = {
9
+ options: T[];
10
10
  };
11
- export type TOptions = TOption[] | TOptionObject[];
11
+ export type TOptions<T extends TOption = TOption> = T[] | TOptionObject<T>[];
12
12
  export type TCustomEvent = {
13
13
  target: {
14
14
  id?: ReactSelectProps<TOption>['inputId'];
@@ -17,7 +17,7 @@ export type TCustomEvent = {
17
17
  };
18
18
  persist: () => void;
19
19
  };
20
- export type TSelectInputProps = {
20
+ export type TSelectInputProps<T extends TOption = TOption> = {
21
21
  /**
22
22
  * Indicates the appearance of the input.
23
23
  * `quiet` appearance is meant to be used with the `horizontalConstraint="auto"`.
@@ -46,25 +46,25 @@ export type TSelectInputProps = {
46
46
  * <br>
47
47
  * [Props from React select was used](https://react-select.com/props)
48
48
  */
49
- 'aria-label'?: ReactSelectProps<TOption>['aria-label'];
49
+ 'aria-label'?: ReactSelectProps<T>['aria-label'];
50
50
  /**
51
51
  * HTML ID of an element that should be used as the label (for assistive tech)
52
52
  * <br>
53
53
  * [Props from React select was used](https://react-select.com/props)
54
54
  */
55
- 'aria-labelledby'?: ReactSelectProps<TOption>['aria-labelledby'];
55
+ 'aria-labelledby'?: ReactSelectProps<T>['aria-labelledby'];
56
56
  /**
57
57
  * Indicate if the value entered in the input is invalid.
58
58
  * <br>
59
59
  * [Props from React select was used](https://react-select.com/props)
60
60
  */
61
- 'aria-invalid'?: ReactSelectProps<TOption>['aria-invalid'];
61
+ 'aria-invalid'?: ReactSelectProps<T>['aria-invalid'];
62
62
  /**
63
63
  * HTML ID of an element containing an error message related to the input.
64
64
  * <br>
65
65
  * [Props from React select was used](https://react-select.com/props)
66
66
  */
67
- 'aria-errormessage'?: ReactSelectProps<TOption>['aria-errormessage'];
67
+ 'aria-errormessage'?: ReactSelectProps<T>['aria-errormessage'];
68
68
  /**
69
69
  * Focus the control when it is mounted
70
70
  */
@@ -74,13 +74,13 @@ export type TSelectInputProps = {
74
74
  * <br>
75
75
  * [Props from React select was used](https://react-select.com/props)
76
76
  */
77
- backspaceRemovesValue?: ReactSelectProps<TOption>['backspaceRemovesValue'];
77
+ backspaceRemovesValue?: ReactSelectProps<T>['backspaceRemovesValue'];
78
78
  /**
79
79
  * Map of components to overwrite the default ones, see what components you can override
80
80
  * <br>
81
81
  * [Props from React select was used](https://react-select.com/props)
82
82
  */
83
- components?: ReactSelectProps<TOption>['components'];
83
+ components?: ReactSelectProps<T>['components'];
84
84
  /**
85
85
  * Whether the input and options are rendered with condensed paddings
86
86
  */
@@ -90,87 +90,87 @@ export type TSelectInputProps = {
90
90
  * <br>
91
91
  * [Props from React select was used](https://react-select.com/props)
92
92
  */
93
- controlShouldRenderValue?: ReactSelectProps<TOption>['controlShouldRenderValue'];
93
+ controlShouldRenderValue?: ReactSelectProps<T>['controlShouldRenderValue'];
94
94
  /**
95
95
  * Custom method to filter whether an option should be displayed in the menu
96
96
  * <br>
97
97
  * [Props from React select was used](https://react-select.com/props)
98
98
  */
99
- filterOption?: ReactSelectProps<TOption>['filterOption'];
99
+ filterOption?: ReactSelectProps<T>['filterOption'];
100
100
  /**
101
101
  * Custom method to determine whether selected options should be displayed in the menu
102
102
  * <br>
103
103
  * [Props from React select was used](https://react-select.com/props)
104
104
  */
105
- hideSelectedOptions?: ReactSelectProps<TOption>['hideSelectedOptions'];
105
+ hideSelectedOptions?: ReactSelectProps<T>['hideSelectedOptions'];
106
106
  /**
107
107
  * Used as HTML id property. An id is generated automatically when not provided.
108
108
  * This forwarded as react-select's "inputId"
109
109
  * <br>
110
110
  * [Props from React select was used](https://react-select.com/props)
111
111
  */
112
- id?: ReactSelectProps<TOption>['inputId'];
112
+ id?: ReactSelectProps<T>['inputId'];
113
113
  /**
114
114
  * The value of the search input
115
115
  * <br>
116
116
  * [Props from React select was used](https://react-select.com/props)
117
117
  */
118
- inputValue?: ReactSelectProps<TOption>['inputValue'];
118
+ inputValue?: ReactSelectProps<T>['inputValue'];
119
119
  /**
120
120
  * The id to set on the SelectContainer component
121
121
  * This is forwarded as react-select's "id"
122
122
  * <br>
123
123
  * [Props from React select was used](https://react-select.com/props)
124
124
  */
125
- containerId?: ReactSelectProps<TOption>['id'];
125
+ containerId?: ReactSelectProps<T>['id'];
126
126
  /**
127
127
  * Is the select value clearable
128
128
  * <br>
129
129
  * [Props from React select was used](https://react-select.com/props)
130
130
  */
131
- isClearable?: ReactSelectProps<TOption>['isClearable'];
131
+ isClearable?: ReactSelectProps<T>['isClearable'];
132
132
  /**
133
133
  * Is the select disabled
134
134
  * <br>
135
135
  * [Props from React select was used](https://react-select.com/props)
136
136
  */
137
- isDisabled?: ReactSelectProps<TOption>['isDisabled'];
137
+ isDisabled?: ReactSelectProps<T>['isDisabled'];
138
138
  /**
139
139
  * Override the built-in logic to detect whether an option is disabled
140
140
  * <br>
141
141
  * [Props from React select was used](https://react-select.com/props)
142
142
  */
143
- isOptionDisabled?: ReactSelectProps<TOption>['isOptionDisabled'];
143
+ isOptionDisabled?: ReactSelectProps<T>['isOptionDisabled'];
144
144
  /**
145
145
  * Support multiple selected options
146
146
  * <br>
147
147
  * [Props from React select was used](https://react-select.com/props)
148
148
  */
149
- isMulti?: ReactSelectProps<TOption>['isMulti'];
149
+ isMulti?: ReactSelectProps<T>['isMulti'];
150
150
  /**
151
151
  * Whether to enable search functionality
152
152
  * <br>
153
153
  * [Props from React select was used](https://react-select.com/props)
154
154
  */
155
- isSearchable?: ReactSelectProps<TOption>['isSearchable'];
155
+ isSearchable?: ReactSelectProps<T>['isSearchable'];
156
156
  /**
157
157
  * Can be used to enforce the select input to be opened
158
158
  * <br>
159
159
  * [Props from React select was used](https://react-select.com/props)
160
160
  */
161
- menuIsOpen?: ReactSelectProps<TOption>['menuIsOpen'];
161
+ menuIsOpen?: ReactSelectProps<T>['menuIsOpen'];
162
162
  /**
163
163
  * Maximum height of the menu before scrolling
164
164
  * <br>
165
165
  * [Props from React select was used](https://react-select.com/props)
166
166
  */
167
- maxMenuHeight?: ReactSelectProps<TOption>['maxMenuHeight'];
167
+ maxMenuHeight?: ReactSelectProps<T>['maxMenuHeight'];
168
168
  /**
169
169
  * Dom element to portal the select menu to
170
170
  * <br>
171
171
  * [Props from React select was used](https://react-select.com/props)
172
172
  */
173
- menuPortalTarget?: ReactSelectProps<TOption>['menuPortalTarget'];
173
+ menuPortalTarget?: ReactSelectProps<T>['menuPortalTarget'];
174
174
  /**
175
175
  * z-index value for the menu portal
176
176
  * <br>
@@ -182,19 +182,19 @@ export type TSelectInputProps = {
182
182
  * <br>
183
183
  * [Props from React select was used](https://react-select.com/props)
184
184
  */
185
- menuShouldBlockScroll?: ReactSelectProps<TOption>['menuShouldBlockScroll'];
185
+ menuShouldBlockScroll?: ReactSelectProps<T>['menuShouldBlockScroll'];
186
186
  /**
187
187
  * Whether the menu should close after a value is selected. Defaults to `true`.
188
188
  * <br>
189
189
  * [Props from React select was used](https://react-select.com/props)
190
190
  */
191
- closeMenuOnSelect?: ReactSelectProps<TOption>['closeMenuOnSelect'];
191
+ closeMenuOnSelect?: ReactSelectProps<T>['closeMenuOnSelect'];
192
192
  /**
193
193
  * Name of the HTML Input (optional - without this, no input will be rendered)
194
194
  * <br>
195
195
  * [Props from React select was used](https://react-select.com/props)
196
196
  */
197
- name?: ReactSelectProps<TOption>['name'];
197
+ name?: ReactSelectProps<T>['name'];
198
198
  /**
199
199
  * Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place). Gets called with { inputValue: String }.
200
200
  * <br />
@@ -202,7 +202,7 @@ export type TSelectInputProps = {
202
202
  * <br>
203
203
  * [Props from React select was used](https://react-select.com/props)
204
204
  */
205
- noOptionsMessage?: ReactSelectProps<TOption>['noOptionsMessage'];
205
+ noOptionsMessage?: ReactSelectProps<T>['noOptionsMessage'];
206
206
  /**
207
207
  * Handle blur events on the control
208
208
  */
@@ -218,17 +218,17 @@ export type TSelectInputProps = {
218
218
  * <br>
219
219
  * [Props from React select was used](https://react-select.com/props)
220
220
  */
221
- onFocus?: ReactSelectProps<TOption>['onFocus'];
221
+ onFocus?: ReactSelectProps<T>['onFocus'];
222
222
  /**
223
223
  * Handle change events on the input
224
224
  * <br>
225
225
  * [Props from React select was used](https://react-select.com/props)
226
226
  */
227
- onInputChange?: ReactSelectProps<TOption>['onInputChange'];
227
+ onInputChange?: ReactSelectProps<T>['onInputChange'];
228
228
  /**
229
229
  * Array of options that populate the select menu
230
230
  */
231
- options?: TOptions;
231
+ options?: TOptions<T>;
232
232
  /** defines how options are rendered */
233
233
  optionStyle?: 'list' | 'checkbox';
234
234
  showOptionGroupDivider?: boolean;
@@ -237,19 +237,19 @@ export type TSelectInputProps = {
237
237
  * <br>
238
238
  * [Props from React select was used](https://react-select.com/props)
239
239
  */
240
- placeholder?: ReactSelectProps<TOption>['placeholder'];
240
+ placeholder?: ReactSelectProps<T>['placeholder'];
241
241
  /**
242
242
  * Sets the tabIndex attribute on the input
243
243
  * <br>
244
244
  * [Props from React select was used](https://react-select.com/props)
245
245
  */
246
- tabIndex?: ReactSelectProps<TOption>['tabIndex'];
246
+ tabIndex?: ReactSelectProps<T>['tabIndex'];
247
247
  /**
248
248
  * Select the currently focused option when the user presses tab
249
249
  * <br>
250
250
  * [Props from React select was used](https://react-select.com/props)
251
251
  */
252
- tabSelectsValue?: ReactSelectProps<TOption>['tabSelectsValue'];
252
+ tabSelectsValue?: ReactSelectProps<T>['tabSelectsValue'];
253
253
  /**
254
254
  * The value of the select; reflected by the selected option
255
255
  */
@@ -270,7 +270,7 @@ export type TSelectInputProps = {
270
270
  count?: number;
271
271
  };
272
272
  declare const SelectInput: {
273
- ({ appearance, maxMenuHeight, menuPortalZIndex, options, optionStyle, ...props }: TSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
273
+ <T extends TOption>({ appearance, maxMenuHeight, menuPortalZIndex, options, optionStyle, ...props }: TSelectInputProps<T>): import("@emotion/react/jsx-runtime").JSX.Element;
274
274
  displayName: string;
275
275
  isTouched(touched: boolean | unknown[]): boolean;
276
276
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/select-input",
3
3
  "description": "An input component getting a selection from the user.",
4
- "version": "20.3.0",
4
+ "version": "20.3.1",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,15 +21,15 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/constraints": "20.3.0",
25
- "@commercetools-uikit/design-system": "20.3.0",
26
- "@commercetools-uikit/icons": "20.3.0",
27
- "@commercetools-uikit/select-utils": "20.3.0",
28
- "@commercetools-uikit/utils": "20.3.0",
24
+ "@commercetools-uikit/constraints": "20.3.1",
25
+ "@commercetools-uikit/design-system": "20.3.1",
26
+ "@commercetools-uikit/icons": "20.3.1",
27
+ "@commercetools-uikit/select-utils": "20.3.1",
28
+ "@commercetools-uikit/utils": "20.3.1",
29
29
  "@emotion/is-prop-valid": "1.4.0",
30
30
  "@emotion/react": "^11.10.5",
31
31
  "@emotion/styled": "^11.10.5",
32
- "lodash": "4.17.21",
32
+ "lodash": "4.17.23",
33
33
  "react-select": "5.10.2"
34
34
  },
35
35
  "devDependencies": {