@commercetools-uikit/creatable-select-field 12.2.7 → 13.0.2

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
@@ -49,62 +49,83 @@ export default Example;
49
49
 
50
50
  ## Properties
51
51
 
52
- | Props | Type | Required | Default | Description |
53
- | ---------------------------------- | -------------------------------------------------------------------------------------------------- | :------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
- | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
55
- | `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. |
56
- | `errors` | `object` | | | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br />&#xA;Unknown errors will be forwarded to `renderError` |
57
- | `errors.missing` | `bool` | | | |
58
- | `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` |
59
- | `isRequired` | `bool` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
60
- | `touched` | `custom` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
61
- | `aria-label` | `string` | | | Aria label (for assistive tech) |
62
- | `aria-labelledby` | `string` | | | HTML ID of an element that should be used as the label (for assistive tech) |
63
- | `isAutofocussed` | `bool` | | | Focus the control when it is mounted |
64
- | `backspaceRemovesValue` | `bool` | | | Remove the currently focused option when the user presses backspace |
65
- | `components` | `objectOf(func)` | | | Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components) |
66
- | `filterOption` | `func` | | | Custom method to filter whether an option should be displayed in the menu |
67
- | `containerId` | `string` | | | The id to set on the SelectContainer component |
68
- | `isClearable` | `bool` | | | Is the select value clearable |
69
- | `isDisabled` | `bool` | | | Is the select disabled |
70
- | `isReadOnly` | `bool` | | | Is the select read-only |
71
- | `isOptionDisabled` | `func` | | | Override the built-in logic to detect whether an option is disabled |
72
- | `isMulti` | `bool` | | | Support multiple selected options |
73
- | `isSearchable` | `bool` | | | Whether to enable search functionality |
74
- | `hasWarning` | `bool` | | | |
75
- | `maxMenuHeight` | `number` | | | Maximum height of the menu before scrolling |
76
- | `menuPortalTarget` | `SafeHTMLElement` | | | Dom element to portal the select menu to |
77
- | `menuPortalZIndex` | `number` | | | z-index value for the menu portal |
78
- | `menuShouldBlockScroll` | `bool` | | | whether the menu should block scroll while open |
79
- | `name` | `string` | | | Name of the HTML Input (optional - without this, no input will be rendered) |
80
- | `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;<br />&#xA;Signature: `({ inputValue }) => string` |
81
- | `onBlur` | `func` | | | Handle blur events on the control |
82
- | `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` |
83
- | `onFocus` | `func` | | | Handle focus events on the control |
84
- | `onInputChange` | `func` | | | Handle change events on the input |
85
- | `options` | `array` | | | Array of options that populate the select menu |
86
- | `options[]<shape>` | `object` | | | |
87
- | `options[]<shape>.value` | `string` || | |
88
- | `options[]<shape>.options` | `array` | | | |
89
- | `options[]<shape>.options[].value` | `string` || | |
90
- | `placeholder` | `string` | | | Placeholder text for the select value |
91
- | `tabIndex` | `string` | | | Sets the tabIndex attribute on the input |
92
- | `tabSelectsValue` | `bool` | | | Select the currently focused option when the user presses tab |
93
- | `value` | `custom` | | | The value of the select; reflected by the selected option |
94
- | `showOptionGroupDivider` | `bool` | | | |
95
- | `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. |
96
- | `formatCreateLabel` | `func` | | | Gets the label for the "create new ..." option in the menu. Is given the current input value. |
97
- | `isValidNewOption` | `func` | | | Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array. |
98
- | `getNewOptionData` | `func` | | | Returns the data for the new option when it is created. Used to display the value, and is passed to onChange. |
99
- | `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. |
100
- | `createOptionPosition` | `string` | | | Sets the position of the createOption element in your options list. |
101
- | `title` | `<string, node>` || | Title of the label |
102
- | `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`. |
103
- | `description` | `<string, node>` | | | Provides a description for the title. |
104
- | `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` |
105
- | `hintIcon` | `node` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
106
- | `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) |
107
- | `iconLeft` | `node` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled. |
52
+ | Props | Type | Required | Default | Description |
53
+ | ------------------------- | ----------------------------------------------------------------------------------------------------- | :------: | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
54
+ | `id` | `CreatableProps['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#creatable-props) |
55
+ | `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. |
56
+ | `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically.&#xA;<br>&#xA;Unknown errors will be forwarded to `renderError` |
57
+ | `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. |
58
+ | `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
59
+ | `touched` | `union`<br/>Possible values:<br/>`boolean[] , boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
60
+ | `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) |
61
+ | `aria-labelledby` | `CreatableProps['aria-label']` | | | 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) |
62
+ | `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
63
+ | `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) |
64
+ | `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) |
65
+ | `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) |
66
+ | `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) |
67
+ | `isClearable` | `CreatableProps['isClearable']` | | | Is the select value clearable&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
68
+ | `isDisabled` | `CreatableProps['isDisabled']` | | | Is the select disabled&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
69
+ | `isReadOnly` | `ConstrainBooleanParameters` | | | Is the select read-only |
70
+ | `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) |
71
+ | `isMulti` | `CreatableProps['isMulti']` | | | Support multiple selected options&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
72
+ | `isSearchable` | `CreatableProps['isSearchable']` | | | Whether to enable search functionality&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props#creatable-props) |
73
+ | `hasWarning` | `boolean` | | | Indicates the input field has an error |
74
+ | `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) |
75
+ | `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) |
76
+ | `menuPortalZIndex` | `number` | | | z-index value for the menu portal |
77
+ | `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) |
78
+ | `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) |
79
+ | `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).&#xA;<br>&#xA;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) |
80
+ | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
81
+ | `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`. |
82
+ | `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) |
83
+ | `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) |
84
+ | `options` | `union`<br/>Possible values:<br/>`TValue[] , { options: TValue[] }[]` | | | Array of options that populate the select menu |
85
+ | `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) |
86
+ | `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) |
87
+ | `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) |
88
+ | `value` | `CreatableProps['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#creatable-props) |
89
+ | `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
90
+ | `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) |
91
+ | `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) |
92
+ | `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) |
93
+ | `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) |
94
+ | `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) |
95
+ | `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) |
96
+ | `title` | `union`<br/>Possible values:<br/>`string , ReactNode` || | Title of the label |
97
+ | `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`. |
98
+ | `description` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Provides a description for the title. |
99
+ | `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. |
100
+ | `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text.&#xA;<br>&#xA;Will only get rendered when `hint` is passed as well. |
101
+ | `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) |
102
+ | `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled. |
103
+
104
+ ## Signatures
105
+
106
+ ### Signature `renderError`
107
+
108
+ ```ts
109
+ (key: string, error?: boolean) => ReactNode;
110
+ ```
111
+
112
+ ### Signature `onBlur`
113
+
114
+ ```ts
115
+ (event: TEvent) => void
116
+ ```
117
+
118
+ ### Signature `onChange`
119
+
120
+ ```ts
121
+ (event: TEvent, info: ActionMeta<unknown>) => void
122
+ ```
123
+
124
+ ### Signature `onInfoButtonClick`
125
+
126
+ ```ts
127
+ () => void
128
+ ```
108
129
 
