@commercetools-uikit/creatable-select-input 12.2.9 → 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
@@ -52,53 +52,64 @@ export default Example;
52
52
 
53
53
  ## Properties
54
54
 
55
- | Props | Type | Required | Default | Description |
56
- | ---------------------------------- | -------------------------------------------------------------------------------------------------- | :------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
57
- | `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. |
58
- | `hasError` | `bool` | | | Indicates the input field has an error |
59
- | `hasWarning` | `bool` | | | Indicates the input field has a warning |
60
- | `isReadOnly` | `bool` | | | Disables the select input as it is read-only |
61
- | `iconLeft` | `node` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
62
- | `aria-label` | `string` | | | Aria label (for assistive tech) |
63
- | `aria-labelledby` | `string` | | | HTML ID of an element that should be used as the label (for assistive tech) |
64
- | `isAutofocussed` | `bool` | | | Focus the control when it is mounted |
65
- | `backspaceRemovesValue` | `bool` | | | Remove the currently focused option when the user presses backspace |
66
- | `components` | `objectOf(func)` | | | Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components) |
67
- | `filterOption` | `func` | | | Custom method to filter whether an option should be displayed in the menu |
68
- | `id` | `string` | | | The id of the search input |
69
- | `inputValue` | `string` | | | |
70
- | `containerId` | `string` | | | The id to set on the SelectContainer component |
71
- | `isClearable` | `bool` | | | Is the select value clearable |
72
- | `isDisabled` | `bool` | | | Is the select disabled |
73
- | `isOptionDisabled` | `func` | | | Override the built-in logic to detect whether an option is disabled |
74
- | `isMulti` | `bool` | | | Support multiple selected options |
75
- | `isSearchable` | `bool` | | `true` | Whether to enable search functionality |
76
- | `maxMenuHeight` | `number` | | | Maximum height of the menu before scrolling |
77
- | `menuPortalTarget` | `SafeHTMLElement` | | | Dom element to portal the select menu to |
78
- | `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal |
79
- | `menuShouldBlockScroll` | `bool` | | | whether the menu should block scroll while open |
80
- | `name` | `string` | | | Name of the HTML Input (optional - without this, no input will be rendered) |
81
- | `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. |
82
- | `onBlur` | `func` | | | Handle blur events on the control |
83
- | `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`.&#xA;<br />&#xA;Signature: `(event) => void` |
84
- | `onFocus` | `func` | | | Handle focus events on the control |
85
- | `onInputChange` | `func` | | | Handle change events on the input |
86
- | `options` | `array` | | | Array of options that populate the select menu |
87
- | `options[]<shape>` | `object` | | | |
88
- | `options[]<shape>.value` | `string` || | |
89
- | `options[]<shape>.options` | `array` | | | |
90
- | `options[]<shape>.options[].value` | `string` || | |
91
- | `showOptionGroupDivider` | `bool` | | | Determines if option groups will be separated by a divider |
92
- | `placeholder` | `string` | | | Placeholder text for the select value |
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
- | `allowCreateWhileLoading` | `bool` | | | Allow options to be created while the isLoading prop is true. Useful to prevent the "create new ..." option being displayed while async results are still being loaded. |
97
- | `formatCreateLabel` | `func` | | | Gets the label for the "create new ..." option in the menu. Is given the current input value. |
98
- | `isValidNewOption` | `func` | | | Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array. |
99
- | `getNewOptionData` | `func` | | | Returns the data for the new option when it is created. Used to display the value, and is passed to onChange. |
100
- | `onCreateOption` | `func` | | | If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created. |
101
- | `createOptionPosition` | `string` | | | Sets the position of the createOption element in your options list. |
55
+ | Props | Type | Required | Default | Description |
56
+ | ------------------------- | ----------------------------------------------------------------------------------------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
57
+ | `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. |
58
+ | `hasError` | `boolean` | | | Indicates the input field has an error |
59
+ | `hasWarning` | `boolean` | | | Indicates the input field has a warning |
60
+ | `isReadOnly` | `boolean` | | | Disables the select input as it is read-only |
61
+ | `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
62
+ | `aria-label` | `CreatableProps['aria-label']` || | Aria label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
63
+ | `aria-labelledby` | `CreatableProps['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#creatable-props) |
64
+ | `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
65
+ | `backspaceRemovesValue` | `CreatableProps['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#creatable-props) |
66
+ | `components` | `CreatableProps['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#creatable-props) |
67
+ | `filterOption` | `CreatableProps['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#creatable-props) |
68
+ | `id` | `CreatableProps['inputId']` | | | The id of the search input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
69
+ | `inputValue` | `CreatableProps['inputValue']` | | | The value of the search input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
70
+ | `containerId` | `CreatableProps['id']` | | | The id to set on the SelectContainer component&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
71
+ | `isClearable` | `CreatableProps['isClearable']` | | | Is the select value clearable&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
72
+ | `isDisabled` | `CreatableProps['isDisabled']` | | | Is the select disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
73
+ | `isOptionDisabled` | `CreatableProps['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#creatable-props) |
74
+ | `isMulti` | `CreatableProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
75
+ | `isSearchable` | `CreatableProps['isSearchable']` | | `true` | Whether to enable search functionality&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
76
+ | `maxMenuHeight` | `CreatableProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
77
+ | `menuPortalTarget` | `CreatableProps['menuPortalTarget']` | | | Dom element to portal the select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
78
+ | `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal |
79
+ | `menuShouldBlockScroll` | `CreatableProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
80
+ | `closeMenuOnSelect` | `CreatableProps['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#creatable-props) |
81
+ | `name` | `CreatableProps['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#creatable-props) |
82
+ | `noOptionsMessage` | `CreatableProps['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#creatable-props) |
83
+ | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
84
+ | `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`.&#xA;<br />&#xA;Signature: `(event) => void` |
85
+ | `onFocus` | `CreatableProps['onFocus']` | | | Handle focus events on the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
86
+ | `onInputChange` | `CreatableProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
87
+ | `options` | `union`<br/>Possible values:<br/>`TValue[] , { options: TValue[] }[]` || | Array of options that populate the select menu |
88
+ | `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
89
+ | `placeholder` | `CreatableProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
90
+ | `tabIndex` | `CreatableProps['tabIndex']` | | | Sets the tabIndex attribute on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
91
+ | `tabSelectsValue` | `CreatableProps['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#creatable-props) |
92
+ | `value` | `CreatableProps['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#creatable-props) |
93
+ | `allowCreateWhileLoading` | `CreatableProps['allowCreateWhileLoading']` | | | Allow options to be created while the isLoading prop is true. Useful to prevent the "create new ..." option being displayed while async results are still being loaded.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
94
+ | `formatCreateLabel` | `CreatableProps['formatCreateLabel']` | | | Gets the label for the "create new ..." option in the menu. Is given the current input value.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
95
+ | `isValidNewOption` | `CreatableProps['isValidNewOption']` | | | Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
96
+ | `getNewOptionData` | `CreatableProps['getNewOptionData']` | | | Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
97
+ | `onCreateOption` | `CreatableProps['onCreateOption']` | | | If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
98
+ | `createOptionPosition` | `CreatableProps['createOptionPosition']` | | | Sets the position of the createOption element in your options list.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
99
+
100
+ ## Signatures
101
+
102
+ ### Signature `onBlur`
103
+
104
+ ```ts
105
+ (event: TEvent) => void
106
+ ```
107
+
108
+ ### Signature `onChange`
109
+
110
+ ```ts
111
+ (event: TEvent, info: ActionMeta<unknown>) => void
112
+ ```
102
113
 
103
114
  This input is built on top of [`react-select`](https://github.com/JedWatson/react-select) v2.
104
115
  It supports mostly same properties as `react-select`. Behaviour 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,8 +11,7 @@ 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');
17
16
  var isEmpty = require('lodash/isEmpty');
18
17
  var react = require('@emotion/react');
@@ -33,20 +32,32 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
33
32
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
34
33
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
35
34
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
36
- var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
37
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
35
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
38
36
  var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
39
37
  var CreatableSelect__default = /*#__PURE__*/_interopDefault(CreatableSelect);
40
38
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
41
39
 
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; }
40
+ 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
41
 
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; }
42
+ 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
43
  var customizedComponents = {
46
44
  DropdownIndicator: selectUtils.DropdownIndicator,
47
45
  ClearIndicator: selectUtils.ClearIndicator,
48
46
  MultiValueRemove: selectUtils.TagRemove
49
47
  };
48
+ var defaultProps = {
49
+ // Using "null" will ensure that the currently selected value disappears in
50
+ // case "undefined" gets passed as the next value
51
+ value: null,
52
+ // The input needs to be searchable, otherwise it's not possible to create
53
+ // new options.
54
+ // We still allow consumers to pass isSearchable={false} so that they can
55
+ // use CreatableSelectInput as an alternative to SelectInput, which does
56
+ // not do the option/value mapping going on there and therefore provides
57
+ // the default API of react-select.
58
+ isSearchable: true,
59
+ menuPortalZIndex: 1
60
+ };
50
61
 
51
62
  var CreatableSelectInput = function CreatableSelectInput(props) {
52
63
  var intl = reactIntl.useIntl();
@@ -61,7 +72,6 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
61
72
  autoFocus: props.isAutofocussed,
62
73
  backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
63
74
  components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.components), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
64
- // eslint-disable-next-line react/display-name
65
75
  Input: function Input(ownProps) {
66
76
  return jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
67
77
  readOnly: true
@@ -96,6 +106,7 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
96
106
  maxMenuHeight: props.maxMenuHeight,
97
107
  menuPortalTarget: props.menuPortalTarget,
98
108
  menuShouldBlockScroll: props.menuShouldBlockScroll,
109
+ closeMenuOnSelect: props.closeMenuOnSelect,
99
110
  name: props.name,
100
111
  noOptionsMessage: props.noOptionsMessage || function (_ref) {
101
112
  var inputValue = _ref.inputValue;
@@ -115,10 +126,9 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
115
126
  return props.name ? "".concat(props.name, ".0") : undefined;
116
127
  }()
117
128
  },
118
- // eslint-disable-next-line @typescript-eslint/no-empty-function
119
129
  persist: function persist() {}
120
130
  };
121
- props.onBlur(event);
131
+ props.onBlur && props.onBlur(event);
122
132
  } : undefined,
123
133
  onChange: function onChange(value, info) {
124
134
  // selectedOptions is either an array, or a single option, or null
@@ -134,7 +144,6 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
134
144
  name: props.name,
135
145
  value: newValue
136
146
  },
137
- // eslint-disable-next-line @typescript-eslint/no-empty-function
138
147
  persist: function persist() {}
139
148
  }, info);
140
149
  },
@@ -155,13 +164,33 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
155
164
  isValidNewOption: props.isValidNewOption,
156
165
  getNewOptionData: props.getNewOptionData,
157
166
  onCreateOption: props.onCreateOption,
158
- createOptionPosition: props.createOptionPosition,
167
+ createOptionPosition: props.createOptionPosition //@ts-ignore
168
+ ,
159
169
  iconLeft: props.iconLeft
160
170
  })
161
171
  }))
162
172
  });
163
173
  };
164
174
 
175
+ CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
176
+ horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
177
+ hasError: _pt__default["default"].bool,
178
+ hasWarning: _pt__default["default"].bool,
179
+ isReadOnly: _pt__default["default"].bool,
180
+ iconLeft: _pt__default["default"].node,
181
+ isAutofocussed: _pt__default["default"].bool,
182
+ menuPortalZIndex: _pt__default["default"].number.isRequired,
183
+ onBlur: _pt__default["default"].func,
184
+ onChange: _pt__default["default"].func.isRequired,
185
+ options: _pt__default["default"].oneOfType([_pt__default["default"].arrayOf(_pt__default["default"].shape({
186
+ value: _pt__default["default"].string.isRequired
187
+ })), _pt__default["default"].arrayOf(_pt__default["default"].shape({
188
+ options: _pt__default["default"].arrayOf(_pt__default["default"].shape({
189
+ value: _pt__default["default"].string.isRequired
190
+ })).isRequired
191
+ }))]).isRequired,
192
+ showOptionGroupDivider: _pt__default["default"].bool
193
+ } : {};
165
194
  CreatableSelectInput.displayName = 'CreatableSelectInput'; // Both "true" and an empty array [] represent a touched state. The Boolean
166
195
  // conveniently handles both cases
167
196
 
@@ -169,260 +198,14 @@ CreatableSelectInput.isTouched = function (touched) {
169
198
  return Boolean(touched);
170
199
  };
171
200
 
172
- CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
173
- /**
174
- * Horizontal size limit of the input fields.
175
- */
176
- horizontalConstraint: PropTypes__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
177
-
178
- /**
179
- * Indicates the input field has an error
180
- */
181
- hasError: PropTypes__default["default"].bool,
182
-
183
- /**
184
- * Indicates the input field has a warning
185
- */
186
- hasWarning: PropTypes__default["default"].bool,
187
-
188
- /**
189
- * Disables the select input as it is read-only
190
- */
191
- isReadOnly: PropTypes__default["default"].bool,
192
-
193
- /**
194
- * Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled.
195
- */
196
- iconLeft: PropTypes__default["default"].node,
197
- // react-select base props
198
- //
199
- // Currently unsupported props are commented out. In case you need one of
200
- // these props when using UI Kit, you can submit a PR and enable the
201
- // prop. Don't forget to add it to the story, docs and other select input
202
- // components as well!
203
- //
204
- // See https://react-select.com/props#select-props
205
-
206
- /**
207
- * Aria label (for assistive tech)
208
- */
209
- 'aria-label': PropTypes__default["default"].string,
210
-
211
- /**
212
- * HTML ID of an element that should be used as the label (for assistive tech)
213
- */
214
- 'aria-labelledby': PropTypes__default["default"].string,
215
-
216
- /**
217
- * Focus the control when it is mounted
218
- */
219
- isAutofocussed: PropTypes__default["default"].bool,
220
- // original: autoFocus
221
-
222
- /**
223
- * Remove the currently focused option when the user presses backspace
224
- */
225
- backspaceRemovesValue: PropTypes__default["default"].bool,
226
-
227
- /**
228
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
229
- */
230
- components: PropTypes__default["default"].objectOf(PropTypes__default["default"].func),
231
-
232
- /**
233
- * Custom method to filter whether an option should be displayed in the menu
234
- */
235
- filterOption: PropTypes__default["default"].func,
236
- // This forwarded as react-select's "inputId"
237
-
238
- /**
239
- * The id of the search input
240
- */
241
- id: PropTypes__default["default"].string,
242
- // This is forwarded as react-select's "id"
243
- inputValue: PropTypes__default["default"].string,
244
-
245
- /**
246
- * The id to set on the SelectContainer component
247
- */
248
- containerId: PropTypes__default["default"].string,
249
-
250
- /**
251
- * Is the select value clearable
252
- */
253
- isClearable: PropTypes__default["default"].bool,
254
-
255
- /**
256
- * Is the select disabled
257
- */
258
- isDisabled: PropTypes__default["default"].bool,
259
-
260
- /**
261
- * Override the built-in logic to detect whether an option is disabled
262
- */
263
- isOptionDisabled: PropTypes__default["default"].func,
264
-
265
- /**
266
- * Support multiple selected options
267
- */
268
- isMulti: PropTypes__default["default"].bool,
269
-
270
- /**
271
- * Whether to enable search functionality
272
- */
273
- isSearchable: PropTypes__default["default"].bool,
274
-
275
- /**
276
- * Maximum height of the menu before scrolling
277
- */
278
- maxMenuHeight: PropTypes__default["default"].number,
279
-
280
- /**
281
- * Dom element to portal the select menu to
282
- */
283
- menuPortalTarget: PropTypes__default["default"].instanceOf(utils.SafeHTMLElement),
284
-
285
- /**
286
- * z-index value for the menu portal
287
- */
288
- menuPortalZIndex: PropTypes__default["default"].number.isRequired,
289
-
290
- /**
291
- * whether the menu should block scroll while open
292
- */
293
- menuShouldBlockScroll: PropTypes__default["default"].bool,
294
-
295
- /**
296
- * Name of the HTML Input (optional - without this, no input will be rendered)
297
- */
298
- name: PropTypes__default["default"].string,
299
-
300
- /**
301
- * 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.
302
- */
303
- noOptionsMessage: PropTypes__default["default"].func,
304
-
305
- /**
306
- * Handle blur events on the control
307
- */
308
- onBlur: PropTypes__default["default"].func,
309
-
310
- /**
311
- * 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`.
312
- * <br />
313
- * Signature: `(event) => void`
314
- */
315
- onChange: PropTypes__default["default"].func.isRequired,
316
-
317
- /**
318
- * Handle focus events on the control
319
- */
320
- onFocus: PropTypes__default["default"].func,
321
-
322
- /**
323
- * Handle change events on the input
324
- */
325
- onInputChange: PropTypes__default["default"].func,
326
-
327
- /**
328
- * Array of options that populate the select menu
329
- */
330
- options: PropTypes__default["default"].arrayOf(PropTypes__default["default"].oneOfType([PropTypes__default["default"].shape({
331
- value: PropTypes__default["default"].string.isRequired
332
- }), PropTypes__default["default"].shape({
333
- options: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
334
- value: PropTypes__default["default"].string.isRequired
335
- }))
336
- })])),
337
-
338
- /**
339
- * Determines if option groups will be separated by a divider
340
- */
341
- showOptionGroupDivider: PropTypes__default["default"].bool,
342
-
343
- /**
344
- * Placeholder text for the select value
345
- */
346
- placeholder: PropTypes__default["default"].string,
347
-
348
- /**
349
- * Sets the tabIndex attribute on the input
350
- */
351
- tabIndex: PropTypes__default["default"].string,
352
-
353
- /**
354
- * Select the currently focused option when the user presses tab
355
- */
356
- tabSelectsValue: PropTypes__default["default"].bool,
357
-
358
- /**
359
- * The value of the select; reflected by the selected option
360
- */
361
- value: function value(props) {
362
- var _context, _context2;
363
-
364
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
365
- rest[_key - 1] = arguments[_key];
366
- }
367
-
368
- return props.isMulti ? PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
369
- value: PropTypes__default["default"].string.isRequired
370
- })).apply(void 0, _concatInstanceProperty__default["default"](_context = [props]).call(_context, rest)) : PropTypes__default["default"].shape({
371
- value: PropTypes__default["default"].string.isRequired
372
- }).apply(void 0, _concatInstanceProperty__default["default"](_context2 = [props]).call(_context2, rest));
373
- },
374
- // Creatable props
375
-
376
- /**
377
- * Allow options to be created while the isLoading prop is true. Useful to prevent the "create new ..." option being displayed while async results are still being loaded.
378
- */
379
- allowCreateWhileLoading: PropTypes__default["default"].bool,
380
-
381
- /**
382
- * Gets the label for the "create new ..." option in the menu. Is given the current input value.
383
- */
384
- formatCreateLabel: PropTypes__default["default"].func,
385
-
386
- /**
387
- * Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.
388
- */
389
- isValidNewOption: PropTypes__default["default"].func,
390
-
391
- /**
392
- * Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.
393
- */
394
- getNewOptionData: PropTypes__default["default"].func,
395
-
396
- /**
397
- * If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created.
398
- */
399
- onCreateOption: PropTypes__default["default"].func,
400
-
401
- /**
402
- * Sets the position of the createOption element in your options list.
403
- */
404
- createOptionPosition: PropTypes__default["default"].string
405
- } : {};
406
- CreatableSelectInput.defaultProps = {
407
- // Using "null" will ensure that the currently selected value disappears in
408
- // case "undefined" gets passed as the next value
409
- value: null,
410
- // The input needs to be searchable, otherwise it's not possible to create
411
- // new options.
412
- // We still allow consumers to pass isSearchable={false} so that they can
413
- // use CreatableSelectInput as an alternative to SelectInput, which does
414
- // not do the option/value mapping going on there and therefore provides
415
- // the default API of react-select.
416
- isSearchable: true,
417
- menuPortalZIndex: 1
418
- };
201
+ CreatableSelectInput.defaultProps = defaultProps;
419
202
  utils.addStaticFields(CreatableSelectInput, _objectSpread(_objectSpread(_objectSpread({}, reactSelect.components), customizedComponents), {}, {
420
203
  isTouched: CreatableSelectInput.isTouched
421
204
  }));
