@commercetools-uikit/async-select-input 12.2.5 → 13.0.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
@@ -58,48 +58,61 @@ export default Example;
58
58
 
59
59
  ## Properties
60
60
 
61
- | Props | Type | Required | Default | Description |
62
- | --------------------------------- | -------------------------------------------------------------------------------------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63
- | `horizontalConstraint` | `enum`<br/>Possible values:<br/>`3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | | Horizontal size limit of the input fields. |
64
- | `hasError` | `bool` | | | Indicates the input field has an error |
65
- | `hasWarning` | `bool` | | | Indicates the input field has a warning |
66
- | `isReadOnly` | `bool` | | | Indicates that the field is displaying read-only content |
67
- | `aria-label` | `string` | | | Aria label (for assistive tech) |
68
- | `aria-labelledby` | `string` | | | HTML ID of an element that should be used as the label (for assistive tech) |
69
- | `isAutofocussed` | `bool` | | | Focus the control when it is mounted |
70
- | `backspaceRemovesValue` | `bool` | | | Remove the currently focused option when the user presses backspace |
71
- | `components` | `objectOf(func)` | | | Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components) |
72
- | `filterOption` | `func` | | | Custom method to filter whether an option should be displayed in the menu |
73
- | `id` | `string` | | | The id of the search input |
74
- | `inputValue` | `string` | | | |
75
- | `containerId` | `string` | | | The id to set on the SelectContainer component |
76
- | `isClearable` | `bool` | | | Is the select value clearable |
77
- | `isDisabled` | `bool` | | | Is the select disabled |
78
- | `isOptionDisabled` | `func` | | | Override the built-in logic to detect whether an option is disabled |
79
- | `isMulti` | `bool` | | | Support multiple selected options |
80
- | `isSearchable` | `bool` | | `true` | Whether to enable search functionality |
81
- | `maxMenuHeight` | `number` | | | Maximum height of the menu before scrolling |
82
- | `menuPortalTarget` | `SafeHTMLElement` | | | Dom element to portal the select menu to |
83
- | `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal |
84
- | `menuShouldBlockScroll` | `bool` | | | whether the menu should block scroll while open |
85
- | `name` | `string` | | | Name of the HTML Input (optional - without this, no input will be rendered) |
86
- | `noOptionsMessage` | `func` | | | 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 }`. `inputValue` will be an empty string when no search text is present. |
87
- | `onBlur` | `func` | | | Handle blur events on the control |
88
- | `onChange` | `func` || | Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`. |
89
- | `onFocus` | `func` | | | Handle focus events on the control |
90
- | `onInputChange` | `func` | | | Handle change events on the input |
91
- | `placeholder` | `string` | | | Placeholder text for the select value |
92
- | `loadingMessage` | `<string, func>` | | | loading message shown while the options are being loaded |
93
- | `tabIndex` | `string` | | | Sets the tabIndex attribute on the input |
94
- | `tabSelectsValue` | `bool` | | | Select the currently focused option when the user presses tab |
95
- | `value` | `custom` | | `null` | The value of the select; reflected by the selected option |
96
- | `defaultOptions` | `<bool, arrayOf>` | | | The default set of options to show before the user starts searching. When set to true, the results for loadOptions('') will be autoloaded. |
97
- | `defaultOptions<arrayOf>` | `array` | | | |
98
- | `defaultOptions<arrayOf>[].value` | `string` | ✅ | | |
99
- | `loadOptions` | `func` || | Function that returns a promise, which is the set of options to be used once the promise resolves. |
100
- | `cacheOptions` | `any` | | | If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value. |
101
- | `showOptionGroupDivider` | `bool` | | | Determines if option groups will be separated by a divider |
102
- | `iconLeft` | `node` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
61
+ | Props | Type | Required | Default | Description |
62
+ | ------------------------ | ----------------------------------------------------------------------------------------------------- | :------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
63
+ | `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | | Horizontal size limit of the input fields. |
64
+ | `hasError` | `boolean` | | | Indicates the input field has an error |
65
+ | `hasWarning` | `boolean` | | | Indicates the input field has a warning |
66
+ | `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
67
+ | `aria-label` | `AsyncProps['aria-label']` | | | Aria label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
68
+ | `aria-labelledby` | `AsyncProps['aria-labelledby']` | | | HTML ID of an element that should be used as the label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
69
+ | `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
70
+ | `backspaceRemovesValue` | `AsyncProps['backspaceRemovesValue']` | | | Remove the currently focused option when the user presses backspace&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
71
+ | `components` | `AsyncProps['components']` | | | Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
72
+ | `filterOption` | `AsyncProps['filterOption']` | | | Custom method to filter whether an option should be displayed in the menu&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
73
+ | `id` | `AsyncProps['inputId']` | | | The id of the search input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
74
+ | `inputValue` | `AsyncProps['inputValue']` | | | The value of the search input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
75
+ | `containerId` | `AsyncProps['id']` | | | The id to set on the SelectContainer component&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
76
+ | `isClearable` | `AsyncProps['isClearable']` | | | Is the select value clearable&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
77
+ | `isDisabled` | `AsyncProps['isDisabled']` | | | Is the select disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
78
+ | `isOptionDisabled` | `AsyncProps['isOptionDisabled']` | | | Override the built-in logic to detect whether an option is disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
79
+ | `isMulti` | `AsyncProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
80
+ | `isSearchable` | `AsyncProps['isSearchable']` | | `true` | Whether to enable search functionality&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
81
+ | `maxMenuHeight` | `AsyncProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
82
+ | `menuPortalTarget` | `AsyncProps['menuPortalTarget']` | | | Dom element to portal the select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
83
+ | `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal |
84
+ | `menuShouldBlockScroll` | `AsyncProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
85
+ | `closeMenuOnSelect` | `AsyncProps['closeMenuOnSelect']` | | | Whether the menu should close after a value is selected. Defaults to `true`.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
86
+ | `name` | `AsyncProps['name']` | | | Name of the HTML Input (optional - without this, no input will be rendered)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
87
+ | `noOptionsMessage` | `AsyncProps['noOptionsMessage']` | | | 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 }`. `inputValue` will be an empty string when no search text is present.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
88
+ | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
89
+ | `onChange` | `Function`<br/>[See signature.](#signature-onChange) || | Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`. |
90
+ | `onFocus` | `AsyncProps['onFocus']` | | | Handle focus events on the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
91
+ | `onInputChange` | `AsyncProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
92
+ | `placeholder` | `AsyncProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
93
+ | `loadingMessage` | `union`<br/>Possible values:<br/>`string , (() => string)` | | | loading message shown while the options are being loaded |
94
+ | `tabIndex` | `AsyncProps['tabIndex']` | | | Sets the tabIndex attribute on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
95
+ | `tabSelectsValue` | `AsyncProps['tabSelectsValue']` | | | Select the currently focused option when the user presses tab&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
96
+ | `value` | `AsyncProps['value']` | | `null` | The value of the select; reflected by the selected option&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
97
+ | `defaultOptions` | `union`<br/>Possible values:<br/>`OptionsOrGroups<unknown, GroupBase<unknown>> , boolean` | | | The default set of options to show before the user starts searching. When set to true, the results for loadOptions('') will be autoloaded.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
98
+ | `loadOptions` | `AsyncProps['loadOptions']` | ✅ | | Function that returns a promise, which is the set of options to be used once the promise resolves. |
99
+ | `cacheOptions` | `AsyncProps['cacheOptions']` | | | If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value. |
100
+ | `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
101
+ | `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
102
+
103
+ ## Signatures
104
+
105
+ ### Signature `onBlur`
106
+
107
+ ```ts
108
+ (event: TEvent) => void
109
+ ```
110
+
111
+ ### Signature `onChange`
112
+
113
+ ```ts
114
+ (event: TEvent, info: ActionMeta<unknown>) => void
115
+ ```
103
116
 
104
117
  This input is built on top of [`react-select`](https://github.com/JedWatson/react-select) v2.
105
118
  It supports mostly same properties as `react-select`. Behavior for some props was changed, and support for others was dropped.
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ export { default } from "./declarations/src/index";
@@ -11,9 +11,9 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
11
11
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
- var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
15
- var PropTypes = require('prop-types');
14
+ var _pt = require('prop-types');
16
15
  var reactIntl = require('react-intl');
16
+ var isEmpty = require('lodash/isEmpty');
17
17
  var react = require('@emotion/react');
18
18
  var reactSelect = require('react-select');
19
19
  var AsyncSelect = require('react-select/async');
@@ -33,15 +33,15 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
33
33
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
34
34
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
35
35
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
36
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
37
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
36
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
37
+ var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
38
38
  var AsyncSelect__default = /*#__PURE__*/_interopDefault(AsyncSelect);
39
39
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
40
40
  var LoadingSpinner__default = /*#__PURE__*/_interopDefault(LoadingSpinner);
41
41
 
42
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
42
+ 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; }
43
43
 
44
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
44
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
45
45
 
46
46
  var LoadingIndicator = function LoadingIndicator() {
47
47
  return jsxRuntime.jsx(LoadingSpinner__default["default"], {
@@ -56,6 +56,13 @@ var customizedComponents = {
56
56
  LoadingIndicator: LoadingIndicator,
57
57
  MultiValueRemove: selectUtils.TagRemove
58
58
  };
59
+ var defaultProps = {
60
+ // Using "null" will ensure that the currently selected value disappears in
61
+ // case "undefined" gets passed as the next value
62
+ value: null,
63
+ isSearchable: true,
64
+ menuPortalZIndex: 1
65
+ };
59
66
 
60
67
  var AsyncSelectInput = function AsyncSelectInput(props) {
61
68
  var theme = react.useTheme();
@@ -79,7 +86,6 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
79
86
  autoFocus: props.isAutofocussed,
80
87
  backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
81
88
  components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
82
- // eslint-disable-next-line react/display-name
83
89
  Input: function Input(ownProps) {
84
90
  return jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
85
91
  readOnly: true
@@ -93,7 +99,10 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
93
99
  showOptionGroupDivider: props.showOptionGroupDivider,
94
100
  menuPortalZIndex: props.menuPortalZIndex,
95
101
  isDisabled: props.isDisabled,
96
- isReadOnly: props.isReadOnly
102
+ isReadOnly: props.isReadOnly,
103
+ iconLeft: props.iconLeft,
104
+ isMulti: props.isMulti,
105
+ hasValue: !isEmpty__default["default"](props.value)
97
106
  }, theme),
98
107
  filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
99
108
  // but we use "id" (for the input) and "containerId" (for the container)
@@ -111,6 +120,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
111
120
  maxMenuHeight: props.maxMenuHeight,
112
121
  menuPortalTarget: props.menuPortalTarget,
113
122
  menuShouldBlockScroll: props.menuShouldBlockScroll,
123
+ closeMenuOnSelect: props.closeMenuOnSelect,
114
124
  name: props.name,
115
125
  loadingMessage: loadingMessage,
116
126
  noOptionsMessage: props.noOptionsMessage || function (_ref) {
@@ -132,10 +142,9 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
132
142
  return "".concat(props.name, ".0");
133
143
  }()
134
144
  },
135
- // eslint-disable-next-line @typescript-eslint/no-empty-function
136
145
  persist: function persist() {}
137
146
  };
138
- props.onBlur(event);
147
+ props.onBlur && props.onBlur(event);
139
148
  } : undefined,
140
149
  onChange: function onChange(value, info) {
141
150
  var newValue = value;
@@ -149,7 +158,6 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
149
158
  name: props.name,
150
159
  value: newValue
151
160
  },
152
- // eslint-disable-next-line @typescript-eslint/no-empty-function
153
161
  persist: function persist() {}
154
162
  }, info);
