@commercetools-uikit/async-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.
@@ -0,0 +1,263 @@
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 AsyncSelect = require('react-select/async');
20
+ var utils = require('@commercetools-uikit/utils');
21
+ var Constraints = require('@commercetools-uikit/constraints');
22
+ var LoadingSpinner = require('@commercetools-uikit/loading-spinner');
23
+ var selectUtils = require('@commercetools-uikit/select-utils');
24
+ var icons = require('@commercetools-uikit/icons');
25
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
26
+
27
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
28
+
29
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
30
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
31
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
32
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
33
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
34
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
35
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
36
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
37
+ var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
38
+ var AsyncSelect__default = /*#__PURE__*/_interopDefault(AsyncSelect);
39
+ var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
40
+ var LoadingSpinner__default = /*#__PURE__*/_interopDefault(LoadingSpinner);
41
+
42
+ const _excluded = ["value", "isSearchable", "menuPortalZIndex", "controlShouldRenderValue", "appearance", "optionStyle"];
43
+ 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; }
44
+ 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; }
45
+ const LoadingIndicator = () => jsxRuntime.jsx(LoadingSpinner__default["default"], {
46
+ scale: "s"
47
+ });
48
+ LoadingIndicator.displayName = 'LoadingIndicator';
49
+ const customizedComponents = {
50
+ DropdownIndicator: selectUtils.DropdownIndicator,
51
+ ClearIndicator: selectUtils.ClearIndicator,
52
+ LoadingIndicator,
53
+ MultiValueRemove: selectUtils.TagRemove
54
+ };
55
+ const AsyncSelectInput = _ref => {
56
+ let _ref$value = _ref.value,
57
+ value = _ref$value === void 0 ? null : _ref$value,
58
+ _ref$isSearchable = _ref.isSearchable,
59
+ isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
60
+ _ref$menuPortalZIndex = _ref.menuPortalZIndex,
61
+ menuPortalZIndex = _ref$menuPortalZIndex === void 0 ? 1 : _ref$menuPortalZIndex,
62
+ _ref$controlShouldRen = _ref.controlShouldRenderValue,
63
+ controlShouldRenderValue = _ref$controlShouldRen === void 0 ? true : _ref$controlShouldRen,
64
+ _ref$appearance = _ref.appearance,
65
+ appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
66
+ _ref$optionStyle = _ref.optionStyle,
67
+ optionStyle = _ref$optionStyle === void 0 ? 'list' : _ref$optionStyle,
68
+ props = _objectWithoutProperties(_ref, _excluded);
69
+ const intl = reactIntl.useIntl();
70
+ if (!props.isReadOnly) ;
71
+ selectUtils.warnIfMenuPortalPropsAreMissing({
72
+ menuPortalZIndex: menuPortalZIndex,
73
+ menuPortalTarget: props.menuPortalTarget,
74
+ componentName: 'AsyncSelectInput'
75
+ });
76
+ const placeholder = props.placeholder || intl.formatMessage(appearance === 'filter' ? selectUtils.messages.selectInputAsFilterPlaceholder : selectUtils.messages.placeholder);
77
+ const loadingMessage = () => {
78
+ if (typeof props.loadingMessage === 'function') {
79
+ return props.loadingMessage();
80
+ }
81
+ return props.loadingMessage || intl.formatMessage(selectUtils.messages.loadingOptions);
82
+ };
83
+ return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
84
+ max: props.horizontalConstraint,
85
+ children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(_objectSpread({
86
+ value,
87
+ isSearchable,
88
+ menuPortalZIndex,
89
+ controlShouldRenderValue,
90
+ appearance,
91
+ optionStyle
92
+ }, props))), {}, {
93
+ children: jsxRuntime.jsx(AsyncSelect__default["default"], _objectSpread(_objectSpread({
94
+ "aria-label": props['aria-label'],
95
+ "aria-labelledby": props['aria-labelledby'],
96
+ "aria-invalid": props['aria-invalid'],
97
+ "aria-errormessage": props['aria-errormessage'],
98
+ autoFocus: props.isAutofocussed,
99
+ backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
100
+ components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
101
+ Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
102
+ readOnly: true
103
+ }))
104
+ } : {}), appearance === 'filter' && {
105
+ DropdownIndicator: () => jsxRuntime.jsx(icons.SearchIcon, {
106
+ color: "neutral60"
107
+ }),
108
+ ClearIndicator: null
109
+ }), optionStyle === 'checkbox' ? selectUtils.optionStyleCheckboxComponents(appearance) : {}), props.components),
110
+ menuIsOpen: props.isReadOnly ? false : appearance === 'filter' ? true : props.menuIsOpen,
111
+ styles: selectUtils.createSelectStyles({
112
+ hasWarning: props.hasWarning,
113
+ appearance: appearance,
114
+ hasError: props.hasError,
115
+ showOptionGroupDivider: props.showOptionGroupDivider,
116
+ menuPortalZIndex: menuPortalZIndex,
117
+ isCondensed: appearance === 'filter' ? true : props.isCondensed,
118
+ isDisabled: props.isDisabled,
119
+ isReadOnly: props.isReadOnly,
120
+ iconLeft: props.iconLeft,
121
+ isMulti: props.isMulti,
122
+ hasValue: !isEmpty__default["default"](value),
123
+ controlShouldRenderValue: controlShouldRenderValue,
124
+ horizontalConstraint: props.horizontalConstraint
125
+ }),
126
+ filterOption: props.filterOption
127
+ // react-select uses "id" (for the container) and "inputId" (for the input),
128
+ // but we use "id" (for the input) and "containerId" (for the container)
129
+ // instead.
130
+ // This makes it easier to less confusing to use with <label />s.
131
+ ,
132
+ id: props.containerId,
133
+ inputId: props.id,
134
+ inputValue: props.inputValue,
135
+ isClearable: props.isReadOnly ? false : props.isClearable,
136
+ isDisabled: props.isDisabled,
137
+ isOptionDisabled: props.isOptionDisabled
138
+ }, optionStyle === 'checkbox' ? selectUtils.optionsStyleCheckboxSelectProps() : {
139
+ hideSelectedOptions: props.hideSelectedOptions
140
+ }), {}, {
141
+ isMulti: props.isMulti,
142
+ isSearchable: isSearchable,
143
+ maxMenuHeight: props.maxMenuHeight,
144
+ menuPortalTarget: props.menuPortalTarget,
145
+ menuShouldBlockScroll: props.menuShouldBlockScroll,
146
+ closeMenuOnSelect: props.closeMenuOnSelect,
147
+ name: props.name,
148
+ loadingMessage: loadingMessage,
149
+ noOptionsMessage: props.noOptionsMessage || (_ref2 => {
150
+ let inputValue = _ref2.inputValue;
151
+ return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
152
+ inputValue
153
+ });
154
+ }),
155
+ onBlur: props.onBlur ? () => {
156
+ const event = {
157
+ target: {
158
+ id: props.id,
159
+ name: (() => {
160
+ if (!props.name) return undefined;
161
+ if (!props.isMulti) return props.name;
162
+ // We append the ".0" to make Formik set the touched
163
+ // state as an array instead of a boolean only.
164
+ // Otherwise the shapes would clash on submission, as
165
+ // Formik will create an array on submission anyways.
166
+ return `${props.name}.0`;
167
+ })()
168
+ },
169
+ persist: () => {}
170
+ };
171
+ props.onBlur && props.onBlur(event);
172
+ } : undefined,
173
+ onChange: (value, info) => {
174
+ let newValue = value;
175
+ if (props.isMulti && !newValue) {
176
+ newValue = [];
177
+ }
178
+ props.onChange?.({
179
+ target: {
180
+ id: props.id,
181
+ name: props.name,
182
+ value: newValue
183
+ },
184
+ persist: () => {}
185
+ }, info);
186
+ },
187
+ onFocus: props.onFocus,
188
+ onInputChange: props.onInputChange,
189
+ placeholder: placeholder,
190
+ tabIndex: props.tabIndex,
191
+ tabSelectsValue: props.tabSelectsValue,
192
+ value: value
193
+ // Async react-select props
194
+ ,
195
+ defaultOptions: props.defaultOptions,
196
+ loadOptions: props.loadOptions,
197
+ cacheOptions: props.cacheOptions
198
+ // Extra props
199
+ // @ts-ignore: passed to the react-select components via `selectProps`.
200
+ ,
201
+ isCondensed: props.isCondensed,
202
+ iconLeft: props.iconLeft,
203
+ controlShouldRenderValue: appearance === 'filter' ? false : controlShouldRenderValue
204
+ }))
205
+ }))
206
+ });
207
+ };
208
+ AsyncSelectInput.propTypes = {};
209
+ AsyncSelectInput.displayName = 'AsyncSelectInput';
210
+
211
+ /**
212
+ * Expose static helper methods.
213
+ */
214
+
215
+ // Formik will set the field to an array on submission, so we always have to
216
+ // deal with an array. The touched state ends up being an empty array in case
217
+ // values were removed only. So we have to treat any array we receive as
218
+ // a signal of the field having been touched.
219
+ AsyncSelectInput.isTouched = touched => Boolean(touched);
220
+
221
+ /**
222
+ * Expose react-select components for customization purposes.
223
+ */
224
+
225
+ // custom
226
+ AsyncSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
227
+ AsyncSelectInput.Control = reactSelect.components.Control;
228
+ //https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
229
+ AsyncSelectInput.CrossIcon = reactSelect.components.CrossIcon;
230
+ //https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
231
+ AsyncSelectInput.DownChevron = reactSelect.components.DownChevron;
232
+ // custom
233
+ AsyncSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
234
+ AsyncSelectInput.Group = reactSelect.components.Group;
235
+ AsyncSelectInput.GroupHeading = reactSelect.components.GroupHeading;
236
+ AsyncSelectInput.IndicatorSeparator = reactSelect.components.IndicatorSeparator;
237
+ AsyncSelectInput.IndicatorsContainer = reactSelect.components.IndicatorsContainer;
238
+ AsyncSelectInput.Input = reactSelect.components.Input;
239
+ // custom
240
+ AsyncSelectInput.LoadingIndicator = customizedComponents.LoadingIndicator;
241
+ AsyncSelectInput.LoadingMessage = reactSelect.components.LoadingMessage;
242
+ AsyncSelectInput.Menu = reactSelect.components.Menu;
243
+ AsyncSelectInput.MenuList = reactSelect.components.MenuList;
244
+ //https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
245
+ AsyncSelectInput.MenuPortal = reactSelect.components.MenuPortal;
246
+ AsyncSelectInput.MultiValue = reactSelect.components.MultiValue;
247
+ AsyncSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
248
+ AsyncSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
249
+ // custom
250
+ AsyncSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
251
+ AsyncSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
252
+ AsyncSelectInput.Option = reactSelect.components.Option;
253
+ AsyncSelectInput.Placeholder = reactSelect.components.Placeholder;
254
+ AsyncSelectInput.SelectContainer = reactSelect.components.SelectContainer;
255
+ AsyncSelectInput.SingleValue = reactSelect.components.SingleValue;
256
+ AsyncSelectInput.ValueContainer = reactSelect.components.ValueContainer;
257
+ var AsyncSelectInput$1 = AsyncSelectInput;
258
+
259
+ // NOTE: This string will be replaced on build time with the package version.
260
+ var version = "19.25.1";
261
+
262
+ exports["default"] = AsyncSelectInput$1;
263
+ exports.version = version;
@@ -0,0 +1,262 @@
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 AsyncSelect from 'react-select/async';
16
+ import { warning, filterDataAttributes } from '@commercetools-uikit/utils';
17
+ import Constraints from '@commercetools-uikit/constraints';
18
+ import LoadingSpinner from '@commercetools-uikit/loading-spinner';
19
+ import { warnIfMenuPortalPropsAreMissing, messages, customComponentsWithIcons, optionStyleCheckboxComponents, createSelectStyles, optionsStyleCheckboxSelectProps, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
20
+ import { SearchIcon } from '@commercetools-uikit/icons';
21
+ import { jsx } from '@emotion/react/jsx-runtime';
22
+
23
+ const _excluded = ["value", "isSearchable", "menuPortalZIndex", "controlShouldRenderValue", "appearance", "optionStyle"];
24
+ 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; }
25
+ 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; }
26
+ const LoadingIndicator = () => jsx(LoadingSpinner, {
27
+ scale: "s"
28
+ });
29
+ LoadingIndicator.displayName = 'LoadingIndicator';
30
+ const customizedComponents = {
31
+ DropdownIndicator,
32
+ ClearIndicator,
33
+ LoadingIndicator,
34
+ MultiValueRemove: TagRemove
35
+ };
36
+ const AsyncSelectInput = _ref => {
37
+ let _ref$value = _ref.value,
38
+ value = _ref$value === void 0 ? null : _ref$value,
39
+ _ref$isSearchable = _ref.isSearchable,
40
+ isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
41
+ _ref$menuPortalZIndex = _ref.menuPortalZIndex,
42
+ menuPortalZIndex = _ref$menuPortalZIndex === void 0 ? 1 : _ref$menuPortalZIndex,
43
+ _ref$controlShouldRen = _ref.controlShouldRenderValue,
44
+ controlShouldRenderValue = _ref$controlShouldRen === void 0 ? true : _ref$controlShouldRen,
45
+ _ref$appearance = _ref.appearance,
46
+ appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
47
+ _ref$optionStyle = _ref.optionStyle,
48
+ optionStyle = _ref$optionStyle === void 0 ? 'list' : _ref$optionStyle,
49
+ props = _objectWithoutProperties(_ref, _excluded);
50
+ const intl = useIntl();
51
+ if (!props.isReadOnly) {
52
+ process.env.NODE_ENV !== "production" ? warning(typeof props.onChange === 'function', 'AsyncSelectInput: `onChange` is required when input is not read only.') : void 0;
53
+ }
54
+ warnIfMenuPortalPropsAreMissing({
55
+ menuPortalZIndex: menuPortalZIndex,
56
+ menuPortalTarget: props.menuPortalTarget,
57
+ componentName: 'AsyncSelectInput'
58
+ });
59
+ const placeholder = props.placeholder || intl.formatMessage(appearance === 'filter' ? messages.selectInputAsFilterPlaceholder : messages.placeholder);
60
+ const loadingMessage = () => {
61
+ if (typeof props.loadingMessage === 'function') {
62
+ return props.loadingMessage();
63
+ }
64
+ return props.loadingMessage || intl.formatMessage(messages.loadingOptions);
65
+ };
66
+ return jsx(Constraints.Horizontal, {
67
+ max: props.horizontalConstraint,
68
+ children: jsx("div", _objectSpread(_objectSpread({}, filterDataAttributes(_objectSpread({
69
+ value,
70
+ isSearchable,
71
+ menuPortalZIndex,
72
+ controlShouldRenderValue,
73
+ appearance,
74
+ optionStyle
75
+ }, props))), {}, {
76
+ children: jsx(AsyncSelect, _objectSpread(_objectSpread({
77
+ "aria-label": props['aria-label'],
78
+ "aria-labelledby": props['aria-labelledby'],
79
+ "aria-invalid": props['aria-invalid'],
80
+ "aria-errormessage": props['aria-errormessage'],
81
+ autoFocus: props.isAutofocussed,
82
+ backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
83
+ components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
84
+ Input: ownProps => jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
85
+ readOnly: true
86
+ }))
87
+ } : {}), appearance === 'filter' && {
88
+ DropdownIndicator: () => jsx(SearchIcon, {
89
+ color: "neutral60"
90
+ }),
91
+ ClearIndicator: null
92
+ }), optionStyle === 'checkbox' ? optionStyleCheckboxComponents(appearance) : {}), props.components),
93
+ menuIsOpen: props.isReadOnly ? false : appearance === 'filter' ? true : props.menuIsOpen,
94
+ styles: createSelectStyles({
95
+ hasWarning: props.hasWarning,
96
+ appearance: appearance,
97
+ hasError: props.hasError,
98
+ showOptionGroupDivider: props.showOptionGroupDivider,
99
+ menuPortalZIndex: menuPortalZIndex,
100
+ isCondensed: appearance === 'filter' ? true : props.isCondensed,
101
+ isDisabled: props.isDisabled,
102
+ isReadOnly: props.isReadOnly,
103
+ iconLeft: props.iconLeft,
104
+ isMulti: props.isMulti,
105
+ hasValue: !isEmpty(value),
106
+ controlShouldRenderValue: controlShouldRenderValue,
107
+ horizontalConstraint: props.horizontalConstraint
108
+ }),
109
+ filterOption: props.filterOption
110
+ // react-select uses "id" (for the container) and "inputId" (for the input),
111
+ // but we use "id" (for the input) and "containerId" (for the container)
112
+ // instead.
113
+ // This makes it easier to less confusing to use with <label />s.
114
+ ,
115
+ id: props.containerId,
116
+ inputId: props.id,
117
+ inputValue: props.inputValue,
118
+ isClearable: props.isReadOnly ? false : props.isClearable,
119
+ isDisabled: props.isDisabled,
120
+ isOptionDisabled: props.isOptionDisabled
121
+ }, optionStyle === 'checkbox' ? optionsStyleCheckboxSelectProps() : {
122
+ hideSelectedOptions: props.hideSelectedOptions
123
+ }), {}, {
124
+ isMulti: props.isMulti,
125
+ isSearchable: isSearchable,
126
+ maxMenuHeight: props.maxMenuHeight,
127
+ menuPortalTarget: props.menuPortalTarget,
128
+ menuShouldBlockScroll: props.menuShouldBlockScroll,
129
+ closeMenuOnSelect: props.closeMenuOnSelect,
130
+ name: props.name,
131
+ loadingMessage: loadingMessage,
132
+ noOptionsMessage: props.noOptionsMessage || (_ref2 => {
133
+ let inputValue = _ref2.inputValue;
134
+ return inputValue === '' ? intl.formatMessage(messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(messages.noOptionsMessageWithInputValue, {
135
+ inputValue
136
+ });
137
+ }),
138
+ onBlur: props.onBlur ? () => {
139
+ const event = {
140
+ target: {
141
+ id: props.id,
142
+ name: (() => {
143
+ if (!props.name) return undefined;
144
+ if (!props.isMulti) return props.name;
145
+ // We append the ".0" to make Formik set the touched
146
+ // state as an array instead of a boolean only.
147
+ // Otherwise the shapes would clash on submission, as
148
+ // Formik will create an array on submission anyways.
149
+ return `${props.name}.0`;
150
+ })()
151
+ },
152
+ persist: () => {}
153
+ };
154
+ props.onBlur && props.onBlur(event);
155
+ } : undefined,
156
+ onChange: (value, info) => {
157
+ let newValue = value;
158
+ if (props.isMulti && !newValue) {
159
+ newValue = [];
160
+ }
161
+ props.onChange?.({
162
+ target: {
163
+ id: props.id,
164
+ name: props.name,
165
+ value: newValue
166
+ },
167
+ persist: () => {}
168
+ }, info);
169
+ },
170
+ onFocus: props.onFocus,
171
+ onInputChange: props.onInputChange,
172
+ placeholder: placeholder,
173
+ tabIndex: props.tabIndex,
174
+ tabSelectsValue: props.tabSelectsValue,
175
+ value: value
176
+ // Async react-select props
177
+ ,
178
+ defaultOptions: props.defaultOptions,
179
+ loadOptions: props.loadOptions,
180
+ cacheOptions: props.cacheOptions
181
+ // Extra props
182
+ // @ts-ignore: passed to the react-select components via `selectProps`.
183
+ ,
184
+ isCondensed: props.isCondensed,
185
+ iconLeft: props.iconLeft,
186
+ controlShouldRenderValue: appearance === 'filter' ? false : controlShouldRenderValue
187
+ }))
188
+ }))
189
+ });
190
+ };
191
+ AsyncSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
192
+ horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
193
+ hasError: _pt.bool,
194
+ hasWarning: _pt.bool,
195
+ isReadOnly: _pt.bool,
196
+ isAutofocussed: _pt.bool,
197
+ isCondensed: _pt.bool,
198
+ menuPortalZIndex: _pt.number,
199
+ onBlur: _pt.func,
200
+ onChange: _pt.func,
201
+ loadingMessage: _pt.oneOfType([_pt.string, _pt.func]),
202
+ defaultOptions: _pt.oneOfType([_pt.any, _pt.bool]),
203
+ showOptionGroupDivider: _pt.bool,
204
+ iconLeft: _pt.node,
205
+ optionStyle: _pt.oneOf(['list', 'checkbox']),
206
+ appearance: _pt.oneOf(['default', 'filter']),
207
+ count: _pt.number
208
+ } : {};
209
+ AsyncSelectInput.displayName = 'AsyncSelectInput';
210
+
211
+ /**
212
+ * Expose static helper methods.
213
+ */
214
+
215
+ // Formik will set the field to an array on submission, so we always have to
216
+ // deal with an array. The touched state ends up being an empty array in case
217
+ // values were removed only. So we have to treat any array we receive as
218
+ // a signal of the field having been touched.
219
+ AsyncSelectInput.isTouched = touched => Boolean(touched);
220
+
221
+ /**
222
+ * Expose react-select components for customization purposes.
223
+ */
224
+
225
+ // custom
226
+ AsyncSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
227
+ AsyncSelectInput.Control = components.Control;
228
+ //https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
229
+ AsyncSelectInput.CrossIcon = components.CrossIcon;
230
+ //https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
231
+ AsyncSelectInput.DownChevron = components.DownChevron;
232
+ // custom
233
+ AsyncSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
234
+ AsyncSelectInput.Group = components.Group;
235
+ AsyncSelectInput.GroupHeading = components.GroupHeading;
236
+ AsyncSelectInput.IndicatorSeparator = components.IndicatorSeparator;
237
+ AsyncSelectInput.IndicatorsContainer = components.IndicatorsContainer;
238
+ AsyncSelectInput.Input = components.Input;
239
+ // custom
240
+ AsyncSelectInput.LoadingIndicator = customizedComponents.LoadingIndicator;
241
+ AsyncSelectInput.LoadingMessage = components.LoadingMessage;
242
+ AsyncSelectInput.Menu = components.Menu;
243
+ AsyncSelectInput.MenuList = components.MenuList;
244
+ //https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
245
+ AsyncSelectInput.MenuPortal = components.MenuPortal;
246
+ AsyncSelectInput.MultiValue = components.MultiValue;
247
+ AsyncSelectInput.MultiValueContainer = components.MultiValueContainer;
248
+ AsyncSelectInput.MultiValueLabel = components.MultiValueLabel;
249
+ // custom
250
+ AsyncSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
251
+ AsyncSelectInput.NoOptionsMessage = components.NoOptionsMessage;
252
+ AsyncSelectInput.Option = components.Option;
253
+ AsyncSelectInput.Placeholder = components.Placeholder;
254
+ AsyncSelectInput.SelectContainer = components.SelectContainer;
255
+ AsyncSelectInput.SingleValue = components.SingleValue;
256
+ AsyncSelectInput.ValueContainer = components.ValueContainer;
257
+ var AsyncSelectInput$1 = AsyncSelectInput;
258
+
259
+ // NOTE: This string will be replaced on build time with the package version.
260
+ var version = "19.25.1";
261
+
262
+ export { AsyncSelectInput$1 as default, version };