@commercetools-uikit/async-creatable-select-input 14.0.1 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -89,7 +89,7 @@ export default Example;
89
89
  | `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) |
90
90
  | `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). 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) |
91
91
  | `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Handle blur events on the control |
92
- | `onChange` | `Function`<br/>[See signature.](#signature-onChange) || | Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`. |
92
+ | `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`. |
93
93
  | `onFocus` | `AsyncCreatableProps['onFocus']` | | | Handle focus events on the control&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
94
94
  | `onInputChange` | `AsyncCreatableProps['onInputChange']` | | | Handle change events on the input&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
95
95
  | `placeholder` | `AsyncCreatableProps['placeholder']` | | | Placeholder text for the select value&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
@@ -112,13 +112,13 @@ export default Example;
112
112
  ### Signature `onBlur`
113
113
 
114
114
  ```ts
115
- (event: TEvent) => void
115
+ (event: TCustomEvent) => void
116
116
  ```
117
117
 
118
118
  ### Signature `onChange`
119
119
 
120
120
  ```ts
121
- (event: TEvent, info: ActionMeta<unknown>) => void
121
+ (event: TCustomEvent, info: ActionMeta<unknown>) => void
122
122
  ```
123
123
 
124
124
  This input is built on top of [`react-select`](https://github.com/JedWatson/react-select) v2.
@@ -71,6 +71,10 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
71
71
  var theme = react.useTheme();
72
72
  var placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
73
73
 
74
+ if (!props.isReadOnly) {
75
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'AsyncCreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
76
+ }
77
+
74
78
  if (props.isMulti) {
75
79
  process.env.NODE_ENV !== "production" ? utils.warning(_Array$isArray__default["default"](props.value), 'AsyncCreatableSelectInput: `value` is expected to be an array when isMulti is true') : void 0;
76
80
  }
@@ -131,6 +135,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
131
135
  onBlur: props.onBlur ? function () {
132
136
  var event = {
133
137
  target: {
138
+ id: props.id,
134
139
  name: function () {
135
140
  if (!props.name) return undefined;
136
141
  if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
@@ -146,6 +151,8 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
146
151
  props.onBlur && props.onBlur(event);
147
152
  } : undefined,
148
153
  onChange: function onChange(value, info) {
154
+ var _props$onChange;
155
+
149
156
  // wrapping breaking changes made in react-select v3
150
157
  var newValue = value;
151
158
 
@@ -153,8 +160,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
153
160
  newValue = [];
154
161
  }
155
162
 
156
- props.onChange({
163
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
157
164
  target: {
165
+ id: props.id,
158
166
  name: props.name,
159
167
  value: newValue
160
168
  },
@@ -198,7 +206,7 @@ AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
198
206
  isAutofocussed: _pt__default["default"].bool,
199
207
  menuPortalZIndex: _pt__default["default"].number.isRequired,
200
208
  onBlur: _pt__default["default"].func,
201
- onChange: _pt__default["default"].func.isRequired,
209
+ onChange: _pt__default["default"].func,
202
210
  showOptionGroupDivider: _pt__default["default"].bool
203
211
  } : {};
204
212
  AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
@@ -251,7 +259,7 @@ AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer
251
259
  var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
252
260
 
253
261
  // NOTE: This string will be replaced on build time with the package version.
254
- var version = "14.0.1";
262
+ var version = "15.0.0";
255
263
 
256
264
  exports["default"] = AsyncCreatableSelectInput$1;
257
265
  exports.version = version;
@@ -69,6 +69,8 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
69
69
  var theme = react.useTheme();
70
70
  var placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
71
71
 
72
+ if (!props.isReadOnly) ;
73
+
72
74
  if (props.isMulti) ;
73
75
 
74
76
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
@@ -127,6 +129,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
127
129
  onBlur: props.onBlur ? function () {
128
130
  var event = {
129
131
  target: {
132
+ id: props.id,
130
133
  name: function () {
131
134
  if (!props.name) return undefined;
132
135
  if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
@@ -142,6 +145,8 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
142
145
  props.onBlur && props.onBlur(event);
143
146
  } : undefined,
144
147
  onChange: function onChange(value, info) {
148
+ var _props$onChange;
149
+
145
150
  // wrapping breaking changes made in react-select v3
146
151
  var newValue = value;
147
152
 
@@ -149,8 +154,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
149
154
  newValue = [];
150
155
  }
151
156
 
152
- props.onChange({
157
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
153
158
  target: {
159
+ id: props.id,
154
160
  name: props.name,
155
161
  value: newValue
156
162
  },
@@ -236,7 +242,7 @@ AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer
236
242
  var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
237
243
 
238
244
  // NOTE: This string will be replaced on build time with the package version.
239
- var version = "14.0.1";
245
+ var version = "15.0.0";
240
246
 
241
247
  exports["default"] = AsyncCreatableSelectInput$1;
242
248
  exports.version = version;
@@ -50,6 +50,10 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
50
50
  var theme = useTheme();
51
51
  var placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
52
52
 
53
+ if (!props.isReadOnly) {
54
+ process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'AsyncCreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
55
+ }
56
+
53
57
  if (props.isMulti) {
54
58
  process.env.NODE_ENV !== "production" ? warning(_Array$isArray(props.value), 'AsyncCreatableSelectInput: `value` is expected to be an array when isMulti is true') : void 0;
55
59
  }
@@ -110,6 +114,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
110
114
  onBlur: props.onBlur ? function () {
111
115
  var event = {
112
116
  target: {
117
+ id: props.id,
113
118
  name: function () {
114
119
  if (!props.name) return undefined;
115
120
  if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
@@ -125,6 +130,8 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
125
130
  props.onBlur && props.onBlur(event);
126
131
  } : undefined,
127
132
  onChange: function onChange(value, info) {
133
+ var _props$onChange;
134
+
128
135
  // wrapping breaking changes made in react-select v3
129
136
  var newValue = value;
130
137
 
@@ -132,8 +139,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
132
139
  newValue = [];
133
140
  }
134
141
 
135
- props.onChange({
142
+ (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
136
143
  target: {
144
+ id: props.id,
137
145
  name: props.name,
138
146
  value: newValue
139
147
  },
@@ -177,7 +185,7 @@ AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
177
185
  isAutofocussed: _pt.bool,
178
186
  menuPortalZIndex: _pt.number.isRequired,
179
187
  onBlur: _pt.func,
180
- onChange: _pt.func.isRequired,
188
+ onChange: _pt.func,
181
189
  showOptionGroupDivider: _pt.bool
182
190
  } : {};
183
191
  AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
@@ -230,6 +238,6 @@ AsyncCreatableSelectInput.ValueContainer = components.ValueContainer;
230
238
  var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
231
239
 
232
240
  // NOTE: This string will be replaced on build time with the package version.
233
- var version = "14.0.1";
241
+ var version = "15.0.0";
234
242
 
235
243
  export { AsyncCreatableSelectInput$1 as default, version };
@@ -1,8 +1,9 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import { type ActionMeta, type GroupBase } from 'react-select';
3
3
  import { type AsyncCreatableProps } from 'react-select/async-creatable';
4
- declare type TEvent = {
4
+ declare type TCustomEvent = {
5
5
  target: {
6
+ id?: string;
6
7
  name?: string;
7
8
  value?: unknown;
8
9
  };
@@ -38,8 +39,8 @@ declare type TAsyncCreatableSelectInputProps = {
38
39
  closeMenuOnSelect?: ReactSelectAsyncCreatableProps['closeMenuOnSelect'];
39
40
  name?: ReactSelectAsyncCreatableProps['name'];
40
41
  noOptionsMessage?: ReactSelectAsyncCreatableProps['noOptionsMessage'];
41
- onBlur?: (event: TEvent) => void;
42
- onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
42
+ onBlur?: (event: TCustomEvent) => void;
43
+ onChange?: (event: TCustomEvent, info: ActionMeta<unknown>) => void;
43
44
  onFocus?: ReactSelectAsyncCreatableProps['onFocus'];
44
45
  onInputChange?: ReactSelectAsyncCreatableProps['onInputChange'];
45
46
  placeholder?: ReactSelectAsyncCreatableProps['placeholder'];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/async-creatable-select-input",
3
3
  "description": "An input component 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": "15.0.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,20 +21,20 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.17.2",
23
23
  "@babel/runtime-corejs3": "^7.17.2",
24
- "@commercetools-uikit/constraints": "14.0.1",
25
- "@commercetools-uikit/design-system": "14.0.0",
26
- "@commercetools-uikit/icons": "14.0.1",
27
- "@commercetools-uikit/loading-spinner": "14.0.1",
28
- "@commercetools-uikit/select-utils": "14.0.1",
29
- "@commercetools-uikit/spacings": "14.0.1",
30
- "@commercetools-uikit/text": "14.0.1",
31
- "@commercetools-uikit/utils": "14.0.1",
24
+ "@commercetools-uikit/constraints": "15.0.0",
25
+ "@commercetools-uikit/design-system": "15.0.0",
26
+ "@commercetools-uikit/icons": "15.0.0",
27
+ "@commercetools-uikit/loading-spinner": "15.0.0",
28
+ "@commercetools-uikit/select-utils": "15.0.0",
29
+ "@commercetools-uikit/spacings": "15.0.0",
30
+ "@commercetools-uikit/text": "15.0.0",
31
+ "@commercetools-uikit/utils": "15.0.0",
32
32
  "@emotion/is-prop-valid": "1.1.2",
33
33
  "@emotion/react": "^11.4.0",
34
34
  "@emotion/styled": "^11.3.0",
35
35
  "lodash": "4.17.21",
36
36
  "prop-types": "15.8.1",
37
- "react-select": "5.2.2"
37
+ "react-select": "5.3.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "react": "17.0.2",