155
163
  },
@@ -162,7 +170,8 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
162
170
  ,
163
171
  defaultOptions: props.defaultOptions,
164
172
  loadOptions: props.loadOptions,
165
- cacheOptions: props.cacheOptions,
173
+ cacheOptions: props.cacheOptions // @ts-ignore
174
+ ,
166
175
  iconLeft: props.iconLeft
167
176
  })
168
177
  }))
@@ -173,238 +182,34 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
173
182
  // a signal of the field having been touched.
174
183
 
175
184
 
185
+ AsyncSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
186
+ horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
187
+ hasError: _pt__default["default"].bool,
188
+ hasWarning: _pt__default["default"].bool,
189
+ isReadOnly: _pt__default["default"].bool,
190
+ isAutofocussed: _pt__default["default"].bool,
191
+ menuPortalZIndex: _pt__default["default"].number.isRequired,
192
+ onBlur: _pt__default["default"].func,
193
+ onChange: _pt__default["default"].func.isRequired,
194
+ loadingMessage: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].func]),
195
+ defaultOptions: _pt__default["default"].oneOfType([_pt__default["default"].any, _pt__default["default"].bool]),
196
+ showOptionGroupDivider: _pt__default["default"].bool,
197
+ iconLeft: _pt__default["default"].node
198
+ } : {};
199
+
176
200
  AsyncSelectInput.isTouched = function (touched) {
177
201
  return Boolean(touched);
178
202
  };
