@commercetools-uikit/async-creatable-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-creatable-select-input.cjs.d.ts +1 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.dev.js +37 -40
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.prod.js +37 -40
- package/dist/commercetools-uikit-async-creatable-select-input.esm.js +40 -43
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ export default Example;
|
|
|
83
83
|
| `isSearchable` | `AsyncCreatableProps['isSearchable']` | | `true` | Whether to enable search functionality
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
84
84
|
| `maxMenuHeight` | `AsyncCreatableProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
85
85
|
| `menuPortalTarget` | `AsyncCreatableProps['menuPortalTarget']` | | | Dom element to portal the select menu to
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
86
|
-
| `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal
|
|
86
|
+
| `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal
<br>
Use in conjunction with `menuPortalTarget` |
|
|
87
87
|
| `menuShouldBlockScroll` | `AsyncCreatableProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
88
88
|
| `closeMenuOnSelect` | `AsyncCreatableProps['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) |
|
|
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) |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commercetools-uikit-async-creatable-select-input.cjs.d.ts","sourceRoot":"","sources":["./declarations/src/index.d.ts"],"names":[],"mappings":"AAAA"}
|
|
@@ -45,20 +45,18 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["def
|
|
|
45
45
|
|
|
46
46
|
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; }
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
};
|
|
48
|
+
const LoadingIndicator = () => jsxRuntime.jsx(LoadingSpinner__default["default"], {
|
|
49
|
+
scale: "s"
|
|
50
|
+
});
|
|
53
51
|
|
|
54
52
|
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
55
|
-
|
|
53
|
+
const customizedComponents = {
|
|
56
54
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
57
55
|
ClearIndicator: selectUtils.ClearIndicator,
|
|
58
|
-
LoadingIndicator
|
|
56
|
+
LoadingIndicator,
|
|
59
57
|
MultiValueRemove: selectUtils.TagRemove
|
|
60
58
|
};
|
|
61
|
-
|
|
59
|
+
const defaultProps = {
|
|
62
60
|
// Using "null" will ensure that the currently selected value disappears in
|
|
63
61
|
// case "undefined" gets passed as the next value
|
|
64
62
|
value: null,
|
|
@@ -66,13 +64,13 @@ var defaultProps = {
|
|
|
66
64
|
menuPortalZIndex: 1
|
|
67
65
|
};
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
const AsyncCreatableSelectInput = props => {
|
|
68
|
+
const intl = reactIntl.useIntl();
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
const _useTheme = designSystem.useTheme(),
|
|
71
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
76
74
|
|
|
77
75
|
if (!props.isReadOnly) {
|
|
78
76
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'AsyncCreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
@@ -82,6 +80,11 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
82
80
|
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;
|
|
83
81
|
}
|
|
84
82
|
|
|
83
|
+
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
84
|
+
menuPortalZIndex: props.menuPortalZIndex,
|
|
85
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
86
|
+
componentName: 'AsyncCreatableSelectInput'
|
|
87
|
+
});
|
|
85
88
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
86
89
|
max: props.horizontalConstraint,
|
|
87
90
|
children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(props)), {}, {
|
|
@@ -93,11 +96,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
93
96
|
autoFocus: props.isAutofocussed,
|
|
94
97
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
95
98
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
96
|
-
Input:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
99
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
100
|
+
readOnly: true
|
|
101
|
+
}))
|
|
101
102
|
} : {}), props.components),
|
|
102
103
|
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
103
104
|
styles: selectUtils.createSelectStyles({
|
|
@@ -110,7 +111,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
110
111
|
iconLeft: props.iconLeft,
|
|
111
112
|
isMulti: props.isMulti,
|
|
112
113
|
hasValue: !isEmpty__default["default"](props.value),
|
|
113
|
-
isNewTheme
|
|
114
|
+
isNewTheme
|
|
114
115
|
}),
|
|
115
116
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
116
117
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -130,17 +131,17 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
130
131
|
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
131
132
|
closeMenuOnScroll: props.closeMenuOnSelect,
|
|
132
133
|
name: props.name,
|
|
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,17 +149,17 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(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
|
// wrapping breaking changes made in react-select v3
|
|
161
|
-
|
|
162
|
+
let newValue = value;
|
|
162
163
|
|
|
163
164
|
if (props.isMulti && !newValue) {
|
|
164
165
|
newValue = [];
|
|
@@ -170,7 +171,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
170
171
|
name: props.name,
|
|
171
172
|
value: newValue
|
|
172
173
|
},
|
|
173
|
-
persist:
|
|
174
|
+
persist: () => {}
|
|
174
175
|
}, info);
|
|
175
176
|
},
|
|
176
177
|
onFocus: props.onFocus,
|
|
@@ -185,11 +186,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
185
186
|
cacheOptions: props.cacheOptions // Creatable props
|
|
186
187
|
,
|
|
187
188
|
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
188
|
-
formatCreateLabel: props.formatCreateLabel ||
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
});
|
|
192
|
-
},
|
|
189
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
190
|
+
inputValue
|
|
191
|
+
})),
|
|
193
192
|
isValidNewOption: props.isValidNewOption,
|
|
194
193
|
getNewOptionData: props.getNewOptionData,
|
|
195
194
|
onCreateOption: props.onCreateOption,
|
|
@@ -223,9 +222,7 @@ AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
|
223
222
|
// values were removed only. So we have to treat any array we receive as
|
|
224
223
|
// a signal of the field having been touched.
|
|
225
224
|
|
|
226
|
-
AsyncCreatableSelectInput.isTouched =
|
|
227
|
-
return Boolean(touched);
|
|
228
|
-
};
|
|
225
|
+
AsyncCreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
229
226
|
/**
|
|
230
227
|
* Expose react-select components for customization purposes.
|
|
231
228
|
*/
|
|
@@ -263,7 +260,7 @@ AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer
|
|
|
263
260
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
264
261
|
|
|
265
262
|
// NOTE: This string will be replaced on build time with the package version.
|
|
266
|
-
var version = "15.
|
|
263
|
+
var version = "15.15.1";
|
|
267
264
|
|
|
268
265
|
exports["default"] = AsyncCreatableSelectInput$1;
|
|
269
266
|
exports.version = version;
|
|
@@ -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,18 +62,23 @@ var defaultProps = {
|
|
|
64
62
|
menuPortalZIndex: 1
|
|
65
63
|
};
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
const AsyncCreatableSelectInput = props => {
|
|
66
|
+
const intl = reactIntl.useIntl();
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
const _useTheme = designSystem.useTheme(),
|
|
69
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
72
70
|
|
|
73
|
-
|
|
71
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
74
72
|
|
|
75
73
|
if (!props.isReadOnly) ;
|
|
76
74
|
|
|
77
75
|
if (props.isMulti) ;
|
|
78
76
|
|
|
77
|
+
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
78
|
+
menuPortalZIndex: props.menuPortalZIndex,
|
|
79
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
80
|
+
componentName: 'AsyncCreatableSelectInput'
|
|
81
|
+
});
|
|
79
82
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
80
83
|
max: props.horizontalConstraint,
|
|
81
84
|
children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(props)), {}, {
|
|
@@ -87,11 +90,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
87
90
|
autoFocus: props.isAutofocussed,
|
|
88
91
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
89
92
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
90
|
-
Input:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
93
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
94
|
+
readOnly: true
|
|
95
|
+
}))
|
|
95
96
|
} : {}), props.components),
|
|
96
97
|
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
97
98
|
styles: selectUtils.createSelectStyles({
|
|
@@ -104,7 +105,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
104
105
|
iconLeft: props.iconLeft,
|
|
105
106
|
isMulti: props.isMulti,
|
|
106
107
|
hasValue: !isEmpty__default["default"](props.value),
|
|
107
|
-
isNewTheme
|
|
108
|
+
isNewTheme
|
|
108
109
|
}),
|
|
109
110
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
110
111
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -124,17 +125,17 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
124
125
|
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
125
126
|
closeMenuOnScroll: props.closeMenuOnSelect,
|
|
126
127
|
name: props.name,
|
|
127
|
-
noOptionsMessage: props.noOptionsMessage ||
|
|
128
|
-
|
|
128
|
+
noOptionsMessage: props.noOptionsMessage || (_ref => {
|
|
129
|
+
let inputValue = _ref.inputValue;
|
|
129
130
|
return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
130
|
-
inputValue
|
|
131
|
+
inputValue
|
|
131
132
|
});
|
|
132
|
-
},
|
|
133
|
-
onBlur: props.onBlur ?
|
|
134
|
-
|
|
133
|
+
}),
|
|
134
|
+
onBlur: props.onBlur ? () => {
|
|
135
|
+
const event = {
|
|
135
136
|
target: {
|
|
136
137
|
id: props.id,
|
|
137
|
-
name:
|
|
138
|
+
name: (() => {
|
|
138
139
|
if (!props.name) return undefined;
|
|
139
140
|
if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
|
|
140
141
|
// state as an array instead of a boolean only.
|
|
@@ -142,17 +143,17 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
142
143
|
// Formik will create an array on submission anyways.
|
|
143
144
|
|
|
144
145
|
return "".concat(props.name, ".0");
|
|
145
|
-
}()
|
|
146
|
+
})()
|
|
146
147
|
},
|
|
147
|
-
persist:
|
|
148
|
+
persist: () => {}
|
|
148
149
|
};
|
|
149
150
|
props.onBlur && props.onBlur(event);
|
|
150
151
|
} : undefined,
|
|
151
|
-
onChange:
|
|
152
|
+
onChange: (value, info) => {
|
|
152
153
|
var _props$onChange;
|
|
153
154
|
|
|
154
155
|
// wrapping breaking changes made in react-select v3
|
|
155
|
-
|
|
156
|
+
let newValue = value;
|
|
156
157
|
|
|
157
158
|
if (props.isMulti && !newValue) {
|
|
158
159
|
newValue = [];
|
|
@@ -164,7 +165,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
164
165
|
name: props.name,
|
|
165
166
|
value: newValue
|
|
166
167
|
},
|
|
167
|
-
persist:
|
|
168
|
+
persist: () => {}
|
|
168
169
|
}, info);
|
|
169
170
|
},
|
|
170
171
|
onFocus: props.onFocus,
|
|
@@ -179,11 +180,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
179
180
|
cacheOptions: props.cacheOptions // Creatable props
|
|
180
181
|
,
|
|
181
182
|
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
182
|
-
formatCreateLabel: props.formatCreateLabel ||
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
});
|
|
186
|
-
},
|
|
183
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
184
|
+
inputValue
|
|
185
|
+
})),
|
|
187
186
|
isValidNewOption: props.isValidNewOption,
|
|
188
187
|
getNewOptionData: props.getNewOptionData,
|
|
189
188
|
onCreateOption: props.onCreateOption,
|
|
@@ -206,9 +205,7 @@ AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
|
206
205
|
// values were removed only. So we have to treat any array we receive as
|
|
207
206
|
// a signal of the field having been touched.
|
|
208
207
|
|
|
209
|
-
AsyncCreatableSelectInput.isTouched =
|
|
210
|
-
return Boolean(touched);
|
|
211
|
-
};
|
|
208
|
+
AsyncCreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
212
209
|
/**
|
|
213
210
|
* Expose react-select components for customization purposes.
|
|
214
211
|
*/
|
|
@@ -246,7 +243,7 @@ AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer
|
|
|
246
243
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
247
244
|
|
|
248
245
|
// NOTE: This string will be replaced on build time with the package version.
|
|
249
|
-
var version = "15.
|
|
246
|
+
var version = "15.15.1";
|
|
250
247
|
|
|
251
248
|
exports["default"] = AsyncCreatableSelectInput$1;
|
|
252
249
|
exports.version = version;
|
|
@@ -15,7 +15,7 @@ import { components } from 'react-select';
|
|
|
15
15
|
import AsyncCreatableSelect from 'react-select/async-creatable';
|
|
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 { messages, warnIfMenuPortalPropsAreMissing, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
19
19
|
import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
20
20
|
import { useTheme } from '@commercetools-uikit/design-system';
|
|
21
21
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
@@ -24,20 +24,18 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
|
|
|
24
24
|
|
|
25
25
|
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; }
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
};
|
|
27
|
+
const LoadingIndicator = () => jsx(LoadingSpinner, {
|
|
28
|
+
scale: "s"
|
|
29
|
+
});
|
|
32
30
|
|
|
33
31
|
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
34
|
-
|
|
35
|
-
DropdownIndicator
|
|
36
|
-
ClearIndicator
|
|
37
|
-
LoadingIndicator
|
|
32
|
+
const customizedComponents = {
|
|
33
|
+
DropdownIndicator,
|
|
34
|
+
ClearIndicator,
|
|
35
|
+
LoadingIndicator,
|
|
38
36
|
MultiValueRemove: TagRemove
|
|
39
37
|
};
|
|
40
|
-
|
|
38
|
+
const defaultProps = {
|
|
41
39
|
// Using "null" will ensure that the currently selected value disappears in
|
|
42
40
|
// case "undefined" gets passed as the next value
|
|
43
41
|
value: null,
|
|
@@ -45,13 +43,13 @@ var defaultProps = {
|
|
|
45
43
|
menuPortalZIndex: 1
|
|
46
44
|
};
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
const AsyncCreatableSelectInput = props => {
|
|
47
|
+
const intl = useIntl();
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
const _useTheme = useTheme(),
|
|
50
|
+
isNewTheme = _useTheme.isNewTheme;
|
|
53
51
|
|
|
54
|
-
|
|
52
|
+
const placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
55
53
|
|
|
56
54
|
if (!props.isReadOnly) {
|
|
57
55
|
process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'AsyncCreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
@@ -61,6 +59,11 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
61
59
|
process.env.NODE_ENV !== "production" ? warning(_Array$isArray(props.value), 'AsyncCreatableSelectInput: `value` is expected to be an array when isMulti is true') : void 0;
|
|
62
60
|
}
|
|
63
61
|
|
|
62
|
+
warnIfMenuPortalPropsAreMissing({
|
|
63
|
+
menuPortalZIndex: props.menuPortalZIndex,
|
|
64
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
65
|
+
componentName: 'AsyncCreatableSelectInput'
|
|
66
|
+
});
|
|
64
67
|
return jsx(Constraints.Horizontal, {
|
|
65
68
|
max: props.horizontalConstraint,
|
|
66
69
|
children: jsx("div", _objectSpread(_objectSpread({}, filterDataAttributes(props)), {}, {
|
|
@@ -72,11 +75,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
72
75
|
autoFocus: props.isAutofocussed,
|
|
73
76
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
74
77
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
75
|
-
Input:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}));
|
|
79
|
-
}
|
|
78
|
+
Input: ownProps => jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
79
|
+
readOnly: true
|
|
80
|
+
}))
|
|
80
81
|
} : {}), props.components),
|
|
81
82
|
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
82
83
|
styles: createSelectStyles({
|
|
@@ -89,7 +90,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
89
90
|
iconLeft: props.iconLeft,
|
|
90
91
|
isMulti: props.isMulti,
|
|
91
92
|
hasValue: !isEmpty(props.value),
|
|
92
|
-
isNewTheme
|
|
93
|
+
isNewTheme
|
|
93
94
|
}),
|
|
94
95
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
95
96
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -109,17 +110,17 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
109
110
|
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
110
111
|
closeMenuOnScroll: props.closeMenuOnSelect,
|
|
111
112
|
name: props.name,
|
|
112
|
-
noOptionsMessage: props.noOptionsMessage ||
|
|
113
|
-
|
|
113
|
+
noOptionsMessage: props.noOptionsMessage || (_ref => {
|
|
114
|
+
let inputValue = _ref.inputValue;
|
|
114
115
|
return inputValue === '' ? intl.formatMessage(messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(messages.noOptionsMessageWithInputValue, {
|
|
115
|
-
inputValue
|
|
116
|
+
inputValue
|
|
116
117
|
});
|
|
117
|
-
},
|
|
118
|
-
onBlur: props.onBlur ?
|
|
119
|
-
|
|
118
|
+
}),
|
|
119
|
+
onBlur: props.onBlur ? () => {
|
|
120
|
+
const event = {
|
|
120
121
|
target: {
|
|
121
122
|
id: props.id,
|
|
122
|
-
name:
|
|
123
|
+
name: (() => {
|
|
123
124
|
if (!props.name) return undefined;
|
|
124
125
|
if (!props.isMulti) return props.name; // We append the ".0" to make Formik set the touched
|
|
125
126
|
// state as an array instead of a boolean only.
|
|
@@ -127,17 +128,17 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
127
128
|
// Formik will create an array on submission anyways.
|
|
128
129
|
|
|
129
130
|
return "".concat(props.name, ".0");
|
|
130
|
-
}()
|
|
131
|
+
})()
|
|
131
132
|
},
|
|
132
|
-
persist:
|
|
133
|
+
persist: () => {}
|
|
133
134
|
};
|
|
134
135
|
props.onBlur && props.onBlur(event);
|
|
135
136
|
} : undefined,
|
|
136
|
-
onChange:
|
|
137
|
+
onChange: (value, info) => {
|
|
137
138
|
var _props$onChange;
|
|
138
139
|
|
|
139
140
|
// wrapping breaking changes made in react-select v3
|
|
140
|
-
|
|
141
|
+
let newValue = value;
|
|
141
142
|
|
|
142
143
|
if (props.isMulti && !newValue) {
|
|
143
144
|
newValue = [];
|
|
@@ -149,7 +150,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
149
150
|
name: props.name,
|
|
150
151
|
value: newValue
|
|
151
152
|
},
|
|
152
|
-
persist:
|
|
153
|
+
persist: () => {}
|
|
153
154
|
}, info);
|
|
154
155
|
},
|
|
155
156
|
onFocus: props.onFocus,
|
|
@@ -164,11 +165,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
164
165
|
cacheOptions: props.cacheOptions // Creatable props
|
|
165
166
|
,
|
|
166
167
|
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
167
|
-
formatCreateLabel: props.formatCreateLabel ||
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
});
|
|
171
|
-
},
|
|
168
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(messages.createLabel, {
|
|
169
|
+
inputValue
|
|
170
|
+
})),
|
|
172
171
|
isValidNewOption: props.isValidNewOption,
|
|
173
172
|
getNewOptionData: props.getNewOptionData,
|
|
174
173
|
onCreateOption: props.onCreateOption,
|
|
@@ -202,9 +201,7 @@ AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
|
202
201
|
// values were removed only. So we have to treat any array we receive as
|
|
203
202
|
// a signal of the field having been touched.
|
|
204
203
|
|
|
205
|
-
AsyncCreatableSelectInput.isTouched =
|
|
206
|
-
return Boolean(touched);
|
|
207
|
-
};
|
|
204
|
+
AsyncCreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
208
205
|
/**
|
|
209
206
|
* Expose react-select components for customization purposes.
|
|
210
207
|
*/
|
|
@@ -242,6 +239,6 @@ AsyncCreatableSelectInput.ValueContainer = components.ValueContainer;
|
|
|
242
239
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
243
240
|
|
|
244
241
|
// NOTE: This string will be replaced on build time with the package version.
|
|
245
|
-
var version = "15.
|
|
242
|
+
var version = "15.15.1";
|
|
246
243
|
|
|
247
244
|
export { AsyncCreatableSelectInput$1 as default, version };
|
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": "15.
|
|
4
|
+
"version": "15.15.1",
|
|
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.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/is-prop-valid": "1.2.0",
|
|
33
33
|
"@emotion/react": "^11.10.5",
|
|
34
34
|
"@emotion/styled": "^11.10.5",
|
|
35
35
|
"lodash": "4.17.21",
|
|
36
36
|
"prop-types": "15.8.1",
|
|
37
|
-
"react-select": "5.7.
|
|
37
|
+
"react-select": "5.7.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"react": "17.0.2",
|