@commercetools-uikit/creatable-select-input 0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339
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/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.d.ts +3 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.dev.js +251 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.js +7 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.prod.js +227 -0
- package/dist/commercetools-uikit-creatable-select-input.esm.js +231 -0
- package/dist/declarations/src/creatable-select-input.d.ts +323 -0
- package/dist/declarations/src/export-types.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +55 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
7
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
9
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
|
+
require('prop-types');
|
|
16
|
+
var reactIntl = require('react-intl');
|
|
17
|
+
var isEmpty = require('lodash/isEmpty');
|
|
18
|
+
var reactSelect = require('react-select');
|
|
19
|
+
var CreatableSelect = require('react-select/creatable');
|
|
20
|
+
var Constraints = require('@commercetools-uikit/constraints');
|
|
21
|
+
var utils = require('@commercetools-uikit/utils');
|
|
22
|
+
var selectUtils = require('@commercetools-uikit/select-utils');
|
|
23
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
24
|
+
|
|
25
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
26
|
+
|
|
27
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
28
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
29
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
30
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
31
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
32
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
33
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
34
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
35
|
+
var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
|
|
36
|
+
var CreatableSelect__default = /*#__PURE__*/_interopDefault(CreatableSelect);
|
|
37
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
38
|
+
|
|
39
|
+
const _excluded = ["value", "isSearchable", "menuPortalZIndex"];
|
|
40
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
41
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
42
|
+
const customizedComponents = {
|
|
43
|
+
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
44
|
+
ClearIndicator: selectUtils.ClearIndicator,
|
|
45
|
+
MultiValueRemove: selectUtils.TagRemove
|
|
46
|
+
};
|
|
47
|
+
const CreatableSelectInput = _ref => {
|
|
48
|
+
let _ref$value = _ref.value,
|
|
49
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
50
|
+
_ref$isSearchable = _ref.isSearchable,
|
|
51
|
+
isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
|
|
52
|
+
_ref$menuPortalZIndex = _ref.menuPortalZIndex,
|
|
53
|
+
menuPortalZIndex = _ref$menuPortalZIndex === void 0 ? 1 : _ref$menuPortalZIndex,
|
|
54
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
55
|
+
const intl = reactIntl.useIntl();
|
|
56
|
+
if (!props.isReadOnly) ;
|
|
57
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
58
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
59
|
+
max: props.horizontalConstraint,
|
|
60
|
+
children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(_objectSpread({
|
|
61
|
+
value,
|
|
62
|
+
isSearchable,
|
|
63
|
+
menuPortalZIndex
|
|
64
|
+
}, props))), {}, {
|
|
65
|
+
children: jsxRuntime.jsx(CreatableSelect__default["default"], {
|
|
66
|
+
"aria-label": props['aria-label'],
|
|
67
|
+
"aria-labelledby": props['aria-labelledby'],
|
|
68
|
+
"aria-invalid": props['aria-invalid'],
|
|
69
|
+
"aria-errormessage": props['aria-errormessage'],
|
|
70
|
+
autoFocus: props.isAutofocussed,
|
|
71
|
+
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
72
|
+
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.components), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
73
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
74
|
+
readOnly: true
|
|
75
|
+
}))
|
|
76
|
+
} : {}), props.components),
|
|
77
|
+
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
78
|
+
styles: selectUtils.createSelectStyles({
|
|
79
|
+
hasWarning: props.hasWarning,
|
|
80
|
+
hasError: props.hasError,
|
|
81
|
+
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
82
|
+
menuPortalZIndex: menuPortalZIndex,
|
|
83
|
+
isCondensed: props.isCondensed,
|
|
84
|
+
isDisabled: props.isDisabled,
|
|
85
|
+
isReadOnly: props.isReadOnly,
|
|
86
|
+
iconLeft: props.iconLeft,
|
|
87
|
+
isMulti: props.isMulti,
|
|
88
|
+
hasValue: !isEmpty__default["default"](value),
|
|
89
|
+
horizontalConstraint: props.horizontalConstraint
|
|
90
|
+
}),
|
|
91
|
+
filterOption: props.filterOption
|
|
92
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
93
|
+
// but we use "id" (for the input) and "containerId" (for the container)
|
|
94
|
+
// instead.
|
|
95
|
+
// This makes it easier to less confusing to use with <label />s.
|
|
96
|
+
,
|
|
97
|
+
id: props.containerId,
|
|
98
|
+
inputId: props.id,
|
|
99
|
+
inputValue: props.inputValue,
|
|
100
|
+
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
101
|
+
isDisabled: props.isDisabled,
|
|
102
|
+
isOptionDisabled: props.isOptionDisabled,
|
|
103
|
+
isMulti: props.isMulti,
|
|
104
|
+
isSearchable: isSearchable,
|
|
105
|
+
maxMenuHeight: props.maxMenuHeight,
|
|
106
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
107
|
+
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
108
|
+
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
109
|
+
name: props.name,
|
|
110
|
+
noOptionsMessage: props.noOptionsMessage || (_ref2 => {
|
|
111
|
+
let inputValue = _ref2.inputValue;
|
|
112
|
+
return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
113
|
+
inputValue
|
|
114
|
+
});
|
|
115
|
+
}),
|
|
116
|
+
onBlur: typeof props.onBlur === 'function' ? () => {
|
|
117
|
+
const event = {
|
|
118
|
+
target: {
|
|
119
|
+
id: props.id,
|
|
120
|
+
name: (() => {
|
|
121
|
+
if (!props.isMulti) return props.name;
|
|
122
|
+
// We append the ".0" to make Formik set the touched
|
|
123
|
+
// state as an array instead of a boolean only.
|
|
124
|
+
// Otherwise the shapes would clash on submission, as
|
|
125
|
+
// Formik will create an array on submission anyways.
|
|
126
|
+
return props.name ? `${props.name}.0` : undefined;
|
|
127
|
+
})()
|
|
128
|
+
},
|
|
129
|
+
persist: () => {}
|
|
130
|
+
};
|
|
131
|
+
props.onBlur && props.onBlur(event);
|
|
132
|
+
} : undefined,
|
|
133
|
+
onChange: (value, info) => {
|
|
134
|
+
// selectedOptions is either an array, or a single option, or null
|
|
135
|
+
// depending on whether we're in multi-mode or not (isMulti)
|
|
136
|
+
|
|
137
|
+
let newValue = value;
|
|
138
|
+
if (props.isMulti && !newValue) {
|
|
139
|
+
newValue = [];
|
|
140
|
+
}
|
|
141
|
+
props.onChange?.({
|
|
142
|
+
target: {
|
|
143
|
+
id: props.id,
|
|
144
|
+
name: props.name,
|
|
145
|
+
value: newValue
|
|
146
|
+
},
|
|
147
|
+
persist: () => {}
|
|
148
|
+
}, info);
|
|
149
|
+
},
|
|
150
|
+
onFocus: props.onFocus,
|
|
151
|
+
onInputChange: props.onInputChange,
|
|
152
|
+
options: props.options,
|
|
153
|
+
placeholder: placeholder,
|
|
154
|
+
tabIndex: props.tabIndex,
|
|
155
|
+
tabSelectsValue: props.tabSelectsValue,
|
|
156
|
+
value: value
|
|
157
|
+
// Creatable props
|
|
158
|
+
,
|
|
159
|
+
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
160
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
161
|
+
inputValue
|
|
162
|
+
})),
|
|
163
|
+
isValidNewOption: props.isValidNewOption,
|
|
164
|
+
getNewOptionData: props.getNewOptionData,
|
|
165
|
+
onCreateOption: props.onCreateOption,
|
|
166
|
+
createOptionPosition: props.createOptionPosition
|
|
167
|
+
//@ts-ignore
|
|
168
|
+
,
|
|
169
|
+
iconLeft: props.iconLeft,
|
|
170
|
+
isCondensed: props.isCondensed
|
|
171
|
+
})
|
|
172
|
+
}))
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
CreatableSelectInput.propTypes = {};
|
|
176
|
+
CreatableSelectInput.displayName = 'CreatableSelectInput';
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Expose static helper methods.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
// Both "true" and an empty array [] represent a touched state. The Boolean
|
|
183
|
+
// conveniently handles both cases
|
|
184
|
+
CreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Expose react-select components for customization purposes.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
// custom
|
|
191
|
+
CreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
192
|
+
CreatableSelectInput.Control = reactSelect.components.Control;
|
|
193
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
194
|
+
CreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
195
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
196
|
+
CreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
197
|
+
// custom
|
|
198
|
+
CreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
199
|
+
CreatableSelectInput.Group = reactSelect.components.Group;
|
|
200
|
+
CreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
201
|
+
CreatableSelectInput.IndicatorSeparator = reactSelect.components.IndicatorSeparator;
|
|
202
|
+
CreatableSelectInput.IndicatorsContainer = reactSelect.components.IndicatorsContainer;
|
|
203
|
+
CreatableSelectInput.Input = reactSelect.components.Input;
|
|
204
|
+
CreatableSelectInput.LoadingIndicator = reactSelect.components.LoadingIndicator;
|
|
205
|
+
CreatableSelectInput.LoadingMessage = reactSelect.components.LoadingMessage;
|
|
206
|
+
CreatableSelectInput.Menu = reactSelect.components.Menu;
|
|
207
|
+
CreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
208
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
209
|
+
CreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
210
|
+
CreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
211
|
+
CreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
212
|
+
CreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
213
|
+
// custom
|
|
214
|
+
CreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
215
|
+
CreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
216
|
+
CreatableSelectInput.Option = reactSelect.components.Option;
|
|
217
|
+
CreatableSelectInput.Placeholder = reactSelect.components.Placeholder;
|
|
218
|
+
CreatableSelectInput.SelectContainer = reactSelect.components.SelectContainer;
|
|
219
|
+
CreatableSelectInput.SingleValue = reactSelect.components.SingleValue;
|
|
220
|
+
CreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
221
|
+
var CreatableSelectInput$1 = CreatableSelectInput;
|
|
222
|
+
|
|
223
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
224
|
+
var version = "19.25.1";
|
|
225
|
+
|
|
226
|
+
exports["default"] = CreatableSelectInput$1;
|
|
227
|
+
exports.version = version;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
|
+
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
|
+
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
4
|
+
import _Object$getOwnPropertyDescriptor from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor';
|
|
5
|
+
import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/for-each';
|
|
6
|
+
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
|
+
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
|
+
import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object/define-property';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
10
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/esm/objectWithoutProperties';
|
|
11
|
+
import _pt from 'prop-types';
|
|
12
|
+
import { useIntl } from 'react-intl';
|
|
13
|
+
import isEmpty from 'lodash/isEmpty';
|
|
14
|
+
import { components } from 'react-select';
|
|
15
|
+
import CreatableSelect from 'react-select/creatable';
|
|
16
|
+
import Constraints from '@commercetools-uikit/constraints';
|
|
17
|
+
import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
|
|
18
|
+
import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
19
|
+
import { jsx } from '@emotion/react/jsx-runtime';
|
|
20
|
+
|
|
21
|
+
const _excluded = ["value", "isSearchable", "menuPortalZIndex"];
|
|
22
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
+
const customizedComponents = {
|
|
25
|
+
DropdownIndicator,
|
|
26
|
+
ClearIndicator,
|
|
27
|
+
MultiValueRemove: TagRemove
|
|
28
|
+
};
|
|
29
|
+
const CreatableSelectInput = _ref => {
|
|
30
|
+
let _ref$value = _ref.value,
|
|
31
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
32
|
+
_ref$isSearchable = _ref.isSearchable,
|
|
33
|
+
isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
|
|
34
|
+
_ref$menuPortalZIndex = _ref.menuPortalZIndex,
|
|
35
|
+
menuPortalZIndex = _ref$menuPortalZIndex === void 0 ? 1 : _ref$menuPortalZIndex,
|
|
36
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
37
|
+
const intl = useIntl();
|
|
38
|
+
if (!props.isReadOnly) {
|
|
39
|
+
process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'CreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
40
|
+
}
|
|
41
|
+
const placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
42
|
+
return jsx(Constraints.Horizontal, {
|
|
43
|
+
max: props.horizontalConstraint,
|
|
44
|
+
children: jsx("div", _objectSpread(_objectSpread({}, filterDataAttributes(_objectSpread({
|
|
45
|
+
value,
|
|
46
|
+
isSearchable,
|
|
47
|
+
menuPortalZIndex
|
|
48
|
+
}, props))), {}, {
|
|
49
|
+
children: jsx(CreatableSelect, {
|
|
50
|
+
"aria-label": props['aria-label'],
|
|
51
|
+
"aria-labelledby": props['aria-labelledby'],
|
|
52
|
+
"aria-invalid": props['aria-invalid'],
|
|
53
|
+
"aria-errormessage": props['aria-errormessage'],
|
|
54
|
+
autoFocus: props.isAutofocussed,
|
|
55
|
+
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
56
|
+
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.components), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
57
|
+
Input: ownProps => jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
58
|
+
readOnly: true
|
|
59
|
+
}))
|
|
60
|
+
} : {}), props.components),
|
|
61
|
+
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
62
|
+
styles: createSelectStyles({
|
|
63
|
+
hasWarning: props.hasWarning,
|
|
64
|
+
hasError: props.hasError,
|
|
65
|
+
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
66
|
+
menuPortalZIndex: menuPortalZIndex,
|
|
67
|
+
isCondensed: props.isCondensed,
|
|
68
|
+
isDisabled: props.isDisabled,
|
|
69
|
+
isReadOnly: props.isReadOnly,
|
|
70
|
+
iconLeft: props.iconLeft,
|
|
71
|
+
isMulti: props.isMulti,
|
|
72
|
+
hasValue: !isEmpty(value),
|
|
73
|
+
horizontalConstraint: props.horizontalConstraint
|
|
74
|
+
}),
|
|
75
|
+
filterOption: props.filterOption
|
|
76
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
77
|
+
// but we use "id" (for the input) and "containerId" (for the container)
|
|
78
|
+
// instead.
|
|
79
|
+
// This makes it easier to less confusing to use with <label />s.
|
|
80
|
+
,
|
|
81
|
+
id: props.containerId,
|
|
82
|
+
inputId: props.id,
|
|
83
|
+
inputValue: props.inputValue,
|
|
84
|
+
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
85
|
+
isDisabled: props.isDisabled,
|
|
86
|
+
isOptionDisabled: props.isOptionDisabled,
|
|
87
|
+
isMulti: props.isMulti,
|
|
88
|
+
isSearchable: isSearchable,
|
|
89
|
+
maxMenuHeight: props.maxMenuHeight,
|
|
90
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
91
|
+
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
92
|
+
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
93
|
+
name: props.name,
|
|
94
|
+
noOptionsMessage: props.noOptionsMessage || (_ref2 => {
|
|
95
|
+
let inputValue = _ref2.inputValue;
|
|
96
|
+
return inputValue === '' ? intl.formatMessage(messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(messages.noOptionsMessageWithInputValue, {
|
|
97
|
+
inputValue
|
|
98
|
+
});
|
|
99
|
+
}),
|
|
100
|
+
onBlur: typeof props.onBlur === 'function' ? () => {
|
|
101
|
+
const event = {
|
|
102
|
+
target: {
|
|
103
|
+
id: props.id,
|
|
104
|
+
name: (() => {
|
|
105
|
+
if (!props.isMulti) return props.name;
|
|
106
|
+
// We append the ".0" to make Formik set the touched
|
|
107
|
+
// state as an array instead of a boolean only.
|
|
108
|
+
// Otherwise the shapes would clash on submission, as
|
|
109
|
+
// Formik will create an array on submission anyways.
|
|
110
|
+
return props.name ? `${props.name}.0` : undefined;
|
|
111
|
+
})()
|
|
112
|
+
},
|
|
113
|
+
persist: () => {}
|
|
114
|
+
};
|
|
115
|
+
props.onBlur && props.onBlur(event);
|
|
116
|
+
} : undefined,
|
|
117
|
+
onChange: (value, info) => {
|
|
118
|
+
// selectedOptions is either an array, or a single option, or null
|
|
119
|
+
// depending on whether we're in multi-mode or not (isMulti)
|
|
120
|
+
|
|
121
|
+
let newValue = value;
|
|
122
|
+
if (props.isMulti && !newValue) {
|
|
123
|
+
newValue = [];
|
|
124
|
+
}
|
|
125
|
+
props.onChange?.({
|
|
126
|
+
target: {
|
|
127
|
+
id: props.id,
|
|
128
|
+
name: props.name,
|
|
129
|
+
value: newValue
|
|
130
|
+
},
|
|
131
|
+
persist: () => {}
|
|
132
|
+
}, info);
|
|
133
|
+
},
|
|
134
|
+
onFocus: props.onFocus,
|
|
135
|
+
onInputChange: props.onInputChange,
|
|
136
|
+
options: props.options,
|
|
137
|
+
placeholder: placeholder,
|
|
138
|
+
tabIndex: props.tabIndex,
|
|
139
|
+
tabSelectsValue: props.tabSelectsValue,
|
|
140
|
+
value: value
|
|
141
|
+
// Creatable props
|
|
142
|
+
,
|
|
143
|
+
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
144
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(messages.createLabel, {
|
|
145
|
+
inputValue
|
|
146
|
+
})),
|
|
147
|
+
isValidNewOption: props.isValidNewOption,
|
|
148
|
+
getNewOptionData: props.getNewOptionData,
|
|
149
|
+
onCreateOption: props.onCreateOption,
|
|
150
|
+
createOptionPosition: props.createOptionPosition
|
|
151
|
+
//@ts-ignore
|
|
152
|
+
,
|
|
153
|
+
iconLeft: props.iconLeft,
|
|
154
|
+
isCondensed: props.isCondensed
|
|
155
|
+
})
|
|
156
|
+
}))
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
160
|
+
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
161
|
+
hasError: _pt.bool,
|
|
162
|
+
hasWarning: _pt.bool,
|
|
163
|
+
isReadOnly: _pt.bool,
|
|
164
|
+
iconLeft: _pt.node,
|
|
165
|
+
isAutofocussed: _pt.bool,
|
|
166
|
+
menuPortalZIndex: _pt.number,
|
|
167
|
+
onBlur: _pt.func,
|
|
168
|
+
onChange: _pt.func,
|
|
169
|
+
options: _pt.oneOfType([_pt.arrayOf(_pt.shape({
|
|
170
|
+
value: _pt.string.isRequired,
|
|
171
|
+
label: _pt.node
|
|
172
|
+
})), _pt.arrayOf(_pt.shape({
|
|
173
|
+
options: _pt.arrayOf(_pt.shape({
|
|
174
|
+
value: _pt.string.isRequired,
|
|
175
|
+
label: _pt.node
|
|
176
|
+
})).isRequired
|
|
177
|
+
}))]),
|
|
178
|
+
showOptionGroupDivider: _pt.bool,
|
|
179
|
+
isCondensed: _pt.bool
|
|
180
|
+
} : {};
|
|
181
|
+
CreatableSelectInput.displayName = 'CreatableSelectInput';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Expose static helper methods.
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
// Both "true" and an empty array [] represent a touched state. The Boolean
|
|
188
|
+
// conveniently handles both cases
|
|
189
|
+
CreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Expose react-select components for customization purposes.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
// custom
|
|
196
|
+
CreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
197
|
+
CreatableSelectInput.Control = components.Control;
|
|
198
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
199
|
+
CreatableSelectInput.CrossIcon = components.CrossIcon;
|
|
200
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
201
|
+
CreatableSelectInput.DownChevron = components.DownChevron;
|
|
202
|
+
// custom
|
|
203
|
+
CreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
204
|
+
CreatableSelectInput.Group = components.Group;
|
|
205
|
+
CreatableSelectInput.GroupHeading = components.GroupHeading;
|
|
206
|
+
CreatableSelectInput.IndicatorSeparator = components.IndicatorSeparator;
|
|
207
|
+
CreatableSelectInput.IndicatorsContainer = components.IndicatorsContainer;
|
|
208
|
+
CreatableSelectInput.Input = components.Input;
|
|
209
|
+
CreatableSelectInput.LoadingIndicator = components.LoadingIndicator;
|
|
210
|
+
CreatableSelectInput.LoadingMessage = components.LoadingMessage;
|
|
211
|
+
CreatableSelectInput.Menu = components.Menu;
|
|
212
|
+
CreatableSelectInput.MenuList = components.MenuList;
|
|
213
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
214
|
+
CreatableSelectInput.MenuPortal = components.MenuPortal;
|
|
215
|
+
CreatableSelectInput.MultiValue = components.MultiValue;
|
|
216
|
+
CreatableSelectInput.MultiValueContainer = components.MultiValueContainer;
|
|
217
|
+
CreatableSelectInput.MultiValueLabel = components.MultiValueLabel;
|
|
218
|
+
// custom
|
|
219
|
+
CreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
220
|
+
CreatableSelectInput.NoOptionsMessage = components.NoOptionsMessage;
|
|
221
|
+
CreatableSelectInput.Option = components.Option;
|
|
222
|
+
CreatableSelectInput.Placeholder = components.Placeholder;
|
|
223
|
+
CreatableSelectInput.SelectContainer = components.SelectContainer;
|
|
224
|
+
CreatableSelectInput.SingleValue = components.SingleValue;
|
|
225
|
+
CreatableSelectInput.ValueContainer = components.ValueContainer;
|
|
226
|
+
var CreatableSelectInput$1 = CreatableSelectInput;
|
|
227
|
+
|
|
228
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
229
|
+
var version = "19.25.1";
|
|
230
|
+
|
|
231
|
+
export { CreatableSelectInput$1 as default, version };
|