@commercetools-uikit/async-creatable-select-input 12.2.5 → 13.0.0
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 +60 -47
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.dev.js +44 -260
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.prod.js +29 -20
- package/dist/commercetools-uikit-async-creatable-select-input.esm.js +42 -259
- package/dist/declarations/src/async-creatable-select-input.d.ts +64 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +16 -23
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
require('prop-types');
|
|
7
|
+
require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
5
8
|
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
9
|
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
7
10
|
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
@@ -10,10 +13,8 @@ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/in
|
|
|
10
13
|
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
14
|
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
15
|
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
-
require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
15
|
-
require('prop-types');
|
|
16
16
|
var reactIntl = require('react-intl');
|
|
17
|
+
var isEmpty = require('lodash/isEmpty');
|
|
17
18
|
var react = require('@emotion/react');
|
|
18
19
|
var reactSelect = require('react-select');
|
|
19
20
|
var AsyncCreatableSelect = require('react-select/async-creatable');
|
|
@@ -33,13 +34,14 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
33
34
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
34
35
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
35
36
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
37
|
+
var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
|
|
36
38
|
var AsyncCreatableSelect__default = /*#__PURE__*/_interopDefault(AsyncCreatableSelect);
|
|
37
39
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
38
40
|
var LoadingSpinner__default = /*#__PURE__*/_interopDefault(LoadingSpinner);
|
|
39
41
|
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
42
|
+
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
43
|
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
43
45
|
|
|
44
46
|
var LoadingIndicator = function LoadingIndicator() {
|
|
45
47
|
return jsxRuntime.jsx(LoadingSpinner__default["default"], {
|
|
@@ -54,11 +56,21 @@ var customizedComponents = {
|
|
|
54
56
|
LoadingIndicator: LoadingIndicator,
|
|
55
57
|
MultiValueRemove: selectUtils.TagRemove
|
|
56
58
|
};
|
|
59
|
+
var defaultProps = {
|
|
60
|
+
// Using "null" will ensure that the currently selected value disappears in
|
|
61
|
+
// case "undefined" gets passed as the next value
|
|
62
|
+
value: null,
|
|
63
|
+
isSearchable: true,
|
|
64
|
+
menuPortalZIndex: 1
|
|
65
|
+
};
|
|
57
66
|
|
|
58
67
|
var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
59
68
|
var intl = reactIntl.useIntl();
|
|
60
69
|
var theme = react.useTheme();
|
|
61
70
|
var placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
71
|
+
|
|
72
|
+
if (props.isMulti) ;
|
|
73
|
+
|
|
62
74
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
63
75
|
max: props.horizontalConstraint,
|
|
64
76
|
children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(props)), {}, {
|
|
@@ -68,7 +80,6 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
68
80
|
autoFocus: props.isAutofocussed,
|
|
69
81
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
70
82
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
71
|
-
// eslint-disable-next-line react/display-name
|
|
72
83
|
Input: function Input(ownProps) {
|
|
73
84
|
return jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
74
85
|
readOnly: true
|
|
@@ -82,7 +93,10 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
82
93
|
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
83
94
|
menuPortalZIndex: props.menuPortalZIndex,
|
|
84
95
|
isDisabled: props.isDisabled,
|
|
85
|
-
isReadOnly: props.isReadOnly
|
|
96
|
+
isReadOnly: props.isReadOnly,
|
|
97
|
+
iconLeft: props.iconLeft,
|
|
98
|
+
isMulti: props.isMulti,
|
|
99
|
+
hasValue: !isEmpty__default["default"](props.value)
|
|
86
100
|
}, theme),
|
|
87
101
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
88
102
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -100,6 +114,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
100
114
|
maxMenuHeight: props.maxMenuHeight,
|
|
101
115
|
menuPortalTarget: props.menuPortalTarget,
|
|
102
116
|
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
117
|
+
closeMenuOnScroll: props.closeMenuOnSelect,
|
|
103
118
|
name: props.name,
|
|
104
119
|
noOptionsMessage: props.noOptionsMessage || function (_ref) {
|
|
105
120
|
var inputValue = _ref.inputValue;
|
|
@@ -120,10 +135,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
120
135
|
return "".concat(props.name, ".0");
|
|
121
136
|
}()
|
|
122
137
|
},
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
124
138
|
persist: function persist() {}
|
|
125
139
|
};
|
|
126
|
-
props.onBlur(event);
|
|
140
|
+
props.onBlur && props.onBlur(event);
|
|
127
141
|
} : undefined,
|
|
128
142
|
onChange: function onChange(value, info) {
|
|
129
143
|
// wrapping breaking changes made in react-select v3
|
|
@@ -138,7 +152,6 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
138
152
|
name: props.name,
|
|
139
153
|
value: newValue
|
|
140
154
|
},
|
|
141
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
142
155
|
persist: function persist() {}
|
|
143
156
|
}, info);
|
|
144
157
|
},
|
|
@@ -162,7 +175,8 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
162
175
|
isValidNewOption: props.isValidNewOption,
|
|
163
176
|
getNewOptionData: props.getNewOptionData,
|
|
164
177
|
onCreateOption: props.onCreateOption,
|
|
165
|
-
createOptionPosition: props.createOptionPosition
|
|
178
|
+
createOptionPosition: props.createOptionPosition // @ts-ignore
|
|
179
|
+
,
|
|
166
180
|
iconLeft: props.iconLeft
|
|
167
181
|
})
|
|
168
182
|
}))
|
|
@@ -173,26 +187,21 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
173
187
|
// a signal of the field having been touched.
|
|
174
188
|
|
|
175
189
|
|
|
190
|
+
AsyncCreatableSelectInput.propTypes = {};
|
|
191
|
+
|
|
176
192
|
AsyncCreatableSelectInput.isTouched = function (touched) {
|
|
177
193
|
return Boolean(touched);
|
|
178
194
|
};
|
|
179
195
|
|
|
180
196
|
AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
|
|
181
|
-
AsyncCreatableSelectInput.defaultProps =
|
|
182
|
-
// Using "null" will ensure that the currently selected value disappears in
|
|
183
|
-
// case "undefined" gets passed as the next value
|
|
184
|
-
value: null,
|
|
185
|
-
isSearchable: true,
|
|
186
|
-
menuPortalZIndex: 1
|
|
187
|
-
};
|
|
188
|
-
AsyncCreatableSelectInput.propTypes = {};
|
|
197
|
+
AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
189
198
|
utils.addStaticFields(AsyncCreatableSelectInput, _objectSpread(_objectSpread(_objectSpread({}, reactSelect.components), customizedComponents), {}, {
|
|
190
199
|
isTouched: AsyncCreatableSelectInput.isTouched
|
|
191
200
|
}));
|
|
192
201
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
193
202
|
|
|
194
203
|
// NOTE: This string will be replaced on build time with the package version.
|
|
195
|
-
var version = "
|
|
204
|
+
var version = "13.0.0";
|
|
196
205
|
|
|
197
206
|
exports["default"] = AsyncCreatableSelectInput$1;
|
|
198
207
|
exports.version = version;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
2
|
+
import _pt from 'prop-types';
|
|
3
|
+
import _Array$isArray from '@babel/runtime-corejs3/core-js-stable/array/is-array';
|
|
1
4
|
import _Object$keys from '@babel/runtime-corejs3/core-js-stable/object/keys';
|
|
2
5
|
import _Object$getOwnPropertySymbols from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols';
|
|
3
6
|
import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
|
|
@@ -6,22 +9,20 @@ import _forEachInstanceProperty from '@babel/runtime-corejs3/core-js-stable/inst
|
|
|
6
9
|
import _Object$getOwnPropertyDescriptors from '@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors';
|
|
7
10
|
import _Object$defineProperties from '@babel/runtime-corejs3/core-js-stable/object/define-properties';
|
|
8
11
|
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 _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
11
|
-
import PropTypes from 'prop-types';
|
|
12
12
|
import { useIntl } from 'react-intl';
|
|
13
|
+
import isEmpty from 'lodash/isEmpty';
|
|
13
14
|
import { useTheme } from '@emotion/react';
|
|
14
15
|
import { components } from 'react-select';
|
|
15
16
|
import AsyncCreatableSelect from 'react-select/async-creatable';
|
|
16
17
|
import Constraints from '@commercetools-uikit/constraints';
|
|
17
18
|
import LoadingSpinner from '@commercetools-uikit/loading-spinner';
|
|
18
19
|
import { messages, customComponentsWithIcons, createSelectStyles, DropdownIndicator, ClearIndicator, TagRemove } from '@commercetools-uikit/select-utils';
|
|
19
|
-
import {
|
|
20
|
+
import { warning, filterDataAttributes, addStaticFields } from '@commercetools-uikit/utils';
|
|
20
21
|
import { jsx } from '@emotion/react/jsx-runtime';
|
|
21
22
|
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object);
|
|
23
|
+
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; }
|
|
23
24
|
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
25
26
|
|
|
26
27
|
var LoadingIndicator = function LoadingIndicator() {
|
|
27
28
|
return jsx(LoadingSpinner, {
|
|
@@ -36,11 +37,23 @@ var customizedComponents = {
|
|
|
36
37
|
LoadingIndicator: LoadingIndicator,
|
|
37
38
|
MultiValueRemove: TagRemove
|
|
38
39
|
};
|
|
40
|
+
var defaultProps = {
|
|
41
|
+
// Using "null" will ensure that the currently selected value disappears in
|
|
42
|
+
// case "undefined" gets passed as the next value
|
|
43
|
+
value: null,
|
|
44
|
+
isSearchable: true,
|
|
45
|
+
menuPortalZIndex: 1
|
|
46
|
+
};
|
|
39
47
|
|
|
40
48
|
var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
41
49
|
var intl = useIntl();
|
|
42
50
|
var theme = useTheme();
|
|
43
51
|
var placeholder = props.placeholder || intl.formatMessage(messages.placeholder);
|
|
52
|
+
|
|
53
|
+
if (props.isMulti) {
|
|
54
|
+
process.env.NODE_ENV !== "production" ? warning(_Array$isArray(props.value), 'AsyncCreatableSelectInput: `value` is expected to be an array when isMulti is true') : void 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
44
57
|
return jsx(Constraints.Horizontal, {
|
|
45
58
|
max: props.horizontalConstraint,
|
|
46
59
|
children: jsx("div", _objectSpread(_objectSpread({}, filterDataAttributes(props)), {}, {
|
|
@@ -50,7 +63,6 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
50
63
|
autoFocus: props.isAutofocussed,
|
|
51
64
|
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
52
65
|
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
53
|
-
// eslint-disable-next-line react/display-name
|
|
54
66
|
Input: function Input(ownProps) {
|
|
55
67
|
return jsx(components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
56
68
|
readOnly: true
|
|
@@ -64,7 +76,10 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
64
76
|
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
65
77
|
menuPortalZIndex: props.menuPortalZIndex,
|
|
66
78
|
isDisabled: props.isDisabled,
|
|
67
|
-
isReadOnly: props.isReadOnly
|
|
79
|
+
isReadOnly: props.isReadOnly,
|
|
80
|
+
iconLeft: props.iconLeft,
|
|
81
|
+
isMulti: props.isMulti,
|
|
82
|
+
hasValue: !isEmpty(props.value)
|
|
68
83
|
}, theme),
|
|
69
84
|
filterOption: props.filterOption // react-select uses "id" (for the container) and "inputId" (for the input),
|
|
70
85
|
// but we use "id" (for the input) and "containerId" (for the container)
|
|
@@ -82,6 +97,7 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
82
97
|
maxMenuHeight: props.maxMenuHeight,
|
|
83
98
|
menuPortalTarget: props.menuPortalTarget,
|
|
84
99
|
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
100
|
+
closeMenuOnScroll: props.closeMenuOnSelect,
|
|
85
101
|
name: props.name,
|
|
86
102
|
noOptionsMessage: props.noOptionsMessage || function (_ref) {
|
|
87
103
|
var inputValue = _ref.inputValue;
|
|
@@ -102,10 +118,9 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
102
118
|
return "".concat(props.name, ".0");
|
|
103
119
|
}()
|
|
104
120
|
},
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
106
121
|
persist: function persist() {}
|
|
107
122
|
};
|
|
108
|
-
props.onBlur(event);
|
|
123
|
+
props.onBlur && props.onBlur(event);
|
|
109
124
|
} : undefined,
|
|
110
125
|
onChange: function onChange(value, info) {
|
|
111
126
|
// wrapping breaking changes made in react-select v3
|
|
@@ -120,7 +135,6 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
120
135
|
name: props.name,
|
|
121
136
|
value: newValue
|
|
122
137
|
},
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
124
138
|
persist: function persist() {}
|
|
125
139
|
}, info);
|
|
126
140
|
},
|
|
@@ -144,7 +158,8 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
144
158
|
isValidNewOption: props.isValidNewOption,
|
|
145
159
|
getNewOptionData: props.getNewOptionData,
|
|
146
160
|
onCreateOption: props.onCreateOption,
|
|
147
|
-
createOptionPosition: props.createOptionPosition
|
|
161
|
+
createOptionPosition: props.createOptionPosition // @ts-ignore
|
|
162
|
+
,
|
|
148
163
|
iconLeft: props.iconLeft
|
|
149
164
|
})
|
|
150
165
|
}))
|
|
@@ -155,263 +170,31 @@ var AsyncCreatableSelectInput = function AsyncCreatableSelectInput(props) {
|
|
|
155
170
|
// a signal of the field having been touched.
|
|
156
171
|
|
|
157
172
|
|
|
173
|
+
AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
174
|
+
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
175
|
+
hasError: _pt.bool,
|
|
176
|
+
hasWarning: _pt.bool,
|
|
177
|
+
isReadOnly: _pt.bool,
|
|
178
|
+
iconLeft: _pt.node,
|
|
179
|
+
isAutofocussed: _pt.bool,
|
|
180
|
+
menuPortalZIndex: _pt.number.isRequired,
|
|
181
|
+
onBlur: _pt.func,
|
|
182
|
+
onChange: _pt.func.isRequired,
|
|
183
|
+
showOptionGroupDivider: _pt.bool
|
|
184
|
+
} : {};
|
|
185
|
+
|
|
158
186
|
AsyncCreatableSelectInput.isTouched = function (touched) {
|
|
159
187
|
return Boolean(touched);
|
|
160
188
|
};
|
|
161
189
|
|
|
162
190
|
AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
|
|
163
|
-
AsyncCreatableSelectInput.defaultProps =
|
|
164
|
-
// Using "null" will ensure that the currently selected value disappears in
|
|
165
|
-
// case "undefined" gets passed as the next value
|
|
166
|
-
value: null,
|
|
167
|
-
isSearchable: true,
|
|
168
|
-
menuPortalZIndex: 1
|
|
169
|
-
};
|
|
170
|
-
AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
171
|
-
/**
|
|
172
|
-
* Horizontal size limit of the input fields.
|
|
173
|
-
*/
|
|
174
|
-
horizontalConstraint: PropTypes.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Indicates the input field has an error
|
|
178
|
-
*/
|
|
179
|
-
hasError: PropTypes.bool,
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Indicates the input field has a warning
|
|
183
|
-
*/
|
|
184
|
-
hasWarning: PropTypes.bool,
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Is the select read-only
|
|
188
|
-
*/
|
|
189
|
-
isReadOnly: PropTypes.bool,
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled.
|
|
193
|
-
*/
|
|
194
|
-
iconLeft: PropTypes.node,
|
|
195
|
-
// react-select base props
|
|
196
|
-
//
|
|
197
|
-
// Currently unsupported props are commented out. In case you need one of
|
|
198
|
-
// these props when using UI Kit, you can submit a PR and enable the
|
|
199
|
-
// prop. Don't forget to add it to the story, docs and other select input
|
|
200
|
-
// components as well!
|
|
201
|
-
//
|
|
202
|
-
// See https://react-select.com/props#select-props
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Aria label (for assistive tech)
|
|
206
|
-
*/
|
|
207
|
-
'aria-label': PropTypes.string,
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* HTML ID of an element that should be used as the label (for assistive tech)
|
|
211
|
-
*/
|
|
212
|
-
'aria-labelledby': PropTypes.string,
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Focus the control when it is mounted
|
|
216
|
-
*/
|
|
217
|
-
isAutofocussed: PropTypes.bool,
|
|
218
|
-
// original: autoFocus
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Remove the currently focused option when the user presses backspace
|
|
222
|
-
*/
|
|
223
|
-
backspaceRemovesValue: PropTypes.bool,
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Map of components to overwrite the default ones, see [what components you can override](https://react-select.com/components)
|
|
227
|
-
*/
|
|
228
|
-
components: PropTypes.objectOf(PropTypes.func),
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Custom method to filter whether an option should be displayed in the menu
|
|
232
|
-
*/
|
|
233
|
-
filterOption: PropTypes.func,
|
|
234
|
-
// This forwarded as react-select's "inputId"
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* The id of the search input
|
|
238
|
-
*/
|
|
239
|
-
id: PropTypes.string,
|
|
240
|
-
// This is forwarded as react-select's "id"
|
|
241
|
-
inputValue: PropTypes.string,
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* The id to set on the SelectContainer component
|
|
245
|
-
*/
|
|
246
|
-
containerId: PropTypes.string,
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Is the select value clearable
|
|
250
|
-
*/
|
|
251
|
-
isClearable: PropTypes.bool,
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Is the select disabled
|
|
255
|
-
*/
|
|
256
|
-
isDisabled: PropTypes.bool,
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Override the built-in logic to detect whether an option is disabled
|
|
260
|
-
*/
|
|
261
|
-
isOptionDisabled: PropTypes.func,
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Support multiple selected options
|
|
265
|
-
*/
|
|
266
|
-
isMulti: PropTypes.bool,
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Whether to enable search functionality
|
|
270
|
-
*/
|
|
271
|
-
isSearchable: PropTypes.bool,
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Maximum height of the menu before scrolling
|
|
275
|
-
*/
|
|
276
|
-
maxMenuHeight: PropTypes.number,
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Dom element to portal the select menu to
|
|
280
|
-
*/
|
|
281
|
-
menuPortalTarget: PropTypes.instanceOf(SafeHTMLElement),
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* z-index value for the menu portal
|
|
285
|
-
*/
|
|
286
|
-
menuPortalZIndex: PropTypes.number.isRequired,
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* whether the menu should block scroll while open
|
|
290
|
-
*/
|
|
291
|
-
menuShouldBlockScroll: PropTypes.bool,
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* Name of the HTML Input (optional - without this, no input will be rendered)
|
|
295
|
-
*/
|
|
296
|
-
name: PropTypes.string,
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Can be used to render a custom value when there are no options (either because of no search results, or all options have been used, or there were none in the first place). Gets called with `{ inputValue: String }`. `inputValue` will be an empty string when no search text is present.
|
|
300
|
-
*/
|
|
301
|
-
noOptionsMessage: PropTypes.func,
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Handle blur events on the control
|
|
305
|
-
*/
|
|
306
|
-
onBlur: PropTypes.func,
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Called with a fake event when value changes. The event's `target.name` will be the `name` supplied in props. The event's `target.value` will hold the value. The value will be the selected option, or an array of options in case `isMulti` is `true`.
|
|
310
|
-
*/
|
|
311
|
-
onChange: PropTypes.func.isRequired,
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Handle focus events on the control
|
|
315
|
-
*/
|
|
316
|
-
onFocus: PropTypes.func,
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Handle change events on the input
|
|
320
|
-
*/
|
|
321
|
-
onInputChange: PropTypes.func,
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Placeholder text for the select value
|
|
325
|
-
*/
|
|
326
|
-
placeholder: PropTypes.string,
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Sets the tabIndex attribute on the input
|
|
330
|
-
*/
|
|
331
|
-
tabIndex: PropTypes.string,
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Select the currently focused option when the user presses tab
|
|
335
|
-
*/
|
|
336
|
-
tabSelectsValue: PropTypes.bool,
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* The value of the select; reflected by the selected option
|
|
340
|
-
*/
|
|
341
|
-
value: function value(props) {
|
|
342
|
-
var _context, _context2;
|
|
343
|
-
|
|
344
|
-
for (var _len = arguments.length, rest = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
345
|
-
rest[_key - 1] = arguments[_key];
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return props.isMulti ? PropTypes.arrayOf(PropTypes.shape({
|
|
349
|
-
value: PropTypes.string.isRequired
|
|
350
|
-
})).apply(void 0, _concatInstanceProperty(_context = [props]).call(_context, rest)) : PropTypes.shape({
|
|
351
|
-
value: PropTypes.string.isRequired
|
|
352
|
-
}).apply(void 0, _concatInstanceProperty(_context2 = [props]).call(_context2, rest));
|
|
353
|
-
},
|
|
354
|
-
// Async props
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* The default set of options to show before the user starts searching. When set to true, the results for loadOptions('') will be autoloaded.
|
|
358
|
-
*/
|
|
359
|
-
defaultOptions: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.shape({
|
|
360
|
-
value: PropTypes.string.isRequired
|
|
361
|
-
}))]),
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Function that returns a promise, which is the set of options to be used once the promise resolves.
|
|
365
|
-
*/
|
|
366
|
-
loadOptions: PropTypes.func.isRequired,
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* If cacheOptions is truthy, then the loaded data will be cached. The cache will remain until cacheOptions changes value.
|
|
370
|
-
*/
|
|
371
|
-
cacheOptions: PropTypes.any,
|
|
372
|
-
// Creatable props
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Allow options to be created while the isLoading prop is true. Useful to prevent the "create new ..." option being displayed while async results are still being loaded.
|
|
376
|
-
*/
|
|
377
|
-
allowCreateWhileLoading: PropTypes.bool,
|
|
378
|
-
|
|
379
|
-
/**
|
|
380
|
-
* Gets the label for the "create new ..." option in the menu. Is given the current input value.
|
|
381
|
-
*/
|
|
382
|
-
formatCreateLabel: PropTypes.func,
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Determines whether the "create new ..." option should be displayed based on the current input value, select value and options array.
|
|
386
|
-
*/
|
|
387
|
-
isValidNewOption: PropTypes.func,
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Returns the data for the new option when it is created. Used to display the value, and is passed to onChange.
|
|
391
|
-
*/
|
|
392
|
-
getNewOptionData: PropTypes.func,
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* If provided, this will be called with the input value when a new option is created, and onChange will not be called. Use this when you need more control over what happens when new options are created.
|
|
396
|
-
*/
|
|
397
|
-
onCreateOption: PropTypes.func,
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Sets the position of the createOption element in your options list.
|
|
401
|
-
*/
|
|
402
|
-
createOptionPosition: PropTypes.string,
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Determines if option groups will be separated by a divider
|
|
406
|
-
*/
|
|
407
|
-
showOptionGroupDivider: PropTypes.bool
|
|
408
|
-
} : {};
|
|
191
|
+
AsyncCreatableSelectInput.defaultProps = defaultProps;
|
|
409
192
|
addStaticFields(AsyncCreatableSelectInput, _objectSpread(_objectSpread(_objectSpread({}, components), customizedComponents), {}, {
|
|
410
193
|
isTouched: AsyncCreatableSelectInput.isTouched
|
|
411
194
|
}));
|
|
412
195
|
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
413
196
|
|
|
414
197
|
// NOTE: This string will be replaced on build time with the package version.
|
|
415
|
-
var version = "
|
|
198
|
+
var version = "13.0.0";
|
|
416
199
|
|
|
417
200
|
export { AsyncCreatableSelectInput$1 as default, version };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { type ActionMeta, type GroupBase } from 'react-select';
|
|
3
|
+
import { type AsyncCreatableProps } from 'react-select/async-creatable';
|
|
4
|
+
declare type TEvent = {
|
|
5
|
+
target: {
|
|
6
|
+
name?: string;
|
|
7
|
+
value?: unknown;
|
|
8
|
+
};
|
|
9
|
+
persist: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare type ReactSelectAsyncCreatableProps = AsyncCreatableProps<unknown, boolean, GroupBase<unknown>>;
|
|
12
|
+
declare type TAsyncCreatableSelectInputProps = {
|
|
13
|
+
horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
14
|
+
hasError?: boolean;
|
|
15
|
+
hasWarning?: boolean;
|
|
16
|
+
isReadOnly?: boolean;
|
|
17
|
+
iconLeft?: ReactNode;
|
|
18
|
+
'aria-label'?: ReactSelectAsyncCreatableProps['aria-label'];
|
|
19
|
+
'aria-labelledby'?: ReactSelectAsyncCreatableProps['aria-labelledby'];
|
|
20
|
+
isAutofocussed?: boolean;
|
|
21
|
+
backspaceRemovesValue?: ReactSelectAsyncCreatableProps['backspaceRemovesValue'];
|
|
22
|
+
components?: ReactSelectAsyncCreatableProps['components'];
|
|
23
|
+
filterOption?: ReactSelectAsyncCreatableProps['filterOption'];
|
|
24
|
+
id?: ReactSelectAsyncCreatableProps['inputId'];
|
|
25
|
+
inputValue?: ReactSelectAsyncCreatableProps['inputValue'];
|
|
26
|
+
containerId?: ReactSelectAsyncCreatableProps['id'];
|
|
27
|
+
isClearable?: ReactSelectAsyncCreatableProps['isClearable'];
|
|
28
|
+
isDisabled?: ReactSelectAsyncCreatableProps['isDisabled'];
|
|
29
|
+
isOptionDisabled?: ReactSelectAsyncCreatableProps['isOptionDisabled'];
|
|
30
|
+
isMulti?: ReactSelectAsyncCreatableProps['isMulti'];
|
|
31
|
+
isSearchable?: ReactSelectAsyncCreatableProps['isSearchable'];
|
|
32
|
+
maxMenuHeight?: ReactSelectAsyncCreatableProps['maxMenuHeight'];
|
|
33
|
+
menuPortalTarget?: ReactSelectAsyncCreatableProps['menuPortalTarget'];
|
|
34
|
+
menuPortalZIndex: number;
|
|
35
|
+
menuShouldBlockScroll?: ReactSelectAsyncCreatableProps['menuShouldBlockScroll'];
|
|
36
|
+
closeMenuOnSelect?: ReactSelectAsyncCreatableProps['closeMenuOnSelect'];
|
|
37
|
+
name?: ReactSelectAsyncCreatableProps['name'];
|
|
38
|
+
noOptionsMessage?: ReactSelectAsyncCreatableProps['noOptionsMessage'];
|
|
39
|
+
onBlur?: (event: TEvent) => void;
|
|
40
|
+
onChange: (event: TEvent, info: ActionMeta<unknown>) => void;
|
|
41
|
+
onFocus?: ReactSelectAsyncCreatableProps['onFocus'];
|
|
42
|
+
onInputChange?: ReactSelectAsyncCreatableProps['onInputChange'];
|
|
43
|
+
placeholder?: ReactSelectAsyncCreatableProps['placeholder'];
|
|
44
|
+
tabIndex?: ReactSelectAsyncCreatableProps['tabIndex'];
|
|
45
|
+
tabSelectsValue?: ReactSelectAsyncCreatableProps['tabSelectsValue'];
|
|
46
|
+
value?: ReactSelectAsyncCreatableProps['value'];
|
|
47
|
+
defaultOptions?: ReactSelectAsyncCreatableProps['defaultOptions'];
|
|
48
|
+
loadOptions: ReactSelectAsyncCreatableProps['loadOptions'];
|
|
49
|
+
cacheOptions?: ReactSelectAsyncCreatableProps['cacheOptions'];
|
|
50
|
+
allowCreateWhileLoading?: ReactSelectAsyncCreatableProps['allowCreateWhileLoading'];
|
|
51
|
+
formatCreateLabel?: ReactSelectAsyncCreatableProps['formatCreateLabel'];
|
|
52
|
+
isValidNewOption?: ReactSelectAsyncCreatableProps['isValidNewOption'];
|
|
53
|
+
getNewOptionData?: ReactSelectAsyncCreatableProps['getNewOptionData'];
|
|
54
|
+
onCreateOption?: ReactSelectAsyncCreatableProps['onCreateOption'];
|
|
55
|
+
createOptionPosition?: ReactSelectAsyncCreatableProps['createOptionPosition'];
|
|
56
|
+
showOptionGroupDivider?: boolean;
|
|
57
|
+
};
|
|
58
|
+
declare const AsyncCreatableSelectInput: {
|
|
59
|
+
(props: TAsyncCreatableSelectInputProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
60
|
+
isTouched(touched: unknown): boolean;
|
|
61
|
+
displayName: string;
|
|
62
|
+
defaultProps: Pick<TAsyncCreatableSelectInputProps, "value" | "isSearchable" | "menuPortalZIndex">;
|
|
63
|
+
};
|
|
64
|
+
export default AsyncCreatableSelectInput;
|