@commercetools-uikit/async-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
@@ -79,7 +79,7 @@ export default Example;
79
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
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
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`. |
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
83
  | `onFocus` | `FocusEventHandler` | | | Handle focus events on the control |
84
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
85
  | `placeholder` | `AsyncProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
@@ -110,13 +110,13 @@ export default Example;
110
110
  ### Signature `onBlur`
111
111
 
112
112
  ```ts
113
- (event: TEvent) => void
113
+ (event: TCustomEvent) => void
114
114
  ```
115
115
 
116
116
  ### Signature `onChange`
117
117
 
118
118
  ```ts
119
- (event: TEvent, info: ActionMeta<unknown>) => void
119
+ (event: TCustomEvent, info: ActionMeta<unknown>) => void
120
120
  ```
121
121
 
122
122
  ### Signature `onInfoButtonClick`
@@ -99,6 +99,10 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
99
99
  value: function render() {
100
100
  var hasError = AsyncSelectInput__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', 'AsyncSelectField: `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), 'AsyncSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
104
108
  }
@@ -208,7 +212,7 @@ AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
208
212
  hasWarning: _pt__default["default"].bool,
209
213
  menuPortalZIndex: _pt__default["default"].number,
210
214
  onBlur: _pt__default["default"].func,
211
- onChange: _pt__default["default"].func.isRequired,
215
+ onChange: _pt__default["default"].func,
212
216
  onFocus: _pt__default["default"].func,
213
217
  loadingMessage: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].func]),
214
218
  showOptionGroupDivider: _pt__default["default"].bool,
@@ -223,7 +227,7 @@ AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
223
227
  } : {};
224
228
 
225
229
  // NOTE: This string will be replaced on build time with the package version.
226
- var version = "14.0.1";
230
+ var version = "14.0.2";
227
231
 
228
232
  exports["default"] = AsyncSelectField;
229
233
  exports.version = version;
@@ -97,6 +97,8 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
97
97
  value: function render() {
98
98
  var hasError = AsyncSelectInput__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) ;
@@ -193,7 +195,7 @@ AsyncSelectField.getDerivedStateFromProps = function (props, state) {
193
195
  AsyncSelectField.propTypes = {};
194
196
 
195
197
  // NOTE: This string will be replaced on build time with the package version.
196
- var version = "14.0.1";
198
+ var version = "14.0.2";
197
199
 
198
200
  exports["default"] = AsyncSelectField;
199
201
  exports.version = version;
@@ -73,6 +73,10 @@ var AsyncSelectField = /*#__PURE__*/function (_Component) {
73
73
  value: function render() {
74
74
  var hasError = AsyncSelectInput.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', 'AsyncSelectField: `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), 'AsyncSelectField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
78
82
  }
@@ -182,7 +186,7 @@ AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
182
186
  hasWarning: _pt.bool,
183
187
  menuPortalZIndex: _pt.number,
184
188
  onBlur: _pt.func,
185
- onChange: _pt.func.isRequired,
189
+ onChange: _pt.func,
186
190
  onFocus: _pt.func,
187
191
  loadingMessage: _pt.oneOfType([_pt.string, _pt.func]),
188
192
  showOptionGroupDivider: _pt.bool,
@@ -197,6 +201,6 @@ AsyncSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
197
201
  } : {};
198
202
 
199
203
  // NOTE: This string will be replaced on build time with the package version.
200
- var version = "14.0.1";
204
+ var version = "14.0.2";
201
205
 
202
206
  export { AsyncSelectField as default, version };
@@ -7,9 +7,10 @@ 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
- name?: string;
12
+ id?: ReactSelectAsyncProps['inputId'];
13
+ name?: ReactSelectAsyncProps['name'];
13
14
  value?: unknown;
14
15
  };
15
16
  persist: () => void;
@@ -41,8 +42,8 @@ declare type TAsyncSelectFieldProps = {
41
42
  menuShouldBlockScroll?: ReactSelectAsyncProps['menuShouldBlockScroll'];
42
43
  name?: ReactSelectAsyncProps['name'];
43
44
  noOptionsMessage?: ReactSelectAsyncProps['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?: FocusEventHandler;
47
48
  onInputChange?: ReactSelectAsyncProps['onInputChange'];
48
49
  placeholder?: ReactSelectAsyncProps['placeholder'];
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": "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-select-input": "14.0.1",
24
+ "@commercetools-uikit/async-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",