422
205
  var CreatableSelectInput$1 = CreatableSelectInput;
423
206
 
424
207
  // NOTE: This string will be replaced on build time with the package version.
425
- var version = "12.2.9";
208
+ var version = "13.0.0";
426
209
 
427
210
  exports["default"] = CreatableSelectInput$1;
428
211
  exports.version = version;
@@ -11,7 +11,6 @@ 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');
17
16
  var isEmpty = require('lodash/isEmpty');
@@ -37,14 +36,27 @@ var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
37
36
  var CreatableSelect__default = /*#__PURE__*/_interopDefault(CreatableSelect);
38
37
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
39
38
 
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; }
39
+ 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
40
 
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; }
41
+ 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
42
  var customizedComponents = {
44
43
  DropdownIndicator: selectUtils.DropdownIndicator,
45
44
  ClearIndicator: selectUtils.ClearIndicator,
46
45
  MultiValueRemove: selectUtils.TagRemove
47
46
  };
47
+ var defaultProps = {
48
+ // Using "null" will ensure that the currently selected value disappears in
49
+ // case "undefined" gets passed as the next value
50
+ value: null,
51
+ // The input needs to be searchable, otherwise it's not possible to create
52
+ // new options.
53
+ // We still allow consumers to pass isSearchable={false} so that they can
54
+ // use CreatableSelectInput as an alternative to SelectInput, which does
55
+ // not do the option/value mapping going on there and therefore provides
56
+ // the default API of react-select.
57
+ isSearchable: true,
58
+ menuPortalZIndex: 1
59
+ };
48
60
 
