@commercetools-uikit/async-creatable-select-field 14.0.1 → 14.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
@@ -81,7 +81,7 @@ export default Example;
81
81
  | `name` | `AsyncCreatableProps['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) |
82
82
  | `noOptionsMessage` | `AsyncCreatableProps['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) |
83
83
  | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
84
- | `onChange` | `Function`<br/>[See signature.](#signature-onChange) || | Called with a fake event when value changes.&#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;[Props from React select was used](https://react-select.com/props) |
84
+ | `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`.&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
85
85
  | `onFocus` | `AsyncCreatableProps['onFocus']` | | | Handle focus events on the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
86
86
  | `onInputChange` | `AsyncCreatableProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
87
87
  | `placeholder` | `AsyncCreatableProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
@@ -117,13 +117,13 @@ export default Example;
117
117
  ### Signature `onBlur`
118
118
 
119
119
  ```ts
120
- (event: TEvent) => void
120
+ (event: TCustomEvent) => void
121
121
  ```
122
122
 
123
123
  ### Signature `onChange`
124
124
 
125
125
  ```ts
126
- (event: TEvent, info: ActionMeta<unknown>) => void
126
+ (event: TCustomEvent, info: ActionMeta<unknown>) => void
127
127
  ```
128
128
 
129
129
  ### Signature `onInfoButtonClick`
@@ -99,6 +99,10 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
99
99
  value: function render() {
100
100
  var hasError = AsyncCreatableSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
101
101
 
102
+ if (!this.props.isReadOnly) {
103
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'AsyncCreatableSelectField: `onChange` is required when field is not read only.') : void 0;
104
+ }
105
+
102
106
  if (this.props.hintIcon) {
103
107
  process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'AsyncCreatableSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
104
108
  }
@@ -214,7 +218,7 @@ AsyncCreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
214
218
  hasWarning: _pt__default["default"].bool,
215
219
  menuPortalZIndex: _pt__default["default"].number,
216
220
  onBlur: _pt__default["default"].func,
217
- onChange: _pt__default["default"].func.isRequired,
221
+ onChange: _pt__default["default"].func,
218
222
  showOptionGroupDivider: _pt__default["default"].bool,
219
223
  title: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]).isRequired,
220
224
  hint: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
@@ -226,7 +230,7 @@ AsyncCreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
226
230
  } : {};
227
231
 
228
232
  // NOTE: This string will be replaced on build time with the package version.
229
- var version = "14.0.1";
233
+ var version = "14.0.2";
230
234
 
231
235
  exports["default"] = AsyncCreatableSelectField;
232
236
  exports.version = version;
@@ -97,6 +97,8 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
97
97
  value: function render() {
98
98
  var hasError = AsyncCreatableSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
99
99
 
100
+ if (!this.props.isReadOnly) ;
101
+
100
102
  if (this.props.hintIcon) ;
101
103
 
102
104
  if (this.props.isMulti) ;
@@ -199,7 +201,7 @@ AsyncCreatableSelectField.getDerivedStateFromProps = function (props, state) {
199
201
  AsyncCreatableSelectField.propTypes = {};
200
202
 
201
203
  // NOTE: This string will be replaced on build time with the package version.
202
- var version = "14.0.1";
204
+ var version = "14.0.2";
203
205
 
204
206
  exports["default"] = AsyncCreatableSelectField;
205
207
  exports.version = version;
@@ -73,6 +73,10 @@ var AsyncCreatableSelectField = /*#__PURE__*/function (_Component) {
73
73
  value: function render() {
74
74
  var hasError = AsyncCreatableSelectInput.isTouched(this.props.touched) && hasErrors(this.props.errors);
75
75
 
76
+ if (!this.props.isReadOnly) {
77
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'AsyncCreatableSelectField: `onChange` is required when field is not read only.') : void 0;
78
+ }
79
+
76
80
  if (this.props.hintIcon) {
77
81
  process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'AsyncCreatableSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
78
82
  }
@@ -188,7 +192,7 @@ AsyncCreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
188
192
  hasWarning: _pt.bool,
189
193
  menuPortalZIndex: _pt.number,
190
194
  onBlur: _pt.func,
191
- onChange: _pt.func.isRequired,
195
+ onChange: _pt.func,
192
196
  showOptionGroupDivider: _pt.bool,
193
197
  title: _pt.oneOfType([_pt.string, _pt.node]).isRequired,
194
198
  hint: _pt.oneOfType([_pt.string, _pt.node]),
@@ -200,6 +204,6 @@ AsyncCreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
200
204
  } : {};
201
205
 
202
206
  // NOTE: This string will be replaced on build time with the package version.
203
- var version = "14.0.1";
207
+ var version = "14.0.2";
204
208
 
205
209
  export { AsyncCreatableSelectField as default, version };
@@ -7,8 +7,9 @@ declare type TFieldErrors = Record<string, boolean>;
7
7
  declare type TCustomFormErrors<Values> = {
8
8
  [K in keyof Values]?: TFieldErrors;
9
9
  };
10
- declare type TEvent = {
10
+ declare type TCustomEvent = {
11
11
  target: {
12
+ id?: string;
12
13
  name?: string;
13
14
  value?: unknown;
14
15
  };
@@ -41,8 +42,8 @@ declare type TAsyncCreatableSelectFieldProps = {
41
42
  menuShouldBlockScroll?: ReactSelectAsyncCreatableProps['menuShouldBlockScroll'];
42
43
  name?: ReactSelectAsyncCreatableProps['name'];
43
44
  noOptionsMessage?: ReactSelectAsyncCreatableProps['noOptionsMessage'];
44
- onBlur?: (event: TEvent) => void;
45
- onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
45
+ onBlur?: (event: TCustomEvent) => void;
46
+ onChange?: (event: TCustomEvent, info: ActionMeta<unknown>) => void;
46
47
  onFocus?: ReactSelectAsyncCreatableProps['onFocus'];
47
48
  onInputChange?: ReactSelectAsyncCreatableProps['onInputChange'];
48
49
  placeholder?: ReactSelectAsyncCreatableProps['placeholder'];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/async-creatable-select-field",
3
3
  "description": "An input component with validation states and a label getting a selection from an asynchronously loaded list from the user, and where options can be created by the user.",
4
- "version": "14.0.1",
4
+ "version": "14.0.2",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,11 +21,11 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.17.2",
23
23
  "@babel/runtime-corejs3": "^7.17.2",
24
- "@commercetools-uikit/async-creatable-select-input": "14.0.1",
24
+ "@commercetools-uikit/async-creatable-select-input": "14.0.2",
25
25
  "@commercetools-uikit/constraints": "14.0.1",
26
26
  "@commercetools-uikit/design-system": "14.0.0",
27
27
  "@commercetools-uikit/field-errors": "14.0.1",
28
- "@commercetools-uikit/field-label": "14.0.1",
28
+ "@commercetools-uikit/field-label": "14.0.2",
29
29
  "@commercetools-uikit/spacings": "14.0.1",
30
30
  "@commercetools-uikit/utils": "14.0.1",
31
31
  "@emotion/react": "^11.4.0",