@commercetools-uikit/creatable-select-input 0.0.0-FCT-1500-adjust-legacy-css-reset-20250527090339
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +165 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.d.ts +3 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.dev.js +251 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.js +7 -0
- package/dist/commercetools-uikit-creatable-select-input.cjs.prod.js +227 -0
- package/dist/commercetools-uikit-creatable-select-input.esm.js +231 -0
- package/dist/declarations/src/creatable-select-input.d.ts +323 -0
- package/dist/declarations/src/export-types.d.ts +1 -0
- package/dist/declarations/src/index.d.ts +3 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +55 -0
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,165 @@
|
|
|
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
|
+
# CreatableSelectInput
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
|
|
8
|
+
An input component getting a selection from the user, and where options can also be created by the user.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
yarn add @commercetools-uikit/creatable-select-input
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
npm --save install @commercetools-uikit/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 PropTypes from 'prop-types';
|
|
34
|
+
import CreatableSelectInput from '@commercetools-uikit/creatable-select-input';
|
|
35
|
+
|
|
36
|
+
const Example = (props) => (
|
|
37
|
+
<CreatableSelectInput
|
|
38
|
+
name="form-field-name"
|
|
39
|
+
value={props.value}
|
|
40
|
+
onChange={() => {}}
|
|
41
|
+
options={[
|
|
42
|
+
{ value: 'one', label: 'One' },
|
|
43
|
+
{ value: 'two', label: 'Two' },
|
|
44
|
+
]}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
Example.propTypes = {
|
|
48
|
+
value: PropTypes.string,
|
|
49
|
+
};
|
|
50
|
+
export default Example;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Properties
|
|
54
|
+
|
|
55
|
+
| Props | Type | Required | Default | Description |
|
|
56
|
+
| ------------------------- | ----------------------------------------------------------------------------------------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `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. |
|
|
58
|
+
| `hasError` | `boolean` | | | Indicates the input field has an error |
|
|
59
|
+
| `hasWarning` | `boolean` | | | Indicates the input field has a warning |
|
|
60
|
+
| `isReadOnly` | `boolean` | | | Disables the select input as it is read-only |
|
|
61
|
+
| `iconLeft` | `ReactNode` | | | Icon to display on the left of the placeholder text and selected value. Has no effect when `isMulti` is enabled. |
|
|
62
|
+
| `aria-label` | `CreatableProps['aria-label']` | | | Aria label (for assistive tech)
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
63
|
+
| `aria-labelledby` | `CreatableProps['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#creatable-props) |
|
|
64
|
+
| `aria-invalid` | `CreatableProps['aria-invalid']` | | | Indicate if the value entered in the input is invalid.
<br>
[Props from React select was used](https://react-select.com/props) |
|
|
65
|
+
| `aria-errormessage` | `CreatableProps['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) |
|
|
66
|
+
| `isAutofocussed` | `boolean` | | | Focus the control when it is mounted |
|
|
67
|
+
| `backspaceRemovesValue` | `CreatableProps['backspaceRemovesValue']` | | | Remove the currently focused option when the user presses backspace
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
68
|
+
| `components` | `CreatableProps['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#creatable-props) |
|
|
69
|
+
| `filterOption` | `CreatableProps['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#creatable-props) |
|
|
70
|
+
| `id` | `CreatableProps['inputId']` | | | The id of the search input
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
71
|
+
| `inputValue` | `CreatableProps['inputValue']` | | | The value of the search input
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
72
|
+
| `containerId` | `CreatableProps['id']` | | | The id to set on the SelectContainer component
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
73
|
+
| `isClearable` | `CreatableProps['isClearable']` | | | Is the select value clearable
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
74
|
+
| `isDisabled` | `CreatableProps['isDisabled']` | | | Is the select disabled
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
75
|
+
| `isOptionDisabled` | `CreatableProps['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#creatable-props) |
|
|
76
|
+
| `isMulti` | `CreatableProps['isMulti']` | | | Support multiple selected options
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
77
|
+
| `isSearchable` | `CreatableProps['isSearchable']` | | `true` | Whether to enable search functionality
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
78
|
+
| `maxMenuHeight` | `CreatableProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
79
|
+
| `menuPortalTarget` | `CreatableProps['menuPortalTarget']` | | | Dom element to portal the select menu to
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
80
|
+
| `menuPortalZIndex` | `number` | | `1` | z-index value for the menu portal
<br>
Use in conjunction with `menuPortalTarget` |
|
|
81
|
+
| `menuShouldBlockScroll` | `CreatableProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
82
|
+
| `closeMenuOnSelect` | `CreatableProps['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#creatable-props) |
|
|
83
|
+
| `name` | `CreatableProps['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#creatable-props) |
|
|
84
|
+
| `noOptionsMessage` | `CreatableProps['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#creatable-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` | `CreatableProps['onFocus']` | | | Handle focus events on the control
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
88
|
+
| `onInputChange` | `CreatableProps['onInputChange']` | | | Handle change events on the input
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
89
|
+
| `options` | `union`<br/>Possible values:<br/>`TValue[] , { options: TValue[] }[]` | | | Array of options that populate the select menu |
|
|
90
|
+
| `showOptionGroupDivider` | `boolean` | | | Determines if option groups will be separated by a divider |
|
|
91
|
+
| `placeholder` | `CreatableProps['placeholder']` | | | Placeholder text for the select value
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
92
|
+
| `isCondensed` | `boolean` | | | Use this property to reduce the paddings of the component for a ui compact variant |
|
|
93
|
+
| `tabIndex` | `CreatableProps['tabIndex']` | | | Sets the tabIndex attribute on the input
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
94
|
+
| `tabSelectsValue` | `CreatableProps['tabSelectsValue']` | | | Select the currently focused option when the user presses tab
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
95
|
+
| `value` | `CreatableProps['value']` | | `null` | The value of the select; reflected by the selected option
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
96
|
+
| `allowCreateWhileLoading` | `CreatableProps['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#creatable-props) |
|
|
97
|
+
| `formatCreateLabel` | `CreatableProps['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#creatable-props) |
|
|
98
|
+
| `isValidNewOption` | `CreatableProps['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#creatable-props) |
|
|
99
|
+
| `getNewOptionData` | `CreatableProps['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#creatable-props) |
|
|
100
|
+
| `onCreateOption` | `CreatableProps['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#creatable-props) |
|
|
101
|
+
| `createOptionPosition` | `CreatableProps['createOptionPosition']` | | | Sets the position of the createOption element in your options list.
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
102
|
+
|
|
103
|
+
## Signatures
|
|
104
|
+
|
|
105
|
+
### Signature `onBlur`
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
(event: TCustomEvent) => void
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Signature `onChange`
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
(event: TCustomEvent, info: ActionMeta<unknown>) => void
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
This input is built on top of [`react-select`](https://github.com/JedWatson/react-select) v2.
|
|
118
|
+
It supports mostly same properties as `react-select`. Behaviour for some props was changed, and support for others was dropped.
|
|
119
|
+
|
|
120
|
+
In case you need one of the currently excluded props, feel free to open a PR adding them.
|
|
121
|
+
|
|
122
|
+
### `options`
|
|
123
|
+
|
|
124
|
+
The options support a `isDisabled` property which will render the option with a disabled style and will prevent users from selecting it.
|
|
125
|
+
|
|
126
|
+
## Static Properties
|
|
127
|
+
|
|
128
|
+
### `isTouched(touched)`
|
|
129
|
+
|
|
130
|
+
Returns truthy value for the Formik `touched` value of this input field.
|
|
131
|
+
|
|
132
|
+
## Components
|
|
133
|
+
|
|
134
|
+
It is possible to customize `CreatableSelectInput` by passing the `components` property.
|
|
135
|
+
`CreatableSelectInput` exports the default underlying components as static exports.
|
|
136
|
+
|
|
137
|
+
Components available as static exports are:
|
|
138
|
+
|
|
139
|
+
- `ClearIndicator`
|
|
140
|
+
- `Control`
|
|
141
|
+
- `CrossIcon`
|
|
142
|
+
- `DownChevron`
|
|
143
|
+
- `DropdownIndicator`
|
|
144
|
+
- `Group`
|
|
145
|
+
- `GroupHeading`
|
|
146
|
+
- `IndicatorsContainer`
|
|
147
|
+
- `IndicatorSeparator`
|
|
148
|
+
- `Input`
|
|
149
|
+
- `LoadingIndicator`
|
|
150
|
+
- `LoadingMessage`
|
|
151
|
+
- `Menu`
|
|
152
|
+
- `MenuList`
|
|
153
|
+
- `MenuPortal`
|
|
154
|
+
- `MultiValue`
|
|
155
|
+
- `MultiValueContainer`
|
|
156
|
+
- `MultiValueLabel`
|
|
157
|
+
- `MultiValueRemove`
|
|
158
|
+
- `NoOptionsMessage`
|
|
159
|
+
- `Option`
|
|
160
|
+
- `Placeholder`
|
|
161
|
+
- `SelectContainer`
|
|
162
|
+
- `SingleValue`
|
|
163
|
+
- `ValueContainer`
|
|
164
|
+
|
|
165
|
+
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy11aWtpdC1jcmVhdGFibGUtc2VsZWN0LWlucHV0LmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
6
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
7
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
8
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
9
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
10
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
11
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
12
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
13
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
14
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
15
|
+
var _pt = require('prop-types');
|
|
16
|
+
var reactIntl = require('react-intl');
|
|
17
|
+
var isEmpty = require('lodash/isEmpty');
|
|
18
|
+
var reactSelect = require('react-select');
|
|
19
|
+
var CreatableSelect = require('react-select/creatable');
|
|
20
|
+
var Constraints = require('@commercetools-uikit/constraints');
|
|
21
|
+
var utils = require('@commercetools-uikit/utils');
|
|
22
|
+
var selectUtils = require('@commercetools-uikit/select-utils');
|
|
23
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
24
|
+
|
|
25
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
26
|
+
|
|
27
|
+
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
28
|
+
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
29
|
+
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
30
|
+
var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
|
|
31
|
+
var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
|
|
32
|
+
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
33
|
+
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
34
|
+
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
35
|
+
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
36
|
+
var isEmpty__default = /*#__PURE__*/_interopDefault(isEmpty);
|
|
37
|
+
var CreatableSelect__default = /*#__PURE__*/_interopDefault(CreatableSelect);
|
|
38
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
39
|
+
|
|
40
|
+
const _excluded = ["value", "isSearchable", "menuPortalZIndex"];
|
|
41
|
+
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; }
|
|
42
|
+
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; }
|
|
43
|
+
const customizedComponents = {
|
|
44
|
+
DropdownIndicator: selectUtils.DropdownIndicator,
|
|
45
|
+
ClearIndicator: selectUtils.ClearIndicator,
|
|
46
|
+
MultiValueRemove: selectUtils.TagRemove
|
|
47
|
+
};
|
|
48
|
+
const CreatableSelectInput = _ref => {
|
|
49
|
+
let _ref$value = _ref.value,
|
|
50
|
+
value = _ref$value === void 0 ? null : _ref$value,
|
|
51
|
+
_ref$isSearchable = _ref.isSearchable,
|
|
52
|
+
isSearchable = _ref$isSearchable === void 0 ? true : _ref$isSearchable,
|
|
53
|
+
_ref$menuPortalZIndex = _ref.menuPortalZIndex,
|
|
54
|
+
menuPortalZIndex = _ref$menuPortalZIndex === void 0 ? 1 : _ref$menuPortalZIndex,
|
|
55
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
|
+
const intl = reactIntl.useIntl();
|
|
57
|
+
if (!props.isReadOnly) {
|
|
58
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof props.onChange === 'function', 'CreatableSelectInput: `onChange` is required when input is not read only.') : void 0;
|
|
59
|
+
}
|
|
60
|
+
const placeholder = props.placeholder || intl.formatMessage(selectUtils.messages.placeholder);
|
|
61
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
62
|
+
max: props.horizontalConstraint,
|
|
63
|
+
children: jsxRuntime.jsx("div", _objectSpread(_objectSpread({}, utils.filterDataAttributes(_objectSpread({
|
|
64
|
+
value,
|
|
65
|
+
isSearchable,
|
|
66
|
+
menuPortalZIndex
|
|
67
|
+
}, props))), {}, {
|
|
68
|
+
children: jsxRuntime.jsx(CreatableSelect__default["default"], {
|
|
69
|
+
"aria-label": props['aria-label'],
|
|
70
|
+
"aria-labelledby": props['aria-labelledby'],
|
|
71
|
+
"aria-invalid": props['aria-invalid'],
|
|
72
|
+
"aria-errormessage": props['aria-errormessage'],
|
|
73
|
+
autoFocus: props.isAutofocussed,
|
|
74
|
+
backspaceRemovesValue: props.isReadOnly ? false : props.backspaceRemovesValue,
|
|
75
|
+
components: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, customizedComponents), props.components), props.iconLeft && !props.isMulti ? selectUtils.customComponentsWithIcons : {}), props.isReadOnly ? {
|
|
76
|
+
Input: ownProps => jsxRuntime.jsx(reactSelect.components.Input, _objectSpread(_objectSpread({}, ownProps), {}, {
|
|
77
|
+
readOnly: true
|
|
78
|
+
}))
|
|
79
|
+
} : {}), props.components),
|
|
80
|
+
menuIsOpen: props.isReadOnly ? false : undefined,
|
|
81
|
+
styles: selectUtils.createSelectStyles({
|
|
82
|
+
hasWarning: props.hasWarning,
|
|
83
|
+
hasError: props.hasError,
|
|
84
|
+
showOptionGroupDivider: props.showOptionGroupDivider,
|
|
85
|
+
menuPortalZIndex: menuPortalZIndex,
|
|
86
|
+
isCondensed: props.isCondensed,
|
|
87
|
+
isDisabled: props.isDisabled,
|
|
88
|
+
isReadOnly: props.isReadOnly,
|
|
89
|
+
iconLeft: props.iconLeft,
|
|
90
|
+
isMulti: props.isMulti,
|
|
91
|
+
hasValue: !isEmpty__default["default"](value),
|
|
92
|
+
horizontalConstraint: props.horizontalConstraint
|
|
93
|
+
}),
|
|
94
|
+
filterOption: props.filterOption
|
|
95
|
+
// react-select uses "id" (for the container) and "inputId" (for the input),
|
|
96
|
+
// but we use "id" (for the input) and "containerId" (for the container)
|
|
97
|
+
// instead.
|
|
98
|
+
// This makes it easier to less confusing to use with <label />s.
|
|
99
|
+
,
|
|
100
|
+
id: props.containerId,
|
|
101
|
+
inputId: props.id,
|
|
102
|
+
inputValue: props.inputValue,
|
|
103
|
+
isClearable: props.isReadOnly ? false : props.isClearable,
|
|
104
|
+
isDisabled: props.isDisabled,
|
|
105
|
+
isOptionDisabled: props.isOptionDisabled,
|
|
106
|
+
isMulti: props.isMulti,
|
|
107
|
+
isSearchable: isSearchable,
|
|
108
|
+
maxMenuHeight: props.maxMenuHeight,
|
|
109
|
+
menuPortalTarget: props.menuPortalTarget,
|
|
110
|
+
menuShouldBlockScroll: props.menuShouldBlockScroll,
|
|
111
|
+
closeMenuOnSelect: props.closeMenuOnSelect,
|
|
112
|
+
name: props.name,
|
|
113
|
+
noOptionsMessage: props.noOptionsMessage || (_ref2 => {
|
|
114
|
+
let inputValue = _ref2.inputValue;
|
|
115
|
+
return inputValue === '' ? intl.formatMessage(selectUtils.messages.noOptionsMessageWithoutInputValue) : intl.formatMessage(selectUtils.messages.noOptionsMessageWithInputValue, {
|
|
116
|
+
inputValue
|
|
117
|
+
});
|
|
118
|
+
}),
|
|
119
|
+
onBlur: typeof props.onBlur === 'function' ? () => {
|
|
120
|
+
const event = {
|
|
121
|
+
target: {
|
|
122
|
+
id: props.id,
|
|
123
|
+
name: (() => {
|
|
124
|
+
if (!props.isMulti) return props.name;
|
|
125
|
+
// We append the ".0" to make Formik set the touched
|
|
126
|
+
// state as an array instead of a boolean only.
|
|
127
|
+
// Otherwise the shapes would clash on submission, as
|
|
128
|
+
// Formik will create an array on submission anyways.
|
|
129
|
+
return props.name ? `${props.name}.0` : undefined;
|
|
130
|
+
})()
|
|
131
|
+
},
|
|
132
|
+
persist: () => {}
|
|
133
|
+
};
|
|
134
|
+
props.onBlur && props.onBlur(event);
|
|
135
|
+
} : undefined,
|
|
136
|
+
onChange: (value, info) => {
|
|
137
|
+
// selectedOptions is either an array, or a single option, or null
|
|
138
|
+
// depending on whether we're in multi-mode or not (isMulti)
|
|
139
|
+
|
|
140
|
+
let newValue = value;
|
|
141
|
+
if (props.isMulti && !newValue) {
|
|
142
|
+
newValue = [];
|
|
143
|
+
}
|
|
144
|
+
props.onChange?.({
|
|
145
|
+
target: {
|
|
146
|
+
id: props.id,
|
|
147
|
+
name: props.name,
|
|
148
|
+
value: newValue
|
|
149
|
+
},
|
|
150
|
+
persist: () => {}
|
|
151
|
+
}, info);
|
|
152
|
+
},
|
|
153
|
+
onFocus: props.onFocus,
|
|
154
|
+
onInputChange: props.onInputChange,
|
|
155
|
+
options: props.options,
|
|
156
|
+
placeholder: placeholder,
|
|
157
|
+
tabIndex: props.tabIndex,
|
|
158
|
+
tabSelectsValue: props.tabSelectsValue,
|
|
159
|
+
value: value
|
|
160
|
+
// Creatable props
|
|
161
|
+
,
|
|
162
|
+
allowCreateWhileLoading: props.allowCreateWhileLoading,
|
|
163
|
+
formatCreateLabel: props.formatCreateLabel || (inputValue => intl.formatMessage(selectUtils.messages.createLabel, {
|
|
164
|
+
inputValue
|
|
165
|
+
})),
|
|
166
|
+
isValidNewOption: props.isValidNewOption,
|
|
167
|
+
getNewOptionData: props.getNewOptionData,
|
|
168
|
+
onCreateOption: props.onCreateOption,
|
|
169
|
+
createOptionPosition: props.createOptionPosition
|
|
170
|
+
//@ts-ignore
|
|
171
|
+
,
|
|
172
|
+
iconLeft: props.iconLeft,
|
|
173
|
+
isCondensed: props.isCondensed
|
|
174
|
+
})
|
|
175
|
+
}))
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
CreatableSelectInput.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
179
|
+
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
180
|
+
hasError: _pt__default["default"].bool,
|
|
181
|
+
hasWarning: _pt__default["default"].bool,
|
|
182
|
+
isReadOnly: _pt__default["default"].bool,
|
|
183
|
+
iconLeft: _pt__default["default"].node,
|
|
184
|
+
isAutofocussed: _pt__default["default"].bool,
|
|
185
|
+
menuPortalZIndex: _pt__default["default"].number,
|
|
186
|
+
onBlur: _pt__default["default"].func,
|
|
187
|
+
onChange: _pt__default["default"].func,
|
|
188
|
+
options: _pt__default["default"].oneOfType([_pt__default["default"].arrayOf(_pt__default["default"].shape({
|
|
189
|
+
value: _pt__default["default"].string.isRequired,
|
|
190
|
+
label: _pt__default["default"].node
|
|
191
|
+
})), _pt__default["default"].arrayOf(_pt__default["default"].shape({
|
|
192
|
+
options: _pt__default["default"].arrayOf(_pt__default["default"].shape({
|
|
193
|
+
value: _pt__default["default"].string.isRequired,
|
|
194
|
+
label: _pt__default["default"].node
|
|
195
|
+
})).isRequired
|
|
196
|
+
}))]),
|
|
197
|
+
showOptionGroupDivider: _pt__default["default"].bool,
|
|
198
|
+
isCondensed: _pt__default["default"].bool
|
|
199
|
+
} : {};
|
|
200
|
+
CreatableSelectInput.displayName = 'CreatableSelectInput';
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Expose static helper methods.
|
|
204
|
+
*/
|
|
205
|
+
|
|
206
|
+
// Both "true" and an empty array [] represent a touched state. The Boolean
|
|
207
|
+
// conveniently handles both cases
|
|
208
|
+
CreatableSelectInput.isTouched = touched => Boolean(touched);
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Expose react-select components for customization purposes.
|
|
212
|
+
*/
|
|
213
|
+
|
|
214
|
+
// custom
|
|
215
|
+
CreatableSelectInput.ClearIndicator = customizedComponents.ClearIndicator;
|
|
216
|
+
CreatableSelectInput.Control = reactSelect.components.Control;
|
|
217
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
218
|
+
CreatableSelectInput.CrossIcon = reactSelect.components.CrossIcon;
|
|
219
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
220
|
+
CreatableSelectInput.DownChevron = reactSelect.components.DownChevron;
|
|
221
|
+
// custom
|
|
222
|
+
CreatableSelectInput.DropdownIndicator = customizedComponents.DropdownIndicator;
|
|
223
|
+
CreatableSelectInput.Group = reactSelect.components.Group;
|
|
224
|
+
CreatableSelectInput.GroupHeading = reactSelect.components.GroupHeading;
|
|
225
|
+
CreatableSelectInput.IndicatorSeparator = reactSelect.components.IndicatorSeparator;
|
|
226
|
+
CreatableSelectInput.IndicatorsContainer = reactSelect.components.IndicatorsContainer;
|
|
227
|
+
CreatableSelectInput.Input = reactSelect.components.Input;
|
|
228
|
+
CreatableSelectInput.LoadingIndicator = reactSelect.components.LoadingIndicator;
|
|
229
|
+
CreatableSelectInput.LoadingMessage = reactSelect.components.LoadingMessage;
|
|
230
|
+
CreatableSelectInput.Menu = reactSelect.components.Menu;
|
|
231
|
+
CreatableSelectInput.MenuList = reactSelect.components.MenuList;
|
|
232
|
+
//https://github.com/commercetools/ui-kit/pull/3054/files#r1943026570
|
|
233
|
+
CreatableSelectInput.MenuPortal = reactSelect.components.MenuPortal;
|
|
234
|
+
CreatableSelectInput.MultiValue = reactSelect.components.MultiValue;
|
|
235
|
+
CreatableSelectInput.MultiValueContainer = reactSelect.components.MultiValueContainer;
|
|
236
|
+
CreatableSelectInput.MultiValueLabel = reactSelect.components.MultiValueLabel;
|
|
237
|
+
// custom
|
|
238
|
+
CreatableSelectInput.MultiValueRemove = customizedComponents.MultiValueRemove;
|
|
239
|
+
CreatableSelectInput.NoOptionsMessage = reactSelect.components.NoOptionsMessage;
|
|
240
|
+
CreatableSelectInput.Option = reactSelect.components.Option;
|
|
241
|
+
CreatableSelectInput.Placeholder = reactSelect.components.Placeholder;
|
|
242
|
+
CreatableSelectInput.SelectContainer = reactSelect.components.SelectContainer;
|
|
243
|
+
CreatableSelectInput.SingleValue = reactSelect.components.SingleValue;
|
|
244
|
+
CreatableSelectInput.ValueContainer = reactSelect.components.ValueContainer;
|
|
245
|
+
var CreatableSelectInput$1 = CreatableSelectInput;
|
|
246
|
+
|
|
247
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
248
|
+
var version = "19.25.1";
|
|
249
|
+
|
|
250
|
+
exports["default"] = CreatableSelectInput$1;
|
|
251
|
+
exports.version = version;
|