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