49
61
  var CreatableSelectInput = function CreatableSelectInput(props) {
50
62
  var intl = reactIntl.useIntl();
@@ -59,7 +71,6 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
59
71
  autoFocus: props.isAutofocussed,
60
72
  backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
61
73
  components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.components), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
62
- // eslint-disable-next-line react/display-name
63
74
  Input: function Input(ownProps) {
64
75
  return jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
65
76
  readOnly: true
@@ -94,6 +105,7 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
94
105
  maxMenuHeight: props.maxMenuHeight,
95
106
  menuPortalTarget: props.menuPortalTarget,
96
107
  menuShouldBlockScroll: props.menuShouldBlockScroll,
108
+ closeMenuOnSelect: props.closeMenuOnSelect,
97
109
  name: props.name,
98
110
  noOptionsMessage: props.noOptionsMessage || function (_ref) {
99
111
  var inputValue = _ref.inputValue;
@@ -113,10 +125,9 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
113
125
  return props.name ? "".concat(props.name, ".0") : undefined;
114
126
  }()
115
127
  },
116
- // eslint-disable-next-line @typescript-eslint/no-empty-function
117
128
  persist: function persist() {}
118
129
  };
119
- props.onBlur(event);
130
+ props.onBlur && props.onBlur(event);
120
131
  } : undefined,