179
203
 
180
204
  AsyncSelectInput.displayName = 'AsyncSelectInput';
181
- AsyncSelectInput.defaultProps = {
182
- // Using "null" will ensure that the currently selected value disappears in
183
- // case "undefined" gets passed as the next value
184
- value: null,
185
- isSearchable: true,
186
- menuPortalZIndex: 1
187
- };
188
- AsyncSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
189
- /**
190
- * Horizontal size limit of the input fields.
191
- */
192
- horizontalConstraint: PropTypes__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
193
-
194
- /**
195
- * Indicates the input field has an error
196
- */
197
- hasError: PropTypes__default["default"].bool,
198
-
199
- /**
200
- * Indicates the input field has a warning
201
- */
202
- hasWarning: PropTypes__default["default"].bool,
203
-
204
- /**
205
- * Indicates that the field is displaying read-only content
206
- */
207
- isReadOnly: PropTypes__default["default"].bool,
208
- // react-select base props
209
- //
210
- // Currently unsupported props are commented out. In case you need one of
211
- // these props when using UI Kit, you can submit a PR and enable the
212
- // prop. Don't forget to add it to the story, docs and other select input
213
- // components as well!
214
- //
215
- // See https://react-select.com/props#select-props
216
-
217
- /**
218
- * Aria label (for assistive tech)
219
- */
220
- 'aria-label': PropTypes__default["default"].string,
221
-
222
- /**
223
- * HTML ID of an element that should be used as the label (for assistive tech)
224
- */
225
- 'aria-labelledby': PropTypes__default["default"].string,
226
- // renamed autoFocus of react-select
227
-
228
- /**
229
- * Focus the control when it is mounted
230
- */
231
- isAutofocussed: PropTypes__default["default"].bool,
232
-
233
- /**
234
- * Remove the currently focused option when the user presses backspace
235
- */
236
- backspaceRemovesValue: PropTypes__default["default"].bool,
237
-
238
- /**
239
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
240
- */
241
- components: PropTypes__default["default"].objectOf(PropTypes__default["default"].func),
242
-
243
- /**
244
- * Custom method to filter whether an option should be displayed in the menu
245
- */
246
- filterOption: PropTypes__default["default"].func,
247
- // This forwarded as react-select's "inputId"
248
-
249
- /**
250
- * The id of the search input
251
- */
252
- id: PropTypes__default["default"].string,
253
- inputValue: PropTypes__default["default"].string,
254
- // This is forwarded as react-select's "id"
255
-
256
- /**
257
- * The id to set on the SelectContainer component
258
- */
259
- containerId: PropTypes__default["default"].string,
260
-
261
- /**
262
- * Is the select value clearable
263
- */
264
- isClearable: PropTypes__default["default"].bool,
265
-
266
- /**
267
- * Is the select disabled
268
- */
269
- isDisabled: PropTypes__default["default"].bool,
270
-
271
- /**
272
- * Override the built-in logic to detect whether an option is disabled
273
- */
274
- isOptionDisabled: PropTypes__default["default"].func,
275
-
276
- /**
277
- * Support multiple selected options
278
- */
279
- isMulti: PropTypes__default["default"].bool,
280
-
281
- /**
282
- * Whether to enable search functionality
283
- */
284
- isSearchable: PropTypes__default["default"].bool,
285
-
286
- /**
287
- * Maximum height of the menu before scrolling
288
- */
289
- maxMenuHeight: PropTypes__default["default"].number,
290
-
291
- /**
292
- * Dom element to portal the select menu to
293
- */
294
- menuPortalTarget: PropTypes__default["default"].instanceOf(utils.SafeHTMLElement),
295
-
296
- /**
297
- * z-index value for the menu portal
298
- */
299
- menuPortalZIndex: PropTypes__default["default"].number.isRequired,
300
-
301
- /**
302
- * whether the menu should block scroll while open
303
- */
304
- menuShouldBlockScroll: PropTypes__default["default"].bool,
305
-
306
- /**
307
- * Name of the HTML Input (optional - without this, no input will be rendered)
308
- */
309
- name: PropTypes__default["default"].string,
310
-
311
- /**
312
- * 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 }`. `inputValue` will be an empty string when no search text is present.
313
- */
314
- noOptionsMessage: PropTypes__default["default"].func,
315
-
316
- /**
317
- * Handle blur events on the control
318
- */
319
- onBlur: PropTypes__default["default"].func,
320
-
321
- /**
322
- * Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`.
323
- */
324
- onChange: PropTypes__default["default"].func.isRequired,
325
-
326
- /**
327
- * Handle focus events on the control
328
- */
329
- onFocus: PropTypes__default["default"].func,
330
-
331
- /**
332
- * Handle change events on the input
333
- */
334
- onInputChange: PropTypes__default["default"].func,
335
-
336
- /**
337
- * Placeholder text for the select value
338
- */
339
- placeholder: PropTypes__default["default"].string,
340
-
341
- /**
342
- * loading message shown while the options are being loaded
343
- */
344
- loadingMessage: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]),
345
-
346
- /**
347
- * Sets the tabIndex attribute on the input
348
- */
349
- tabIndex: PropTypes__default["default"].string,
350
-
351
- /**
352
- * Select the currently focused option when the user presses tab
353
- */
354
- tabSelectsValue: PropTypes__default["default"].bool,
355
-
356
- /**
357
- * The value of the select; reflected by the selected option
358
- */
359
- value: function value(props) {
360
- var _context, _context2;
361
-
362
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
363
- rest[_key - 1] = arguments[_key];
364
- }
365
-
366
- return props.isMulti ? PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
367
- value: PropTypes__default["default"].string.isRequired
368
- })).apply(void 0, _concatInstanceProperty__default["default"](_context = [props]).call(_context, rest)) : PropTypes__default["default"].shape({
369
- value: PropTypes__default["default"].string.isRequired
370
- }).apply(void 0, _concatInstanceProperty__default["default"](_context2 = [props]).call(_context2, rest));
371
- },
372
- // Async props
373
-
374
- /**
375
- * The default set of options to show before the user starts searching. When set to true, the results for loadOptions('') will be autoloaded.
376
- */
377
- defaultOptions: PropTypes__default["default"].oneOfType([PropTypes__default["default"].bool, PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
378
- value: PropTypes__default["default"].string.isRequired
379
- }))]),
380
-
381
- /**
382
- * Function that returns a promise, which is the set of options to be used once the promise resolves.
383
- */
384
- loadOptions: PropTypes__default["default"].func.isRequired,
385
-
386
- /**
387
- * If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.
388
- */
389
- cacheOptions: PropTypes__default["default"].any,
390
-
391
- /**
392
- * Determines if option groups will be separated by a divider
393
- */
394
- showOptionGroupDivider: PropTypes__default["default"].bool,
395
-
396
- /**
397
- * Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled.
398
- */
399
- iconLeft: PropTypes__default["default"].node
400
- } : {};
205
+ AsyncSelectInput.defaultProps = defaultProps;
401
206
  utils.addStaticFields(AsyncSelectInput, _objectSpread(_objectSpread(_objectSpread({}, reactSelect.components), customizedComponents), {}, {
402
207
  isTouched: AsyncSelectInput.isTouched
403
208
  }));
