@commercetools-uikit/creatable-select-input 16.0.0 → 16.1.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.
|
@@ -19,7 +19,6 @@ var CreatableSelect = require('react-select/creatable');
|
|
|
19
19
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
20
20
|
var utils = require('@commercetools-uikit/utils');
|
|
21
21
|
var selectUtils = require('@commercetools-uikit/select-utils');
|
|
22
|
-
var designSystem = require('@commercetools-uikit/design-system');
|
|
23
22
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
24
23
|
|
|
25
24
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -38,7 +37,6 @@ var CreatableSelect__default = /*#__PURE__*/_interopDefault(CreatableSelect);
|
|
|
38
37
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
39
38
|
|
|
40
39
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
-
|
|
42
40
|
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; }
|
|
43
41
|
const customizedComponents = {
|
|
44
42
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
@@ -58,17 +56,11 @@ const defaultProps = {
|
|
|
58
56
|
isSearchable: true,
|
|
59
57
|
menuPortalZIndex: 1
|
|
60
58
|
};
|
|
61
|
-
|
|
62
59
|
const CreatableSelectInput = props => {
|
|
63
60
|
const intl = reactIntl.useIntl();
|
|
64
|
-
|
|
65
|
-
const _useTheme = designSystem.useTheme(),
|
|
66
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
67
|
-
|
|
68
61
|
if (!props.isReadOnly) {
|
|
69
62
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'CreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
70
63
|
}
|
|
71
|
-
|
|
72
64
|
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
73
65
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
74
66
|
max: props.horizontalConstraint,
|
|
@@ -95,10 +87,10 @@ const CreatableSelectInput = props => {
|
|
|
95
87
|
isReadOnly: props.isReadOnly,
|
|
96
88
|
iconLeft: props.iconLeft,
|
|
97
89
|
isMulti: props.isMulti,
|
|
98
|
-
hasValue: !isEmpty__default["default"](props.value)
|
|
99
|
-
isNewTheme
|
|
90
|
+
hasValue: !isEmpty__default["default"](props.value)
|
|
100
91
|
}),
|
|
101
|
-
filterOption: props.filterOption
|
|
92
|
+
filterOption: props.filterOption
|
|
93
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
102
94
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
103
95
|
// instead.
|
|
104
96
|
// This makes it easier to less confusing to use with <label />s.
|
|
@@ -127,11 +119,11 @@ const CreatableSelectInput = props => {
|
|
|
127
119
|
target: {
|
|
128
120
|
id: props.id,
|
|
129
121
|
name: (() => {
|
|
130
|
-
if (!props.isMulti) return props.name;
|
|
122
|
+
if (!props.isMulti) return props.name;
|
|
123
|
+
// We append the ".0" to make Formik set the touched
|
|
131
124
|
// state as an array instead of a boolean only.
|
|
132
125
|
// Otherwise the shapes would clash on submission, as
|
|
133
126
|
// Formik will create an array on submission anyways.
|
|
134
|
-
|
|
135
127
|
return props.name ? "".concat(props.name, ".0") : undefined;
|
|
136
128
|
})()
|
|
137
129
|
},
|
|
@@ -141,15 +133,13 @@ const CreatableSelectInput = props => {
|
|
|
141
133
|
} : undefined,
|
|
142
134
|
onChange: (value, info) => {
|
|
143
135
|
var _props$onChange;
|
|
144
|
-
|
|
145
136
|
// selectedOptions is either an array, or a single option, or null
|
|
146
137
|
// depending on whether we're in multi-mode or not (isMulti)
|
|
147
|
-
let newValue = value;
|
|
148
138
|
|
|
139
|
+
let newValue = value;
|
|
149
140
|
if (props.isMulti && !newValue) {
|
|
150
141
|
newValue = [];
|
|
151
142
|
}
|
|
152
|
-
|
|
153
143
|
(_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
|
|
154
144
|
target: {
|
|
155
145
|
id: props.id,
|
|
@@ -165,7 +155,8 @@ const CreatableSelectInput = props => {
|
|
|
165
155
|
placeholder: placeholder,
|
|
166
156
|
tabIndex: props.tabIndex,
|
|
167
157
|
tabSelectsValue: props.tabSelectsValue,
|
|
168
|
-
value: props.value
|
|
158
|
+
value: props.value
|
|
159
|
+
// Creatable props
|
|
169
160
|
,
|
|
170
161
|
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
171
162
|
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
@@ -174,14 +165,14 @@ const CreatableSelectInput = props => {
|
|
|
174
165
|
isValidNewOption: props.isValidNewOption,
|
|
175
166
|
getNewOptionData: props.getNewOptionData,
|
|
176
167
|
onCreateOption: props.onCreateOption,
|
|
177
|
-
createOptionPosition: props.createOptionPosition
|
|
168
|
+
createOptionPosition: props.createOptionPosition
|
|
169
|
+
//@ts-ignore
|
|
178
170
|
,
|
|
179
171
|
iconLeft: props.iconLeft
|
|
180
172
|
})
|
|
181
173
|
}))
|
|
182
174
|
});
|
|
183
175
|
};
|
|
184
|
-
|
|
185
176
|
CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
186
177
|
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
187
178
|
hasError: _pt__default["default"].bool,
|
|
@@ -205,24 +196,25 @@ CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
205
196
|
} : {};
|
|
206
197
|
CreatableSelectInput.displayName = 'CreatableSelectInput';
|
|
207
198
|
CreatableSelectInput.defaultProps = defaultProps;
|
|
199
|
+
|
|
208
200
|
/**
|
|
209
201
|
* Expose static helper methods.
|
|
210
202
|
*/
|
|
203
|
+
|
|
211
204
|
// Both "true" and an empty array [] represent a touched state. The Boolean
|
|
212
205
|
// conveniently handles both cases
|
|
213
|
-
|
|
214
206
|
CreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
207
|
+
|
|
215
208
|
/**
|
|
216
209
|
* Expose react-select components for customization purposes.
|
|
217
210
|
*/
|
|
218
|
-
// custom
|
|
219
|
-
|
|
220
211
|
|
|
212
|
+
// custom
|
|
221
213
|
CreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
222
214
|
CreatableSelectInput.Control = reactSelect.components.Control;
|
|
223
215
|
CreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
224
|
-
CreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
225
|
-
|
|
216
|
+
CreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
217
|
+
// custom
|
|
226
218
|
CreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
227
219
|
CreatableSelectInput.Group = reactSelect.components.Group;
|
|
228
220
|
CreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
@@ -236,8 +228,8 @@ CreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
|
236
228
|
CreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
237
229
|
CreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
238
230
|
CreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
239
|
-
CreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
240
|
-
|
|
231
|
+
CreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
232
|
+
// custom
|
|
241
233
|
CreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
242
234
|
CreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
243
235
|
CreatableSelectInput.Option = reactSelect.components.Option;
|
|
@@ -248,7 +240,7 @@ CreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
|
248
240
|
var CreatableSelectInput$1 = CreatableSelectInput;
|
|
249
241
|
|
|
250
242
|
// NOTE: This string will be replaced on build time with the package version.
|
|
251
|
-
var version = "16.
|
|
243
|
+
var version = "16.1.1";
|
|
252
244
|
|
|
253
245
|
exports["default"] = CreatableSelectInput$1;
|
|
254
246
|
exports.version = version;
|
|
@@ -19,7 +19,6 @@ var CreatableSelect = require('react-select/creatable');
|
|
|
19
19
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
20
20
|
var utils = require('@commercetools-uikit/utils');
|
|
21
21
|
var selectUtils = require('@commercetools-uikit/select-utils');
|
|
22
|
-
var designSystem = require('@commercetools-uikit/design-system');
|
|
23
22
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
24
23
|
|
|
25
24
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -37,7 +36,6 @@ var CreatableSelect__default = /*#__PURE__*/_interopDefault(CreatableSelect);
|
|
|
37
36
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
38
37
|
|
|
39
38
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
40
|
-
|
|
41
39
|
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; }
|
|
42
40
|
const customizedComponents = {
|
|
43
41
|
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
@@ -57,15 +55,9 @@ const defaultProps = {
|
|
|
57
55
|
isSearchable: true,
|
|
58
56
|
menuPortalZIndex: 1
|
|
59
57
|
};
|
|
60
|
-
|
|
61
58
|
const CreatableSelectInput = props => {
|
|
62
59
|
const intl = reactIntl.useIntl();
|
|
63
|
-
|
|
64
|
-
const _useTheme = designSystem.useTheme(),
|
|
65
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
66
|
-
|
|
67
60
|
if (!props.isReadOnly) ;
|
|
68
|
-
|
|
69
61
|
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
70
62
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
71
63
|
max: props.horizontalConstraint,
|
|
@@ -92,10 +84,10 @@ const CreatableSelectInput = props => {
|
|
|
92
84
|
isReadOnly: props.isReadOnly,
|
|
93
85
|
iconLeft: props.iconLeft,
|
|
94
86
|
isMulti: props.isMulti,
|
|
95
|
-
hasValue: !isEmpty__default["default"](props.value)
|
|
96
|
-
isNewTheme
|
|
87
|
+
hasValue: !isEmpty__default["default"](props.value)
|
|
97
88
|
}),
|
|
98
|
-
filterOption: props.filterOption
|
|
89
|
+
filterOption: props.filterOption
|
|
90
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
99
91
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
100
92
|
// instead.
|
|
101
93
|
// This makes it easier to less confusing to use with <label />s.
|
|
@@ -124,11 +116,11 @@ const CreatableSelectInput = props => {
|
|
|
124
116
|
target: {
|
|
125
117
|
id: props.id,
|
|
126
118
|
name: (() => {
|
|
127
|
-
if (!props.isMulti) return props.name;
|
|
119
|
+
if (!props.isMulti) return props.name;
|
|
120
|
+
// We append the ".0" to make Formik set the touched
|
|
128
121
|
// state as an array instead of a boolean only.
|
|
129
122
|
// Otherwise the shapes would clash on submission, as
|
|
130
123
|
// Formik will create an array on submission anyways.
|
|
131
|
-
|
|
132
124
|
return props.name ? "".concat(props.name, ".0") : undefined;
|
|
133
125
|
})()
|
|
134
126
|
},
|
|
@@ -138,15 +130,13 @@ const CreatableSelectInput = props => {
|
|
|
138
130
|
} : undefined,
|
|
139
131
|
onChange: (value, info) => {
|
|
140
132
|
var _props$onChange;
|
|
141
|
-
|
|
142
133
|
// selectedOptions is either an array, or a single option, or null
|
|
143
134
|
// depending on whether we're in multi-mode or not (isMulti)
|
|
144
|
-
let newValue = value;
|
|
145
135
|
|
|
136
|
+
let newValue = value;
|
|
146
137
|
if (props.isMulti && !newValue) {
|
|
147
138
|
newValue = [];
|
|
148
139
|
}
|
|
149
|
-
|
|
150
140
|
(_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
|
|
151
141
|
target: {
|
|
152
142
|
id: props.id,
|
|
@@ -162,7 +152,8 @@ const CreatableSelectInput = props => {
|
|
|
162
152
|
placeholder: placeholder,
|
|
163
153
|
tabIndex: props.tabIndex,
|
|
164
154
|
tabSelectsValue: props.tabSelectsValue,
|
|
165
|
-
value: props.value
|
|
155
|
+
value: props.value
|
|
156
|
+
// Creatable props
|
|
166
157
|
,
|
|
167
158
|
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
168
159
|
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
@@ -171,35 +162,36 @@ const CreatableSelectInput = props => {
|
|
|
171
162
|
isValidNewOption: props.isValidNewOption,
|
|
172
163
|
getNewOptionData: props.getNewOptionData,
|
|
173
164
|
onCreateOption: props.onCreateOption,
|
|
174
|
-
createOptionPosition: props.createOptionPosition
|
|
165
|
+
createOptionPosition: props.createOptionPosition
|
|
166
|
+
//@ts-ignore
|
|
175
167
|
,
|
|
176
168
|
iconLeft: props.iconLeft
|
|
177
169
|
})
|
|
178
170
|
}))
|
|
179
171
|
});
|
|
180
172
|
};
|
|
181
|
-
|
|
182
173
|
CreatableSelectInput.propTypes = {};
|
|
183
174
|
CreatableSelectInput.displayName = 'CreatableSelectInput';
|
|
184
175
|
CreatableSelectInput.defaultProps = defaultProps;
|
|
176
|
+
|
|
185
177
|
/**
|
|
186
178
|
* Expose static helper methods.
|
|
187
179
|
*/
|
|
180
|
+
|
|
188
181
|
// Both "true" and an empty array [] represent a touched state. The Boolean
|
|
189
182
|
// conveniently handles both cases
|
|
190
|
-
|
|
191
183
|
CreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
184
|
+
|
|
192
185
|
/**
|
|
193
186
|
* Expose react-select components for customization purposes.
|
|
194
187
|
*/
|
|
195
|
-
// custom
|
|
196
|
-
|
|
197
188
|
|
|
189
|
+
// custom
|
|
198
190
|
CreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
199
191
|
CreatableSelectInput.Control = reactSelect.components.Control;
|
|
200
192
|
CreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
201
|
-
CreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
202
|
-
|
|
193
|
+
CreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
194
|
+
// custom
|
|
203
195
|
CreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
204
196
|
CreatableSelectInput.Group = reactSelect.components.Group;
|
|
205
197
|
CreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
@@ -213,8 +205,8 @@ CreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
|
213
205
|
CreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
214
206
|
CreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
215
207
|
CreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
216
|
-
CreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
217
|
-
|
|
208
|
+
CreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
209
|
+
// custom
|
|
218
210
|
CreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
219
211
|
CreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
220
212
|
CreatableSelectInput.Option = reactSelect.components.Option;
|
|
@@ -225,7 +217,7 @@ CreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
|
225
217
|
var CreatableSelectInput$1 = CreatableSelectInput;
|
|
226
218
|
|
|
227
219
|
// NOTE: This string will be replaced on build time with the package version.
|
|
228
|
-
var version = "16.
|
|
220
|
+
var version = "16.1.1";
|
|
229
221
|
|
|
230
222
|
exports["default"] = CreatableSelectInput$1;
|
|
231
223
|
exports.version = version;
|
|
@@ -15,11 +15,9 @@ import CreatableSelect from 'react-select/creatable';
|
|
|
15
15
|
import Constraints from '@commercetools-uikit/constraints';
|
|
16
16
|
import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
17
17
|
import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
18
|
-
import { useTheme } from '@commercetools-uikit/design-system';
|
|
19
18
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
20
19
|
|
|
21
20
|
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; }
|
|
22
|
-
|
|
23
21
|
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; }
|
|
24
22
|
const customizedComponents = {
|
|
25
23
|
DropdownIndicator,
|
|
@@ -39,17 +37,11 @@ const defaultProps = {
|
|
|
39
37
|
isSearchable: true,
|
|
40
38
|
menuPortalZIndex: 1
|
|
41
39
|
};
|
|
42
|
-
|
|
43
40
|
const CreatableSelectInput = props => {
|
|
44
41
|
const intl = useIntl();
|
|
45
|
-
|
|
46
|
-
const _useTheme = useTheme(),
|
|
47
|
-
isNewTheme = _useTheme.isNewTheme;
|
|
48
|
-
|
|
49
42
|
if (!props.isReadOnly) {
|
|
50
43
|
process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'CreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
const placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
54
46
|
return jsx(Constraints.Horizontal, {
|
|
55
47
|
max: props.horizontalConstraint,
|
|
@@ -76,10 +68,10 @@ const CreatableSelectInput = props => {
|
|
|
76
68
|
isReadOnly: props.isReadOnly,
|
|
77
69
|
iconLeft: props.iconLeft,
|
|
78
70
|
isMulti: props.isMulti,
|
|
79
|
-
hasValue: !isEmpty(props.value)
|
|
80
|
-
isNewTheme
|
|
71
|
+
hasValue: !isEmpty(props.value)
|
|
81
72
|
}),
|
|
82
|
-
filterOption: props.filterOption
|
|
73
|
+
filterOption: props.filterOption
|
|
74
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
83
75
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
84
76
|
// instead.
|
|
85
77
|
// This makes it easier to less confusing to use with <label />s.
|
|
@@ -108,11 +100,11 @@ const CreatableSelectInput = props => {
|
|
|
108
100
|
target: {
|
|
109
101
|
id: props.id,
|
|
110
102
|
name: (() => {
|
|
111
|
-
if (!props.isMulti) return props.name;
|
|
103
|
+
if (!props.isMulti) return props.name;
|
|
104
|
+
// We append the ".0" to make Formik set the touched
|
|
112
105
|
// state as an array instead of a boolean only.
|
|
113
106
|
// Otherwise the shapes would clash on submission, as
|
|
114
107
|
// Formik will create an array on submission anyways.
|
|
115
|
-
|
|
116
108
|
return props.name ? "".concat(props.name, ".0") : undefined;
|
|
117
109
|
})()
|
|
118
110
|
},
|
|
@@ -122,15 +114,13 @@ const CreatableSelectInput = props => {
|
|
|
122
114
|
} : undefined,
|
|
123
115
|
onChange: (value, info) => {
|
|
124
116
|
var _props$onChange;
|
|
125
|
-
|
|
126
117
|
// selectedOptions is either an array, or a single option, or null
|
|
127
118
|
// depending on whether we're in multi-mode or not (isMulti)
|
|
128
|
-
let newValue = value;
|
|
129
119
|
|
|
120
|
+
let newValue = value;
|
|
130
121
|
if (props.isMulti && !newValue) {
|
|
131
122
|
newValue = [];
|
|
132
123
|
}
|
|
133
|
-
|
|
134
124
|
(_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
|
|
135
125
|
target: {
|
|
136
126
|
id: props.id,
|
|
@@ -146,7 +136,8 @@ const CreatableSelectInput = props => {
|
|
|
146
136
|
placeholder: placeholder,
|
|
147
137
|
tabIndex: props.tabIndex,
|
|
148
138
|
tabSelectsValue: props.tabSelectsValue,
|
|
149
|
-
value: props.value
|
|
139
|
+
value: props.value
|
|
140
|
+
// Creatable props
|
|
150
141
|
,
|
|
151
142
|
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
152
143
|
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(messages.createLabel, {
|
|
@@ -155,14 +146,14 @@ const CreatableSelectInput = props => {
|
|
|
155
146
|
isValidNewOption: props.isValidNewOption,
|
|
156
147
|
getNewOptionData: props.getNewOptionData,
|
|
157
148
|
onCreateOption: props.onCreateOption,
|
|
158
|
-
createOptionPosition: props.createOptionPosition
|
|
149
|
+
createOptionPosition: props.createOptionPosition
|
|
150
|
+
//@ts-ignore
|
|
159
151
|
,
|
|
160
152
|
iconLeft: props.iconLeft
|
|
161
153
|
})
|
|
162
154
|
}))
|
|
163
155
|
});
|
|
164
156
|
};
|
|
165
|
-
|
|
166
157
|
CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
167
158
|
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
168
159
|
hasError: _pt.bool,
|
|
@@ -186,24 +177,25 @@ CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
186
177
|
} : {};
|
|
187
178
|
CreatableSelectInput.displayName = 'CreatableSelectInput';
|
|
188
179
|
CreatableSelectInput.defaultProps = defaultProps;
|
|
180
|
+
|
|
189
181
|
/**
|
|
190
182
|
* Expose static helper methods.
|
|
191
183
|
*/
|
|
184
|
+
|
|
192
185
|
// Both "true" and an empty array [] represent a touched state. The Boolean
|
|
193
186
|
// conveniently handles both cases
|
|
194
|
-
|
|
195
187
|
CreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
188
|
+
|
|
196
189
|
/**
|
|
197
190
|
* Expose react-select components for customization purposes.
|
|
198
191
|
*/
|
|
199
|
-
// custom
|
|
200
|
-
|
|
201
192
|
|
|
193
|
+
// custom
|
|
202
194
|
CreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
203
195
|
CreatableSelectInput.Control = components.Control;
|
|
204
196
|
CreatableSelectInput.CrossIcon = components.CrossIcon;
|
|
205
|
-
CreatableSelectInput.DownChevron = components.DownChevron;
|
|
206
|
-
|
|
197
|
+
CreatableSelectInput.DownChevron = components.DownChevron;
|
|
198
|
+
// custom
|
|
207
199
|
CreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
208
200
|
CreatableSelectInput.Group = components.Group;
|
|
209
201
|
CreatableSelectInput.GroupHeading = components.GroupHeading;
|
|
@@ -217,8 +209,8 @@ CreatableSelectInput.MenuList = components.MenuList;
|
|
|
217
209
|
CreatableSelectInput.MenuPortal = components.MenuPortal;
|
|
218
210
|
CreatableSelectInput.MultiValue = components.MultiValue;
|
|
219
211
|
CreatableSelectInput.MultiValueContainer = components.MultiValueContainer;
|
|
220
|
-
CreatableSelectInput.MultiValueLabel = components.MultiValueLabel;
|
|
221
|
-
|
|
212
|
+
CreatableSelectInput.MultiValueLabel = components.MultiValueLabel;
|
|
213
|
+
// custom
|
|
222
214
|
CreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
223
215
|
CreatableSelectInput.NoOptionsMessage = components.NoOptionsMessage;
|
|
224
216
|
CreatableSelectInput.Option = components.Option;
|
|
@@ -229,6 +221,6 @@ CreatableSelectInput.ValueContainer = components.ValueContainer;
|
|
|
229
221
|
var CreatableSelectInput$1 = CreatableSelectInput;
|
|
230
222
|
|
|
231
223
|
// NOTE: This string will be replaced on build time with the package version.
|
|
232
|
-
var version = "16.
|
|
224
|
+
var version = "16.1.1";
|
|
233
225
|
|
|
234
226
|
export { CreatableSelectInput$1 as default, version };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/creatable-select-input",
|
|
3
3
|
"description": "An input component getting a selection from the user, and where options can also be created by the user.",
|
|
4
|
-
"version": "16.
|
|
4
|
+
"version": "16.1.1",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,18 +21,18 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/constraints": "16.
|
|
25
|
-
"@commercetools-uikit/design-system": "16.
|
|
26
|
-
"@commercetools-uikit/icons": "16.
|
|
27
|
-
"@commercetools-uikit/select-utils": "16.
|
|
28
|
-
"@commercetools-uikit/spacings": "16.
|
|
29
|
-
"@commercetools-uikit/text": "16.
|
|
30
|
-
"@commercetools-uikit/utils": "16.
|
|
24
|
+
"@commercetools-uikit/constraints": "16.1.1",
|
|
25
|
+
"@commercetools-uikit/design-system": "16.1.1",
|
|
26
|
+
"@commercetools-uikit/icons": "16.1.1",
|
|
27
|
+
"@commercetools-uikit/select-utils": "16.1.1",
|
|
28
|
+
"@commercetools-uikit/spacings": "16.1.1",
|
|
29
|
+
"@commercetools-uikit/text": "16.1.1",
|
|
30
|
+
"@commercetools-uikit/utils": "16.1.1",
|
|
31
31
|
"@emotion/react": "^11.10.5",
|
|
32
32
|
"@emotion/styled": "^11.10.5",
|
|
33
33
|
"lodash": "4.17.21",
|
|
34
34
|
"prop-types": "15.8.1",
|
|
35
|
-
"react-select": "5.7.
|
|
35
|
+
"react-select": "5.7.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"react": "17.0.2",
|