@commercetools-uikit/async-select-field 12.2.6 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,57 +50,80 @@ export default Example;
50
50
 
51
51
  ## Properties
52
52
 
53
- | Props | Type | Required | Default | Description |
54
- | --------------------------------- | -------------------------------------------------------------------------------------------------- | :------: | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
- | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
56
- | `horizontalConstraint` | `enum`<br/>Possible values:<br/>`3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
57
- | `errors` | `object` | | | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br />&#xA;Unknown errors will be forwarded to `renderError` |
58
- | `errors.missing` | `bool` | | | |
59
- | `renderError` | `func` | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.&#xA;<br />&#xA;Signature: `(key, error) => React.node` |
60
- | `isRequired` | `bool` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
61
- | `touched` | `custom` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
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
- | `containerId` | `string` | | | The id to set on the SelectContainer component |
69
- | `isClearable` | `bool` | | | Is the select value clearable |
70
- | `isDisabled` | `bool` | | | Is the select disabled |
71
- | `isReadOnly` | `bool` | | | Is the select read-only |
72
- | `isOptionDisabled` | `func` | | | Override the built-in logic to detect whether an option is disabled&#xA;<br />&#xA;Signature: `(option, options) => boolean` |
73
- | `isMulti` | `bool` | | | Support multiple selected options |
74
- | `isSearchable` | `bool` | | | Whether to enable search functionality |
75
- | `hasWarning` | `bool` | | | |
76
- | `maxMenuHeight` | `number` | | | Maximum height of the menu before scrolling |
77
- | `menuPortalTarget` | `SafeHTMLElement` | | | Dom element to portal the select menu to |
78
- | `menuPortalZIndex` | `number` | | | 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).&#xA;<br />&#xA;Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.&#xA;Signature: `({ inputValue }) => React.node ` |
82
- | `onBlur` | `func` | | | Handle blur events on the control |
83
- | `onChange` | `func` | | | Called with a fake event when value changes.&#xA;<br />&#xA;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
- | `placeholder` | `string` | | | Placeholder text for the select value |
87
- | `loadingMessage` | `<string, func>` | | | loading message shown while the options are being loaded |
88
- | `tabIndex` | `string` | | | Sets the tabIndex attribute on the input |
89
- | `tabSelectsValue` | `bool` | | | Select the currently focused option when the user presses tab |
90
- | `value` | `custom` | | | The value of the select; reflected by the selected option |
91
- | `showOptionGroupDivider` | `bool` | | | |
92
- | `defaultOptions` | `<bool, arrayOf>` | | | The default set of options to show before the user starts searching.&#xA;<br />&#xA;When set to `true`, the results for `loadOptions('')` will be autoloaded. |
93
- | `defaultOptions<arrayOf>` | `array` | | | |
94
- | `defaultOptions<arrayOf>[].value` | `string` | ✅ | | |
95
- | `loadOptions` | `func` || | Function that returns a promise, which is the set of options to be used once the promise resolves. |
96
- | `cacheOptions` | `any` | | | If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value. |
97
- | `title` | `<string, node>` || | Title of the label |
98
- | `hint` | `custom` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`. |
99
- | `description` | `<string, node>` | | | Provides a description for the title. |
100
- | `onInfoButtonClick` | `func` | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed.&#xA;<br />&#xA;Signature: `(event) => void` |
101
- | `hintIcon` | `node` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
102
- | `badge` | `node` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
103
- | `iconLeft` | `node` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled. |
53
+ | Props | Type | Required | Default | Description |
54
+ | ------------------------ | ----------------------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
+ | `id` | `AsyncProps['inputId']` | | | Used as HTML id property. An id is auto-generated when it is not specified.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
56
+ | `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
57
+ | `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br />&#xA;Unknown errors will be forwarded to `renderError` |
58
+ | `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
59
+ | `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
60
+ | `touched` | `union`<br/>Possible values:<br/>`boolean[] , boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
61
+ | `aria-label` | `AsyncProps['aria-label']` | | | Aria label (for assistive tech)&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
62
+ | `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) |
63
+ | `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
64
+ | `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) |
65
+ | `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) |
66
+ | `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) |
67
+ | `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) |
68
+ | `isClearable` | `AsyncProps['isClearable']` | | | Is the select value clearable&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
69
+ | `isDisabled` | `AsyncProps['isDisabled']` | | | Is the select disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
70
+ | `isReadOnly` | `boolean` | | | Is the select read-only |
71
+ | `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) |
72
+ | `isMulti` | `AsyncProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
73
+ | `isSearchable` | `AsyncProps['isSearchable']` | | | Whether to enable search functionality&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
74
+ | `hasWarning` | `boolean` | | | Indicates the input field has a warning |
75
+ | `maxMenuHeight` | `AsyncProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
76
+ | `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) |
77
+ | `menuPortalZIndex` | `number` | | | z-index value for the menu portal |
78
+ | `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) |
79
+ | `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) |
80
+ | `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).&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
81
+ | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
82
+ | `onChange` | `Function`<br/>[See signature.](#signature-onChange) || | Called with a fake event when value changes.&#xA;<br />&#xA;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`. |
83
+ | `onFocus` | `FocusEventHandler` | | | Handle focus events on the control |
84
+ | `onInputChange` | `AsyncProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
85
+ | `placeholder` | `AsyncProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
86
+ | `loadingMessage` | `union`<br/>Possible values:<br/>`string , (() => string)` | | | loading message shown while the options are being loaded |
87
+ | `tabIndex` | `AsyncProps['tabIndex']` | | | Sets the tabIndex attribute on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
88
+ | `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) |
89
+ | `value` | `AsyncProps['value']` | | | The value of the select; reflected by the selected option&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
90
+ | `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
91
+ | `defaultOptions` | `union`<br/>Possible values:<br/>`OptionsOrGroups<unknown, GroupBase<unknown>> , boolean` | | | The default set of options to show before the user starts searching.&#xA;<br />&#xA;When set to `true`, the results for `loadOptions('')` will be autoloaded. |
92
+ | `loadOptions` | `AsyncProps['loadOptions']` || | Function that returns a promise, which is the set of options to be used once the promise resolves.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
93
+ | `cacheOptions` | `AsyncProps['cacheOptions']` | | | If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
94
+ | `title` | `union`<br/>Possible values:<br/>`string , ReactNode` | ✅ | | Title of the label |
95
+ | `hint` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`. |
96
+ | `description` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Provides a description for the title. |
97
+ | `onInfoButtonClick` | `Function`<br/>[See signature.](#signature-onInfoButtonClick) | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed. |
98
+ | `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
99
+ | `badge` | `ReactNode` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
100
+ | `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled. |
101
+
102
+ ## Signatures
103
+
104
+ ### Signature `renderError`
105
+
106
+ ```ts
107
+ (key: string, error?: boolean) => ReactNode;
108
+ ```
109
+
110
+ ### Signature `onBlur`
111
+
112
+ ```ts
113
+ (event: TEvent) => void
114
+ ```
115
+
116
+ ### Signature `onChange`
117
+
118
+ ```ts
119
+ (event: TEvent, info: ActionMeta<unknown>) => void
120
+ ```
121
+
122
+ ### Signature `onInfoButtonClick`
123
+
124
+ ```ts
125
+ () => void
126
+ ```
104
127
 
105
128
  ## `data-*` props
106
129
 
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ export { default } from "./declarations/src/index";
@@ -17,12 +17,12 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
17
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
18
18
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
19
19
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
20
+ var _pt = require('prop-types');
20
21
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
21
22
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
22
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
24
+ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
23
25
  var react = require('react');
24
- var PropTypes = require('prop-types');
25
- var requiredIf = require('react-required-if');
26
26
  var utils = require('@commercetools-uikit/utils');
27
27
  var Constraints = require('@commercetools-uikit/constraints');
28
28
  var Spacings = require('@commercetools-uikit/spacings');
@@ -42,20 +42,20 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
42
42
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
43
43
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
44
44
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
45
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
45
46
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
46
47
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
47
48
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
48
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
49
- var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
49
+ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
50
50
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
51
51
  var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
52
52
  var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
53
53
  var AsyncSelectInput__default = /*#__PURE__*/_interopDefault(AsyncSelectInput);
54
54
  var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
55
55
 
56
- 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; }
56
+ 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; }
57
57
 
58
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context8; _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(source), true)).call(_context8, 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 _context9; _forEachInstanceProperty__default["default"](_context9 = ownKeys(Object(source))).call(_context9, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
58
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
59
59
 
60
60
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
61
61
 
@@ -97,6 +97,16 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
97
97
  key: "render",
98
98
  value: function render() {
99
99
  var hasError = AsyncSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
100
+
101
+ if (this.props.hintIcon) {
102
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'TextField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
103
+ }
104
+
105
+ if (this.props.isMulti) {
106
+ process.env.NODE_ENV !== "production" ? utils.warning(_Array$isArray__default["default"](this.props.value), 'AsyncSelectField: `value` is expected to be an array of string when isMulti is true') : void 0;
107
+ process.env.NODE_ENV !== "production" ? utils.warning(_Array$isArray__default["default"](this.props.touched), 'AsyncSelectField: `touched` is expected to be an array of boolean when isMulti is true') : void 0;
108
+ }
109
+
100
110
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
101
111
  max: this.props.horizontalConstraint,
102
112
  children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
@@ -173,285 +183,32 @@ AsyncSelectField.getDerivedStateFromProps = function (props, state) {
173
183
  };
174
184
  };
175
185
  AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
176
- // AsyncSelectField
177
-
178
- /**
179
- * Used as HTML id property. An id is auto-generated when it is not specified.
180
- */
181
- id: PropTypes__default["default"].string,
182
-
183
- /**
184
- * Horizontal size limit of the input fields.
185
- */
186
- horizontalConstraint: PropTypes__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
187
-
188
- /**
189
- * A map of errors. Error messages for known errors are rendered automatically.
190
- * <br />
191
- * Unknown errors will be forwarded to `renderError`
192
- */
193
- errors: PropTypes__default["default"].shape({
194
- missing: PropTypes__default["default"].bool
195
- }),
196
-
197
- /**
198
- * Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
199
- * <br />
200
- * Signature: `(key, error) => React.node`
201
- */
202
- renderError: PropTypes__default["default"].func,
203
-
204
- /**
205
- * Indicates if the value is required. Shows an the "required asterisk" if so.
206
- */
207
- isRequired: PropTypes__default["default"].bool,
208
-
209
- /**
210
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
211
- */
212
- touched: function touched(props) {
213
- var _context3, _context4, _context5;
214
-
215
- for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
216
- rest[_key2 - 1] = arguments[_key2];
217
- }
218
-
219
- return props.isMulti ? PropTypes__default["default"].arrayOf.apply(PropTypes__default["default"], _concatInstanceProperty__default["default"](_context3 = [PropTypes__default["default"].bool]).call(_context3, rest)).apply(void 0, _concatInstanceProperty__default["default"](_context4 = [props]).call(_context4, rest)) : PropTypes__default["default"].bool.apply(PropTypes__default["default"], _concatInstanceProperty__default["default"](_context5 = [props]).call(_context5, rest));
220
- },
221
- // AsyncSelectInput
222
-
223
- /**
224
- * Aria label (for assistive tech)
225
- */
226
- 'aria-label': PropTypes__default["default"].string,
227
-
228
- /**
229
- * HTML ID of an element that should be used as the label (for assistive tech)
230
- */
231
- 'aria-labelledby': PropTypes__default["default"].string,
232
-
233
- /**
234
- * Focus the control when it is mounted
235
- */
236
- isAutofocussed: PropTypes__default["default"].bool,
237
-
238
- /**
239
- * Remove the currently focused option when the user presses backspace
240
- */
241
- backspaceRemovesValue: PropTypes__default["default"].bool,
242
-
243
- /**
244
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
245
- */
246
- components: PropTypes__default["default"].objectOf(PropTypes__default["default"].func),
247
-
248
- /**
249
- * Custom method to filter whether an option should be displayed in the menu
250
- */
251
- filterOption: PropTypes__default["default"].func,
252
-
253
- /**
254
- * The id to set on the SelectContainer component
255
- */
256
- containerId: PropTypes__default["default"].string,
257
-
258
- /**
259
- * Is the select value clearable
260
- */
261
- isClearable: PropTypes__default["default"].bool,
262
-
263
- /**
264
- * Is the select disabled
265
- */
266
- isDisabled: PropTypes__default["default"].bool,
267
-
268
- /**
269
- * Is the select read-only
270
- */
271
- isReadOnly: PropTypes__default["default"].bool,
272
-
273
- /**
274
- * Override the built-in logic to detect whether an option is disabled
275
- * <br />
276
- * Signature: `(option, options) => boolean`
277
- */
278
- isOptionDisabled: PropTypes__default["default"].func,
279
-
280
- /**
281
- * Support multiple selected options
282
- */
283
- isMulti: PropTypes__default["default"].bool,
284
-
285
- /**
286
- * Whether to enable search functionality
287
- */
288
- isSearchable: PropTypes__default["default"].bool,
289
- hasWarning: PropTypes__default["default"].bool,
290
-
291
- /**
292
- * Maximum height of the menu before scrolling
293
- */
294
- maxMenuHeight: PropTypes__default["default"].number,
295
-
296
- /**
297
- * Dom element to portal the select menu to
298
- */
299
- menuPortalTarget: PropTypes__default["default"].instanceOf(utils.SafeHTMLElement),
300
-
301
- /**
302
- * z-index value for the menu portal
303
- */
304
- menuPortalZIndex: PropTypes__default["default"].number,
305
-
306
- /**
307
- * whether the menu should block scroll while open
308
- */
309
- menuShouldBlockScroll: PropTypes__default["default"].bool,
310
-
311
- /**
312
- * Name of the HTML Input (optional - without this, no input will be rendered)
313
- */
314
- name: PropTypes__default["default"].string,
315
-
316
- /**
317
- * 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).
318
- * <br />
319
- * Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.
320
- * Signature: `({ inputValue }) => React.node `
321
- */
322
- noOptionsMessage: PropTypes__default["default"].func,
323
-
324
- /**
325
- * Handle blur events on the control
326
- */
327
- onBlur: PropTypes__default["default"].func,
328
-
329
- /**
330
- * Called with a fake event when value changes.
331
- * <br />
332
- * 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`.
333
- * <br />
334
- * Signature: `(event) => void`
335
- */
336
- onChange: PropTypes__default["default"].func,
337
-
338
- /**
339
- * Handle focus events on the control
340
- */
341
- onFocus: PropTypes__default["default"].func,
342
-
343
- /**
344
- * Handle change events on the input
345
- */
346
- onInputChange: PropTypes__default["default"].func,
347
-
348
- /**
349
- * Placeholder text for the select value
350
- */
351
- placeholder: PropTypes__default["default"].string,
352
-
353
- /**
354
- * loading message shown while the options are being loaded
355
- */
356
- loadingMessage: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]),
357
-
358
- /**
359
- * Sets the tabIndex attribute on the input
360
- */
361
- tabIndex: PropTypes__default["default"].string,
362
-
363
- /**
364
- * Select the currently focused option when the user presses tab
365
- */
366
- tabSelectsValue: PropTypes__default["default"].bool,
367
-
368
- /**
369
- * The value of the select; reflected by the selected option
370
- */
371
- value: function value(props) {
372
- var _context6, _context7;
373
-
374
- for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
375
- rest[_key3 - 1] = arguments[_key3];
376
- }
377
-
378
- return props.isMulti ? PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
379
- value: PropTypes__default["default"].string.isRequired
380
- })).apply(void 0, _concatInstanceProperty__default["default"](_context6 = [props]).call(_context6, rest)) : PropTypes__default["default"].shape({
381
- value: PropTypes__default["default"].string.isRequired
382
- }).apply(void 0, _concatInstanceProperty__default["default"](_context7 = [props]).call(_context7, rest));
383
- },
384
- showOptionGroupDivider: PropTypes__default["default"].bool,
385
- // Async props
386
-
387
- /**
388
- * The default set of options to show before the user starts searching.
389
- * <br />
390
- * When set to `true`, the results for `loadOptions('')` will be autoloaded.
391
- */
392
- defaultOptions: PropTypes__default["default"].oneOfType([PropTypes__default["default"].bool, PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
393
- value: PropTypes__default["default"].string.isRequired
394
- }))]),
395
-
396
- /**
397
- * Function that returns a promise, which is the set of options to be used once the promise resolves.
398
- */
399
- loadOptions: PropTypes__default["default"].func.isRequired,
400
-
401
- /**
402
- * If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.
403
- */
404
- cacheOptions: PropTypes__default["default"].any,
405
- // LabelField
406
-
407
- /**
408
- * Title of the label
409
- */
410
- title: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]).isRequired,
411
-
412
- /**
413
- * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`.
414
- */
415
- hint: requiredIf__default["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]), function (props) {
416
- return props.hintIcon;
417
- }),
418
-
419
- /**
420
- * Provides a description for the title.
421
- */
422
- description: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
423
-
424
- /**
425
- * Function called when info button is pressed.
426
- * <br />
427
- * Info button will only be visible when this prop is passed.
428
- * <br />
429
- * Signature: `(event) => void`
430
- */
431
- onInfoButtonClick: PropTypes__default["default"].func,
432
-
433
- /**
434
- * Icon to be displayed beside the hint text.
435
- * <br />
436
- * Will only get rendered when `hint` is passed as well.
437
- */
438
- hintIcon: PropTypes__default["default"].node,
439
-
440
- /**
441
- * Badge to be displayed beside the label.
442
- * <br />
443
- * Might be used to display additional information about the content of the field (E.g verified email)
444
- */
445
- badge: PropTypes__default["default"].node,
446
-
447
- /**
448
- * Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.
449
- */
450
- iconLeft: PropTypes__default["default"].node
186
+ horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
187
+ errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
188
+ renderError: _pt__default["default"].func,
189
+ isRequired: _pt__default["default"].bool,
190
+ touched: _pt__default["default"].oneOfType([_pt__default["default"].arrayOf(_pt__default["default"].bool), _pt__default["default"].bool]),
191
+ isAutofocussed: _pt__default["default"].bool,
192
+ isReadOnly: _pt__default["default"].bool,
193
+ hasWarning: _pt__default["default"].bool,
194
+ menuPortalZIndex: _pt__default["default"].number,
195
+ onBlur: _pt__default["default"].func,
196
+ onChange: _pt__default["default"].func.isRequired,
197
+ onFocus: _pt__default["default"].func,
198
+ loadingMessage: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].func]),
199
+ showOptionGroupDivider: _pt__default["default"].bool,
200
+ defaultOptions: _pt__default["default"].oneOfType([_pt__default["default"].any, _pt__default["default"].bool]),
201
+ title: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]).isRequired,
202
+ hint: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
203
+ description: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
204
+ onInfoButtonClick: _pt__default["default"].func,
205
+ hintIcon: _pt__default["default"].element,
206
+ badge: _pt__default["default"].node,
207
+ iconLeft: _pt__default["default"].node
451
208
  } : {};