121
132
  onChange: function onChange(value, info) {
122
133
  // selectedOptions is either an array, or a single option, or null
@@ -132,7 +143,6 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
132
143
  name: props.name,
133
144
  value: newValue
134
145
  },
135
- // eslint-disable-next-line @typescript-eslint/no-empty-function
136
146
  persist: function persist() {}
137
147
  }, info);
138
148
  },
@@ -153,13 +163,15 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
153
163
  isValidNewOption: props.isValidNewOption,
154
164
  getNewOptionData: props.getNewOptionData,
155
165
  onCreateOption: props.onCreateOption,
156
- createOptionPosition: props.createOptionPosition,
166
+ createOptionPosition: props.createOptionPosition //@ts-ignore
167
+ ,
157
168
  iconLeft: props.iconLeft
158
169
  })
159
170
  }))
160
171
  });
161
172
  };
162
173
 
174
+ CreatableSelectInput.propTypes = {};
163
175
  CreatableSelectInput.displayName = 'CreatableSelectInput'; // Both "true" and an empty array [] represent a touched state. The Boolean
164
176
  // conveniently handles both cases
165
177
 
@@ -167,27 +179,14 @@ CreatableSelectInput.isTouched = function (touched) {
167
179
  return Boolean(touched);
168
180
  };