404
209
  var AsyncSelectInput$1 = AsyncSelectInput;
405
210
 
406
211
  // NOTE: This string will be replaced on build time with the package version.
407
- var version = "12.2.5";
212
+ var version = "13.0.0";
408
213
 
409
214
  exports["default"] = AsyncSelectInput$1;
410
215
  exports.version = version;
@@ -11,9 +11,9 @@ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-
11
11
  var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
12
12
  var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
13
13
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
14
- require('@babel/runtime-corejs3/core-js-stable/instance/concat');
15
14
  require('prop-types');
16
15
  var reactIntl = require('react-intl');
16
+ var isEmpty = require('lodash/isEmpty');
17
17
  var react = require('@emotion/react');
18
18
  var reactSelect = require('react-select');
19
19
  var AsyncSelect = require('react-select/async');
@@ -33,13 +33,14 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
33
33
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
34
34
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
35
35
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
36
+ var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
36
37
  var AsyncSelect__default = /*#__PURE__*/_interopDefault(AsyncSelect);
37
38
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
38
39
  var LoadingSpinner__default = /*#__PURE__*/_interopDefault(LoadingSpinner);
39
40
 
40
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
41
+ 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; }
41
42
 
42
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
43
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
43
44
 
44
45
  var LoadingIndicator = function LoadingIndicator() {
45
46
  return jsxRuntime.jsx(LoadingSpinner__default["default"], {
@@ -54,6 +55,13 @@ var customizedComponents = {
54
55
  LoadingIndicator: LoadingIndicator,
55
56
  MultiValueRemove: selectUtils.TagRemove
56
57
  };
58
+ var defaultProps = {
59
+ // Using "null" will ensure that the currently selected value disappears in
60
+ // case "undefined" gets passed as the next value
61
+ value: null,
62
+ isSearchable: true,
63
+ menuPortalZIndex: 1
64
+ };
57
65
 
58
66
  var AsyncSelectInput = function AsyncSelectInput(props) {
59
67
  var theme = react.useTheme();
@@ -77,7 +85,6 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
77
85
  autoFocus: props.isAutofocussed,
78
86
  backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
79
87
  components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
80
- // eslint-disable-next-line react/display-name
81
88
  Input: function Input(ownProps) {
82
89
  return jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
83
90
  readOnly: true
@@ -91,7 +98,10 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
91
98
  showOptionGroupDivider: props.showOptionGroupDivider,
92
99
  menuPortalZIndex: props.menuPortalZIndex,
93
100
  isDisabled: props.isDisabled,
94
- isReadOnly: props.isReadOnly
101
+ isReadOnly: props.isReadOnly,
102
+ iconLeft: props.iconLeft,
103
+ isMulti: props.isMulti,
104
+ hasValue: !isEmpty__default["default"](props.value)
95
105
  }, theme),
96
106
  filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
97
107
  // but we use "id" (for the input) and "containerId" (for the container)
@@ -109,6 +119,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
109
119
  maxMenuHeight: props.maxMenuHeight,
110
120
  menuPortalTarget: props.menuPortalTarget,
111
121
  menuShouldBlockScroll: props.menuShouldBlockScroll,
122
+ closeMenuOnSelect: props.closeMenuOnSelect,
112
123
  name: props.name,
113
124
  loadingMessage: loadingMessage,
114
125
  noOptionsMessage: props.noOptionsMessage || function (_ref) {
@@ -130,10 +141,9 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
130
141
  return "".concat(props.name, ".0");
131
142
  }()
132
143
  },
133
- // eslint-disable-next-line @typescript-eslint/no-empty-function
134
144
  persist: function persist() {}
135
145
  };
136
- props.onBlur(event);
146
+ props.onBlur && props.onBlur(event);
137
147
  } : undefined,