452
209
 
453
210
  // NOTE: This string will be replaced on build time with the package version.
454
- var version = "12.2.6";
211
+ var version = "13.0.1";
455
212
 
456
213
  exports["default"] = AsyncSelectField;
457
214
  exports.version = version;
@@ -17,12 +17,12 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
17
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
18
18
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
19
19
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
20
+ require('prop-types');
20
21
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
21
22
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
22
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
24
+ require('@babel/runtime-corejs3/core-js-stable/array/is-array');
23
25
  var react = require('react');
24
- require('prop-types');
25
- require('react-required-if');
26
26
  var utils = require('@commercetools-uikit/utils');
27
27
  var Constraints = require('@commercetools-uikit/constraints');
28
28
  var Spacings = require('@commercetools-uikit/spacings');
@@ -51,9 +51,9 @@ var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
51
51
  var AsyncSelectInput__default = /*#__PURE__*/_interopDefault(AsyncSelectInput);
52
52
  var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
53
53
 
54
- 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; }
54
+ 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; }
55
55
 
56
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context8; _forEachInstanceProperty__default["default"](_context8 = ownKeys(Object(source), true)).call(_context8, 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 _context9; _forEachInstanceProperty__default["default"](_context9 = ownKeys(Object(source))).call(_context9, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
56
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _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; }
57
57
 
58
58
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
59
59
 
@@ -95,6 +95,11 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
95
95
  key: "render",
96
96
  value: function render() {
97
97
  var hasError = AsyncSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
98
+
99
+ if (this.props.hintIcon) ;
100
+
101
+ if (this.props.isMulti) ;
102
+
98
103
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
99
104
  max: this.props.horizontalConstraint,
100
105
  children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
@@ -173,7 +178,7 @@ AsyncSelectField.getDerivedStateFromProps = function (props, state) {
173
178
  AsyncSelectField.propTypes = {};
174
179
 
175
180
  // NOTE: This string will be replaced on build time with the package version.
176
- var version = "12.2.6";
181
+ var version = "13.0.1";
177
182
 
178
183
  exports["default"] = AsyncSelectField;
179
184
  exports.version = version;
@@ -13,13 +13,13 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
13
13
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
14
14
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
15
15
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
16
+ import _pt from 'prop-types';
16
17
  import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
17
18
  import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
18
19
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
19
- import { Component } from 'react';
20
- import PropTypes from 'prop-types';
21
- import requiredIf from 'react-required-if';
22
- import { createSequentialId, filterDataAttributes, getFieldId, SafeHTMLElement } from '@commercetools-uikit/utils';
20
+ import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
21
+ import { isValidElement, Component } from 'react';
22
+ import { createSequentialId, warning, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
23
23
  import Constraints from '@commercetools-uikit/constraints';
24
24
  import Spacings from '@commercetools-uikit/spacings';
25
25
  import FieldLabel from '@commercetools-uikit/field-label';
@@ -27,9 +27,9 @@ import AsyncSelectInput from '@commercetools-uikit/async-select-input';
27
27
  import FieldErrors from '@commercetools-uikit/field-errors';
28
28
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
29
29
 
30
- 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; }
30
+ 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; }
31
31
 
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context8; _forEachInstanceProperty(_context8 = ownKeys(Object(source), true)).call(_context8, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context9; _forEachInstanceProperty(_context9 = ownKeys(Object(source))).call(_context9, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
32
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
33
33
 
34
34
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
35
 
@@ -71,6 +71,16 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
71
71
  key: "render",
72
72
  value: function render() {
73
73
  var hasError = AsyncSelectInput.isTouched(this.props.touched) && hasErrors(this.props.errors);
74
+
75
+ if (this.props.hintIcon) {
76
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'TextField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
77
+ }
78
+
79
+ if (this.props.isMulti) {
80
+ process.env.NODE_ENV !== "production" ? warning(_Array$isArray(this.props.value), 'AsyncSelectField: `value` is expected to be an array of string when isMulti is true') : void 0;
81
+ process.env.NODE_ENV !== "production" ? warning(_Array$isArray(this.props.touched), 'AsyncSelectField: `touched` is expected to be an array of boolean when isMulti is true') : void 0;
82
+ }
83
+
74
84
  return jsx(Constraints.Horizontal, {
75
85
  max: this.props.horizontalConstraint,
76
86
  children: jsxs(Spacings.Stack, {
@@ -147,284 +157,31 @@ AsyncSelectField.getDerivedStateFromProps = function (props, state) {
147
157
  };
148
158
  };
149
159
  AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
150
- // AsyncSelectField
151
-
152
- /**
153
- * Used as HTML id property. An id is auto-generated when it is not specified.
154
- */
155
- id: PropTypes.string,
156
-
157
- /**
158
- * Horizontal size limit of the input fields.
159
- */
160
- horizontalConstraint: PropTypes.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
161
-
162
- /**
163
- * A map of errors. Error messages for known errors are rendered automatically.
164
- * <br />
165
- * Unknown errors will be forwarded to `renderError`
166
- */
167
- errors: PropTypes.shape({
168
- missing: PropTypes.bool
169
- }),
170
-
171
- /**
172
- * Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
173
- * <br />
174
- * Signature: `(key, error) => React.node`
175
- */
176
- renderError: PropTypes.func,
177
-
178
- /**
179
- * Indicates if the value is required. Shows an the "required asterisk" if so.
180
- */
181
- isRequired: PropTypes.bool,
182
-
183
- /**
184
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
185
- */
186
- touched: function touched(props) {
187
- var _context3, _context4, _context5;
188
-
189
- for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
190
- rest[_key2 - 1] = arguments[_key2];
191
- }
192
-
193
- return props.isMulti ? PropTypes.arrayOf.apply(PropTypes, _concatInstanceProperty(_context3 = [PropTypes.bool]).call(_context3, rest)).apply(void 0, _concatInstanceProperty(_context4 = [props]).call(_context4, rest)) : PropTypes.bool.apply(PropTypes, _concatInstanceProperty(_context5 = [props]).call(_context5, rest));
194
- },
195
- // AsyncSelectInput
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
-
207
- /**
208
- * Focus the control when it is mounted
209
- */
210
- isAutofocussed: PropTypes.bool,
211
-
212
- /**
213
- * Remove the currently focused option when the user presses backspace
214
- */
215
- backspaceRemovesValue: PropTypes.bool,
216
-
217
- /**
218
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
219
- */
220
- components: PropTypes.objectOf(PropTypes.func),
221
-
222
- /**
223
- * Custom method to filter whether an option should be displayed in the menu
224
- */
225
- filterOption: PropTypes.func,
226
-
227
- /**
228
- * The id to set on the SelectContainer component
229
- */
230
- containerId: PropTypes.string,
231
-
232
- /**
233
- * Is the select value clearable
234
- */
235
- isClearable: PropTypes.bool,
236
-
237
- /**
238
- * Is the select disabled
239
- */
240
- isDisabled: PropTypes.bool,
241
-
242
- /**
243
- * Is the select read-only
244
- */
245
- isReadOnly: PropTypes.bool,
246
-
247
- /**
248
- * Override the built-in logic to detect whether an option is disabled
249
- * <br />
250
- * Signature: `(option, options) => boolean`
251
- */
252
- isOptionDisabled: PropTypes.func,
253
-
254
- /**
255
- * Support multiple selected options
256
- */
257
- isMulti: PropTypes.bool,
258
-
259
- /**
260
- * Whether to enable search functionality
261
- */
262
- isSearchable: PropTypes.bool,
263
- hasWarning: PropTypes.bool,
264
-
265
- /**
266
- * Maximum height of the menu before scrolling
267
- */
268
- maxMenuHeight: PropTypes.number,
269
-
270
- /**
271
- * Dom element to portal the select menu to
272
- */
273
- menuPortalTarget: PropTypes.instanceOf(SafeHTMLElement),
274
-
275
- /**
276
- * z-index value for the menu portal
277
- */
278
- menuPortalZIndex: PropTypes.number,
279
-
280
- /**
281
- * whether the menu should block scroll while open
282
- */
283
- menuShouldBlockScroll: PropTypes.bool,
284
-
285
- /**
286
- * Name of the HTML Input (optional - without this, no input will be rendered)
287
- */
288
- name: PropTypes.string,
289
-
290
- /**
291
- * 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).
292
- * <br />
293
- * Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.
294
- * Signature: `({ inputValue }) => React.node `
295
- */
296
- noOptionsMessage: PropTypes.func,
297
-
298
- /**
299
- * Handle blur events on the control
300
- */
301
- onBlur: PropTypes.func,
302
-
303
- /**
304
- * Called with a fake event when value changes.
305
- * <br />
306
- * 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`.
307
- * <br />
308
- * Signature: `(event) => void`
309
- */
310
- onChange: PropTypes.func,
311
-
312
- /**
313
- * Handle focus events on the control
314
- */
315
- onFocus: PropTypes.func,
316
-
317
- /**
318
- * Handle change events on the input
319
- */
320
- onInputChange: PropTypes.func,
321
-
322
- /**
323
- * Placeholder text for the select value
324
- */
325
- placeholder: PropTypes.string,
326
-
327
- /**
328
- * loading message shown while the options are being loaded
329
- */
330
- loadingMessage: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
331
-
332
- /**
333
- * Sets the tabIndex attribute on the input
334
- */
335
- tabIndex: PropTypes.string,
336
-
337
- /**
338
- * Select the currently focused option when the user presses tab
339
- */
340
- tabSelectsValue: PropTypes.bool,
341
-
342
- /**
343
- * The value of the select; reflected by the selected option
344
- */
345
- value: function value(props) {
346
- var _context6, _context7;
347
-
348
- for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
349
- rest[_key3 - 1] = arguments[_key3];
350
- }
351
-
352
- return props.isMulti ? PropTypes.arrayOf(PropTypes.shape({
353
- value: PropTypes.string.isRequired
354
- })).apply(void 0, _concatInstanceProperty(_context6 = [props]).call(_context6, rest)) : PropTypes.shape({
355
- value: PropTypes.string.isRequired
356
- }).apply(void 0, _concatInstanceProperty(_context7 = [props]).call(_context7, rest));
357
- },
358
- showOptionGroupDivider: PropTypes.bool,
359
- // Async props
360
-
361
- /**
362
- * The default set of options to show before the user starts searching.
363
- * <br />
364
- * When set to `true`, the results for `loadOptions('')` will be autoloaded.
365
- */
366
- defaultOptions: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.shape({
367
- value: PropTypes.string.isRequired
368
- }))]),
369
-
370
- /**
371
- * Function that returns a promise, which is the set of options to be used once the promise resolves.
372
- */
373
- loadOptions: PropTypes.func.isRequired,
374
-
375
- /**
376
- * If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.
377
- */
378
- cacheOptions: PropTypes.any,
379
- // LabelField
380
-
381
- /**
382
- * Title of the label
383
- */
384
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
385
-
386
- /**
387
- * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`.
388
- */
389
- hint: requiredIf(PropTypes.oneOfType([PropTypes.string, PropTypes.node]), function (props) {
390
- return props.hintIcon;
391
- }),
392
-
393
- /**
394
- * Provides a description for the title.
395
- */
396
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
397
-
398
- /**
399
- * Function called when info button is pressed.
400
- * <br />
401
- * Info button will only be visible when this prop is passed.
402
- * <br />
403
- * Signature: `(event) => void`
404
- */
405
- onInfoButtonClick: PropTypes.func,
406
-
407
- /**
408
- * Icon to be displayed beside the hint text.
409
- * <br />
410
- * Will only get rendered when `hint` is passed as well.
411
- */
412
- hintIcon: PropTypes.node,
413
-
414
- /**
415
- * Badge to be displayed beside the label.
416
- * <br />
417
- * Might be used to display additional information about the content of the field (E.g verified email)
418
- */
419
- badge: PropTypes.node,
420
-
421
- /**
422
- * Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.
423
- */
424
- iconLeft: PropTypes.node
160
+ horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
161
+ errors: _pt.objectOf(_pt.bool),
162
+ renderError: _pt.func,
163
+ isRequired: _pt.bool,
164
+ touched: _pt.oneOfType([_pt.arrayOf(_pt.bool), _pt.bool]),
165
+ isAutofocussed: _pt.bool,
166
+ isReadOnly: _pt.bool,
167
+ hasWarning: _pt.bool,
168
+ menuPortalZIndex: _pt.number,
169
+ onBlur: _pt.func,
170
+ onChange: _pt.func.isRequired,
171
+ onFocus: _pt.func,
172
+ loadingMessage: _pt.oneOfType([_pt.string, _pt.func]),
173
+ showOptionGroupDivider: _pt.bool,
174
+ defaultOptions: _pt.oneOfType([_pt.any, _pt.bool]),
175
+ title: _pt.oneOfType([_pt.string, _pt.node]).isRequired,
176
+ hint: _pt.oneOfType([_pt.string, _pt.node]),
177
+ description: _pt.oneOfType([_pt.string, _pt.node]),
178
+ onInfoButtonClick: _pt.func,
179
+ hintIcon: _pt.element,
180
+ badge: _pt.node,
181
+ iconLeft: _pt.node
425
182
  } : {};
426
183
 
427
184
  // NOTE: This string will be replaced on build time with the package version.
428
- var version = "12.2.6";
185
+ var version = "13.0.1";
429
186
 
430
187
  export { AsyncSelectField as default, version };
@@ -0,0 +1,74 @@
1
+ import { Component, type FocusEventHandler, type ReactElement, type ReactNode } from 'react';
2
+ import type { AsyncProps } from 'react-select/async';
3
+ import type { GroupBase, OptionsOrGroups, ActionMeta } from 'react-select';
4
+ declare type ReactSelectAsyncProps = AsyncProps<unknown, boolean, GroupBase<unknown>>;
5
+ declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
6
+ declare type TFieldErrors = Record<string, boolean>;
7
+ declare type TEvent = {
8
+ target: {
9
+ name?: string;
10
+ value?: unknown;
11
+ };
12
+ persist: () => void;
13
+ };
14
+ declare type TAsyncSelectFieldProps = {
15
+ id?: ReactSelectAsyncProps['inputId'];
16
+ horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
17
+ errors?: TFieldErrors;
18
+ renderError?: TErrorRenderer;
19
+ isRequired?: boolean;
20
+ touched?: boolean[] | boolean;
21
+ 'aria-label'?: ReactSelectAsyncProps['aria-label'];
22
+ 'aria-labelledby'?: ReactSelectAsyncProps['aria-labelledby'];
23
+ isAutofocussed?: boolean;
24
+ backspaceRemovesValue?: ReactSelectAsyncProps['backspaceRemovesValue'];
25
+ components?: ReactSelectAsyncProps['components'];
26
+ filterOption?: ReactSelectAsyncProps['filterOption'];
27
+ containerId?: ReactSelectAsyncProps['id'];
28
+ isClearable?: ReactSelectAsyncProps['isClearable'];
29
+ isDisabled?: ReactSelectAsyncProps['isDisabled'];
30
+ isReadOnly?: boolean;
31
+ isOptionDisabled?: ReactSelectAsyncProps['isOptionDisabled'];
32
+ isMulti?: ReactSelectAsyncProps['isMulti'];
33
+ isSearchable?: ReactSelectAsyncProps['isSearchable'];
34
+ hasWarning?: boolean;
35
+ maxMenuHeight?: ReactSelectAsyncProps['maxMenuHeight'];
36
+ menuPortalTarget?: ReactSelectAsyncProps['menuPortalTarget'];
37
+ menuPortalZIndex?: number;
38
+ menuShouldBlockScroll?: ReactSelectAsyncProps['menuShouldBlockScroll'];
39
+ name?: ReactSelectAsyncProps['name'];
40
+ noOptionsMessage?: ReactSelectAsyncProps['noOptionsMessage'];
41
+ onBlur?: (event: TEvent) => void;
42
+ onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
43
+ onFocus?: FocusEventHandler;
44
+ onInputChange?: ReactSelectAsyncProps['onInputChange'];
45
+ placeholder?: ReactSelectAsyncProps['placeholder'];
46
+ loadingMessage?: string | (() => string);
47
+ tabIndex?: ReactSelectAsyncProps['tabIndex'];
48
+ tabSelectsValue?: ReactSelectAsyncProps['tabSelectsValue'];
49
+ value?: ReactSelectAsyncProps['value'];
50
+ showOptionGroupDivider?: boolean;
51
+ defaultOptions?: OptionsOrGroups<unknown, GroupBase<unknown>> | boolean;
52
+ loadOptions: ReactSelectAsyncProps['loadOptions'];
53
+ cacheOptions?: ReactSelectAsyncProps['cacheOptions'];
54
+ title: string | ReactNode;
55
+ hint?: string | ReactNode;
56
+ description?: string | ReactNode;
57
+ onInfoButtonClick?: () => void;
58
+ hintIcon?: ReactElement;
59
+ badge?: ReactNode;
60
+ iconLeft?: ReactNode;
61
+ };
62
+ declare type TAsyncSelectFieldState = Pick<TAsyncSelectFieldProps, 'id'>;
63
+ export default class AsyncSelectField extends Component<TAsyncSelectFieldProps, TAsyncSelectFieldState> {
64
+ static displayName: string;
65
+ static defaultProps: Pick<TAsyncSelectFieldProps, 'horizontalConstraint'>;
66
+ state: {
67
+ id: string | undefined;
68
+ };
69
+ static getDerivedStateFromProps: (props: TAsyncSelectFieldProps, state: TAsyncSelectFieldState) => {
70
+ id: string;
71
+ };
72
+ render(): import("@emotion/react/jsx-runtime").JSX.Element;
73
+ }
74
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from './async-select-field';
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-field",
3
3
  "description": "A controlled input component with validation states and a label getting a selection from an asynchronously loaded list from the user.",
4
- "version": "12.2.6",
4
+ "version": "13.0.1",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,18 +19,18 @@
19
19
  "module": "dist/commercetools-uikit-async-select-field.esm.js",
20
20
  "files": ["dist"],
21
21
  "dependencies": {
22
- "@babel/runtime": "7.16.3",
23
- "@babel/runtime-corejs3": "7.16.3",
24
- "@commercetools-uikit/async-select-input": "12.2.6",
25
- "@commercetools-uikit/constraints": "12.2.5",
26
- "@commercetools-uikit/design-system": "12.2.5",
27
- "@commercetools-uikit/field-errors": "12.2.5",
28
- "@commercetools-uikit/field-label": "12.2.6",
29
- "@commercetools-uikit/spacings": "12.2.5",
30
- "@commercetools-uikit/utils": "12.2.5",
22
+ "@babel/runtime": "7.17.2",
23
+ "@babel/runtime-corejs3": "7.17.2",
24
+ "@commercetools-uikit/async-select-input": "13.0.1",
25
+ "@commercetools-uikit/constraints": "13.0.0",
26
+ "@commercetools-uikit/design-system": "13.0.0",
27
+ "@commercetools-uikit/field-errors": "13.0.0",
28
+ "@commercetools-uikit/field-label": "13.0.1",
29
+ "@commercetools-uikit/spacings": "13.0.1",
30
+ "@commercetools-uikit/utils": "12.2.9",
31
31
  "@emotion/react": "^11.4.0",
32
32
  "@emotion/styled": "^11.3.0",
33
- "prop-types": "15.7.2",
33
+ "prop-types": "15.8.1",
34
34
  "react-required-if": "1.0.3"
35
35
  },
36
36
  "devDependencies": {