109
130
  ## `data-*` props
110
131
 
@@ -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 CreatableSelectInput__default = /*#__PURE__*/_interopDefault(CreatableSelectInput);
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 CreatableSelectField = /*#__PURE__*/function (_Component) {
97
97
  key: "render",
98
98
  value: function render() {
99
99
  var hasError = CreatableSelectInput__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), 'CreatableSelectField: `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), 'CreatableSelectField: `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), 'CreatableSelectField: `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, {
@@ -175,302 +185,36 @@ CreatableSelectField.getDerivedStateFromProps = function (props, state) {
175
185
  };
176
186
  };
177
187
  CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
178
- // CreatableSelectField
179
-
180
- /**
181
- * Used as HTML id property. An id is auto-generated when it is not specified.
182
- */
183
- id: PropTypes__default["default"].string,
184
-
185
- /**
186
- * Horizontal size limit of the input fields.
187
- */
188
- horizontalConstraint: PropTypes__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
189
-
190
- /**
191
- * A map of errors. Error messages for known errors are rendered automatically.
192
- * <br />
193
- * Unknown errors will be forwarded to `renderError`
194
- */
195
- errors: PropTypes__default["default"].shape({
196
- missing: PropTypes__default["default"].bool
197
- }),
198
-
199
- /**
200
- * 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.
201
- * <br />
202
- * Signature: `(key, error) => React.node`
203
- */
204
- renderError: PropTypes__default["default"].func,
205
-
206
- /**
207
- * Indicates if the value is required. Shows an the "required asterisk" if so.
208
- */
209
- isRequired: PropTypes__default["default"].bool,
210
-
211
- /**
212
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
213
- */
214
- touched: function touched(props) {
215
- var _context3, _context4, _context5;
216
-
217
- for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
218
- rest[_key2 - 1] = arguments[_key2];
219
- }
220
-
221
- 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));
222
- },
223
- // CreatableSelectInput
224
-
225
- /**
226
- * Aria label (for assistive tech)
227
- */
228
- 'aria-label': PropTypes__default["default"].string,
229
-
230
- /**
231
- * HTML ID of an element that should be used as the label (for assistive tech)
232
- */
233
- 'aria-labelledby': PropTypes__default["default"].string,
234
-
235
- /**
236
- * Focus the control when it is mounted
237
- */
238
- isAutofocussed: PropTypes__default["default"].bool,
239
-
240
- /**
241
- * Remove the currently focused option when the user presses backspace
242
- */
243
- backspaceRemovesValue: PropTypes__default["default"].bool,
244
-
245
- /**
246
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
247
- */
248
- components: PropTypes__default["default"].objectOf(PropTypes__default["default"].func),
249
-
250
- /**
251
- * Custom method to filter whether an option should be displayed in the menu
252
- */
253
- filterOption: PropTypes__default["default"].func,
254
-
255
- /**
256
- * The id to set on the SelectContainer component
257
- */
258
- containerId: PropTypes__default["default"].string,
259
-
260
- /**
261
- * Is the select value clearable
262
- */
263
- isClearable: PropTypes__default["default"].bool,
264
-
265
- /**
266
- * Is the select disabled
267
- */
268
- isDisabled: PropTypes__default["default"].bool,
269
-
270
- /**
271
- * Is the select read-only
272
- */
273
- // eslint-disable-next-line react/no-unused-prop-types
274
- isReadOnly: PropTypes__default["default"].bool,
275
-
276
- /**
277
- * Override the built-in logic to detect whether an option is disabled
278
- */
279
- isOptionDisabled: PropTypes__default["default"].func,
280
-
281
- /**
282
- * Support multiple selected options
283
- */
284
- isMulti: PropTypes__default["default"].bool,
285
-
286
- /**
287
- * Whether to enable search functionality
288
- */
289
- isSearchable: PropTypes__default["default"].bool,
290
- hasWarning: PropTypes__default["default"].bool,
291
-
292
- /**
293
- * Maximum height of the menu before scrolling
294
- */
295
- maxMenuHeight: PropTypes__default["default"].number,
296
-
297
- /**
298
- * Dom element to portal the select menu to
299
- */
300
- menuPortalTarget: PropTypes__default["default"].instanceOf(utils.SafeHTMLElement),
301
-
302
- /**
303
- * z-index value for the menu portal
304
- */
305
- menuPortalZIndex: PropTypes__default["default"].number,
306
-
307
- /**
308
- * whether the menu should block scroll while open
309
- */
310
- menuShouldBlockScroll: PropTypes__default["default"].bool,
311
-
312
- /**
313
- * Name of the HTML Input (optional - without this, no input will be rendered)
314
- */
315
- name: PropTypes__default["default"].string,
316
-
317
- /**
318
- * 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).
319
- * <br/>
320
- * Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.
321
- * <br />
322
- * Signature: `({ inputValue }) => string`
323
- */
324
- noOptionsMessage: PropTypes__default["default"].func,
325
-
326
- /**
327
- * Handle blur events on the control
328
- */
329
- onBlur: PropTypes__default["default"].func,
330
-
331
- /**
332
- * Called with a fake event when value changes.
333
- * <br />
334
- * 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`.
335
- * <br />
336
- * Signature: `(event) => void`
337
- */
338
- onChange: PropTypes__default["default"].func,
339
-
340
- /**
341
- * Handle focus events on the control
342
- */
343
- onFocus: PropTypes__default["default"].func,
344
-
345
- /**
346
- * Handle change events on the input
347
- */
348
- onInputChange: PropTypes__default["default"].func,
349
-
350
- /**
351
- * Array of options that populate the select menu
352
- */
353
- options: PropTypes__default["default"].arrayOf(PropTypes__default["default"].oneOfType([PropTypes__default["default"].shape({
354
- value: PropTypes__default["default"].string.isRequired
355
- }), PropTypes__default["default"].shape({
356
- options: PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
357
- value: PropTypes__default["default"].string.isRequired
358
- }))
359
- })])),
360
-
361
- /**
362
- * Placeholder text for the select value
363
- */
364
- placeholder: PropTypes__default["default"].string,
365
-
366
- /**
367
- * Sets the tabIndex attribute on the input
368
- */
369
- tabIndex: PropTypes__default["default"].string,
370
-
371
- /**
372
- * Select the currently focused option when the user presses tab
373
- */
374
- tabSelectsValue: PropTypes__default["default"].bool,
375
-
376
- /**
377
- * The value of the select; reflected by the selected option
378
- */
379
- value: function value(props) {
380
- var _context6, _context7;
381
-
382
- for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
383
- rest[_key3 - 1] = arguments[_key3];
384
- }
385
-
386
- return props.isMulti ? PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
387
- value: PropTypes__default["default"].string.isRequired
388
- })).apply(void 0, _concatInstanceProperty__default["default"](_context6 = [props]).call(_context6, rest)) : PropTypes__default["default"].shape({
389
- value: PropTypes__default["default"].string.isRequired
390
- }).apply(void 0, _concatInstanceProperty__default["default"](_context7 = [props]).call(_context7, rest));
391
- },
392
- showOptionGroupDivider: PropTypes__default["default"].bool,
393
- // Creatable props
394
-
395
- /**
396
- * 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.
397
- */
398
- allowCreateWhileLoading: PropTypes__default["default"].bool,
399
-
400
- /**
401
- * Gets the label for the "create new ..." option in the menu. Is given the current input value.
402
- */
403
- formatCreateLabel: PropTypes__default["default"].func,
404
-
405
- /**
406
- * Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.
407
- */
408
- isValidNewOption: PropTypes__default["default"].func,
409
-
410
- /**
411
- * Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.
412
- */
413
- getNewOptionData: PropTypes__default["default"].func,
414
-
415
- /**
416
- * 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.
417
- */
418
- onCreateOption: PropTypes__default["default"].func,
419
-
420
- /**
421
- * Sets the position of the createOption element in your options list.
422
- */
423
- createOptionPosition: PropTypes__default["default"].string,
424
- // LabelField
425
-
426
- /**
427
- * Title of the label
428
- */
429
- title: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]).isRequired,
430
-
431
- /**
432
- * 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`.
433
- */
434
- hint: requiredIf__default["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]), function (props) {
435
- return props.hintIcon;
436
- }),
437
-
438
- /**
439
- * Provides a description for the title.
440
- */
441
- description: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
442
-
443
- /**
444
- * Function called when info button is pressed.
445
- * <br />
446
- * Info button will only be visible when this prop is passed.
447
- * <br />
448
- * Signature: `(event) => void`
449
- */
450
- onInfoButtonClick: PropTypes__default["default"].func,
451
-
452
- /**
453
- * Icon to be displayed beside the hint text.
454
- * <br />
455
- * Will only get rendered when `hint` is passed as well.
456
- */
457
- hintIcon: PropTypes__default["default"].node,
458
-
459
- /**
460
- * Badge to be displayed beside the label.
461
- * <br />
462
- * Might be used to display additional information about the content of the field (E.g verified email)
463
- */
464
- badge: PropTypes__default["default"].node,
465
-
466
- /**
467
- * Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.
468
- */
469
- iconLeft: PropTypes__default["default"].node
188
+ horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
189
+ errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
190
+ renderError: _pt__default["default"].func,
191
+ isRequired: _pt__default["default"].bool,
192
+ touched: _pt__default["default"].oneOfType([_pt__default["default"].arrayOf(_pt__default["default"].bool), _pt__default["default"].bool]),
193
+ isAutofocussed: _pt__default["default"].bool,
194
+ isReadOnly: _pt__default["default"].any,
195
+ hasWarning: _pt__default["default"].bool,
196
+ menuPortalZIndex: _pt__default["default"].number,
197
+ onBlur: _pt__default["default"].func,
198
+ onChange: _pt__default["default"].func.isRequired,
199
+ options: _pt__default["default"].oneOfType([_pt__default["default"].arrayOf(_pt__default["default"].shape({
200
+ value: _pt__default["default"].string.isRequired
201
+ })), _pt__default["default"].arrayOf(_pt__default["default"].shape({
202
+ options: _pt__default["default"].arrayOf(_pt__default["default"].shape({
203
+ value: _pt__default["default"].string.isRequired
204
+ })).isRequired
205
+ }))]),
206
+ showOptionGroupDivider: _pt__default["default"].bool,
207
+ title: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]).isRequired,
208
+ hint: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
209
+ description: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
210
+ onInfoButtonClick: _pt__default["default"].func,
211
+ hintIcon: _pt__default["default"].element,
212
+ badge: _pt__default["default"].node,
213
+ iconLeft: _pt__default["default"].node
470
214
  } : {};