138
148
  onChange: function onChange(value, info) {
139
149
  var newValue = value;
@@ -147,7 +157,6 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
147
157
  name: props.name,
148
158
  value: newValue
149
159
  },
150
- // eslint-disable-next-line @typescript-eslint/no-empty-function
151
160
  persist: function persist() {}
152
161
  }, info);
153
162
  },
@@ -160,7 +169,8 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
160
169
  ,
161
170
  defaultOptions: props.defaultOptions,
162
171
  loadOptions: props.loadOptions,
163
- cacheOptions: props.cacheOptions,
172
+ cacheOptions: props.cacheOptions // @ts-ignore
173
+ ,
164
174
  iconLeft: props.iconLeft
165
175
  })
166
176
  }))
@@ -171,26 +181,21 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
171
181
  // a signal of the field having been touched.
172
182
 
173
183
 
184
+ AsyncSelectInput.propTypes = {};
185
+
174
186
  AsyncSelectInput.isTouched = function (touched) {
175
187
  return Boolean(touched);
176
188
  };
177
189
 
178
190
  AsyncSelectInput.displayName = 'AsyncSelectInput';
179
- AsyncSelectInput.defaultProps = {
180
- // Using "null" will ensure that the currently selected value disappears in
181
- // case "undefined" gets passed as the next value
182
- value: null,
183
- isSearchable: true,
184
- menuPortalZIndex: 1
185
- };
186
- AsyncSelectInput.propTypes = {};
191
+ AsyncSelectInput.defaultProps = defaultProps;
187
192
  utils.addStaticFields(AsyncSelectInput, _objectSpread(_objectSpread(_objectSpread({}, reactSelect.components), customizedComponents), {}, {
188
193
  isTouched: AsyncSelectInput.isTouched
189
194
  }));
190
195
  var AsyncSelectInput$1 = AsyncSelectInput;
191
196
 
192
197
  // NOTE: This string will be replaced on build time with the package version.
193
- var version = "12.2.5";
198
+ var version = "13.0.0";
194
199
 
195
200
  exports["default"] = AsyncSelectInput$1;
196
201
  exports.version = version;
@@ -7,21 +7,21 @@ import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-st
7
7
  import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
8
8
  import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
9
9
  import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
10
- import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
11
- import PropTypes from 'prop-types';
10
+ import _pt from 'prop-types';
12
11
  import { useIntl } from 'react-intl';
12
+ import isEmpty from 'lodash/isEmpty';
13
13
  import { useTheme } from '@emotion/react';
14
14
  import { components } from 'react-select';
15
15
  import AsyncSelect from 'react-select/async';
16
- import { filterDataAttributes, SafeHTMLElement, addStaticFields } from '@commercetools-uikit/utils';
16
+ import { filterDataAttributes, addStaticFields } from '@commercetools-uikit/utils';
17
17
  import Constraints from '@commercetools-uikit/constraints';
18
18
  import LoadingSpinner from '@commercetools-uikit/loading-spinner';
19
19
  import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
20
20
  import { jsx } from '@emotion/react/jsx-runtime';
21
21
 
22
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
22
+ 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; }
23
23
 
24
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
25
25
 
