@commercetools-uikit/select-input 15.15.1 → 16.1.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/README.md
CHANGED
|
@@ -72,7 +72,7 @@ export default Example;
|
|
|
72
72
|
| `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
|
|
73
73
|
| `backspaceRemovesValue` | `ReactSelectProps['backspaceRemovesValue']` | | | Remove the currently focused option when the user presses backspace
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
74
74
|
| `components` | `ReactSelectProps['components']` | | | Map of components to overwrite the default ones, see what components you can override
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
75
|
-
| `controlShouldRenderValue` | `ReactSelectProps['controlShouldRenderValue']` | |
|
|
75
|
+
| `controlShouldRenderValue` | `ReactSelectProps['controlShouldRenderValue']` | | | Control whether the selected values should be rendered in the control
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
76
76
|
| `filterOption` | `ReactSelectProps['filterOption']` | | | Custom method to filter whether an option should be displayed in the menu
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
77
77
|
| `id` | `ReactSelectProps['inputId']` | | | Used as HTML id property. An id is generated automatically when not provided.
This forwarded as react-select's "inputId"
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
78
78
|
| `inputValue` | `ReactSelectProps['inputValue']` | | | The value of the search input
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
@@ -45,7 +45,6 @@ var Select__default = /*#__PURE__*/_interopDefault(Select);
|
|
|
45
45
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
46
46
|
|
|
47
47
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
48
|
-
|
|
49
48
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
50
49
|
const customizedComponents = {
|
|
51
50
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
@@ -55,26 +54,21 @@ const customizedComponents = {
|
|
|
55
54
|
const defaultProps = {
|
|
56
55
|
maxMenuHeight: 220,
|
|
57
56
|
menuPortalZIndex: 1,
|
|
58
|
-
controlShouldRenderValue: true,
|
|
59
57
|
options: []
|
|
60
58
|
};
|
|
61
|
-
|
|
62
59
|
const isOptionObject = option => option.options !== undefined;
|
|
63
|
-
|
|
64
60
|
const SelectInput = props => {
|
|
65
61
|
var _context, _context2, _context3;
|
|
66
|
-
|
|
67
62
|
const intl = reactIntl.useIntl();
|
|
68
|
-
|
|
69
63
|
const _useTheme = designSystem.useTheme(),
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
72
65
|
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
73
66
|
menuPortalZIndex: props.menuPortalZIndex,
|
|
74
67
|
menuPortalTarget: props.menuPortalTarget,
|
|
75
68
|
componentName: 'SelectInput'
|
|
76
69
|
});
|
|
77
|
-
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
70
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
71
|
+
// Options can be grouped as
|
|
78
72
|
// const colourOptions = [{ value: 'green', label: 'Green' }];
|
|
79
73
|
// const flavourOptions = [{ value: 'vanilla', label: 'Vanilla' }];
|
|
80
74
|
// const groupedOptions = [
|
|
@@ -82,16 +76,14 @@ const SelectInput = props => {
|
|
|
82
76
|
// { label: 'Flavours', options: flavourOptions },
|
|
83
77
|
// ];
|
|
84
78
|
// So we "ungroup" the options by merging them all into one list first.
|
|
85
|
-
|
|
86
79
|
const optionsWithoutGroups = _flatMapInstanceProperty__default["default"](_context = props.options).call(_context, option => {
|
|
87
80
|
if (isOptionObject(option)) {
|
|
88
81
|
return option.options;
|
|
89
82
|
}
|
|
90
|
-
|
|
91
83
|
return option;
|
|
92
84
|
});
|
|
93
|
-
|
|
94
|
-
|
|
85
|
+
const selectedOptions = props.isMulti ? _filterInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](_context3 = props.value || []
|
|
86
|
+
// Pass the options in the order selected by the use, so that the
|
|
95
87
|
// sorting is not lost
|
|
96
88
|
).call(_context3, value => _findInstanceProperty__default["default"](optionsWithoutGroups).call(optionsWithoutGroups, option => option.value === value))).call(_context2, Boolean) : _findInstanceProperty__default["default"](optionsWithoutGroups).call(optionsWithoutGroups, option => has__default["default"](option, 'value') && option.value === props.value) || null;
|
|
97
89
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
@@ -123,7 +115,8 @@ const SelectInput = props => {
|
|
|
123
115
|
controlShouldRenderValue: props.controlShouldRenderValue,
|
|
124
116
|
isNewTheme
|
|
125
117
|
}),
|
|
126
|
-
filterOption: props.filterOption
|
|
118
|
+
filterOption: props.filterOption
|
|
119
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
127
120
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
128
121
|
// instead.
|
|
129
122
|
// This makes it easier to less confusing to use with <label />s.
|
|
@@ -133,7 +126,8 @@ const SelectInput = props => {
|
|
|
133
126
|
inputValue: props.inputValue,
|
|
134
127
|
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
135
128
|
isDisabled: props.isDisabled,
|
|
136
|
-
isOptionDisabled: props.isOptionDisabled
|
|
129
|
+
isOptionDisabled: props.isOptionDisabled
|
|
130
|
+
// @ts-ignore
|
|
137
131
|
,
|
|
138
132
|
isReadOnly: props.isReadOnly,
|
|
139
133
|
isMulti: props.isMulti,
|
|
@@ -154,11 +148,11 @@ const SelectInput = props => {
|
|
|
154
148
|
target: {
|
|
155
149
|
id: props.id,
|
|
156
150
|
name: (() => {
|
|
157
|
-
if (!props.isMulti) return props.name;
|
|
151
|
+
if (!props.isMulti) return props.name;
|
|
152
|
+
// We append the ".0" to make Formik set the touched
|
|
158
153
|
// state as an array instead of a boolean only.
|
|
159
154
|
// Otherwise the shapes would clash on submission, as
|
|
160
155
|
// Formik will create an array on submission anyways.
|
|
161
|
-
|
|
162
156
|
return props.name ? "".concat(props.name, ".0") : undefined;
|
|
163
157
|
})()
|
|
164
158
|
},
|
|
@@ -170,11 +164,9 @@ const SelectInput = props => {
|
|
|
170
164
|
// nextSelectedOptions is either an array, or a single option, or null
|
|
171
165
|
// depending on whether we're in multi-mode or not (isMulti)
|
|
172
166
|
let value = null;
|
|
173
|
-
|
|
174
167
|
if (props.isMulti) {
|
|
175
168
|
if (nextSelectedOptions) {
|
|
176
169
|
var _context4;
|
|
177
|
-
|
|
178
170
|
value = _mapInstanceProperty__default["default"](_context4 = nextSelectedOptions).call(_context4, option => option.value);
|
|
179
171
|
} else {
|
|
180
172
|
value = [];
|
|
@@ -182,7 +174,6 @@ const SelectInput = props => {
|
|
|
182
174
|
} else if (nextSelectedOptions) {
|
|
183
175
|
value = nextSelectedOptions.value;
|
|
184
176
|
}
|
|
185
|
-
|
|
186
177
|
props.onChange && props.onChange({
|
|
187
178
|
target: {
|
|
188
179
|
id: props.id,
|
|
@@ -205,7 +196,6 @@ const SelectInput = props => {
|
|
|
205
196
|
}))
|
|
206
197
|
});
|
|
207
198
|
};
|
|
208
|
-
|
|
209
199
|
SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
210
200
|
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
211
201
|
hasError: _pt__default["default"].bool,
|
|
@@ -229,17 +219,18 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
229
219
|
} : {};
|
|
230
220
|
SelectInput.displayName = 'SelectInput';
|
|
231
221
|
SelectInput.defaultProps = defaultProps;
|
|
222
|
+
|
|
232
223
|
/**
|
|
233
224
|
* Expose static helper methods.
|
|
234
225
|
*/
|
|
235
|
-
// Both "true" and an empty array [] represent a touched state.
|
|
236
226
|
|
|
227
|
+
// Both "true" and an empty array [] represent a touched state.
|
|
237
228
|
SelectInput.isTouched = touched => Boolean(touched);
|
|
229
|
+
|
|
238
230
|
/**
|
|
239
231
|
* Expose react-select components for customization purposes.
|
|
240
232
|
*/
|
|
241
233
|
|
|
242
|
-
|
|
243
234
|
SelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
244
235
|
SelectInput.Control = Select.components.Control;
|
|
245
236
|
SelectInput.CrossIcon = Select.components.CrossIcon;
|
|
@@ -268,7 +259,7 @@ SelectInput.ValueContainer = Select.components.ValueContainer;
|
|
|
268
259
|
var SelectInput$1 = SelectInput;
|
|
269
260
|
|
|
270
261
|
// NOTE: This string will be replaced on build time with the package version.
|
|
271
|
-
var version = "
|
|
262
|
+
var version = "16.1.0";
|
|
272
263
|
|
|
273
264
|
exports["default"] = SelectInput$1;
|
|
274
265
|
exports.version = version;
|
|
@@ -44,7 +44,6 @@ var Select__default = /*#__PURE__*/_interopDefault(Select);
|
|
|
44
44
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
45
45
|
|
|
46
46
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
-
|
|
48
47
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
49
48
|
const customizedComponents = {
|
|
50
49
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
@@ -54,26 +53,21 @@ const customizedComponents = {
|
|
|
54
53
|
const defaultProps = {
|
|
55
54
|
maxMenuHeight: 220,
|
|
56
55
|
menuPortalZIndex: 1,
|
|
57
|
-
controlShouldRenderValue: true,
|
|
58
56
|
options: []
|
|
59
57
|
};
|
|
60
|
-
|
|
61
58
|
const isOptionObject = option => option.options !== undefined;
|
|
62
|
-
|
|
63
59
|
const SelectInput = props => {
|
|
64
60
|
var _context, _context2, _context3;
|
|
65
|
-
|
|
66
61
|
const intl = reactIntl.useIntl();
|
|
67
|
-
|
|
68
62
|
const _useTheme = designSystem.useTheme(),
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
71
64
|
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
72
65
|
menuPortalZIndex: props.menuPortalZIndex,
|
|
73
66
|
menuPortalTarget: props.menuPortalTarget,
|
|
74
67
|
componentName: 'SelectInput'
|
|
75
68
|
});
|
|
76
|
-
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
69
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
70
|
+
// Options can be grouped as
|
|
77
71
|
// const colourOptions = [{ value: 'green', label: 'Green' }];
|
|
78
72
|
// const flavourOptions = [{ value: 'vanilla', label: 'Vanilla' }];
|
|
79
73
|
// const groupedOptions = [
|
|
@@ -81,16 +75,14 @@ const SelectInput = props => {
|
|
|
81
75
|
// { label: 'Flavours', options: flavourOptions },
|
|
82
76
|
// ];
|
|
83
77
|
// So we "ungroup" the options by merging them all into one list first.
|
|
84
|
-
|
|
85
78
|
const optionsWithoutGroups = _flatMapInstanceProperty__default["default"](_context = props.options).call(_context, option => {
|
|
86
79
|
if (isOptionObject(option)) {
|
|
87
80
|
return option.options;
|
|
88
81
|
}
|
|
89
|
-
|
|
90
82
|
return option;
|
|
91
83
|
});
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
const selectedOptions = props.isMulti ? _filterInstanceProperty__default["default"](_context2 = _mapInstanceProperty__default["default"](_context3 = props.value || []
|
|
85
|
+
// Pass the options in the order selected by the use, so that the
|
|
94
86
|
// sorting is not lost
|
|
95
87
|
).call(_context3, value => _findInstanceProperty__default["default"](optionsWithoutGroups).call(optionsWithoutGroups, option => option.value === value))).call(_context2, Boolean) : _findInstanceProperty__default["default"](optionsWithoutGroups).call(optionsWithoutGroups, option => has__default["default"](option, 'value') && option.value === props.value) || null;
|
|
96
88
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
@@ -122,7 +114,8 @@ const SelectInput = props => {
|
|
|
122
114
|
controlShouldRenderValue: props.controlShouldRenderValue,
|
|
123
115
|
isNewTheme
|
|
124
116
|
}),
|
|
125
|
-
filterOption: props.filterOption
|
|
117
|
+
filterOption: props.filterOption
|
|
118
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
126
119
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
127
120
|
// instead.
|
|
128
121
|
// This makes it easier to less confusing to use with <label />s.
|
|
@@ -132,7 +125,8 @@ const SelectInput = props => {
|
|
|
132
125
|
inputValue: props.inputValue,
|
|
133
126
|
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
134
127
|
isDisabled: props.isDisabled,
|
|
135
|
-
isOptionDisabled: props.isOptionDisabled
|
|
128
|
+
isOptionDisabled: props.isOptionDisabled
|
|
129
|
+
// @ts-ignore
|
|
136
130
|
,
|
|
137
131
|
isReadOnly: props.isReadOnly,
|
|
138
132
|
isMulti: props.isMulti,
|
|
@@ -153,11 +147,11 @@ const SelectInput = props => {
|
|
|
153
147
|
target: {
|
|
154
148
|
id: props.id,
|
|
155
149
|
name: (() => {
|
|
156
|
-
if (!props.isMulti) return props.name;
|
|
150
|
+
if (!props.isMulti) return props.name;
|
|
151
|
+
// We append the ".0" to make Formik set the touched
|
|
157
152
|
// state as an array instead of a boolean only.
|
|
158
153
|
// Otherwise the shapes would clash on submission, as
|
|
159
154
|
// Formik will create an array on submission anyways.
|
|
160
|
-
|
|
161
155
|
return props.name ? "".concat(props.name, ".0") : undefined;
|
|
162
156
|
})()
|
|
163
157
|
},
|
|
@@ -169,11 +163,9 @@ const SelectInput = props => {
|
|
|
169
163
|
// nextSelectedOptions is either an array, or a single option, or null
|
|
170
164
|
// depending on whether we're in multi-mode or not (isMulti)
|
|
171
165
|
let value = null;
|
|
172
|
-
|
|
173
166
|
if (props.isMulti) {
|
|
174
167
|
if (nextSelectedOptions) {
|
|
175
168
|
var _context4;
|
|
176
|
-
|
|
177
169
|
value = _mapInstanceProperty__default["default"](_context4 = nextSelectedOptions).call(_context4, option => option.value);
|
|
178
170
|
} else {
|
|
179
171
|
value = [];
|
|
@@ -181,7 +173,6 @@ const SelectInput = props => {
|
|
|
181
173
|
} else if (nextSelectedOptions) {
|
|
182
174
|
value = nextSelectedOptions.value;
|
|
183
175
|
}
|
|
184
|
-
|
|
185
176
|
props.onChange && props.onChange({
|
|
186
177
|
target: {
|
|
187
178
|
id: props.id,
|
|
@@ -204,21 +195,21 @@ const SelectInput = props => {
|
|
|
204
195
|
}))
|
|
205
196
|
});
|
|
206
197
|
};
|
|
207
|
-
|
|
208
198
|
SelectInput.propTypes = {};
|
|
209
199
|
SelectInput.displayName = 'SelectInput';
|
|
210
200
|
SelectInput.defaultProps = defaultProps;
|
|
201
|
+
|
|
211
202
|
/**
|
|
212
203
|
* Expose static helper methods.
|
|
213
204
|
*/
|
|
214
|
-
// Both "true" and an empty array [] represent a touched state.
|
|
215
205
|
|
|
206
|
+
// Both "true" and an empty array [] represent a touched state.
|
|
216
207
|
SelectInput.isTouched = touched => Boolean(touched);
|
|
208
|
+
|
|
217
209
|
/**
|
|
218
210
|
* Expose react-select components for customization purposes.
|
|
219
211
|
*/
|
|
220
212
|
|
|
221
|
-
|
|
222
213
|
SelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
223
214
|
SelectInput.Control = Select.components.Control;
|
|
224
215
|
SelectInput.CrossIcon = Select.components.CrossIcon;
|
|
@@ -247,7 +238,7 @@ SelectInput.ValueContainer = Select.components.ValueContainer;
|
|
|
247
238
|
var SelectInput$1 = SelectInput;
|
|
248
239
|
|
|
249
240
|
// NOTE: This string will be replaced on build time with the package version.
|
|
250
|
-
var version = "
|
|
241
|
+
var version = "16.1.0";
|
|
251
242
|
|
|
252
243
|
exports["default"] = SelectInput$1;
|
|
253
244
|
exports.version = version;
|
|
@@ -22,7 +22,6 @@ import { useTheme } from '@commercetools-uikit/design-system';
|
|
|
22
22
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
23
23
|
|
|
24
24
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
-
|
|
26
25
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context5, _context6; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context5 = ownKeys(Object(source), !0)).call(_context5, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context6 = ownKeys(Object(source))).call(_context6, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
26
|
const customizedComponents = {
|
|
28
27
|
DropdownIndicator,
|
|
@@ -32,26 +31,21 @@ const customizedComponents = {
|
|
|
32
31
|
const defaultProps = {
|
|
33
32
|
maxMenuHeight: 220,
|
|
34
33
|
menuPortalZIndex: 1,
|
|
35
|
-
controlShouldRenderValue: true,
|
|
36
34
|
options: []
|
|
37
35
|
};
|
|
38
|
-
|
|
39
36
|
const isOptionObject = option => option.options !== undefined;
|
|
40
|
-
|
|
41
37
|
const SelectInput = props => {
|
|
42
38
|
var _context, _context2, _context3;
|
|
43
|
-
|
|
44
39
|
const intl = useIntl();
|
|
45
|
-
|
|
46
40
|
const _useTheme = useTheme(),
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
49
42
|
warnIfMenuPortalPropsAreMissing({
|
|
50
43
|
menuPortalZIndex: props.menuPortalZIndex,
|
|
51
44
|
menuPortalTarget: props.menuPortalTarget,
|
|
52
45
|
componentName: 'SelectInput'
|
|
53
46
|
});
|
|
54
|
-
const placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
47
|
+
const placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
48
|
+
// Options can be grouped as
|
|
55
49
|
// const colourOptions = [{ value: 'green', label: 'Green' }];
|
|
56
50
|
// const flavourOptions = [{ value: 'vanilla', label: 'Vanilla' }];
|
|
57
51
|
// const groupedOptions = [
|
|
@@ -59,16 +53,14 @@ const SelectInput = props => {
|
|
|
59
53
|
// { label: 'Flavours', options: flavourOptions },
|
|
60
54
|
// ];
|
|
61
55
|
// So we "ungroup" the options by merging them all into one list first.
|
|
62
|
-
|
|
63
56
|
const optionsWithoutGroups = _flatMapInstanceProperty(_context = props.options).call(_context, option => {
|
|
64
57
|
if (isOptionObject(option)) {
|
|
65
58
|
return option.options;
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
return option;
|
|
69
61
|
});
|
|
70
|
-
|
|
71
|
-
|
|
62
|
+
const selectedOptions = props.isMulti ? _filterInstanceProperty(_context2 = _mapInstanceProperty(_context3 = props.value || []
|
|
63
|
+
// Pass the options in the order selected by the use, so that the
|
|
72
64
|
// sorting is not lost
|
|
73
65
|
).call(_context3, value => _findInstanceProperty(optionsWithoutGroups).call(optionsWithoutGroups, option => option.value === value))).call(_context2, Boolean) : _findInstanceProperty(optionsWithoutGroups).call(optionsWithoutGroups, option => has(option, 'value') && option.value === props.value) || null;
|
|
74
66
|
return jsx(Constraints.Horizontal, {
|
|
@@ -100,7 +92,8 @@ const SelectInput = props => {
|
|
|
100
92
|
controlShouldRenderValue: props.controlShouldRenderValue,
|
|
101
93
|
isNewTheme
|
|
102
94
|
}),
|
|
103
|
-
filterOption: props.filterOption
|
|
95
|
+
filterOption: props.filterOption
|
|
96
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
104
97
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
105
98
|
// instead.
|
|
106
99
|
// This makes it easier to less confusing to use with <label />s.
|
|
@@ -110,7 +103,8 @@ const SelectInput = props => {
|
|
|
110
103
|
inputValue: props.inputValue,
|
|
111
104
|
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
112
105
|
isDisabled: props.isDisabled,
|
|
113
|
-
isOptionDisabled: props.isOptionDisabled
|
|
106
|
+
isOptionDisabled: props.isOptionDisabled
|
|
107
|
+
// @ts-ignore
|
|
114
108
|
,
|
|
115
109
|
isReadOnly: props.isReadOnly,
|
|
116
110
|
isMulti: props.isMulti,
|
|
@@ -131,11 +125,11 @@ const SelectInput = props => {
|
|
|
131
125
|
target: {
|
|
132
126
|
id: props.id,
|
|
133
127
|
name: (() => {
|
|
134
|
-
if (!props.isMulti) return props.name;
|
|
128
|
+
if (!props.isMulti) return props.name;
|
|
129
|
+
// We append the ".0" to make Formik set the touched
|
|
135
130
|
// state as an array instead of a boolean only.
|
|
136
131
|
// Otherwise the shapes would clash on submission, as
|
|
137
132
|
// Formik will create an array on submission anyways.
|
|
138
|
-
|
|
139
133
|
return props.name ? "".concat(props.name, ".0") : undefined;
|
|
140
134
|
})()
|
|
141
135
|
},
|
|
@@ -147,11 +141,9 @@ const SelectInput = props => {
|
|
|
147
141
|
// nextSelectedOptions is either an array, or a single option, or null
|
|
148
142
|
// depending on whether we're in multi-mode or not (isMulti)
|
|
149
143
|
let value = null;
|
|
150
|
-
|
|
151
144
|
if (props.isMulti) {
|
|
152
145
|
if (nextSelectedOptions) {
|
|
153
146
|
var _context4;
|
|
154
|
-
|
|
155
147
|
value = _mapInstanceProperty(_context4 = nextSelectedOptions).call(_context4, option => option.value);
|
|
156
148
|
} else {
|
|
157
149
|
value = [];
|
|
@@ -159,7 +151,6 @@ const SelectInput = props => {
|
|
|
159
151
|
} else if (nextSelectedOptions) {
|
|
160
152
|
value = nextSelectedOptions.value;
|
|
161
153
|
}
|
|
162
|
-
|
|
163
154
|
props.onChange && props.onChange({
|
|
164
155
|
target: {
|
|
165
156
|
id: props.id,
|
|
@@ -182,7 +173,6 @@ const SelectInput = props => {
|
|
|
182
173
|
}))
|
|
183
174
|
});
|
|
184
175
|
};
|
|
185
|
-
|
|
186
176
|
SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
187
177
|
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
188
178
|
hasError: _pt.bool,
|
|
@@ -206,17 +196,18 @@ SelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
206
196
|
} : {};
|
|
207
197
|
SelectInput.displayName = 'SelectInput';
|
|
208
198
|
SelectInput.defaultProps = defaultProps;
|
|
199
|
+
|
|
209
200
|
/**
|
|
210
201
|
* Expose static helper methods.
|
|
211
202
|
*/
|
|
212
|
-
// Both "true" and an empty array [] represent a touched state.
|
|
213
203
|
|
|
204
|
+
// Both "true" and an empty array [] represent a touched state.
|
|
214
205
|
SelectInput.isTouched = touched => Boolean(touched);
|
|
206
|
+
|
|
215
207
|
/**
|
|
216
208
|
* Expose react-select components for customization purposes.
|
|
217
209
|
*/
|
|
218
210
|
|
|
219
|
-
|
|
220
211
|
SelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
221
212
|
SelectInput.Control = components.Control;
|
|
222
213
|
SelectInput.CrossIcon = components.CrossIcon;
|
|
@@ -245,6 +236,6 @@ SelectInput.ValueContainer = components.ValueContainer;
|
|
|
245
236
|
var SelectInput$1 = SelectInput;
|
|
246
237
|
|
|
247
238
|
// NOTE: This string will be replaced on build time with the package version.
|
|
248
|
-
var version = "
|
|
239
|
+
var version = "16.1.0";
|
|
249
240
|
|
|
250
241
|
export { SelectInput$1 as default, version };
|
|
@@ -60,7 +60,7 @@ export type TSelectInputProps = {
|
|
|
60
60
|
declare const SelectInput: {
|
|
61
61
|
(props: TSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
62
62
|
displayName: string;
|
|
63
|
-
defaultProps: Pick<TSelectInputProps, "
|
|
63
|
+
defaultProps: Pick<TSelectInputProps, "maxMenuHeight" | "options" | "menuPortalZIndex">;
|
|
64
64
|
isTouched(touched: boolean | unknown[]): boolean;
|
|
65
65
|
ClearIndicator: {
|
|
66
66
|
(props: import("@commercetools-uikit/select-utils").TClearIndicatorProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
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": "
|
|
4
|
+
"version": "16.1.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,24 +21,24 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/constraints": "
|
|
25
|
-
"@commercetools-uikit/design-system": "
|
|
26
|
-
"@commercetools-uikit/icons": "
|
|
27
|
-
"@commercetools-uikit/select-utils": "
|
|
28
|
-
"@commercetools-uikit/utils": "
|
|
29
|
-
"@emotion/is-prop-valid": "1.2.
|
|
24
|
+
"@commercetools-uikit/constraints": "16.1.0",
|
|
25
|
+
"@commercetools-uikit/design-system": "16.1.0",
|
|
26
|
+
"@commercetools-uikit/icons": "16.1.0",
|
|
27
|
+
"@commercetools-uikit/select-utils": "16.1.0",
|
|
28
|
+
"@commercetools-uikit/utils": "16.1.0",
|
|
29
|
+
"@emotion/is-prop-valid": "1.2.1",
|
|
30
30
|
"@emotion/react": "^11.10.5",
|
|
31
31
|
"@emotion/styled": "^11.10.5",
|
|
32
32
|
"lodash": "4.17.21",
|
|
33
33
|
"prop-types": "15.8.1",
|
|
34
|
-
"react-select": "5.7.
|
|
34
|
+
"react-select": "5.7.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"react": "17.0.2",
|
|
38
|
-
"react-intl": "^
|
|
38
|
+
"react-intl": "^6.3.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "17.x",
|
|
42
|
-
"react-intl": "
|
|
42
|
+
"react-intl": "6.x"
|
|
43
43
|
}
|
|
44
44
|
}
|