471
215
 
472
216
  // NOTE: This string will be replaced on build time with the package version.
473
- var version = "12.2.7";
217
+ var version = "13.0.2";
474
218
 
475
219
  exports["default"] = CreatableSelectField;
476
220
  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 CreatableSelectInput__default = /*#__PURE__*/_interopDefault(CreatableSelectInput);
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 CreatableSelectField = /*#__PURE__*/function (_Component) {
95
95
  key: "render",
96
96
  value: function render() {
97
97
  var hasError = CreatableSelectInput__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, {
@@ -175,7 +180,7 @@ CreatableSelectField.getDerivedStateFromProps = function (props, state) {
175
180
  CreatableSelectField.propTypes = {};
176
181
 
177
182
  // NOTE: This string will be replaced on build time with the package version.
178
- var version = "12.2.7";
183
+ var version = "13.0.2";
179
184
 
180
185
  exports["default"] = CreatableSelectField;
181
186
  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 CreatableSelectInput from '@commercetools-uikit/creatable-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 CreatableSelectField = /*#__PURE__*/function (_Component) {
71
71
  key: "render",
72
72
  value: function render() {
73
73
  var hasError = CreatableSelectInput.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), 'CreatableSelectField: `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), 'CreatableSelectField: `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), 'CreatableSelectField: `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, {
@@ -149,301 +159,35 @@ CreatableSelectField.getDerivedStateFromProps = function (props, state) {
149
159
  };
150
160
  };
151
161
  CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
152
- // CreatableSelectField
153
-
154
- /**
155
- * Used as HTML id property. An id is auto-generated when it is not specified.
156
- */
157
- id: PropTypes.string,
158
-
159
- /**
160
- * Horizontal size limit of the input fields.
161
- */
162
- horizontalConstraint: PropTypes.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
163
-
164
- /**
165
- * A map of errors. Error messages for known errors are rendered automatically.
166
- * <br />
167
- * Unknown errors will be forwarded to `renderError`
168
- */
169
- errors: PropTypes.shape({
170
- missing: PropTypes.bool
171
- }),
172
-
173
- /**
174
- * 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.
175
- * <br />
176
- * Signature: `(key, error) => React.node`
177
- */
178
- renderError: PropTypes.func,
179
-
180
- /**
181
- * Indicates if the value is required. Shows an the "required asterisk" if so.
182
- */
183
- isRequired: PropTypes.bool,
184
-
185
- /**
186
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
187
- */
188
- touched: function touched(props) {
189
- var _context3, _context4, _context5;
190
-
191
- for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
192
- rest[_key2 - 1] = arguments[_key2];
193
- }
194
-
195
- 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));
196
- },
197
- // CreatableSelectInput
198
-
199
- /**
200
- * Aria label (for assistive tech)
201
- */
202
- 'aria-label': PropTypes.string,
203
-
204
- /**
205
- * HTML ID of an element that should be used as the label (for assistive tech)
206
- */
207
- 'aria-labelledby': PropTypes.string,
208
-
209
- /**
210
- * Focus the control when it is mounted
211
- */
212
- isAutofocussed: PropTypes.bool,
213
-
214
- /**
215
- * Remove the currently focused option when the user presses backspace
216
- */
217
- backspaceRemovesValue: PropTypes.bool,
218
-
219
- /**
220
- * Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
221
- */
222
- components: PropTypes.objectOf(PropTypes.func),
223
-
224
- /**
225
- * Custom method to filter whether an option should be displayed in the menu
226
- */
227
- filterOption: PropTypes.func,
228
-
229
- /**
230
- * The id to set on the SelectContainer component
231
- */
232
- containerId: PropTypes.string,
233
-
234
- /**
235
- * Is the select value clearable
236
- */
237
- isClearable: PropTypes.bool,
238
-
239
- /**
240
- * Is the select disabled
241
- */
242
- isDisabled: PropTypes.bool,
243
-
244
- /**
245
- * Is the select read-only
246
- */
247
- // eslint-disable-next-line react/no-unused-prop-types
248
- isReadOnly: PropTypes.bool,
249
-
250
- /**
251
- * Override the built-in logic to detect whether an option is disabled
252
- */
253
- isOptionDisabled: PropTypes.func,
254
-
255
- /**
256
- * Support multiple selected options
257
- */
258
- isMulti: PropTypes.bool,
259
-
260
- /**
261
- * Whether to enable search functionality
262
- */
263
- isSearchable: PropTypes.bool,
264
- hasWarning: PropTypes.bool,
265
-
266
- /**
267
- * Maximum height of the menu before scrolling
268
- */
269
- maxMenuHeight: PropTypes.number,
270
-
271
- /**
272
- * Dom element to portal the select menu to
273
- */
274
- menuPortalTarget: PropTypes.instanceOf(SafeHTMLElement),
275
-
276
- /**
277
- * z-index value for the menu portal
278
- */
279
- menuPortalZIndex: PropTypes.number,
280
-
281
- /**
282
- * whether the menu should block scroll while open
283
- */
284
- menuShouldBlockScroll: PropTypes.bool,
285
-
286
- /**
287
- * Name of the HTML Input (optional - without this, no input will be rendered)
288
- */
289
- name: PropTypes.string,
290
-
291
- /**
292
- * Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place).
293
- * <br/>
294
- * Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.
295
- * <br />
296
- * Signature: `({ inputValue }) => string`
297
- */
298
- noOptionsMessage: PropTypes.func,
299
-
300
- /**
301
- * Handle blur events on the control
302
- */
303
- onBlur: PropTypes.func,
304
-
305
- /**
306
- * Called with a fake event when value changes.
307
- * <br />
308
- * 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`.
309
- * <br />
310
- * Signature: `(event) => void`
311
- */
312
- onChange: PropTypes.func,
313
-
314
- /**
315
- * Handle focus events on the control
316
- */
317
- onFocus: PropTypes.func,
318
-
319
- /**
320
- * Handle change events on the input
321
- */
322
- onInputChange: PropTypes.func,
323
-
324
- /**
325
- * Array of options that populate the select menu
326
- */
327
- options: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.shape({
328
- value: PropTypes.string.isRequired
329
- }), PropTypes.shape({
330
- options: PropTypes.arrayOf(PropTypes.shape({
331
- value: PropTypes.string.isRequired
332
- }))
333
- })])),
334
-
335
- /**
336
- * Placeholder text for the select value
337
- */
338
- placeholder: PropTypes.string,
339
-
340
- /**
341
- * Sets the tabIndex attribute on the input
342
- */
343
- tabIndex: PropTypes.string,
344
-
345
- /**
346
- * Select the currently focused option when the user presses tab
347
- */
348
- tabSelectsValue: PropTypes.bool,
349
-
350
- /**
351
- * The value of the select; reflected by the selected option
352
- */
353
- value: function value(props) {
354
- var _context6, _context7;
355
-
356
- for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
357
- rest[_key3 - 1] = arguments[_key3];
358
- }
359
-
360
- return props.isMulti ? PropTypes.arrayOf(PropTypes.shape({
361
- value: PropTypes.string.isRequired
362
- })).apply(void 0, _concatInstanceProperty(_context6 = [props]).call(_context6, rest)) : PropTypes.shape({
363
- value: PropTypes.string.isRequired
364
- }).apply(void 0, _concatInstanceProperty(_context7 = [props]).call(_context7, rest));
365
- },
366
- showOptionGroupDivider: PropTypes.bool,
367
- // Creatable props
368
-
369
- /**
370
- * 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.
371
- */
372
- allowCreateWhileLoading: PropTypes.bool,
373
-
374
- /**
375
- * Gets the label for the "create new ..." option in the menu. Is given the current input value.
376
- */
377
- formatCreateLabel: PropTypes.func,
378
-
379
- /**
380
- * Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.
381
- */
382
- isValidNewOption: PropTypes.func,
383
-
384
- /**
385
- * Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.
386
- */
387
- getNewOptionData: PropTypes.func,
388
-
389
- /**
390
- * 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.
391
- */
392
- onCreateOption: PropTypes.func,
393
-
394
- /**
395
- * Sets the position of the createOption element in your options list.
396
- */
397
- createOptionPosition: PropTypes.string,
398
- // LabelField
399
-
400
- /**
401
- * Title of the label
402
- */
403
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
404
-
405
- /**
406
- * 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`.
407
- */
408
- hint: requiredIf(PropTypes.oneOfType([PropTypes.string, PropTypes.node]), function (props) {
409
- return props.hintIcon;
410
- }),
411
-
412
- /**
413
- * Provides a description for the title.
414
- */
415
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
416
-
417
- /**
418
- * Function called when info button is pressed.
419
- * <br />
420
- * Info button will only be visible when this prop is passed.
421
- * <br />
422
- * Signature: `(event) => void`
423
- */
424
- onInfoButtonClick: PropTypes.func,
425
-
426
- /**
427
- * Icon to be displayed beside the hint text.
428
- * <br />
429
- * Will only get rendered when `hint` is passed as well.
430
- */
431
- hintIcon: PropTypes.node,
432
-
433
- /**
434
- * Badge to be displayed beside the label.
435
- * <br />
436
- * Might be used to display additional information about the content of the field (E.g verified email)
437
- */
438
- badge: PropTypes.node,
439
-
440
- /**
441
- * Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.
442
- */
443
- iconLeft: PropTypes.node
162
+ horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
163
+ errors: _pt.objectOf(_pt.bool),
164
+ renderError: _pt.func,
165
+ isRequired: _pt.bool,
166
+ touched: _pt.oneOfType([_pt.arrayOf(_pt.bool), _pt.bool]),
167
+ isAutofocussed: _pt.bool,
168
+ isReadOnly: _pt.any,
169
+ hasWarning: _pt.bool,
170
+ menuPortalZIndex: _pt.number,
171
+ onBlur: _pt.func,
172
+ onChange: _pt.func.isRequired,
173
+ options: _pt.oneOfType([_pt.arrayOf(_pt.shape({
174
+ value: _pt.string.isRequired
175
+ })), _pt.arrayOf(_pt.shape({
176
+ options: _pt.arrayOf(_pt.shape({
177
+ value: _pt.string.isRequired
178
+ })).isRequired
179
+ }))]),
180
+ showOptionGroupDivider: _pt.bool,
181
+ title: _pt.oneOfType([_pt.string, _pt.node]).isRequired,
182
+ hint: _pt.oneOfType([_pt.string, _pt.node]),
183
+ description: _pt.oneOfType([_pt.string, _pt.node]),
184
+ onInfoButtonClick: _pt.func,
185
+ hintIcon: _pt.element,
186
+ badge: _pt.node,
187
+ iconLeft: _pt.node
444
188
  } : {};