169
181
 
170
- CreatableSelectInput.propTypes = {};
171
- CreatableSelectInput.defaultProps = {
172
- // Using "null" will ensure that the currently selected value disappears in
173
- // case "undefined" gets passed as the next value
174
- value: null,
175
- // The input needs to be searchable, otherwise it's not possible to create
176
- // new options.
177
- // We still allow consumers to pass isSearchable={false} so that they can
178
- // use CreatableSelectInput as an alternative to SelectInput, which does
179
- // not do the option/value mapping going on there and therefore provides
180
- // the default API of react-select.
181
- isSearchable: true,
182
- menuPortalZIndex: 1
183
- };
182
+ CreatableSelectInput.defaultProps = defaultProps;
184
183
  utils.addStaticFields(CreatableSelectInput, _objectSpread(_objectSpread(_objectSpread({}, reactSelect.components), customizedComponents), {}, {
185
184
  isTouched: CreatableSelectInput.isTouched
186
185
  }));
187
186
  var CreatableSelectInput$1 = CreatableSelectInput;
188
187
 
189
188
  // NOTE: This string will be replaced on build time with the package version.
190
- var version = "12.2.9";
189
+ var version = "13.0.0";
191
190
 
192
191
  exports["default"] = CreatableSelectInput$1;
193
192
  exports.version = version;
@@ -7,26 +7,38 @@ 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';
13
12
  import isEmpty from 'lodash/isEmpty';
14
13
  import { useTheme } from '@emotion/react';
15
14
  import { components } from 'react-select';
16
15
  import CreatableSelect from 'react-select/creatable';
17
16
  import Constraints from '@commercetools-uikit/constraints';
18
- import { filterDataAttributes, SafeHTMLElement, addStaticFields } from '@commercetools-uikit/utils';
17
+ import { filterDataAttributes, addStaticFields } from '@commercetools-uikit/utils';
19
18
  import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
20
19
  import { jsx } from '@emotion/react/jsx-runtime';
21
20
 
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; }
21
+ 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
22
 
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; }
23
+ 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
24
  var customizedComponents = {
26
25
  DropdownIndicator: DropdownIndicator,
27
26
  ClearIndicator: ClearIndicator,
28
27
  MultiValueRemove: TagRemove
29
28
  };
29
+ var defaultProps = {
30
+ // Using "null" will ensure that the currently selected value disappears in
31
+ // case "undefined" gets passed as the next value
32
+ value: null,
33
+ // The input needs to be searchable, otherwise it's not possible to create
34
+ // new options.
35
+ // We still allow consumers to pass isSearchable={false} so that they can
36
+ // use CreatableSelectInput as an alternative to SelectInput, which does
37
+ // not do the option/value mapping going on there and therefore provides
38
+ // the default API of react-select.
39
+ isSearchable: true,
40
+ menuPortalZIndex: 1
41
+ };
30
42
 
31
43
  var CreatableSelectInput = function CreatableSelectInput(props) {
32
44
  var intl = useIntl();
@@ -41,7 +53,6 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
41
53
  autoFocus: props.isAutofocussed,
42
54
  backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
43
55
  components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.components), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
