@commercetools-uikit/async-creatable-select-input 0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.d.ts +3 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.dev.js +265 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.js +7 -0
- package/dist/commercetools-uikit-async-creatable-select-input.cjs.prod.js +247 -0
- package/dist/commercetools-uikit-async-creatable-select-input.esm.js +243 -0
- package/dist/declarations/src/async-creatable-select-input.d.ts +333 -0
- package/dist/declarations/src/export-types.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<!-- THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -->
|
|
2
|
+
<!-- This file is created by the `yarn generate-readme` script. -->
|
|
3
|
+
|
|
4
|
+
# AsyncCreatableSelectInput
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
|
|
8
|
+
An input component getting a selection from an asynchronously loaded list from the user, and where options can be created by the user.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
yarn add @commercetools-uikit/async-creatable-select-input
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npm --save install @commercetools-uikit/async-creatable-select-input
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Additionally install the peer dependencies (if not present)
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
yarn add react react-dom react-intl
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
npm --save install react react-dom react-intl
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```jsx
|
|
33
|
+
import AsyncCreatableSelectInput from '@commercetools-uikit/async-creatable-select-input';
|
|
34
|
+
|
|
35
|
+
const Example = (props) => (
|
|
36
|
+
<AsyncCreatableSelectInput
|
|
37
|
+
name="form-field-name"
|
|
38
|
+
value={{ value: 'one', label: 'One' }}
|
|
39
|
+
onChange={(event) => alert(event.target.value)}
|
|
40
|
+
loadOptions={() =>
|
|
41
|
+
Promise.resolve([
|
|
42
|
+
{ value: 'one', label: 'One' },
|
|
43
|
+
{ value: 'two', label: 'Two' },
|
|
44
|
+
])
|
|
45
|
+
}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export default Example;
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Properties
|
|
53
|
+
|
|
54
|
+
| Props | Type | Required | Default | Description |
|
|
55
|
+
| ------------------------- | ----------------------------------------------------------------------------------------------------- | :------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
56
|
+
| `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. |
|
|
57
|
+
| `hasError` | `boolean` | | | Indicates the input field has an error |
|
|
58
|
+
| `hasWarning` | `boolean` | | | Indicates the input field has a warning |
|
|
59
|
+
| `isReadOnly` | `boolean` | | | Is the select read-only |
|
|
60
|
+
| `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when isMulti is enabled. |
|
|
61
|
+
| `aria-label` | `AsyncCreatableProps['aria-label']` | | | Aria label (for assistive tech)
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
62
|
+
| `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) |
|
|
63
|
+
| `aria-invalid` | `AsyncCreatableProps['aria-invalid']` | | | Indicate if the value entered in the input is invalid.
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
64
|
+
| `aria-errormessage` | `AsyncCreatableProps['aria-errormessage']` | | | HTML ID of an element containing an error message related to the input.
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
65
|
+
| `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
|
|
66
|
+
| `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) |
|
|
67
|
+
| `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) |
|
|
68
|
+
| `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) |
|
|
69
|
+
| `id` | `AsyncCreatableProps['inputId']` | | | The id of the search input
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
70
|
+
| `inputValue` | `AsyncCreatableProps['inputValue']` | | | The value of the search input
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
71
|
+
| `containerId` | `AsyncCreatableProps['id']` | | | The id to set on the SelectContainer component
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
72
|
+
| `isClearable` | `AsyncCreatableProps['isClearable']` | | | Is the select value clearable
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
73
|
+
| `isCondensed` | `boolean` | | | Use this property to reduce the paddings of the component for a ui compact variant |
|
|
74
|
+
| `isDisabled` | `AsyncCreatableProps['isDisabled']` | | | Is the select disabled
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
75
|
+
| `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) |
|
|
76
|
+
| `isMulti` | `AsyncCreatableProps['isMulti']` | | | Support multiple selected options
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
77
|
+
| `isSearchable` | `AsyncCreatableProps['isSearchable']` | | `true` | Whether to enable search functionality
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
78
|
+
| `maxMenuHeight` | `AsyncCreatableProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
79
|
+
| `menuPortalTarget` | `AsyncCreatableProps['menuPortalTarget']` | | | Dom element to portal the select menu to
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
80
|
+
| `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal
<br>
Use in conjunction with `menuPortalTarget` |
|
|
81
|
+
| `menuShouldBlockScroll` | `AsyncCreatableProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
82
|
+
| `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) |
|
|
83
|
+
| `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) |
|
|
84
|
+
| `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) |
|
|
85
|
+
| `onBlur` | `Function`<br/>[See signature.](#signature-onblur) | | | Handle blur events on the control |
|
|
86
|
+
| `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`. |
|
|
87
|
+
| `onFocus` | `AsyncCreatableProps['onFocus']` | | | Handle focus events on the control
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
88
|
+
| `onInputChange` | `AsyncCreatableProps['onInputChange']` | | | Handle change events on the input
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
89
|
+
| `placeholder` | `AsyncCreatableProps['placeholder']` | | | Placeholder text for the select value
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
90
|
+
| `tabIndex` | `AsyncCreatableProps['tabIndex']` | | | Sets the tabIndex attribute on the input
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
91
|
+
| `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) |
|
|
92
|
+
| `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) |
|
|
93
|
+
| `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) |
|
|
94
|
+
| `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) |
|
|
95
|
+
| `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) |
|
|
96
|
+
| `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) |
|
|
97
|
+
| `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) |
|
|
98
|
+
| `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) |
|
|
99
|
+
| `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) |
|
|
100
|
+
| `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) |
|
|
101
|
+
| `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) |
|
|
102
|
+
| `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
|
|
103
|
+
|
|
104
|
+
## Signatures
|
|
105
|
+
|
|
106
|
+
### Signature `onBlur`
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
(event: TCustomEvent) => void
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Signature `onChange`
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
(event: TCustomEvent, info: ActionMeta<unknown>) => void
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This input is built on top of [`react-select`](https://github.com/JedWatson/react-select) v2.
|
|
119
|
+
It supports mostly same properties as `react-select`. Behaviour for some props was changed, and support for others was dropped.
|
|
120
|
+
|
|
121
|
+
In case you need one of the currently excluded props, feel free to open a PR adding them.
|
|
122
|
+
|
|
123
|
+
### Static Properties
|
|
124
|
+
|
|
125
|
+
#### `isTouched(touched)`
|
|
126
|
+
|
|
127
|
+
Returns truthy value for the Formik `touched` value of this input field.
|
|
128
|
+
|
|
129
|
+
## Components
|
|
130
|
+
|
|
131
|
+
It is possible to customize `AsyncCreatableSelectInput` by passing the `components` property.
|
|
132
|
+
`AsyncCreatableSelectInput` exports the default underlying components as static exports.
|
|
133
|
+
|
|
134
|
+
Components available as static exports are:
|
|
135
|
+
|
|
136
|
+
- `ClearIndicator`
|
|
137
|
+
- `Control`
|
|
138
|
+
- `CrossIcon`
|
|
139
|
+
- `DownChevron`
|
|
140
|
+
- `DropdownIndicator`
|
|
141
|
+
- `Group`
|
|
142
|
+
- `GroupHeading`
|
|
143
|
+
- `IndicatorsContainer`
|
|
144
|
+
- `IndicatorSeparator`
|
|
145
|
+
- `Input`
|
|
146
|
+
- `LoadingIndicator`
|
|
147
|
+
- `LoadingMessage`
|
|
148
|
+
- `Menu`
|
|
149
|
+
- `MenuList`
|
|
150
|
+
- `MenuPortal`
|
|
151
|
+
- `MultiValue`
|
|
152
|
+
- `MultiValueContainer`
|
|
153
|
+
- `MultiValueLabel`
|
|
154
|
+
- `MultiValueRemove`
|
|
155
|
+
- `NoOptionsMessage`
|
|
156
|
+
- `Option`
|
|
157
|
+
- `Placeholder`
|
|
158
|
+
- `SelectContainer`
|
|
159
|
+
- `SingleValue`
|
|
160
|
+
- `ValueContainer`
|
|
161
|
+
|
|
162
|
+
See the [official documentation](https://react-select.com/components) for more information about the props they receive.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export * from "./declarations/src/index.js";
|
|
2
|
+
export { default } from "./declarations/src/index.js";
|
|
3
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy11aWtpdC1hc3luYy1jcmVhdGFibGUtc2VsZWN0LWlucHV0LmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
7
|
+
var _pt = require('prop-types');
|
|
8
|
+
var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
|
|
9
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
10
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
11
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
12
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
13
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
14
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
15
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
16
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
17
|
+
var reactIntl = require('react-intl');
|
|
18
|
+
var isEmpty = require('lodash/isEmpty');
|
|
19
|
+
var reactSelect = require('react-select');
|
|
20
|
+
var AsyncCreatableSelect = require('react-select/async-creatable');
|
|
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 utils = require('@commercetools-uikit/utils');
|
|
25
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
26
|
+
|
|
27
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
28
|
+
|
|
29
|
+
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
30
|
+
var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
|
|
31
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
32
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
33
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
34
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
35
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
36
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
37
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
38
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
39
|
+
var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
|
|
40
|
+
var AsyncCreatableSelect__default = /*#__PURE__*/_interopDefault(AsyncCreatableSelect);
|
|
41
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
42
|
+
var LoadingSpinner__default = /*#__PURE__*/_interopDefault(LoadingSpinner);
|
|
43
|
+
|
|
44
|
+
const _excluded = ["value", "isSearchable", "menuPortalZIndex"];
|
|
45
|
+
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; }
|
|
46
|
+
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; }
|
|
47
|
+
const LoadingIndicator = () => jsxRuntime.jsx(LoadingSpinner__default["default"], {
|
|
48
|
+
scale: "s"
|
|
49
|
+
});
|
|
50
|
+
LoadingIndicator.displayName = 'LoadingIndicator';
|
|
51
|
+
const customizedComponents = {
|
|
52
|
+
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
53
|
+
ClearIndicator: selectUtils.ClearIndicator,
|
|
54
|
+
LoadingIndicator,
|
|
55
|
+
MultiValueRemove: selectUtils.TagRemove
|
|
56
|
+
};
|
|
57
|
+
const AsyncCreatableSelectInput = _ref => {
|
|
58
|
+
let _ref$value = _ref.value,
|
|
59
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
60
|
+
_ref$isSearchable = _ref.isSearchable,
|
|
61
|
+
isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
|
|
62
|
+
_ref$menuPortalZIndex = _ref.menuPortalZIndex,
|
|
63
|
+
menuPortalZIndex = _ref$menuPortalZIndex === void 0 ? 1 : _ref$menuPortalZIndex,
|
|
64
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
65
|
+
const intl = reactIntl.useIntl();
|
|
66
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
67
|
+
if (!props.isReadOnly) {
|
|
68
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'AsyncCreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
69
|
+
}
|
|
70
|
+
if (props.isMulti) {
|
|
71
|
+
process.env.NODE_ENV !== "production" ? utils.warning(_Array$isArray__default["default"](value), 'AsyncCreatableSelectInput: `value` is expected to be an array when isMulti is true') : void 0;
|
|
72
|
+
}
|
|
73
|
+
selectUtils.warnIfMenuPortalPropsAreMissing({
|
|
74
|
+
menuPortalZIndex: menuPortalZIndex,
|
|
75
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
76
|
+
componentName: 'AsyncCreatableSelectInput'
|
|
77
|
+
});
|
|
78
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
79
|
+
max: props.horizontalConstraint,
|
|
80
|
+
children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(_objectSpread({
|
|
81
|
+
value,
|
|
82
|
+
isSearchable,
|
|
83
|
+
menuPortalZIndex
|
|
84
|
+
}, props))), {}, {
|
|
85
|
+
children: jsxRuntime.jsx(AsyncCreatableSelect__default["default"], {
|
|
86
|
+
"aria-label": props['aria-label'],
|
|
87
|
+
"aria-labelledby": props['aria-labelledby'],
|
|
88
|
+
"aria-invalid": props['aria-invalid'],
|
|
89
|
+
"aria-errormessage": props['aria-errormessage'],
|
|
90
|
+
autoFocus: props.isAutofocussed,
|
|
91
|
+
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
92
|
+
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
93
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
94
|
+
readOnly: true
|
|
95
|
+
}))
|
|
96
|
+
} : {}), props.components),
|
|
97
|
+
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
98
|
+
styles: selectUtils.createSelectStyles({
|
|
99
|
+
hasWarning: props.hasWarning,
|
|
100
|
+
hasError: props.hasError,
|
|
101
|
+
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
102
|
+
menuPortalZIndex: menuPortalZIndex,
|
|
103
|
+
isCondensed: props.isCondensed,
|
|
104
|
+
isDisabled: props.isDisabled,
|
|
105
|
+
isReadOnly: props.isReadOnly,
|
|
106
|
+
iconLeft: props.iconLeft,
|
|
107
|
+
isMulti: props.isMulti,
|
|
108
|
+
hasValue: !isEmpty__default["default"](value),
|
|
109
|
+
horizontalConstraint: props.horizontalConstraint
|
|
110
|
+
}),
|
|
111
|
+
filterOption: props.filterOption
|
|
112
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
113
|
+
// but we use "id" (for the input) and "containerId" (for the container)
|
|
114
|
+
// instead.
|
|
115
|
+
// This makes it easier to less confusing to use with <label />s.
|
|
116
|
+
,
|
|
117
|
+
id: props.containerId,
|
|
118
|
+
inputId: props.id,
|
|
119
|
+
inputValue: props.inputValue,
|
|
120
|
+
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
121
|
+
isDisabled: props.isDisabled,
|
|
122
|
+
isOptionDisabled: props.isOptionDisabled,
|
|
123
|
+
isMulti: props.isMulti,
|
|
124
|
+
isSearchable: isSearchable,
|
|
125
|
+
maxMenuHeight: props.maxMenuHeight,
|
|
126
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
127
|
+
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
128
|
+
closeMenuOnScroll: props.closeMenuOnSelect,
|
|
129
|
+
name: props.name,
|
|
130
|
+
noOptionsMessage: props.noOptionsMessage || (_ref2 => {
|
|
131
|
+
let inputValue = _ref2.inputValue;
|
|
132
|
+
return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
133
|
+
inputValue
|
|
134
|
+
});
|
|
135
|
+
}),
|
|
136
|
+
onBlur: props.onBlur ? () => {
|
|
137
|
+
const event = {
|
|
138
|
+
target: {
|
|
139
|
+
id: props.id,
|
|
140
|
+
name: (() => {
|
|
141
|
+
if (!props.name) return undefined;
|
|
142
|
+
if (!props.isMulti) return props.name;
|
|
143
|
+
// We append the ".0" to make Formik set the touched
|
|
144
|
+
// state as an array instead of a boolean only.
|
|
145
|
+
// Otherwise the shapes would clash on submission, as
|
|
146
|
+
// Formik will create an array on submission anyways.
|
|
147
|
+
return `${props.name}.0`;
|
|
148
|
+
})()
|
|
149
|
+
},
|
|
150
|
+
persist: () => {}
|
|
151
|
+
};
|
|
152
|
+
props.onBlur && props.onBlur(event);
|
|
153
|
+
} : undefined,
|
|
154
|
+
onChange: (value, info) => {
|
|
155
|
+
// wrapping breaking changes made in react-select v3
|
|
156
|
+
let newValue = value;
|
|
157
|
+
if (props.isMulti && !newValue) {
|
|
158
|
+
newValue = [];
|
|
159
|
+
}
|
|
160
|
+
props.onChange?.({
|
|
161
|
+
target: {
|
|
162
|
+
id: props.id,
|
|
163
|
+
name: props.name,
|
|
164
|
+
value: newValue
|
|
165
|
+
},
|
|
166
|
+
persist: () => {}
|
|
167
|
+
}, info);
|
|
168
|
+
},
|
|
169
|
+
onFocus: props.onFocus,
|
|
170
|
+
onInputChange: props.onInputChange,
|
|
171
|
+
placeholder: placeholder,
|
|
172
|
+
tabIndex: props.tabIndex,
|
|
173
|
+
tabSelectsValue: props.tabSelectsValue,
|
|
174
|
+
value: value
|
|
175
|
+
// Async react-select props
|
|
176
|
+
,
|
|
177
|
+
defaultOptions: props.defaultOptions,
|
|
178
|
+
loadOptions: props.loadOptions,
|
|
179
|
+
cacheOptions: props.cacheOptions
|
|
180
|
+
// Creatable props
|
|
181
|
+
,
|
|
182
|
+
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
183
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
184
|
+
inputValue
|
|
185
|
+
})),
|
|
186
|
+
isValidNewOption: props.isValidNewOption,
|
|
187
|
+
getNewOptionData: props.getNewOptionData,
|
|
188
|
+
onCreateOption: props.onCreateOption,
|
|
189
|
+
createOptionPosition: props.createOptionPosition
|
|
190
|
+
// @ts-ignore
|
|
191
|
+
,
|
|
192
|
+
iconLeft: props.iconLeft,
|
|
193
|
+
isCondensed: props.isCondensed
|
|
194
|
+
})
|
|
195
|
+
}))
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
AsyncCreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
199
|
+
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
200
|
+
hasError: _pt__default["default"].bool,
|
|
201
|
+
hasWarning: _pt__default["default"].bool,
|
|
202
|
+
isReadOnly: _pt__default["default"].bool,
|
|
203
|
+
iconLeft: _pt__default["default"].node,
|
|
204
|
+
isAutofocussed: _pt__default["default"].bool,
|
|
205
|
+
isCondensed: _pt__default["default"].bool,
|
|
206
|
+
menuPortalZIndex: _pt__default["default"].number,
|
|
207
|
+
onBlur: _pt__default["default"].func,
|
|
208
|
+
onChange: _pt__default["default"].func,
|
|
209
|
+
showOptionGroupDivider: _pt__default["default"].bool
|
|
210
|
+
} : {};
|
|
211
|
+
AsyncCreatableSelectInput.displayName = 'AsyncCreatableSelectInput';
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Expose static helper methods.
|
|
215
|
+
*/
|
|
216
|
+
|
|
217
|
+
// Formik will set the field to an array on submission, so we always have to
|
|
218
|
+
// deal with an array. The touched state ends up being an empty array in case
|
|
219
|
+
// values were removed only. So we have to treat any array we receive as
|
|
220
|
+
// a signal of the field having been touched.
|
|
221
|
+
AsyncCreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Expose react-select components for customization purposes.
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
// custom
|
|
228
|
+
AsyncCreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
229
|
+
AsyncCreatableSelectInput.Control = reactSelect.components.Control;
|
|
230
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
231
|
+
AsyncCreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
232
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
233
|
+
AsyncCreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
234
|
+
// custom
|
|
235
|
+
AsyncCreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
236
|
+
AsyncCreatableSelectInput.Group = reactSelect.components.Group;
|
|
237
|
+
AsyncCreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
238
|
+
AsyncCreatableSelectInput.IndicatorSeparator = reactSelect.components.IndicatorSeparator;
|
|
239
|
+
AsyncCreatableSelectInput.IndicatorsContainer = reactSelect.components.IndicatorsContainer;
|
|
240
|
+
AsyncCreatableSelectInput.Input = reactSelect.components.Input;
|
|
241
|
+
// custom
|
|
242
|
+
AsyncCreatableSelectInput.LoadingIndicator = customizedComponents.LoadingIndicator;
|
|
243
|
+
AsyncCreatableSelectInput.LoadingMessage = reactSelect.components.LoadingMessage;
|
|
244
|
+
AsyncCreatableSelectInput.Menu = reactSelect.components.Menu;
|
|
245
|
+
AsyncCreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
246
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
247
|
+
AsyncCreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
248
|
+
AsyncCreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
249
|
+
AsyncCreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
250
|
+
AsyncCreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
251
|
+
// custom
|
|
252
|
+
AsyncCreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
253
|
+
AsyncCreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
254
|
+
AsyncCreatableSelectInput.Option = reactSelect.components.Option;
|
|
255
|
+
AsyncCreatableSelectInput.Placeholder = reactSelect.components.Placeholder;
|
|
256
|
+
AsyncCreatableSelectInput.SelectContainer = reactSelect.components.SelectContainer;
|
|
257
|
+
AsyncCreatableSelectInput.SingleValue = reactSelect.components.SingleValue;
|
|
258
|
+
AsyncCreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
259
|
+
var AsyncCreatableSelectInput$1 = AsyncCreatableSelectInput;
|
|
260
|
+
|
|
261
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
262
|
+
var version = "19.25.1";
|
|
263
|
+
|
|
264
|
+
exports["default"] = AsyncCreatableSelectInput$1;
|
|
265
|
+
exports.version = version;
|