26
26
  var LoadingIndicator = function LoadingIndicator() {
27
27
  return jsx(LoadingSpinner, {
@@ -36,6 +36,13 @@ var customizedComponents = {
36
36
  LoadingIndicator: LoadingIndicator,
37
37
  MultiValueRemove: TagRemove
38
38
  };
39
+ var defaultProps = {
40
+ // Using "null" will ensure that the currently selected value disappears in
41
+ // case "undefined" gets passed as the next value
42
+ value: null,
43
+ isSearchable: true,
44
+ menuPortalZIndex: 1
45
+ };
39
46
 
40
47
  var AsyncSelectInput = function AsyncSelectInput(props) {
41
48
  var theme = useTheme();
@@ -59,7 +66,6 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
59
66
  autoFocus: props.isAutofocussed,
60
67
  backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
61
68
  components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
62
- // eslint-disable-next-line react/display-name
63
69
  Input: function Input(ownProps) {
64
70
  return jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
65
71
  readOnly: true
@@ -73,7 +79,10 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
73
79
  showOptionGroupDivider: props.showOptionGroupDivider,
74
80
  menuPortalZIndex: props.menuPortalZIndex,
75
81
  isDisabled: props.isDisabled,
76
- isReadOnly: props.isReadOnly
82
+ isReadOnly: props.isReadOnly,
83
+ iconLeft: props.iconLeft,
84
+ isMulti: props.isMulti,
85
+ hasValue: !isEmpty(props.value)
77
86
  }, theme),
78
87
  filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
79
88
  // but we use "id" (for the input) and "containerId" (for the container)
@@ -91,6 +100,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
91
100
  maxMenuHeight: props.maxMenuHeight,
92
101
  menuPortalTarget: props.menuPortalTarget,
93
102
  menuShouldBlockScroll: props.menuShouldBlockScroll,
103
+ closeMenuOnSelect: props.closeMenuOnSelect,
94
104
  name: props.name,
95
105
  loadingMessage: loadingMessage,
96
106
  noOptionsMessage: props.noOptionsMessage || function (_ref) {
@@ -112,10 +122,9 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
112
122
  return "".concat(props.name, ".0");
113
123
  }()
114
124
  },
115
- // eslint-disable-next-line @typescript-eslint/no-empty-function
116
125
  persist: function persist() {}
117
126
  };
118
- props.onBlur(event);
127
+ props.onBlur && props.onBlur(event);
119
128
  } : undefined,
120
129
  onChange: function onChange(value, info) {
121
130
  var newValue = value;
@@ -129,7 +138,6 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
129
138
  name: props.name,
130
139
  value: newValue
131
140
  },
132
- // eslint-disable-next-line @typescript-eslint/no-empty-function
133
141
  persist: function persist() {}
134
142
  }, info);
135
143
  },
@@ -142,7 +150,8 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
142
150
  ,
143
151
  defaultOptions: props.defaultOptions,
144
152
  loadOptions: props.loadOptions,
145
- cacheOptions: props.cacheOptions,
153
+ cacheOptions: props.cacheOptions // @ts-ignore
154
+ ,
146
155
  iconLeft: props.iconLeft
147
156
  })
148
157
  }))
@@ -153,237 +162,33 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
153
162
  // a signal of the field having been touched.
154
163
 
155
164
 
165
+ AsyncSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
166
+ horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
167
+ hasError: _pt.bool,
168
+ hasWarning: _pt.bool,
169
+ isReadOnly: _pt.bool,
170
+ isAutofocussed: _pt.bool,
171
+ menuPortalZIndex: _pt.number.isRequired,
172
+ onBlur: _pt.func,
173
+ onChange: _pt.func.isRequired,
174
+ loadingMessage: _pt.oneOfType([_pt.string, _pt.func]),
175
+ defaultOptions: _pt.oneOfType([_pt.any, _pt.bool]),
176
+ showOptionGroupDivider: _pt.bool,
177
+ iconLeft: _pt.node
178
+ } : {};
179
+
156
180
  AsyncSelectInput.isTouched = function (touched) {
157
181
  return Boolean(touched);
158
182
  };
159
183
 
160
184
  AsyncSelectInput.displayName = 'AsyncSelectInput';