44
- // eslint-disable-next-line react/display-name
45
56
  Input: function Input(ownProps) {
46
57
  return jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
47
58
  readOnly: true
@@ -76,6 +87,7 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
76
87
  maxMenuHeight: props.maxMenuHeight,
77
88
  menuPortalTarget: props.menuPortalTarget,
78
89
  menuShouldBlockScroll: props.menuShouldBlockScroll,
90
+ closeMenuOnSelect: props.closeMenuOnSelect,
79
91
  name: props.name,
80
92
  noOptionsMessage: props.noOptionsMessage || function (_ref) {
81
93
  var inputValue = _ref.inputValue;
@@ -95,10 +107,9 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
95
107
  return props.name ? "".concat(props.name, ".0") : undefined;
96
108
  }()
97
109
  },
98
- // eslint-disable-next-line @typescript-eslint/no-empty-function
99
110
  persist: function persist() {}
100
111
  };
101
- props.onBlur(event);
112
+ props.onBlur && props.onBlur(event);
102
113
  } : undefined,
103
114
  onChange: function onChange(value, info) {
104
115
  // selectedOptions is either an array, or a single option, or null
@@ -114,7 +125,6 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
114
125
  name: props.name,
115
126
  value: newValue
116
127
  },
117
- // eslint-disable-next-line @typescript-eslint/no-empty-function
118
128
  persist: function persist() {}
119
129
  }, info);
120
130
  },
@@ -135,13 +145,33 @@ var CreatableSelectInput = function CreatableSelectInput(props) {
135
145
  isValidNewOption: props.isValidNewOption,
136
146
  getNewOptionData: props.getNewOptionData,
137
147
  onCreateOption: props.onCreateOption,
138
- createOptionPosition: props.createOptionPosition,
148
+ createOptionPosition: props.createOptionPosition //@ts-ignore
149
+ ,
139
150
  iconLeft: props.iconLeft
140
151
  })
141
152
  }))
142
153
  });
143
154
  };
144
155
 
156
+ CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
157
+ horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
158
+ hasError: _pt.bool,
159
+ hasWarning: _pt.bool,
160
+ isReadOnly: _pt.bool,
161
+ iconLeft: _pt.node,
162
+ isAutofocussed: _pt.bool,
163
+ menuPortalZIndex: _pt.number.isRequired,
164
+ onBlur: _pt.func,
165
+ onChange: _pt.func.isRequired,
166
+ options: _pt.oneOfType([_pt.arrayOf(_pt.shape({
167
+ value: _pt.string.isRequired
168
+ })), _pt.arrayOf(_pt.shape({
169
+ options: _pt.arrayOf(_pt.shape({
170
+ value: _pt.string.isRequired
171
+ })).isRequired
172
+ }))]).isRequired,
173
+ showOptionGroupDivider: _pt.bool
174
+ } : {};
145
175
  CreatableSelectInput.displayName = 'CreatableSelectInput'; // Both "true" and an empty array [] represent a touched state. The Boolean
146
176
  // conveniently handles both cases
147
177
 
@@ -149,259 +179,13 @@ CreatableSelectInput.isTouched = function (touched) {
149
179
  return Boolean(touched);
150
180
  };
151
181
 