445
189
 
446
190
  // NOTE: This string will be replaced on build time with the package version.
447
- var version = "12.2.7";
191
+ var version = "13.0.2";
448
192
 
449
193
  export { CreatableSelectField as default, version };
@@ -0,0 +1,85 @@
1
+ import { Component, type ReactElement, type ReactNode } from 'react';
2
+ import type { GroupBase, ActionMeta } from 'react-select';
3
+ import type { CreatableProps } from 'react-select/creatable';
4
+ declare type ReactSelectCreatableProps = CreatableProps<unknown, boolean, GroupBase<unknown>>;
5
+ declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
6
+ declare type TFieldErrors = Record<string, boolean>;
7
+ declare type TValue = {
8
+ value: string;
9
+ };
10
+ declare type TOptions = TValue[] | {
11
+ options: TValue[];
12
+ }[];
13
+ declare type TEvent = {
14
+ target: {
15
+ name?: string;
16
+ value?: unknown;
17
+ };
18
+ persist?: () => void;
19
+ };
20
+ declare type TCreatableSelectFieldProps = {
21
+ id?: ReactSelectCreatableProps['inputId'];
22
+ horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
23
+ errors?: TFieldErrors;
24
+ renderError?: TErrorRenderer;
25
+ isRequired?: boolean;
26
+ touched?: boolean[] | boolean;
27
+ 'aria-label'?: ReactSelectCreatableProps['aria-label'];
28
+ 'aria-labelledby'?: ReactSelectCreatableProps['aria-label'];
29
+ isAutofocussed?: boolean;
30
+ backspaceRemovesValue?: ReactSelectCreatableProps['backspaceRemovesValue'];
31
+ components?: ReactSelectCreatableProps['components'];
32
+ filterOption?: ReactSelectCreatableProps['filterOption'];
33
+ containerId?: ReactSelectCreatableProps['id'];
34
+ isClearable?: ReactSelectCreatableProps['isClearable'];
35
+ isDisabled?: ReactSelectCreatableProps['isDisabled'];
36
+ isReadOnly?: ConstrainBooleanParameters;
37
+ isOptionDisabled?: ReactSelectCreatableProps['isOptionDisabled'];
38
+ isMulti?: ReactSelectCreatableProps['isMulti'];
39
+ isSearchable?: ReactSelectCreatableProps['isSearchable'];
40
+ hasWarning?: boolean;
41
+ maxMenuHeight?: ReactSelectCreatableProps['maxMenuHeight'];
42
+ menuPortalTarget?: ReactSelectCreatableProps['menuPortalTarget'];
43
+ menuPortalZIndex?: number;
44
+ menuShouldBlockScroll?: ReactSelectCreatableProps['menuShouldBlockScroll'];
45
+ name?: ReactSelectCreatableProps['name'];
46
+ noOptionsMessage?: ReactSelectCreatableProps['noOptionsMessage'];
47
+ onBlur?: (event: TEvent) => void;
48
+ onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
49
+ onFocus?: ReactSelectCreatableProps['onFocus'];
50
+ onInputChange?: ReactSelectCreatableProps['onInputChange'];
51
+ options?: TOptions;
52
+ placeholder?: ReactSelectCreatableProps['placeholder'];
53
+ tabIndex?: ReactSelectCreatableProps['tabIndex'];
54
+ tabSelectsValue?: ReactSelectCreatableProps['tabSelectsValue'];
55
+ value?: ReactSelectCreatableProps['value'];
56
+ showOptionGroupDivider?: boolean;
57
+ allowCreateWhileLoading?: ReactSelectCreatableProps['allowCreateWhileLoading'];
58
+ formatCreateLabel?: ReactSelectCreatableProps['formatCreateLabel'];
59
+ isValidNewOption?: ReactSelectCreatableProps['isValidNewOption'];
60
+ getNewOptionData?: ReactSelectCreatableProps['getNewOptionData'];
61
+ onCreateOption?: ReactSelectCreatableProps['onCreateOption'];
62
+ createOptionPosition?: ReactSelectCreatableProps['createOptionPosition'];
63
+ title: string | ReactNode;
64
+ hint?: string | ReactNode;
65
+ description?: string | ReactNode;
66
+ onInfoButtonClick?: () => void;
67
+ hintIcon?: ReactElement;
68
+ badge?: ReactNode;
69
+ iconLeft?: ReactNode;
70
+ };
71
+ declare type TCreatableSelectFieldState = Pick<TCreatableSelectFieldProps, 'id'>;
72
+ export default class CreatableSelectField extends Component<TCreatableSelectFieldProps, TCreatableSelectFieldState> {
73
+ static displayName: string;
74
+ static defaultProps: {
75
+ horizontalConstraint: string;
76
+ };
77
+ state: {
78
+ id: string | undefined;
79
+ };
80
+ static getDerivedStateFromProps: (props: TCreatableSelectFieldProps, state: TCreatableSelectFieldState) => {
81
+ id: string;
82
+ };
83
+ render(): import("@emotion/react/jsx-runtime").JSX.Element;
84
+ }
85
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default } from './creatable-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/creatable-select-field",
3
3
  "description": "A controlled input component with validation states and a label getting a selection from the user, and where options can also be created by the user.",
4
- "version": "12.2.7",
4
+ "version": "13.0.2",
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-creatable-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/constraints": "12.2.5",
25
- "@commercetools-uikit/creatable-select-input": "12.2.7",
26
- "@commercetools-uikit/design-system": "12.2.5",
27
- "@commercetools-uikit/field-errors": "12.2.5",
28
- "@commercetools-uikit/field-label": "12.2.7",
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/constraints": "13.0.2",
25
+ "@commercetools-uikit/creatable-select-input": "13.0.2",
26
+ "@commercetools-uikit/design-system": "13.0.0",
27
+ "@commercetools-uikit/field-errors": "13.0.2",
28
+ "@commercetools-uikit/field-label": "13.0.2",
29
+ "@commercetools-uikit/spacings": "13.0.2",
30
+ "@commercetools-uikit/utils": "13.0.2",
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": {