@commercetools-uikit/creatable-select-field 17.0.1 → 18.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 +9 -1
- package/dist/commercetools-uikit-creatable-select-field.cjs.dev.js +23 -9
- package/dist/commercetools-uikit-creatable-select-field.cjs.prod.js +21 -9
- package/dist/commercetools-uikit-creatable-select-field.esm.js +22 -9
- package/dist/declarations/src/creatable-select-field.d.ts +3 -0
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -55,6 +55,8 @@ export default Example;
|
|
|
55
55
|
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
|
|
56
56
|
| `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically.
<br>
Unknown errors will be forwarded to `renderError` |
|
|
57
57
|
| `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
|
|
58
|
+
| `warnings` | `Record` | | | A map of warnings. Warning messages for known warnings are rendered automatically.
<br />
Unknown warnings will be forwarded to `renderWarning` |
|
|
59
|
+
| `renderWarning` | `Function`<br/>[See signature.](#signature-renderWarning) | | | Called with custom warnings. This function can return a message which will be wrapped in an WarningMessage. It can also return null to show no warning. |
|
|
58
60
|
| `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
|
|
59
61
|
| `touched` | `union`<br/>Possible values:<br/>`boolean[] , boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
|
|
60
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) |
|
|
@@ -70,7 +72,7 @@ export default Example;
|
|
|
70
72
|
| `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) |
|
|
71
73
|
| `isMulti` | `CreatableProps['isMulti']` | | | Support multiple selected options
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
72
74
|
| `isSearchable` | `CreatableProps['isSearchable']` | | | Whether to enable search functionality
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
73
|
-
| `hasWarning` | `boolean` | | | Indicates the input field has an error
|
|
75
|
+
| `hasWarning` | `boolean` | | | Indicates the input field has an error
@deprecated Please use the `warnings` prop instead so users know the reason why the field is in warning state. |
|
|
74
76
|
| `maxMenuHeight` | `CreatableProps['maxMenuHeight']` | | | Maximum height of the menu before scrolling
<br>
[Props from React select was used](https://react-select.com/props#creatable-props) |
|
|
75
77
|
| `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) |
|
|
76
78
|
| `menuPortalZIndex` | `number` | | | z-index value for the menu portal
<br>
Use in conjunction with `menuPortalTarget` |
|
|
@@ -109,6 +111,12 @@ export default Example;
|
|
|
109
111
|
(key: string, error?: boolean) => ReactNode;
|
|
110
112
|
```
|
|
111
113
|
|
|
114
|
+
### Signature `renderWarning`
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
(key: string, warning?: boolean) => ReactNode;
|
|
118
|
+
```
|
|
119
|
+
|
|
112
120
|
### Signature `onBlur`
|
|
113
121
|
|
|
114
122
|
```ts
|
|
@@ -14,9 +14,9 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
14
14
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
15
15
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
16
16
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
17
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
18
17
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
19
18
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
19
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
20
20
|
var _pt = require('prop-types');
|
|
21
21
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
22
22
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
@@ -28,6 +28,7 @@ var Spacings = require('@commercetools-uikit/spacings');
|
|
|
28
28
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
29
29
|
var CreatableSelectInput = require('@commercetools-uikit/creatable-select-input');
|
|
30
30
|
var FieldErrors = require('@commercetools-uikit/field-errors');
|
|
31
|
+
var FieldWarnings = require('@commercetools-uikit/field-warnings');
|
|
31
32
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
32
33
|
|
|
33
34
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -50,27 +51,32 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
50
51
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
51
52
|
var CreatableSelectInput__default = /*#__PURE__*/_interopDefault(CreatableSelectInput);
|
|
52
53
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
54
|
+
var FieldWarnings__default = /*#__PURE__*/_interopDefault(FieldWarnings);
|
|
53
55
|
|
|
54
|
-
function ownKeys(
|
|
55
|
-
function _objectSpread(
|
|
56
|
-
function
|
|
57
|
-
function _isNativeReflectConstruct() {
|
|
56
|
+
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; }
|
|
57
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
58
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
59
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
58
60
|
const sequentialId = utils.createSequentialId('creatable-select-field-');
|
|
59
61
|
const sequentialErrorsId = utils.createSequentialId('creatable-select-field-error-')();
|
|
62
|
+
const sequentialWarningsId = utils.createSequentialId('creatable-select-field-warning-')();
|
|
60
63
|
const hasErrors = errors => {
|
|
61
64
|
var _context;
|
|
62
65
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
63
66
|
};
|
|
67
|
+
const hasWarnings = warnings => {
|
|
68
|
+
var _context2;
|
|
69
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
70
|
+
};
|
|
64
71
|
let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
65
72
|
_inherits(CreatableSelectField, _Component);
|
|
66
|
-
var _super = _createSuper(CreatableSelectField);
|
|
67
73
|
function CreatableSelectField() {
|
|
68
74
|
var _this;
|
|
69
75
|
_classCallCheck(this, CreatableSelectField);
|
|
70
76
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
71
77
|
args[_key] = arguments[_key];
|
|
72
78
|
}
|
|
73
|
-
_this =
|
|
79
|
+
_this = _callSuper(this, CreatableSelectField, [...args]);
|
|
74
80
|
_this.state = {
|
|
75
81
|
// We generate an id in case no id is provided by the parent to attach the
|
|
76
82
|
// label to the input component.
|
|
@@ -82,6 +88,7 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
82
88
|
key: "render",
|
|
83
89
|
value: function render() {
|
|
84
90
|
const hasError = CreatableSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
|
|
91
|
+
const hasWarning = this.props.hasWarning || CreatableSelectInput__default["default"].isTouched(this.props.touched) && hasWarnings(this.props.warnings);
|
|
85
92
|
if (!this.props.isReadOnly) {
|
|
86
93
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'CreatableSelectField: `onChange` is required when field is not read only.') : void 0;
|
|
87
94
|
}
|
|
@@ -123,7 +130,7 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
123
130
|
isOptionDisabled: this.props.isOptionDisabled,
|
|
124
131
|
isMulti: this.props.isMulti,
|
|
125
132
|
isSearchable: this.props.isSearchable,
|
|
126
|
-
hasWarning:
|
|
133
|
+
hasWarning: hasWarning,
|
|
127
134
|
maxMenuHeight: this.props.maxMenuHeight,
|
|
128
135
|
menuPortalTarget: this.props.menuPortalTarget,
|
|
129
136
|
menuPortalZIndex: this.props.menuPortalZIndex,
|
|
@@ -154,6 +161,11 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
154
161
|
errors: this.props.errors,
|
|
155
162
|
isVisible: hasError,
|
|
156
163
|
renderError: this.props.renderError
|
|
164
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
165
|
+
id: sequentialWarningsId,
|
|
166
|
+
warnings: this.props.warnings,
|
|
167
|
+
isVisible: hasWarning,
|
|
168
|
+
renderWarning: this.props.renderWarning
|
|
157
169
|
})]
|
|
158
170
|
})
|
|
159
171
|
});
|
|
@@ -183,6 +195,8 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
183
195
|
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
184
196
|
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
185
197
|
renderError: _pt__default["default"].func,
|
|
198
|
+
warnings: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
199
|
+
renderWarning: _pt__default["default"].func,
|
|
186
200
|
isRequired: _pt__default["default"].bool,
|
|
187
201
|
touched: _pt__default["default"].oneOfType([_pt__default["default"].arrayOf(_pt__default["default"].bool), _pt__default["default"].bool]),
|
|
188
202
|
isAutofocussed: _pt__default["default"].bool,
|
|
@@ -211,7 +225,7 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
211
225
|
} : {};
|
|
212
226
|
|
|
213
227
|
// NOTE: This string will be replaced on build time with the package version.
|
|
214
|
-
var version = "
|
|
228
|
+
var version = "18.0.0";
|
|
215
229
|
|
|
216
230
|
exports["default"] = CreatableSelectField;
|
|
217
231
|
exports.version = version;
|
|
@@ -14,9 +14,9 @@ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/obje
|
|
|
14
14
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
15
15
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
16
16
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
17
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
18
17
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
19
18
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
19
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
20
20
|
require('prop-types');
|
|
21
21
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
22
22
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
@@ -28,6 +28,7 @@ var Spacings = require('@commercetools-uikit/spacings');
|
|
|
28
28
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
29
29
|
var CreatableSelectInput = require('@commercetools-uikit/creatable-select-input');
|
|
30
30
|
var FieldErrors = require('@commercetools-uikit/field-errors');
|
|
31
|
+
var FieldWarnings = require('@commercetools-uikit/field-warnings');
|
|
31
32
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
32
33
|
|
|
33
34
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -48,27 +49,32 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
48
49
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
49
50
|
var CreatableSelectInput__default = /*#__PURE__*/_interopDefault(CreatableSelectInput);
|
|
50
51
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
52
|
+
var FieldWarnings__default = /*#__PURE__*/_interopDefault(FieldWarnings);
|
|
51
53
|
|
|
52
|
-
function ownKeys(
|
|
53
|
-
function _objectSpread(
|
|
54
|
-
function
|
|
55
|
-
function _isNativeReflectConstruct() {
|
|
54
|
+
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; }
|
|
55
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
56
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
57
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
56
58
|
const sequentialId = utils.createSequentialId('creatable-select-field-');
|
|
57
59
|
const sequentialErrorsId = utils.createSequentialId('creatable-select-field-error-')();
|
|
60
|
+
const sequentialWarningsId = utils.createSequentialId('creatable-select-field-warning-')();
|
|
58
61
|
const hasErrors = errors => {
|
|
59
62
|
var _context;
|
|
60
63
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
61
64
|
};
|
|
65
|
+
const hasWarnings = warnings => {
|
|
66
|
+
var _context2;
|
|
67
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
68
|
+
};
|
|
62
69
|
let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
63
70
|
_inherits(CreatableSelectField, _Component);
|
|
64
|
-
var _super = _createSuper(CreatableSelectField);
|
|
65
71
|
function CreatableSelectField() {
|
|
66
72
|
var _this;
|
|
67
73
|
_classCallCheck(this, CreatableSelectField);
|
|
68
74
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
69
75
|
args[_key] = arguments[_key];
|
|
70
76
|
}
|
|
71
|
-
_this =
|
|
77
|
+
_this = _callSuper(this, CreatableSelectField, [...args]);
|
|
72
78
|
_this.state = {
|
|
73
79
|
// We generate an id in case no id is provided by the parent to attach the
|
|
74
80
|
// label to the input component.
|
|
@@ -80,6 +86,7 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
80
86
|
key: "render",
|
|
81
87
|
value: function render() {
|
|
82
88
|
const hasError = CreatableSelectInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
|
|
89
|
+
const hasWarning = this.props.hasWarning || CreatableSelectInput__default["default"].isTouched(this.props.touched) && hasWarnings(this.props.warnings);
|
|
83
90
|
if (!this.props.isReadOnly) ;
|
|
84
91
|
if (this.props.hintIcon) ;
|
|
85
92
|
if (this.props.isMulti) ;
|
|
@@ -114,7 +121,7 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
114
121
|
isOptionDisabled: this.props.isOptionDisabled,
|
|
115
122
|
isMulti: this.props.isMulti,
|
|
116
123
|
isSearchable: this.props.isSearchable,
|
|
117
|
-
hasWarning:
|
|
124
|
+
hasWarning: hasWarning,
|
|
118
125
|
maxMenuHeight: this.props.maxMenuHeight,
|
|
119
126
|
menuPortalTarget: this.props.menuPortalTarget,
|
|
120
127
|
menuPortalZIndex: this.props.menuPortalZIndex,
|
|
@@ -145,6 +152,11 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
145
152
|
errors: this.props.errors,
|
|
146
153
|
isVisible: hasError,
|
|
147
154
|
renderError: this.props.renderError
|
|
155
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
156
|
+
id: sequentialWarningsId,
|
|
157
|
+
warnings: this.props.warnings,
|
|
158
|
+
isVisible: hasWarning,
|
|
159
|
+
renderWarning: this.props.renderWarning
|
|
148
160
|
})]
|
|
149
161
|
})
|
|
150
162
|
});
|
|
@@ -173,7 +185,7 @@ CreatableSelectField.getDerivedStateFromProps = (props, state) => ({
|
|
|
173
185
|
CreatableSelectField.propTypes = {};
|
|
174
186
|
|
|
175
187
|
// NOTE: This string will be replaced on build time with the package version.
|
|
176
|
-
var version = "
|
|
188
|
+
var version = "18.0.0";
|
|
177
189
|
|
|
178
190
|
exports["default"] = CreatableSelectField;
|
|
179
191
|
exports.version = version;
|
|
@@ -10,9 +10,9 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
|
|
|
10
10
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
11
11
|
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
12
12
|
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
13
|
-
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
14
13
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
15
14
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
15
|
+
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
16
16
|
import _pt from 'prop-types';
|
|
17
17
|
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
18
18
|
import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
@@ -24,28 +24,33 @@ import Spacings from '@commercetools-uikit/spacings';
|
|
|
24
24
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
25
25
|
import CreatableSelectInput from '@commercetools-uikit/creatable-select-input';
|
|
26
26
|
import FieldErrors from '@commercetools-uikit/field-errors';
|
|
27
|
+
import FieldWarnings from '@commercetools-uikit/field-warnings';
|
|
27
28
|
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
28
29
|
|
|
29
|
-
function ownKeys(
|
|
30
|
-
function _objectSpread(
|
|
31
|
-
function
|
|
32
|
-
function _isNativeReflectConstruct() {
|
|
30
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
32
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
33
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
33
34
|
const sequentialId = createSequentialId('creatable-select-field-');
|
|
34
35
|
const sequentialErrorsId = createSequentialId('creatable-select-field-error-')();
|
|
36
|
+
const sequentialWarningsId = createSequentialId('creatable-select-field-warning-')();
|
|
35
37
|
const hasErrors = errors => {
|
|
36
38
|
var _context;
|
|
37
39
|
return errors && _someInstanceProperty(_context = _Object$values(errors)).call(_context, Boolean);
|
|
38
40
|
};
|
|
41
|
+
const hasWarnings = warnings => {
|
|
42
|
+
var _context2;
|
|
43
|
+
return warnings && _someInstanceProperty(_context2 = _Object$values(warnings)).call(_context2, Boolean);
|
|
44
|
+
};
|
|
39
45
|
let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
40
46
|
_inherits(CreatableSelectField, _Component);
|
|
41
|
-
var _super = _createSuper(CreatableSelectField);
|
|
42
47
|
function CreatableSelectField() {
|
|
43
48
|
var _this;
|
|
44
49
|
_classCallCheck(this, CreatableSelectField);
|
|
45
50
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
46
51
|
args[_key] = arguments[_key];
|
|
47
52
|
}
|
|
48
|
-
_this =
|
|
53
|
+
_this = _callSuper(this, CreatableSelectField, [...args]);
|
|
49
54
|
_this.state = {
|
|
50
55
|
// We generate an id in case no id is provided by the parent to attach the
|
|
51
56
|
// label to the input component.
|
|
@@ -57,6 +62,7 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
57
62
|
key: "render",
|
|
58
63
|
value: function render() {
|
|
59
64
|
const hasError = CreatableSelectInput.isTouched(this.props.touched) && hasErrors(this.props.errors);
|
|
65
|
+
const hasWarning = this.props.hasWarning || CreatableSelectInput.isTouched(this.props.touched) && hasWarnings(this.props.warnings);
|
|
60
66
|
if (!this.props.isReadOnly) {
|
|
61
67
|
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'CreatableSelectField: `onChange` is required when field is not read only.') : void 0;
|
|
62
68
|
}
|
|
@@ -98,7 +104,7 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
98
104
|
isOptionDisabled: this.props.isOptionDisabled,
|
|
99
105
|
isMulti: this.props.isMulti,
|
|
100
106
|
isSearchable: this.props.isSearchable,
|
|
101
|
-
hasWarning:
|
|
107
|
+
hasWarning: hasWarning,
|
|
102
108
|
maxMenuHeight: this.props.maxMenuHeight,
|
|
103
109
|
menuPortalTarget: this.props.menuPortalTarget,
|
|
104
110
|
menuPortalZIndex: this.props.menuPortalZIndex,
|
|
@@ -129,6 +135,11 @@ let CreatableSelectField = /*#__PURE__*/function (_Component) {
|
|
|
129
135
|
errors: this.props.errors,
|
|
130
136
|
isVisible: hasError,
|
|
131
137
|
renderError: this.props.renderError
|
|
138
|
+
}), jsx(FieldWarnings, {
|
|
139
|
+
id: sequentialWarningsId,
|
|
140
|
+
warnings: this.props.warnings,
|
|
141
|
+
isVisible: hasWarning,
|
|
142
|
+
renderWarning: this.props.renderWarning
|
|
132
143
|
})]
|
|
133
144
|
})
|
|
134
145
|
});
|
|
@@ -158,6 +169,8 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
158
169
|
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
159
170
|
errors: _pt.objectOf(_pt.bool),
|
|
160
171
|
renderError: _pt.func,
|
|
172
|
+
warnings: _pt.objectOf(_pt.bool),
|
|
173
|
+
renderWarning: _pt.func,
|
|
161
174
|
isRequired: _pt.bool,
|
|
162
175
|
touched: _pt.oneOfType([_pt.arrayOf(_pt.bool), _pt.bool]),
|
|
163
176
|
isAutofocussed: _pt.bool,
|
|
@@ -186,6 +199,6 @@ CreatableSelectField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
186
199
|
} : {};
|
|
187
200
|
|
|
188
201
|
// NOTE: This string will be replaced on build time with the package version.
|
|
189
|
-
var version = "
|
|
202
|
+
var version = "18.0.0";
|
|
190
203
|
|
|
191
204
|
export { CreatableSelectField as default, version };
|
|
@@ -3,6 +3,7 @@ import type { GroupBase, ActionMeta } from 'react-select';
|
|
|
3
3
|
import type { CreatableProps } from 'react-select/creatable';
|
|
4
4
|
type ReactSelectCreatableProps = CreatableProps<unknown, boolean, GroupBase<unknown>>;
|
|
5
5
|
type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
6
|
+
type TFieldWarnings = Record<string, boolean>;
|
|
6
7
|
type TFieldErrors = Record<string, boolean>;
|
|
7
8
|
type TCustomFormErrors<Values> = {
|
|
8
9
|
[K in keyof Values]?: TFieldErrors;
|
|
@@ -27,6 +28,8 @@ export type TCreatableSelectFieldProps = {
|
|
|
27
28
|
horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
28
29
|
errors?: TFieldErrors;
|
|
29
30
|
renderError?: TErrorRenderer;
|
|
31
|
+
warnings?: TFieldWarnings;
|
|
32
|
+
renderWarning?: (key: string, warning?: boolean) => ReactNode;
|
|
30
33
|
isRequired?: boolean;
|
|
31
34
|
touched?: boolean[] | boolean;
|
|
32
35
|
'aria-label'?: ReactSelectCreatableProps['aria-label'];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/creatable-select-field",
|
|
3
3
|
"description": "A controlled input component with validation states and a label getting a selection from the user, and where options can also be created by the user.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "18.0.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/constraints": "
|
|
25
|
-
"@commercetools-uikit/creatable-select-input": "
|
|
26
|
-
"@commercetools-uikit/design-system": "
|
|
27
|
-
"@commercetools-uikit/field-errors": "
|
|
28
|
-
"@commercetools-uikit/field-label": "
|
|
29
|
-
"@commercetools-uikit/
|
|
30
|
-
"@commercetools-uikit/
|
|
24
|
+
"@commercetools-uikit/constraints": "18.0.0",
|
|
25
|
+
"@commercetools-uikit/creatable-select-input": "18.0.0",
|
|
26
|
+
"@commercetools-uikit/design-system": "18.0.0",
|
|
27
|
+
"@commercetools-uikit/field-errors": "18.0.0",
|
|
28
|
+
"@commercetools-uikit/field-label": "18.0.0",
|
|
29
|
+
"@commercetools-uikit/field-warnings": "18.0.0",
|
|
30
|
+
"@commercetools-uikit/spacings": "18.0.0",
|
|
31
|
+
"@commercetools-uikit/utils": "18.0.0",
|
|
31
32
|
"@emotion/react": "^11.10.5",
|
|
32
33
|
"@emotion/styled": "^11.10.5",
|
|
33
34
|
"prop-types": "15.8.1",
|