152
- CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
153
- /**
154
- * Horizontal size limit of the input fields.
155
- */
156
- horizontalConstraint: PropTypes.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
157
-
158
- /**
159
- * Indicates the input field has an error
160
- */
161
- hasError: PropTypes.bool,
162
-
163
- /**
164
- * Indicates the input field has a warning
165
- */
166
- hasWarning: PropTypes.bool,
167
-
168
- /**
169
- * Disables the select input as it is read-only
170
- */
171
- isReadOnly: PropTypes.bool,
172
-
173
- /**
174
- * Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled.
175
- */
176
- iconLeft: PropTypes.node,
177
- // react-select base props
178
- //
179
- // Currently unsupported props are commented out. In case you need one of
180
- // these props when using UI Kit, you can submit a PR and enable the
181
- // prop. Don't forget to add it to the story, docs and other select input
182
- // components as well!
183
- //
184
- // See https://react-select.com/props#select-props
185
-
186
- /**
187
- * Aria label (for assistive tech)
188
- */
189
- 'aria-label': PropTypes.string,
190
-
191
- /**
192
- * HTML ID of an element that should be used as the label (for assistive tech)
193
- */
194
- 'aria-labelledby': PropTypes.string,
195
-
196
- /**
197
- * Focus the control when it is mounted
198
- */
199
- isAutofocussed: PropTypes.bool,
200
- // original: autoFocus
201
-
202
- /**
203
- * Remove the currently focused option when the user presses backspace
204
- */
205
- backspaceRemovesValue: PropTypes.bool,
206
-
207
- /**
208
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
209
- */
210
- components: PropTypes.objectOf(PropTypes.func),
211
-
212
- /**
213
- * Custom method to filter whether an option should be displayed in the menu
214
- */
215
- filterOption: PropTypes.func,
216
- // This forwarded as react-select's "inputId"
217
-
218
- /**
219
- * The id of the search input
220
- */
221
- id: PropTypes.string,
222
- // This is forwarded as react-select's "id"
223
- inputValue: PropTypes.string,
224
-
225
- /**
226
- * The id to set on the SelectContainer component
227
- */
228
- containerId: PropTypes.string,
229
-
230
- /**
231
- * Is the select value clearable
232
- */
233
- isClearable: PropTypes.bool,
234
-
235
- /**
236
- * Is the select disabled
237
- */
238
- isDisabled: PropTypes.bool,
239
-
240
- /**
241
- * Override the built-in logic to detect whether an option is disabled
242
- */
243
- isOptionDisabled: PropTypes.func,
244
-
245
- /**
246
- * Support multiple selected options
247
- */
248
- isMulti: PropTypes.bool,
249
-
250
- /**
251
- * Whether to enable search functionality
252
- */
253
- isSearchable: PropTypes.bool,
254
-
255
- /**
256
- * Maximum height of the menu before scrolling
257
- */
258
- maxMenuHeight: PropTypes.number,
259
-
260
- /**
261
- * Dom element to portal the select menu to
262
- */
263
- menuPortalTarget: PropTypes.instanceOf(SafeHTMLElement),
264
-
265
- /**
266
- * z-index value for the menu portal
267
- */
268
- menuPortalZIndex: PropTypes.number.isRequired,
269
-
270
- /**
271
- * whether the menu should block scroll while open
272
- */
273
- menuShouldBlockScroll: PropTypes.bool,
274
-
275
- /**
276
- * Name of the HTML Input (optional - without this, no input will be rendered)
277
- */
278
- name: PropTypes.string,
279
-
280
- /**
281
- * 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.
282
- */
283
- noOptionsMessage: PropTypes.func,
284
-
285
- /**
286
- * Handle blur events on the control
287
- */
288
- onBlur: PropTypes.func,
289
-
290
- /**
291
- * 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`.
292
- * <br />
293
- * Signature: `(event) => void`
294
- */
295
- onChange: PropTypes.func.isRequired,
296
-
297
- /**
298
- * Handle focus events on the control
299
- */
300
- onFocus: PropTypes.func,
301
-
302
- /**
303
- * Handle change events on the input
304
- */
305
- onInputChange: PropTypes.func,
306
-
307
- /**
308
- * Array of options that populate the select menu
309
- */
310
- options: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape({
311
- value: PropTypes.string.isRequired
312
- }), PropTypes.shape({
313
- options: PropTypes.arrayOf(PropTypes.shape({
314
- value: PropTypes.string.isRequired
315
- }))
316
- })])),
317
-
318
- /**
319
- * Determines if option groups will be separated by a divider
320
- */
321
- showOptionGroupDivider: PropTypes.bool,
322
-
323
- /**
324
- * Placeholder text for the select value
325
- */
326
- placeholder: PropTypes.string,
327
-
328
- /**
329
- * Sets the tabIndex attribute on the input
330
- */
331
- tabIndex: PropTypes.string,
332
-
333
- /**
334
- * Select the currently focused option when the user presses tab
335
- */
336
- tabSelectsValue: PropTypes.bool,
337
-
338
- /**
339
- * The value of the select; reflected by the selected option
340
- */
341
- value: function value(props) {
342
- var _context, _context2;
343
-
344
- for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
345
- rest[_key - 1] = arguments[_key];
346
- }
347
-
348
- return props.isMulti ? PropTypes.arrayOf(PropTypes.shape({
349
- value: PropTypes.string.isRequired
350
- })).apply(void 0, _concatInstanceProperty(_context = [props]).call(_context, rest)) : PropTypes.shape({
351
- value: PropTypes.string.isRequired
352
- }).apply(void 0, _concatInstanceProperty(_context2 = [props]).call(_context2, rest));
353
- },
354
- // Creatable props
355
-
356
- /**
357
- * Allow options to be created while the isLoading prop is true. Useful to prevent the "create new ..." option being displayed while async results are still being loaded.
358
- */
359
- allowCreateWhileLoading: PropTypes.bool,
360
-
361
- /**
362
- * Gets the label for the "create new ..." option in the menu. Is given the current input value.
363
- */
364
- formatCreateLabel: PropTypes.func,
365
-
366
- /**
367
- * Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.
368
- */
369
- isValidNewOption: PropTypes.func,
370
-
371
- /**
372
- * Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.
373
- */
374
- getNewOptionData: PropTypes.func,
375
-
376
- /**
377
- * If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created.
378
- */
379
- onCreateOption: PropTypes.func,
380
-
381
- /**
382
- * Sets the position of the createOption element in your options list.
383
- */
384
- createOptionPosition: PropTypes.string
385
- } : {};
386
- CreatableSelectInput.defaultProps = {
387
- // Using "null" will ensure that the currently selected value disappears in
388
- // case "undefined" gets passed as the next value
389
- value: null,
390
- // The input needs to be searchable, otherwise it's not possible to create
391
- // new options.
392
- // We still allow consumers to pass isSearchable={false} so that they can
393
- // use CreatableSelectInput as an alternative to SelectInput, which does
394
- // not do the option/value mapping going on there and therefore provides
395
- // the default API of react-select.
396
- isSearchable: true,
397
- menuPortalZIndex: 1
398
- };
182
+ CreatableSelectInput.defaultProps = defaultProps;
399
183
  addStaticFields(CreatableSelectInput, _objectSpread(_objectSpread(_objectSpread({}, components), customizedComponents), {}, {
400
184
  isTouched: CreatableSelectInput.isTouched
401
185
  }));
402
186
  var CreatableSelectInput$1 = CreatableSelectInput;
403
187
 
404
188
  // NOTE: This string will be replaced on build time with the package version.
405
- var version = "12.2.9";
189
+ var version = "13.0.0";
406
190
 
407
191
  export { CreatableSelectInput$1 as default, version };
