@commercetools-uikit/async-select-input 15.14.3 → 15.15.1
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 +1 -1
- package/dist/commercetools-uikit-async-select-input.cjs.d.ts +1 -0
- package/dist/commercetools-uikit-async-select-input.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-async-select-input.cjs.dev.js +35 -36
- package/dist/commercetools-uikit-async-select-input.cjs.prod.js +35 -36
- package/dist/commercetools-uikit-async-select-input.esm.js +38 -39
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ export default Example;
|
|
|
82
82
|
| `isSearchable` | `AsyncProps['isSearchable']` | | `true` | Whether to enable search functionality
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
83
83
|
| `maxMenuHeight` | `AsyncProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
84
84
|
| `menuPortalTarget` | `AsyncProps['menuPortalTarget']` | | | Dom element to portal the select menu to
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
85
|
-
| `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal
|
|
85
|
+
| `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal
<br>
Use in conjunction with `menuPortalTarget` |
|
|
86
86
|
| `menuShouldBlockScroll` | `AsyncProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
87
87
|
| `closeMenuOnSelect` | `AsyncProps['closeMenuOnSelect']` | | | Whether the menu should close after a value is selected. Defaults to `true`.
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
88
88
|
| `name` | `AsyncProps['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) |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commercetools-uikit-async-select-input.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|
|
@@ -43,20 +43,18 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
|
|
|
43
43
|
|
|
44
44
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
};
|
|
46
|
+
const LoadingIndicator = () => jsxRuntime.jsx(LoadingSpinner__default["default"], {
|
|
47
|
+
scale: "s"
|
|
48
|
+
});
|
|
51
49
|
|
|
52
50
|
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
53
|
-
|
|
51
|
+
const customizedComponents = {
|
|
54
52
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
55
53
|
ClearIndicator: selectUtils.ClearIndicator,
|
|
56
|
-
LoadingIndicator
|
|
54
|
+
LoadingIndicator,
|
|
57
55
|
MultiValueRemove: selectUtils.TagRemove
|
|
58
56
|
};
|
|
59
|
-
|
|
57
|
+
const defaultProps = {
|
|
60
58
|
// Using "null" will ensure that the currently selected value disappears in
|
|
61
59
|
// case "undefined" gets passed as the next value
|
|
62
60
|
value: null,
|
|
@@ -64,19 +62,24 @@ var defaultProps = {
|
|
|
64
62
|
menuPortalZIndex: 1
|
|
65
63
|
};
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const AsyncSelectInput = props => {
|
|
66
|
+
const intl = reactIntl.useIntl();
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const _useTheme = designSystem.useTheme(),
|
|
69
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
72
70
|
|
|
73
71
|
if (!props.isReadOnly) {
|
|
74
72
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'AsyncSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
|
|
75
|
+
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
76
|
+
menuPortalZIndex: props.menuPortalZIndex,
|
|
77
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
78
|
+
componentName: 'AsyncSelectInput'
|
|
79
|
+
});
|
|
80
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
78
81
|
|
|
79
|
-
|
|
82
|
+
const loadingMessage = () => {
|
|
80
83
|
if (typeof props.loadingMessage === 'function') {
|
|
81
84
|
return props.loadingMessage();
|
|
82
85
|
}
|
|
@@ -95,11 +98,9 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
95
98
|
autoFocus: props.isAutofocussed,
|
|
96
99
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
97
100
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
98
|
-
Input:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}));
|
|
102
|
-
}
|
|
101
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
102
|
+
readOnly: true
|
|
103
|
+
}))
|
|
103
104
|
} : {}), props.components),
|
|
104
105
|
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
105
106
|
styles: selectUtils.createSelectStyles({
|
|
@@ -112,7 +113,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
112
113
|
iconLeft: props.iconLeft,
|
|
113
114
|
isMulti: props.isMulti,
|
|
114
115
|
hasValue: !isEmpty__default["default"](props.value),
|
|
115
|
-
isNewTheme
|
|
116
|
+
isNewTheme
|
|
116
117
|
}),
|
|
117
118
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
118
119
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -133,17 +134,17 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
133
134
|
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
134
135
|
name: props.name,
|
|
135
136
|
loadingMessage: loadingMessage,
|
|
136
|
-
noOptionsMessage: props.noOptionsMessage ||
|
|
137
|
-
|
|
137
|
+
noOptionsMessage: props.noOptionsMessage || (_ref => {
|
|
138
|
+
let inputValue = _ref.inputValue;
|
|
138
139
|
return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
139
|
-
inputValue
|
|
140
|
+
inputValue
|
|
140
141
|
});
|
|
141
|
-
},
|
|
142
|
-
onBlur: props.onBlur ?
|
|
143
|
-
|
|
142
|
+
}),
|
|
143
|
+
onBlur: props.onBlur ? () => {
|
|
144
|
+
const event = {
|
|
144
145
|
target: {
|
|
145
146
|
id: props.id,
|
|
146
|
-
name:
|
|
147
|
+
name: (() => {
|
|
147
148
|
if (!props.name) return undefined;
|
|
148
149
|
if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
|
|
149
150
|
// state as an array instead of a boolean only.
|
|
@@ -151,16 +152,16 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
151
152
|
// Formik will create an array on submission anyways.
|
|
152
153
|
|
|
153
154
|
return "".concat(props.name, ".0");
|
|
154
|
-
}()
|
|
155
|
+
})()
|
|
155
156
|
},
|
|
156
|
-
persist:
|
|
157
|
+
persist: () => {}
|
|
157
158
|
};
|
|
158
159
|
props.onBlur && props.onBlur(event);
|
|
159
160
|
} : undefined,
|
|
160
|
-
onChange:
|
|
161
|
+
onChange: (value, info) => {
|
|
161
162
|
var _props$onChange;
|
|
162
163
|
|
|
163
|
-
|
|
164
|
+
let newValue = value;
|
|
164
165
|
|
|
165
166
|
if (props.isMulti && !newValue) {
|
|
166
167
|
newValue = [];
|
|
@@ -172,7 +173,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
172
173
|
name: props.name,
|
|
173
174
|
value: newValue
|
|
174
175
|
},
|
|
175
|
-
persist:
|
|
176
|
+
persist: () => {}
|
|
176
177
|
}, info);
|
|
177
178
|
},
|
|
178
179
|
onFocus: props.onFocus,
|
|
@@ -217,9 +218,7 @@ AsyncSelectInput.defaultProps = defaultProps;
|
|
|
217
218
|
// values were removed only. So we have to treat any array we receive as
|
|
218
219
|
// a signal of the field having been touched.
|
|
219
220
|
|
|
220
|
-
AsyncSelectInput.isTouched =
|
|
221
|
-
return Boolean(touched);
|
|
222
|
-
};
|
|
221
|
+
AsyncSelectInput.isTouched = touched => Boolean(touched);
|
|
223
222
|
/**
|
|
224
223
|
* Expose react-select components for customization purposes.
|
|
225
224
|
*/
|
|
@@ -257,7 +256,7 @@ AsyncSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
|
257
256
|
var AsyncSelectInput$1 = AsyncSelectInput;
|
|
258
257
|
|
|
259
258
|
// NOTE: This string will be replaced on build time with the package version.
|
|
260
|
-
var version = "15.
|
|
259
|
+
var version = "15.15.1";
|
|
261
260
|
|
|
262
261
|
exports["default"] = AsyncSelectInput$1;
|
|
263
262
|
exports.version = version;
|
|
@@ -42,20 +42,18 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
|
|
|
42
42
|
|
|
43
43
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
-
};
|
|
45
|
+
const LoadingIndicator = () => jsxRuntime.jsx(LoadingSpinner__default["default"], {
|
|
46
|
+
scale: "s"
|
|
47
|
+
});
|
|
50
48
|
|
|
51
49
|
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
52
|
-
|
|
50
|
+
const customizedComponents = {
|
|
53
51
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
54
52
|
ClearIndicator: selectUtils.ClearIndicator,
|
|
55
|
-
LoadingIndicator
|
|
53
|
+
LoadingIndicator,
|
|
56
54
|
MultiValueRemove: selectUtils.TagRemove
|
|
57
55
|
};
|
|
58
|
-
|
|
56
|
+
const defaultProps = {
|
|
59
57
|
// Using "null" will ensure that the currently selected value disappears in
|
|
60
58
|
// case "undefined" gets passed as the next value
|
|
61
59
|
value: null,
|
|
@@ -63,17 +61,22 @@ var defaultProps = {
|
|
|
63
61
|
menuPortalZIndex: 1
|
|
64
62
|
};
|
|
65
63
|
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const AsyncSelectInput = props => {
|
|
65
|
+
const intl = reactIntl.useIntl();
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const _useTheme = designSystem.useTheme(),
|
|
68
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
71
69
|
|
|
72
70
|
if (!props.isReadOnly) ;
|
|
73
71
|
|
|
74
|
-
|
|
72
|
+
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
73
|
+
menuPortalZIndex: props.menuPortalZIndex,
|
|
74
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
75
|
+
componentName: 'AsyncSelectInput'
|
|
76
|
+
});
|
|
77
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
const loadingMessage = () => {
|
|
77
80
|
if (typeof props.loadingMessage === 'function') {
|
|
78
81
|
return props.loadingMessage();
|
|
79
82
|
}
|
|
@@ -92,11 +95,9 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
92
95
|
autoFocus: props.isAutofocussed,
|
|
93
96
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
94
97
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
95
|
-
Input:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}));
|
|
99
|
-
}
|
|
98
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
99
|
+
readOnly: true
|
|
100
|
+
}))
|
|
100
101
|
} : {}), props.components),
|
|
101
102
|
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
102
103
|
styles: selectUtils.createSelectStyles({
|
|
@@ -109,7 +110,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
109
110
|
iconLeft: props.iconLeft,
|
|
110
111
|
isMulti: props.isMulti,
|
|
111
112
|
hasValue: !isEmpty__default["default"](props.value),
|
|
112
|
-
isNewTheme
|
|
113
|
+
isNewTheme
|
|
113
114
|
}),
|
|
114
115
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
115
116
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -130,17 +131,17 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
130
131
|
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
131
132
|
name: props.name,
|
|
132
133
|
loadingMessage: loadingMessage,
|
|
133
|
-
noOptionsMessage: props.noOptionsMessage ||
|
|
134
|
-
|
|
134
|
+
noOptionsMessage: props.noOptionsMessage || (_ref => {
|
|
135
|
+
let inputValue = _ref.inputValue;
|
|
135
136
|
return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
136
|
-
inputValue
|
|
137
|
+
inputValue
|
|
137
138
|
});
|
|
138
|
-
},
|
|
139
|
-
onBlur: props.onBlur ?
|
|
140
|
-
|
|
139
|
+
}),
|
|
140
|
+
onBlur: props.onBlur ? () => {
|
|
141
|
+
const event = {
|
|
141
142
|
target: {
|
|
142
143
|
id: props.id,
|
|
143
|
-
name:
|
|
144
|
+
name: (() => {
|
|
144
145
|
if (!props.name) return undefined;
|
|
145
146
|
if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
|
|
146
147
|
// state as an array instead of a boolean only.
|
|
@@ -148,16 +149,16 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
148
149
|
// Formik will create an array on submission anyways.
|
|
149
150
|
|
|
150
151
|
return "".concat(props.name, ".0");
|
|
151
|
-
}()
|
|
152
|
+
})()
|
|
152
153
|
},
|
|
153
|
-
persist:
|
|
154
|
+
persist: () => {}
|
|
154
155
|
};
|
|
155
156
|
props.onBlur && props.onBlur(event);
|
|
156
157
|
} : undefined,
|
|
157
|
-
onChange:
|
|
158
|
+
onChange: (value, info) => {
|
|
158
159
|
var _props$onChange;
|
|
159
160
|
|
|
160
|
-
|
|
161
|
+
let newValue = value;
|
|
161
162
|
|
|
162
163
|
if (props.isMulti && !newValue) {
|
|
163
164
|
newValue = [];
|
|
@@ -169,7 +170,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
169
170
|
name: props.name,
|
|
170
171
|
value: newValue
|
|
171
172
|
},
|
|
172
|
-
persist:
|
|
173
|
+
persist: () => {}
|
|
173
174
|
}, info);
|
|
174
175
|
},
|
|
175
176
|
onFocus: props.onFocus,
|
|
@@ -201,9 +202,7 @@ AsyncSelectInput.defaultProps = defaultProps;
|
|
|
201
202
|
// values were removed only. So we have to treat any array we receive as
|
|
202
203
|
// a signal of the field having been touched.
|
|
203
204
|
|
|
204
|
-
AsyncSelectInput.isTouched =
|
|
205
|
-
return Boolean(touched);
|
|
206
|
-
};
|
|
205
|
+
AsyncSelectInput.isTouched = touched => Boolean(touched);
|
|
207
206
|
/**
|
|
208
207
|
* Expose react-select components for customization purposes.
|
|
209
208
|
*/
|
|
@@ -241,7 +240,7 @@ AsyncSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
|
241
240
|
var AsyncSelectInput$1 = AsyncSelectInput;
|
|
242
241
|
|
|
243
242
|
// NOTE: This string will be replaced on build time with the package version.
|
|
244
|
-
var version = "15.
|
|
243
|
+
var version = "15.15.1";
|
|
245
244
|
|
|
246
245
|
exports["default"] = AsyncSelectInput$1;
|
|
247
246
|
exports.version = version;
|
|
@@ -15,7 +15,7 @@ import AsyncSelect from 'react-select/async';
|
|
|
15
15
|
import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
16
16
|
import Constraints from '@commercetools-uikit/constraints';
|
|
17
17
|
import LoadingSpinner from '@commercetools-uikit/loading-spinner';
|
|
18
|
-
import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
18
|
+
import { warnIfMenuPortalPropsAreMissing, messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
19
19
|
import { useTheme } from '@commercetools-uikit/design-system';
|
|
20
20
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
21
21
|
|
|
@@ -23,20 +23,18 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
|
23
23
|
|
|
24
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
};
|
|
26
|
+
const LoadingIndicator = () => jsx(LoadingSpinner, {
|
|
27
|
+
scale: "s"
|
|
28
|
+
});
|
|
31
29
|
|
|
32
30
|
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
33
|
-
|
|
34
|
-
DropdownIndicator
|
|
35
|
-
ClearIndicator
|
|
36
|
-
LoadingIndicator
|
|
31
|
+
const customizedComponents = {
|
|
32
|
+
DropdownIndicator,
|
|
33
|
+
ClearIndicator,
|
|
34
|
+
LoadingIndicator,
|
|
37
35
|
MultiValueRemove: TagRemove
|
|
38
36
|
};
|
|
39
|
-
|
|
37
|
+
const defaultProps = {
|
|
40
38
|
// Using "null" will ensure that the currently selected value disappears in
|
|
41
39
|
// case "undefined" gets passed as the next value
|
|
42
40
|
value: null,
|
|
@@ -44,19 +42,24 @@ var defaultProps = {
|
|
|
44
42
|
menuPortalZIndex: 1
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const AsyncSelectInput = props => {
|
|
46
|
+
const intl = useIntl();
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const _useTheme = useTheme(),
|
|
49
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
52
50
|
|
|
53
51
|
if (!props.isReadOnly) {
|
|
54
52
|
process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'AsyncSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
|
|
55
|
+
warnIfMenuPortalPropsAreMissing({
|
|
56
|
+
menuPortalZIndex: props.menuPortalZIndex,
|
|
57
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
58
|
+
componentName: 'AsyncSelectInput'
|
|
59
|
+
});
|
|
60
|
+
const placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
const loadingMessage = () => {
|
|
60
63
|
if (typeof props.loadingMessage === 'function') {
|
|
61
64
|
return props.loadingMessage();
|
|
62
65
|
}
|
|
@@ -75,11 +78,9 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
75
78
|
autoFocus: props.isAutofocussed,
|
|
76
79
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
77
80
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
78
|
-
Input:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
81
|
+
Input: ownProps => jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
82
|
+
readOnly: true
|
|
83
|
+
}))
|
|
83
84
|
} : {}), props.components),
|
|
84
85
|
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
85
86
|
styles: createSelectStyles({
|
|
@@ -92,7 +93,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
92
93
|
iconLeft: props.iconLeft,
|
|
93
94
|
isMulti: props.isMulti,
|
|
94
95
|
hasValue: !isEmpty(props.value),
|
|
95
|
-
isNewTheme
|
|
96
|
+
isNewTheme
|
|
96
97
|
}),
|
|
97
98
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
98
99
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -113,17 +114,17 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
113
114
|
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
114
115
|
name: props.name,
|
|
115
116
|
loadingMessage: loadingMessage,
|
|
116
|
-
noOptionsMessage: props.noOptionsMessage ||
|
|
117
|
-
|
|
117
|
+
noOptionsMessage: props.noOptionsMessage || (_ref => {
|
|
118
|
+
let inputValue = _ref.inputValue;
|
|
118
119
|
return inputValue === '' ? intl.formatMessage(messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(messages.noOptionsMessageWithInputValue, {
|
|
119
|
-
inputValue
|
|
120
|
+
inputValue
|
|
120
121
|
});
|
|
121
|
-
},
|
|
122
|
-
onBlur: props.onBlur ?
|
|
123
|
-
|
|
122
|
+
}),
|
|
123
|
+
onBlur: props.onBlur ? () => {
|
|
124
|
+
const event = {
|
|
124
125
|
target: {
|
|
125
126
|
id: props.id,
|
|
126
|
-
name:
|
|
127
|
+
name: (() => {
|
|
127
128
|
if (!props.name) return undefined;
|
|
128
129
|
if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
|
|
129
130
|
// state as an array instead of a boolean only.
|
|
@@ -131,16 +132,16 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
131
132
|
// Formik will create an array on submission anyways.
|
|
132
133
|
|
|
133
134
|
return "".concat(props.name, ".0");
|
|
134
|
-
}()
|
|
135
|
+
})()
|
|
135
136
|
},
|
|
136
|
-
persist:
|
|
137
|
+
persist: () => {}
|
|
137
138
|
};
|
|
138
139
|
props.onBlur && props.onBlur(event);
|
|
139
140
|
} : undefined,
|
|
140
|
-
onChange:
|
|
141
|
+
onChange: (value, info) => {
|
|
141
142
|
var _props$onChange;
|
|
142
143
|
|
|
143
|
-
|
|
144
|
+
let newValue = value;
|
|
144
145
|
|
|
145
146
|
if (props.isMulti && !newValue) {
|
|
146
147
|
newValue = [];
|
|
@@ -152,7 +153,7 @@ var AsyncSelectInput = function AsyncSelectInput(props) {
|
|
|
152
153
|
name: props.name,
|
|
153
154
|
value: newValue
|
|
154
155
|
},
|
|
155
|
-
persist:
|
|
156
|
+
persist: () => {}
|
|
156
157
|
}, info);
|
|
157
158
|
},
|
|
158
159
|
onFocus: props.onFocus,
|
|
@@ -197,9 +198,7 @@ AsyncSelectInput.defaultProps = defaultProps;
|
|
|
197
198
|
// values were removed only. So we have to treat any array we receive as
|
|
198
199
|
// a signal of the field having been touched.
|
|
199
200
|
|
|
200
|
-
AsyncSelectInput.isTouched =
|
|
201
|
-
return Boolean(touched);
|
|
202
|
-
};
|
|
201
|
+
AsyncSelectInput.isTouched = touched => Boolean(touched);
|
|
203
202
|
/**
|
|
204
203
|
* Expose react-select components for customization purposes.
|
|
205
204
|
*/
|
|
@@ -237,6 +236,6 @@ AsyncSelectInput.ValueContainer = components.ValueContainer;
|
|
|
237
236
|
var AsyncSelectInput$1 = AsyncSelectInput;
|
|
238
237
|
|
|
239
238
|
// NOTE: This string will be replaced on build time with the package version.
|
|
240
|
-
var version = "15.
|
|
239
|
+
var version = "15.15.1";
|
|
241
240
|
|
|
242
241
|
export { AsyncSelectInput$1 as default, version };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/async-select-input",
|
|
3
3
|
"description": "An input component getting a selection from an asynchronously loaded list from the user.",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.15.1",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/constraints": "15.
|
|
25
|
-
"@commercetools-uikit/design-system": "15.
|
|
26
|
-
"@commercetools-uikit/icons": "15.
|
|
27
|
-
"@commercetools-uikit/loading-spinner": "15.
|
|
28
|
-
"@commercetools-uikit/select-utils": "15.
|
|
29
|
-
"@commercetools-uikit/spacings": "15.
|
|
30
|
-
"@commercetools-uikit/text": "15.
|
|
31
|
-
"@commercetools-uikit/utils": "15.
|
|
24
|
+
"@commercetools-uikit/constraints": "15.15.1",
|
|
25
|
+
"@commercetools-uikit/design-system": "15.15.1",
|
|
26
|
+
"@commercetools-uikit/icons": "15.15.1",
|
|
27
|
+
"@commercetools-uikit/loading-spinner": "15.15.1",
|
|
28
|
+
"@commercetools-uikit/select-utils": "15.15.1",
|
|
29
|
+
"@commercetools-uikit/spacings": "15.15.1",
|
|
30
|
+
"@commercetools-uikit/text": "15.15.1",
|
|
31
|
+
"@commercetools-uikit/utils": "15.15.1",
|
|
32
32
|
"@emotion/react": "^11.10.5",
|
|
33
33
|
"@emotion/styled": "^11.10.5",
|
|
34
34
|
"lodash": "4.17.21",
|
|
35
35
|
"prop-types": "15.8.1",
|
|
36
|
-
"react-select": "5.7.
|
|
36
|
+
"react-select": "5.7.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"react": "17.0.2",
|