161
- AsyncSelectInput.defaultProps = {
162
- // Using "null" will ensure that the currently selected value disappears in
163
- // case "undefined" gets passed as the next value
164
- value: null,
165
- isSearchable: true,
166
- menuPortalZIndex: 1
167
- };
168
- AsyncSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
169
- /**
170
- * Horizontal size limit of the input fields.
171
- */
172
- horizontalConstraint: PropTypes.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
173
-
174
- /**
175
- * Indicates the input field has an error
176
- */
177
- hasError: PropTypes.bool,
178
-
179
- /**
180
- * Indicates the input field has a warning
181
- */
182
- hasWarning: PropTypes.bool,
183
-
184
- /**
185
- * Indicates that the field is displaying read-only content
186
- */
187
- isReadOnly: PropTypes.bool,
188
- // react-select base props
189
- //
190
- // Currently unsupported props are commented out. In case you need one of
191
- // these props when using UI Kit, you can submit a PR and enable the
192
- // prop. Don't forget to add it to the story, docs and other select input
193
- // components as well!
194
- //
195
- // See https://react-select.com/props#select-props
196
-
197
- /**
198
- * Aria label (for assistive tech)
199
- */
200
- 'aria-label': PropTypes.string,
201
-
202
- /**
203
- * HTML ID of an element that should be used as the label (for assistive tech)
204
- */
205
- 'aria-labelledby': PropTypes.string,
206
- // renamed autoFocus of react-select
207
-
208
- /**
209
- * Focus the control when it is mounted
210
- */
211
- isAutofocussed: PropTypes.bool,
212
-
213
- /**
214
- * Remove the currently focused option when the user presses backspace
215
- */
216
- backspaceRemovesValue: PropTypes.bool,
217
-
218
- /**
219
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
220
- */
221
- components: PropTypes.objectOf(PropTypes.func),
222
-
223
- /**
224
- * Custom method to filter whether an option should be displayed in the menu
225
- */
226
- filterOption: PropTypes.func,
227
- // This forwarded as react-select's "inputId"
228
-
229
- /**
230
- * The id of the search input
231
- */
232
- id: PropTypes.string,
233
- inputValue: PropTypes.string,
234
- // This is forwarded as react-select's "id"
235
-
236
- /**
237
- * The id to set on the SelectContainer component
238
- */
239
- containerId: PropTypes.string,
240
-
241
- /**
242
- * Is the select value clearable
243
- */
244
- isClearable: PropTypes.bool,
245
-
246
- /**
247
- * Is the select disabled
248
- */
249
- isDisabled: PropTypes.bool,
250
-
251
- /**
252
- * Override the built-in logic to detect whether an option is disabled
253
- */
254
- isOptionDisabled: PropTypes.func,
255
-
256
- /**
257
- * Support multiple selected options
258
- */
259
- isMulti: PropTypes.bool,
260
-
261
- /**
262
- * Whether to enable search functionality
263
- */
264
- isSearchable: PropTypes.bool,
265
-
266
- /**
267
- * Maximum height of the menu before scrolling
268
- */
269
- maxMenuHeight: PropTypes.number,
270
-
271
- /**
272
- * Dom element to portal the select menu to
273
- */
274
- menuPortalTarget: PropTypes.instanceOf(SafeHTMLElement),
275
-
276
- /**
277
- * z-index value for the menu portal
278
- */
279
- menuPortalZIndex: PropTypes.number.isRequired,
280
-
281
- /**
282
- * whether the menu should block scroll while open
283
- */
284
- menuShouldBlockScroll: PropTypes.bool,
285
-
286
- /**
287
- * Name of the HTML Input (optional - without this, no input will be rendered)
288
- */
289
- name: PropTypes.string,
290
-
291
- /**
292
- * 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 }`. `inputValue` will be an empty string when no search text is present.
293
- */
294
- noOptionsMessage: PropTypes.func,
295
-
296
- /**
297
- * Handle blur events on the control
298
- */
299
- onBlur: PropTypes.func,
300
-
301
- /**
302
- * Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`.
303
- */
304
- onChange: PropTypes.func.isRequired,
305
-
306
- /**
307
- * Handle focus events on the control
308
- */
309
- onFocus: PropTypes.func,
310
-
311
- /**
312
- * Handle change events on the input
313
- */
314
- onInputChange: PropTypes.func,
315
-
316
- /**
317
- * Placeholder text for the select value
318
- */
319
- placeholder: PropTypes.string,
320
-
321
- /**
322
- * loading message shown while the options are being loaded
323
- */
324
- loadingMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
325
-
326
- /**
327
- * Sets the tabIndex attribute on the input
328
- */
329
- tabIndex: PropTypes.string,
330
-
331
- /**
332
- * Select the currently focused option when the user presses tab
333
- */
334
- tabSelectsValue: PropTypes.bool,
335
-
336
- /**
337
- * The value of the select; reflected by the selected option
338
- */
339
- value: function value(props) {
340
- var _context, _context2;
341
-
342
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
343
- rest[_key - 1] = arguments[_key];
344
- }
345
-
346
- return props.isMulti ? PropTypes.arrayOf(PropTypes.shape({
347
- value: PropTypes.string.isRequired
348
- })).apply(void 0, _concatInstanceProperty(_context = [props]).call(_context, rest)) : PropTypes.shape({
349
- value: PropTypes.string.isRequired
350
- }).apply(void 0, _concatInstanceProperty(_context2 = [props]).call(_context2, rest));
351
- },
352
- // Async props
353
-
354
- /**
355
- * The default set of options to show before the user starts searching. When set to true, the results for loadOptions('') will be autoloaded.
356
- */
357
- defaultOptions: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.shape({
358
- value: PropTypes.string.isRequired
359
- }))]),
360
-
361
- /**
362
- * Function that returns a promise, which is the set of options to be used once the promise resolves.
363
- */
364
- loadOptions: PropTypes.func.isRequired,
365
-
366
- /**
367
- * If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.
368
- */
369
- cacheOptions: PropTypes.any,
370
-
371
- /**
372
- * Determines if option groups will be separated by a divider
373
- */
374
- showOptionGroupDivider: PropTypes.bool,
375
-
376
- /**
377
- * Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled.
378
- */
379
- iconLeft: PropTypes.node
380
- } : {};
185
+ AsyncSelectInput.defaultProps = defaultProps;
381
186
  addStaticFields(AsyncSelectInput, _objectSpread(_objectSpread(_objectSpread({}, components), customizedComponents), {}, {
382
187
  isTouched: AsyncSelectInput.isTouched
383
188
  }));
384
189
  var AsyncSelectInput$1 = AsyncSelectInput;
385
190
 
386
191
  // NOTE: This string will be replaced on build time with the package version.
387
- var version = "12.2.5";
192
+ var version = "13.0.0";
388
193
 
389
194
  export { AsyncSelectInput$1 as default, version };
