@commercetools-uikit/async-creatable-select-input 13.0.4 → 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 +11 -12
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.dev.js +54 -13
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.prod.js +51 -12
- package/dist/commercetools-uikit-async-creatable-select-input.esm.js +56 -15
- package/dist/declarations/src/async-creatable-select-input.d.ts +60 -4
- package/package.json +12 -12
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)
<br>
[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.
<br>
[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) |
|
|
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
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
94
94
|
| `onInputChange` | `AsyncCreatableProps['onInputChange']` | | | Handle change events on the input
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
95
95
|
| `placeholder` | `AsyncCreatableProps['placeholder']` | | | Placeholder text for the select value
<br>
[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:
|
|
115
|
+
(event: TCustomEvent) => void
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
### Signature `onChange`
|
|
119
119
|
|
|
120
120
|
```ts
|
|
121
|
-
(event:
|
|
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.
|
|
@@ -130,36 +130,35 @@ In case you need one of the currently excluded props, feel free to open a PR add
|
|
|
130
130
|
|
|
131
131
|
#### `isTouched(touched)`
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
Returns `true` when truthy.
|
|
133
|
+
Returns truthy value for the Formik `touched` value of this input field.
|
|
135
134
|
|
|
136
|
-
|
|
135
|
+
## Components
|
|
137
136
|
|
|
138
|
-
It is possible to customize `
|
|
139
|
-
`
|
|
137
|
+
It is possible to customize `AsyncCreatableSelectInput` by passing the `components` property.
|
|
138
|
+
`AsyncCreatableSelectInput` exports the default underlying components as static exports.
|
|
140
139
|
|
|
141
140
|
Components available as static exports are:
|
|
142
141
|
|
|
143
142
|
- `ClearIndicator`
|
|
144
143
|
- `Control`
|
|
145
|
-
- `DropdownIndicator`
|
|
146
|
-
- `DownChevron`
|
|
147
144
|
- `CrossIcon`
|
|
145
|
+
- `DownChevron`
|
|
146
|
+
- `DropdownIndicator`
|
|
148
147
|
- `Group`
|
|
149
148
|
- `GroupHeading`
|
|
150
149
|
- `IndicatorsContainer`
|
|
151
150
|
- `IndicatorSeparator`
|
|
152
151
|
- `Input`
|
|
153
152
|
- `LoadingIndicator`
|
|
153
|
+
- `LoadingMessage`
|
|
154
154
|
- `Menu`
|
|
155
155
|
- `MenuList`
|
|
156
156
|
- `MenuPortal`
|
|
157
|
-
- `LoadingMessage`
|
|
158
|
-
- `NoOptionsMessage`
|
|
159
157
|
- `MultiValue`
|
|
160
158
|
- `MultiValueContainer`
|
|
161
159
|
- `MultiValueLabel`
|
|
162
160
|
- `MultiValueRemove`
|
|
161
|
+
- `NoOptionsMessage`
|
|
163
162
|
- `Option`
|
|
164
163
|
- `Placeholder`
|
|
165
164
|
- `SelectContainer`
|
|
@@ -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
|
},
|
|
@@ -187,11 +195,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
187
195
|
})
|
|
188
196
|
}))
|
|
189
197
|
});
|
|
190
|
-
};
|
|
191
|
-
// deal with an array. The touched state ends up being an empty array in case
|
|
192
|
-
// values were removed only. So we have to treat any array we receive as
|
|
193
|
-
// a signal of the field having been touched.
|
|
194
|
-
|
|
198
|
+
};
|
|
195
199
|
|
|
196
200
|
AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
197
201
|
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
@@ -202,23 +206,60 @@ AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
202
206
|
isAutofocussed: _pt__default["default"].bool,
|
|
203
207
|
menuPortalZIndex: _pt__default["default"].number.isRequired,
|
|
204
208
|
onBlur: _pt__default["default"].func,
|
|
205
|
-
onChange: _pt__default["default"].func
|
|
209
|
+
onChange: _pt__default["default"].func,
|
|
206
210
|
showOptionGroupDivider: _pt__default["default"].bool
|
|
207
211
|
} : {};
|
|
212
|
+
AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
|
|
213
|
+
AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
214
|
+
/**
|
|
215
|
+
* Expose static helper methods.
|
|
216
|
+
*/
|
|
217
|
+
// Formik will set the field to an array on submission, so we always have to
|
|
218
|
+
// deal with an array. The touched state ends up being an empty array in case
|
|
219
|
+
// values were removed only. So we have to treat any array we receive as
|
|
220
|
+
// a signal of the field having been touched.
|
|
208
221
|
|
|
209
222
|
AsyncCreatableSelectInput.isTouched = function (touched) {
|
|
210
223
|
return Boolean(touched);
|
|
211
224
|
};
|
|
225
|
+
/**
|
|
226
|
+
* Expose react-select components for customization purposes.
|
|
227
|
+
*/
|
|
228
|
+
// custom
|
|
212
229
|
|
|
213
|
-
|
|
214
|
-
AsyncCreatableSelectInput.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
230
|
+
|
|
231
|
+
AsyncCreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
232
|
+
AsyncCreatableSelectInput.Control = reactSelect.components.Control;
|
|
233
|
+
AsyncCreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
234
|
+
AsyncCreatableSelectInput.DownChevron = reactSelect.components.DownChevron; // custom
|
|
235
|
+
|
|
236
|
+
AsyncCreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
237
|
+
AsyncCreatableSelectInput.Group = reactSelect.components.Group;
|
|
238
|
+
AsyncCreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
239
|
+
AsyncCreatableSelectInput.IndicatorSeparator = reactSelect.components.IndicatorSeparator;
|
|
240
|
+
AsyncCreatableSelectInput.IndicatorsContainer = reactSelect.components.IndicatorsContainer;
|
|
241
|
+
AsyncCreatableSelectInput.Input = reactSelect.components.Input; // custom
|
|
242
|
+
|
|
243
|
+
AsyncCreatableSelectInput.LoadingIndicator = customizedComponents.LoadingIndicator;
|
|
244
|
+
AsyncCreatableSelectInput.LoadingMessage = reactSelect.components.LoadingMessage;
|
|
245
|
+
AsyncCreatableSelectInput.Menu = reactSelect.components.Menu;
|
|
246
|
+
AsyncCreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
247
|
+
AsyncCreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
248
|
+
AsyncCreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
249
|
+
AsyncCreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
250
|
+
AsyncCreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel; // custom
|
|
251
|
+
|
|
252
|
+
AsyncCreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
253
|
+
AsyncCreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
254
|
+
AsyncCreatableSelectInput.Option = reactSelect.components.Option;
|
|
255
|
+
AsyncCreatableSelectInput.Placeholder = reactSelect.components.Placeholder;
|
|
256
|
+
AsyncCreatableSelectInput.SelectContainer = reactSelect.components.SelectContainer;
|
|
257
|
+
AsyncCreatableSelectInput.SingleValue = reactSelect.components.SingleValue;
|
|
258
|
+
AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
218
259
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
219
260
|
|
|
220
261
|
// NOTE: This string will be replaced on build time with the package version.
|
|
221
|
-
var version = "
|
|
262
|
+
var version = "14.0.2";
|
|
222
263
|
|
|
223
264
|
exports["default"] = AsyncCreatableSelectInput$1;
|
|
224
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
|
},
|
|
@@ -183,27 +189,60 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
183
189
|
})
|
|
184
190
|
}))
|
|
185
191
|
});
|
|
186
|
-
};
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
AsyncCreatableSelectInput.propTypes = {};
|
|
195
|
+
AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
|
|
196
|
+
AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
197
|
+
/**
|
|
198
|
+
* Expose static helper methods.
|
|
199
|
+
*/
|
|
200
|
+
// Formik will set the field to an array on submission, so we always have to
|
|
187
201
|
// deal with an array. The touched state ends up being an empty array in case
|
|
188
202
|
// values were removed only. So we have to treat any array we receive as
|
|
189
203
|
// a signal of the field having been touched.
|
|
190
204
|
|
|
191
|
-
|
|
192
|
-
AsyncCreatableSelectInput.propTypes = {};
|
|
193
|
-
|
|
194
205
|
AsyncCreatableSelectInput.isTouched = function (touched) {
|
|
195
206
|
return Boolean(touched);
|
|
196
207
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
/**
|
|
209
|
+
* Expose react-select components for customization purposes.
|
|
210
|
+
*/
|
|
211
|
+
// custom
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
AsyncCreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
215
|
+
AsyncCreatableSelectInput.Control = reactSelect.components.Control;
|
|
216
|
+
AsyncCreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
217
|
+
AsyncCreatableSelectInput.DownChevron = reactSelect.components.DownChevron; // custom
|
|
218
|
+
|
|
219
|
+
AsyncCreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
220
|
+
AsyncCreatableSelectInput.Group = reactSelect.components.Group;
|
|
221
|
+
AsyncCreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
222
|
+
AsyncCreatableSelectInput.IndicatorSeparator = reactSelect.components.IndicatorSeparator;
|
|
223
|
+
AsyncCreatableSelectInput.IndicatorsContainer = reactSelect.components.IndicatorsContainer;
|
|
224
|
+
AsyncCreatableSelectInput.Input = reactSelect.components.Input; // custom
|
|
225
|
+
|
|
226
|
+
AsyncCreatableSelectInput.LoadingIndicator = customizedComponents.LoadingIndicator;
|
|
227
|
+
AsyncCreatableSelectInput.LoadingMessage = reactSelect.components.LoadingMessage;
|
|
228
|
+
AsyncCreatableSelectInput.Menu = reactSelect.components.Menu;
|
|
229
|
+
AsyncCreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
230
|
+
AsyncCreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
231
|
+
AsyncCreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
232
|
+
AsyncCreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
233
|
+
AsyncCreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel; // custom
|
|
234
|
+
|
|
235
|
+
AsyncCreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
236
|
+
AsyncCreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
237
|
+
AsyncCreatableSelectInput.Option = reactSelect.components.Option;
|
|
238
|
+
AsyncCreatableSelectInput.Placeholder = reactSelect.components.Placeholder;
|
|
239
|
+
AsyncCreatableSelectInput.SelectContainer = reactSelect.components.SelectContainer;
|
|
240
|
+
AsyncCreatableSelectInput.SingleValue = reactSelect.components.SingleValue;
|
|
241
|
+
AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
203
242
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
204
243
|
|
|
205
244
|
// NOTE: This string will be replaced on build time with the package version.
|
|
206
|
-
var version = "
|
|
245
|
+
var version = "14.0.2";
|
|
207
246
|
|
|
208
247
|
exports["default"] = AsyncCreatableSelectInput$1;
|
|
209
248
|
exports.version = version;
|
|
@@ -17,7 +17,7 @@ import AsyncCreatableSelect from 'react-select/async-creatable';
|
|
|
17
17
|
import Constraints from '@commercetools-uikit/constraints';
|
|
18
18
|
import LoadingSpinner from '@commercetools-uikit/loading-spinner';
|
|
19
19
|
import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
20
|
-
import { warning, filterDataAttributes
|
|
20
|
+
import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
21
21
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
22
22
|
|
|
23
23
|
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; }
|
|
@@ -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
|
},
|
|
@@ -166,11 +174,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
166
174
|
})
|
|
167
175
|
}))
|
|
168
176
|
});
|
|
169
|
-
};
|
|
170
|
-
// deal with an array. The touched state ends up being an empty array in case
|
|
171
|
-
// values were removed only. So we have to treat any array we receive as
|
|
172
|
-
// a signal of the field having been touched.
|
|
173
|
-
|
|
177
|
+
};
|
|
174
178
|
|
|
175
179
|
AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
176
180
|
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
@@ -181,22 +185,59 @@ AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
181
185
|
isAutofocussed: _pt.bool,
|
|
182
186
|
menuPortalZIndex: _pt.number.isRequired,
|
|
183
187
|
onBlur: _pt.func,
|
|
184
|
-
onChange: _pt.func
|
|
188
|
+
onChange: _pt.func,
|
|
185
189
|
showOptionGroupDivider: _pt.bool
|
|
186
190
|
} : {};
|
|
191
|
+
AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
|
|
192
|
+
AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
193
|
+
/**
|
|
194
|
+
* Expose static helper methods.
|
|
195
|
+
*/
|
|
196
|
+
// Formik will set the field to an array on submission, so we always have to
|
|
197
|
+
// deal with an array. The touched state ends up being an empty array in case
|
|
198
|
+
// values were removed only. So we have to treat any array we receive as
|
|
199
|
+
// a signal of the field having been touched.
|
|
187
200
|
|
|
188
201
|
AsyncCreatableSelectInput.isTouched = function (touched) {
|
|
189
202
|
return Boolean(touched);
|
|
190
203
|
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Expose react-select components for customization purposes.
|
|
206
|
+
*/
|
|
207
|
+
// custom
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
AsyncCreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
211
|
+
AsyncCreatableSelectInput.Control = components.Control;
|
|
212
|
+
AsyncCreatableSelectInput.CrossIcon = components.CrossIcon;
|
|
213
|
+
AsyncCreatableSelectInput.DownChevron = components.DownChevron; // custom
|
|
214
|
+
|
|
215
|
+
AsyncCreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
216
|
+
AsyncCreatableSelectInput.Group = components.Group;
|
|
217
|
+
AsyncCreatableSelectInput.GroupHeading = components.GroupHeading;
|
|
218
|
+
AsyncCreatableSelectInput.IndicatorSeparator = components.IndicatorSeparator;
|
|
219
|
+
AsyncCreatableSelectInput.IndicatorsContainer = components.IndicatorsContainer;
|
|
220
|
+
AsyncCreatableSelectInput.Input = components.Input; // custom
|
|
221
|
+
|
|
222
|
+
AsyncCreatableSelectInput.LoadingIndicator = customizedComponents.LoadingIndicator;
|
|
223
|
+
AsyncCreatableSelectInput.LoadingMessage = components.LoadingMessage;
|
|
224
|
+
AsyncCreatableSelectInput.Menu = components.Menu;
|
|
225
|
+
AsyncCreatableSelectInput.MenuList = components.MenuList;
|
|
226
|
+
AsyncCreatableSelectInput.MenuPortal = components.MenuPortal;
|
|
227
|
+
AsyncCreatableSelectInput.MultiValue = components.MultiValue;
|
|
228
|
+
AsyncCreatableSelectInput.MultiValueContainer = components.MultiValueContainer;
|
|
229
|
+
AsyncCreatableSelectInput.MultiValueLabel = components.MultiValueLabel; // custom
|
|
230
|
+
|
|
231
|
+
AsyncCreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
232
|
+
AsyncCreatableSelectInput.NoOptionsMessage = components.NoOptionsMessage;
|
|
233
|
+
AsyncCreatableSelectInput.Option = components.Option;
|
|
234
|
+
AsyncCreatableSelectInput.Placeholder = components.Placeholder;
|
|
235
|
+
AsyncCreatableSelectInput.SelectContainer = components.SelectContainer;
|
|
236
|
+
AsyncCreatableSelectInput.SingleValue = components.SingleValue;
|
|
237
|
+
AsyncCreatableSelectInput.ValueContainer = components.ValueContainer;
|
|
197
238
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
198
239
|
|
|
199
240
|
// NOTE: This string will be replaced on build time with the package version.
|
|
200
|
-
var version = "
|
|
241
|
+
var version = "14.0.2";
|
|
201
242
|
|
|
202
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
|
|
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:
|
|
42
|
-
onChange
|
|
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'];
|
|
@@ -59,8 +60,63 @@ declare type TAsyncCreatableSelectInputProps = {
|
|
|
59
60
|
};
|
|
60
61
|
declare const AsyncCreatableSelectInput: {
|
|
61
62
|
(props: TAsyncCreatableSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
62
|
-
isTouched(touched: unknown): boolean;
|
|
63
63
|
displayName: string;
|
|
64
64
|
defaultProps: Pick<TAsyncCreatableSelectInputProps, "value" | "isSearchable" | "menuPortalZIndex">;
|
|
65
|
+
isTouched(touched: unknown): boolean;
|
|
66
|
+
ClearIndicator: {
|
|
67
|
+
(props: {
|
|
68
|
+
innerProps: {
|
|
69
|
+
ref: import("react").LegacyRef<HTMLButtonElement>;
|
|
70
|
+
} & import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>;
|
|
71
|
+
} & import("react-select").ClearIndicatorProps<unknown, boolean, GroupBase<unknown>>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
72
|
+
displayName: string;
|
|
73
|
+
};
|
|
74
|
+
Control: <Option_1, IsMulti_1 extends boolean, Group_1 extends GroupBase<Option_1>>(props: import("react-select").ControlProps<Option_1, IsMulti_1, Group_1>) => import("@emotion/react").jsx.JSX.Element;
|
|
75
|
+
CrossIcon: (props: import("react-select/dist/declarations/src/components/indicators").CrossIconProps) => import("@emotion/react").jsx.JSX.Element;
|
|
76
|
+
DownChevron: (props: import("react-select/dist/declarations/src/components/indicators").DownChevronProps) => import("@emotion/react").jsx.JSX.Element;
|
|
77
|
+
DropdownIndicator: {
|
|
78
|
+
(props: import("react-select").DropdownIndicatorProps<unknown, boolean, GroupBase<unknown>>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
79
|
+
displayName: string;
|
|
80
|
+
};
|
|
81
|
+
Group: <Option_3, IsMulti_3 extends boolean, Group_3 extends GroupBase<Option_3>>(props: import("react-select").GroupProps<Option_3, IsMulti_3, Group_3>) => import("@emotion/react").jsx.JSX.Element;
|
|
82
|
+
GroupHeading: <Option_4, IsMulti_4 extends boolean, Group_4 extends GroupBase<Option_4>>(props: import("react-select").GroupHeadingProps<Option_4, IsMulti_4, Group_4>) => import("@emotion/react").jsx.JSX.Element;
|
|
83
|
+
IndicatorSeparator: <Option_6, IsMulti_6 extends boolean, Group_6 extends GroupBase<Option_6>>(props: import("react-select").IndicatorSeparatorProps<Option_6, IsMulti_6, Group_6>) => import("@emotion/react").jsx.JSX.Element;
|
|
84
|
+
IndicatorsContainer: <Option_5, IsMulti_5 extends boolean, Group_5 extends GroupBase<Option_5>>(props: import("react-select").IndicatorsContainerProps<Option_5, IsMulti_5, Group_5>) => import("@emotion/react").jsx.JSX.Element;
|
|
85
|
+
Input: <Option_7, IsMulti_7 extends boolean, Group_7 extends GroupBase<Option_7>>(props: import("react-select").InputProps<Option_7, IsMulti_7, Group_7>) => import("@emotion/react").jsx.JSX.Element;
|
|
86
|
+
LoadingIndicator: {
|
|
87
|
+
(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
88
|
+
displayName: string;
|
|
89
|
+
};
|
|
90
|
+
LoadingMessage: {
|
|
91
|
+
<Option_11, IsMulti_11 extends boolean, Group_11 extends GroupBase<Option_11>>(props: import("react-select").NoticeProps<Option_11, IsMulti_11, Group_11>): import("@emotion/react").jsx.JSX.Element;
|
|
92
|
+
defaultProps: {
|
|
93
|
+
children: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
Menu: <Option_9, IsMulti_9 extends boolean, Group_9 extends GroupBase<Option_9>>(props: import("react-select").MenuProps<Option_9, IsMulti_9, Group_9>) => import("@emotion/react").jsx.JSX.Element;
|
|
97
|
+
MenuList: <Option_10, IsMulti_10 extends boolean, Group_10 extends GroupBase<Option_10>>(props: import("react-select").MenuListProps<Option_10, IsMulti_10, Group_10>) => import("@emotion/react").jsx.JSX.Element;
|
|
98
|
+
MenuPortal: typeof import("react-select/dist/declarations/src/components/Menu").MenuPortal;
|
|
99
|
+
MultiValue: <Option_13, IsMulti_13 extends boolean, Group_13 extends GroupBase<Option_13>>(props: import("react-select").MultiValueProps<Option_13, IsMulti_13, Group_13>) => import("@emotion/react").jsx.JSX.Element;
|
|
100
|
+
MultiValueContainer: <Option_14, IsMulti_14 extends boolean, Group_14 extends GroupBase<Option_14>>({ children, innerProps, }: import("react-select").MultiValueGenericProps<Option_14, IsMulti_14, Group_14>) => import("@emotion/react").jsx.JSX.Element;
|
|
101
|
+
MultiValueLabel: <Option_14_1, IsMulti_14_1 extends boolean, Group_14_1 extends GroupBase<Option_14_1>>({ children, innerProps, }: import("react-select").MultiValueGenericProps<Option_14_1, IsMulti_14_1, Group_14_1>) => import("@emotion/react").jsx.JSX.Element;
|
|
102
|
+
MultiValueRemove: {
|
|
103
|
+
(props: {
|
|
104
|
+
selectProps: {
|
|
105
|
+
isReadOnly: boolean;
|
|
106
|
+
} & import("react-select/dist/declarations/src/Select").Props<unknown, boolean, GroupBase<unknown>>;
|
|
107
|
+
} & import("react-select").MultiValueGenericProps<unknown, boolean, GroupBase<unknown>>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
108
|
+
displayName: string;
|
|
109
|
+
};
|
|
110
|
+
NoOptionsMessage: {
|
|
111
|
+
<Option_12, IsMulti_12 extends boolean, Group_12 extends GroupBase<Option_12>>(props: import("react-select").NoticeProps<Option_12, IsMulti_12, Group_12>): import("@emotion/react").jsx.JSX.Element;
|
|
112
|
+
defaultProps: {
|
|
113
|
+
children: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
Option: <Option_15, IsMulti_15 extends boolean, Group_15 extends GroupBase<Option_15>>(props: import("react-select").OptionProps<Option_15, IsMulti_15, Group_15>) => import("@emotion/react").jsx.JSX.Element;
|
|
117
|
+
Placeholder: <Option_16, IsMulti_16 extends boolean, Group_16 extends GroupBase<Option_16>>(props: import("react-select").PlaceholderProps<Option_16, IsMulti_16, Group_16>) => import("@emotion/react").jsx.JSX.Element;
|
|
118
|
+
SelectContainer: <Option_17, IsMulti_17 extends boolean, Group_17 extends GroupBase<Option_17>>(props: import("react-select").ContainerProps<Option_17, IsMulti_17, Group_17>) => import("@emotion/react").jsx.JSX.Element;
|
|
119
|
+
SingleValue: <Option_18, IsMulti_18 extends boolean, Group_18 extends GroupBase<Option_18>>(props: import("react-select").SingleValueProps<Option_18, IsMulti_18, Group_18>) => import("@emotion/react").jsx.JSX.Element;
|
|
120
|
+
ValueContainer: <Option_19, IsMulti_19 extends boolean, Group_19 extends GroupBase<Option_19>>(props: import("react-select").ValueContainerProps<Option_19, IsMulti_19, Group_19>) => import("@emotion/react").jsx.JSX.Element;
|
|
65
121
|
};
|
|
66
122
|
export default AsyncCreatableSelectInput;
|
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": "
|
|
4
|
+
"version": "14.0.2",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"directory": "packages/components/inputs/async-creatable-select-input"
|
|
10
10
|
},
|
|
11
11
|
"homepage": "https://uikit.commercetools.com",
|
|
12
|
-
"keywords": ["javascript", "design
|
|
12
|
+
"keywords": ["javascript", "typescript", "design-system", "react", "uikit"],
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"module": "dist/commercetools-uikit-async-creatable-select-input.esm.js",
|
|
20
20
|
"files": ["dist"],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/runtime": "7.17.2",
|
|
23
|
-
"@babel/runtime-corejs3": "7.17.2",
|
|
24
|
-
"@commercetools-uikit/constraints": "
|
|
25
|
-
"@commercetools-uikit/design-system": "
|
|
26
|
-
"@commercetools-uikit/icons": "
|
|
27
|
-
"@commercetools-uikit/loading-spinner": "
|
|
28
|
-
"@commercetools-uikit/select-utils": "
|
|
29
|
-
"@commercetools-uikit/spacings": "
|
|
30
|
-
"@commercetools-uikit/text": "
|
|
31
|
-
"@commercetools-uikit/utils": "
|
|
22
|
+
"@babel/runtime": "^7.17.2",
|
|
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",
|
|
32
32
|
"@emotion/is-prop-valid": "1.1.2",
|
|
33
33
|
"@emotion/react": "^11.4.0",
|
|
34
34
|
"@emotion/styled": "^11.3.0",
|