@@ -0,0 +1,68 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type GroupBase, type ActionMeta } from 'react-select';
3
+ import { type CreatableProps } from 'react-select/creatable';
4
+ declare type TValue = {
5
+ value: string;
6
+ };
7
+ declare type TOptions = TValue[] | {
8
+ options: TValue[];
9
+ }[];
10
+ declare type TEvent = {
11
+ target: {
12
+ name?: string;
13
+ value?: unknown;
14
+ };
15
+ persist?: () => void;
16
+ };
17
+ declare type ReactSelectCreatableProps = CreatableProps<unknown, boolean, GroupBase<unknown>>;
18
+ declare type TCreatableSelectInputProps = {
19
+ horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
20
+ hasError?: boolean;
21
+ hasWarning?: boolean;
22
+ isReadOnly?: boolean;
23
+ iconLeft?: ReactNode;
24
+ 'aria-label': ReactSelectCreatableProps['aria-label'];
25
+ 'aria-labelledby': ReactSelectCreatableProps['aria-labelledby'];
26
+ isAutofocussed?: boolean;
27
+ backspaceRemovesValue?: ReactSelectCreatableProps['backspaceRemovesValue'];
28
+ components?: ReactSelectCreatableProps['components'];
29
+ filterOption?: ReactSelectCreatableProps['filterOption'];
30
+ id?: ReactSelectCreatableProps['inputId'];
31
+ inputValue?: ReactSelectCreatableProps['inputValue'];
32
+ containerId?: ReactSelectCreatableProps['id'];
33
+ isClearable?: ReactSelectCreatableProps['isClearable'];
34
+ isDisabled?: ReactSelectCreatableProps['isDisabled'];
35
+ isOptionDisabled?: ReactSelectCreatableProps['isOptionDisabled'];
36
+ isMulti?: ReactSelectCreatableProps['isMulti'];
37
+ isSearchable?: ReactSelectCreatableProps['isSearchable'];
38
+ maxMenuHeight?: ReactSelectCreatableProps['maxMenuHeight'];
39
+ menuPortalTarget?: ReactSelectCreatableProps['menuPortalTarget'];
40
+ menuPortalZIndex: number;
41
+ menuShouldBlockScroll?: ReactSelectCreatableProps['menuShouldBlockScroll'];
42
+ closeMenuOnSelect?: ReactSelectCreatableProps['closeMenuOnSelect'];
43
+ name?: ReactSelectCreatableProps['name'];
44
+ noOptionsMessage?: ReactSelectCreatableProps['noOptionsMessage'];
45
+ onBlur?: (event: TEvent) => void;
46
+ onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
47
+ onFocus?: ReactSelectCreatableProps['onFocus'];
48
+ onInputChange?: ReactSelectCreatableProps['onInputChange'];
49
+ options: TOptions;
50
+ showOptionGroupDivider?: boolean;
51
+ placeholder?: ReactSelectCreatableProps['placeholder'];
52
+ tabIndex?: ReactSelectCreatableProps['tabIndex'];
53
+ tabSelectsValue?: ReactSelectCreatableProps['tabSelectsValue'];
54
+ value: ReactSelectCreatableProps['value'];
55
+ allowCreateWhileLoading?: ReactSelectCreatableProps['allowCreateWhileLoading'];
56
+ formatCreateLabel?: ReactSelectCreatableProps['formatCreateLabel'];
57
+ isValidNewOption?: ReactSelectCreatableProps['isValidNewOption'];
58
+ getNewOptionData?: ReactSelectCreatableProps['getNewOptionData'];
59
+ onCreateOption?: ReactSelectCreatableProps['onCreateOption'];
60
+ createOptionPosition?: ReactSelectCreatableProps['createOptionPosition'];
61
+ };
62
+ declare const CreatableSelectInput: {
63
+ (props: TCreatableSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
64
+ displayName: string;
65
+ isTouched(touched: unknown): boolean;
66
+ defaultProps: Pick<TCreatableSelectInputProps, "value" | "isSearchable" | "menuPortalZIndex">;
67
+ };
68
+ export default CreatableSelectInput;
@@ -0,0 +1,2 @@
1
+ export { default } from './creatable-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/creatable-select-input",
3
3
  "description": "An input component getting a selection from the user, and where options can also be created by the user.",
4
- "version": "12.2.9",
4
+ "version": "13.0.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,25 +19,25 @@
19
19
  "module": "dist/commercetools-uikit-creatable-select-input.esm.js",
20
20
  "files": ["dist"],
21
21
  "dependencies": {
22
- "@babel/runtime": "7.16.5",
23
- "@babel/runtime-corejs3": "7.16.5",
24
- "@commercetools-uikit/constraints": "12.2.9",
25
- "@commercetools-uikit/design-system": "12.2.9",
26
- "@commercetools-uikit/icons": "12.2.9",
27
- "@commercetools-uikit/select-utils": "12.2.9",
28
- "@commercetools-uikit/spacings": "12.2.9",
29
- "@commercetools-uikit/text": "12.2.9",
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/select-utils": "13.0.0",
28
+ "@commercetools-uikit/spacings": "13.0.0",
29
+ "@commercetools-uikit/text": "13.0.0",
30
30
  "@commercetools-uikit/utils": "12.2.9",
31
31
  "@emotion/react": "^11.4.0",
32
32
  "@emotion/styled": "^11.3.0",
33
33
  "lodash": "4.17.21",
34
- "prop-types": "15.7.2",
35
- "react-select": "5.2.1"
34
+ "prop-types": "15.8.1",
35
+ "react-select": "5.2.2"
36
36
  },
37
37
  "devDependencies": {
38
38
  "react": "17.0.2",
39
39
  "react-dom": "17.0.2",
40
- "react-intl": "5.23.0"
40
+ "react-intl": "5.24.6"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "17.x",