@@ -0,0 +1,59 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ActionMeta, type GroupBase, type OptionsOrGroups } from 'react-select';
3
+ import { type AsyncProps } from 'react-select/async';
4
+ declare type TEvent = {
5
+ target: {
6
+ name?: string;
7
+ value?: unknown;
8
+ };
9
+ persist: () => void;
10
+ };
11
+ declare type ReactSelectAsyncProps = AsyncProps<unknown, boolean, GroupBase<unknown>>;
12
+ declare type TAsyncSelectInputProps = {
13
+ horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
14
+ hasError?: boolean;
15
+ hasWarning?: boolean;
16
+ isReadOnly?: boolean;
17
+ 'aria-label'?: ReactSelectAsyncProps['aria-label'];
18
+ 'aria-labelledby'?: ReactSelectAsyncProps['aria-labelledby'];
19
+ isAutofocussed?: boolean;
20
+ backspaceRemovesValue?: ReactSelectAsyncProps['backspaceRemovesValue'];
21
+ components?: ReactSelectAsyncProps['components'];
22
+ filterOption?: ReactSelectAsyncProps['filterOption'];
23
+ id?: ReactSelectAsyncProps['inputId'];
24
+ inputValue?: ReactSelectAsyncProps['inputValue'];
25
+ containerId?: ReactSelectAsyncProps['id'];
26
+ isClearable?: ReactSelectAsyncProps['isClearable'];
27
+ isDisabled?: ReactSelectAsyncProps['isDisabled'];
28
+ isOptionDisabled?: ReactSelectAsyncProps['isOptionDisabled'];
29
+ isMulti?: ReactSelectAsyncProps['isMulti'];
30
+ isSearchable?: ReactSelectAsyncProps['isSearchable'];
31
+ maxMenuHeight?: ReactSelectAsyncProps['maxMenuHeight'];
32
+ menuPortalTarget?: ReactSelectAsyncProps['menuPortalTarget'];
33
+ menuPortalZIndex: number;
34
+ menuShouldBlockScroll?: ReactSelectAsyncProps['menuShouldBlockScroll'];
35
+ closeMenuOnSelect?: ReactSelectAsyncProps['closeMenuOnSelect'];
36
+ name?: ReactSelectAsyncProps['name'];
37
+ noOptionsMessage?: ReactSelectAsyncProps['noOptionsMessage'];
38
+ onBlur?: (event: TEvent) => void;
39
+ onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
40
+ onFocus?: ReactSelectAsyncProps['onFocus'];
41
+ onInputChange?: ReactSelectAsyncProps['onInputChange'];
42
+ placeholder?: ReactSelectAsyncProps['placeholder'];
43
+ loadingMessage?: string | (() => string);
44
+ tabIndex?: ReactSelectAsyncProps['tabIndex'];
45
+ tabSelectsValue?: ReactSelectAsyncProps['tabSelectsValue'];
46
+ value?: ReactSelectAsyncProps['value'];
47
+ defaultOptions?: OptionsOrGroups<unknown, GroupBase<unknown>> | boolean;
48
+ loadOptions: ReactSelectAsyncProps['loadOptions'];
49
+ cacheOptions?: ReactSelectAsyncProps['cacheOptions'];
50
+ showOptionGroupDivider?: boolean;
51
+ iconLeft?: ReactNode;
52
+ };
53
+ declare const AsyncSelectInput: {
54
+ (props: TAsyncSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
55
+ isTouched(touched: unknown): boolean;
56
+ displayName: string;
57
+ defaultProps: Pick<TAsyncSelectInputProps, "value" | "isSearchable" | "menuPortalZIndex">;
58
+ };
59
+ export default AsyncSelectInput;
@@ -0,0 +1,2 @@
1
+ export { default } from './async-select-input';
2
+ export { default as version } from './version';
@@ -0,0 +1,2 @@
1
+ declare const _default: "__@UI_KIT_PACKAGE/VERSION_OF_RELEASE__";
2
+ export default _default;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/async-select-input",
3
3
  "description": "An input component getting a selection from an asynchronously loaded list from the user.",
4
- "version": "12.2.5",
4
+ "version": "13.0.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -9,12 +9,7 @@
9
9
  "directory": "packages/components/inputs/async-select-input"
10
10
  },
11
11
  "homepage": "https://uikit.commercetools.com",
12
- "keywords": [
13
- "javascript",
14
- "design system",
15
- "react",
16
- "uikit"
17
- ],
12
+ "keywords": ["javascript", "design system", "react", "uikit"],
18
13
  "license": "MIT",
19
14
  "publishConfig": {
20
15
  "access": "public"
@@ -22,30 +17,28 @@
22
17
  "sideEffects": false,
23
18
  "main": "dist/commercetools-uikit-async-select-input.cjs.js",
24
19
  "module": "dist/commercetools-uikit-async-select-input.esm.js",
25
- "files": [
26
- "dist"
27
- ],
20
+ "files": ["dist"],
28
21
  "dependencies": {
29
- "@babel/runtime": "7.16.3",
30
- "@babel/runtime-corejs3": "7.16.3",
31
- "@commercetools-uikit/constraints": "12.2.5",
32
- "@commercetools-uikit/design-system": "12.2.5",
33
- "@commercetools-uikit/icons": "12.2.5",
34
- "@commercetools-uikit/loading-spinner": "12.2.5",
35
- "@commercetools-uikit/select-utils": "12.2.5",
36
- "@commercetools-uikit/spacings": "12.2.5",
37
- "@commercetools-uikit/text": "12.2.5",
38
- "@commercetools-uikit/utils": "12.2.5",
22
+ "@babel/runtime": "7.17.2",
23
+ "@babel/runtime-corejs3": "7.17.2",
24
+ "@commercetools-uikit/constraints": "13.0.0",
25
+ "@commercetools-uikit/design-system": "13.0.0",
26
+ "@commercetools-uikit/icons": "13.0.0",
27
+ "@commercetools-uikit/loading-spinner": "13.0.0",
28
+ "@commercetools-uikit/select-utils": "13.0.0",
29
+ "@commercetools-uikit/spacings": "13.0.0",
30
+ "@commercetools-uikit/text": "13.0.0",
31
+ "@commercetools-uikit/utils": "12.2.9",
39
32
  "@emotion/react": "^11.4.0",
40
33
  "@emotion/styled": "^11.3.0",
41
34
  "lodash": "4.17.21",
42
- "prop-types": "15.7.2",
43
- "react-select": "4.3.1"
35
+ "prop-types": "15.8.1",
36
+ "react-select": "5.2.2"
44
37
  },
45
38
  "devDependencies": {
46
39
  "react": "17.0.2",
47
40
  "react-dom": "17.0.2",
48
- "react-intl": "5.21.2"
41
+ "react-intl": "5.24.6"
49
42
  },
50
43
  "peerDependencies": {
51
44
  "react": "17.x",