@commercetools-uikit/radio-field 17.0.1 → 17.1.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
CHANGED
|
@@ -55,7 +55,9 @@ export default Example;
|
|
|
55
55
|
| `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
|
|
56
56
|
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
|
|
57
57
|
| `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically. Unknown errors will be forwarded to `renderError`. |
|
|
58
|
+
| `warnings` | `Record` | | | A map of warnings. Warning messages for known warnings are rendered automatically.
<br/>
Unknown warnings will be forwarded to renderWarning. |
|
|
58
59
|
| `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors.
<br/>
This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
|
|
60
|
+
| `renderWarning` | `Function`<br/>[See signature.](#signature-renderWarning) | | | Called with custom warnings, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.
<br />
It can also return null to show no warning. |
|
|
59
61
|
| `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
|
|
60
62
|
| `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
|
|
61
63
|
| `name` | `string` | | | Used as HTML name of the input component. |
|
|
@@ -83,6 +85,12 @@ export default Example;
|
|
|
83
85
|
(key: string, error?: boolean) => ReactNode;
|
|
84
86
|
```
|
|
85
87
|
|
|
88
|
+
### Signature `renderWarning`
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
(key: string, warning?: boolean) => ReactNode;
|
|
92
|
+
```
|
|
93
|
+
|
|
86
94
|
### Signature `onInfoButtonClick`
|
|
87
95
|
|
|
88
96
|
```ts
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
7
7
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
8
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
9
8
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
10
9
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
10
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
11
11
|
var _pt = require('prop-types');
|
|
12
12
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
13
13
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
@@ -27,6 +27,7 @@ var Stack = require('@commercetools-uikit/spacings-stack');
|
|
|
27
27
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
28
28
|
var FieldErrors = require('@commercetools-uikit/field-errors');
|
|
29
29
|
var RadioInput = require('@commercetools-uikit/radio-input');
|
|
30
|
+
var FieldWarnings = require('@commercetools-uikit/field-warnings');
|
|
30
31
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
31
32
|
|
|
32
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -48,27 +49,32 @@ var Stack__default = /*#__PURE__*/_interopDefault(Stack);
|
|
|
48
49
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
49
50
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
50
51
|
var RadioInput__default = /*#__PURE__*/_interopDefault(RadioInput);
|
|
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('radio-field-');
|
|
57
59
|
const sequentialErrorsId = utils.createSequentialId('radio-field-error-')();
|
|
60
|
+
const sequentialWarningsId = utils.createSequentialId('radio-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 RadioField = /*#__PURE__*/function (_Component) {
|
|
63
70
|
_inherits(RadioField, _Component);
|
|
64
|
-
var _super = _createSuper(RadioField);
|
|
65
71
|
function RadioField() {
|
|
66
72
|
var _this;
|
|
67
73
|
_classCallCheck(this, RadioField);
|
|
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, RadioField, [...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 RadioField = /*#__PURE__*/function (_Component) {
|
|
|
80
86
|
key: "render",
|
|
81
87
|
value: function render() {
|
|
82
88
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
89
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
83
90
|
if (!this.props.isReadOnly) {
|
|
84
91
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when field is not read only.') : void 0;
|
|
85
92
|
}
|
|
@@ -109,6 +116,7 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
109
116
|
isDisabled: this.props.isDisabled,
|
|
110
117
|
isReadOnly: this.props.isReadOnly,
|
|
111
118
|
hasError: hasError,
|
|
119
|
+
hasWarning: hasWarning,
|
|
112
120
|
horizontalConstraint: this.props.horizontalConstraint,
|
|
113
121
|
direction: this.props.direction,
|
|
114
122
|
directionProps: this.props.directionProps
|
|
@@ -121,6 +129,11 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
121
129
|
errors: this.props.errors,
|
|
122
130
|
isVisible: hasError,
|
|
123
131
|
renderError: this.props.renderError
|
|
132
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
133
|
+
id: sequentialWarningsId,
|
|
134
|
+
warnings: this.props.warnings,
|
|
135
|
+
isVisible: hasWarning,
|
|
136
|
+
renderWarning: this.props.renderWarning
|
|
124
137
|
})]
|
|
125
138
|
})
|
|
126
139
|
});
|
|
@@ -150,7 +163,9 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
150
163
|
id: _pt__default["default"].string,
|
|
151
164
|
horizontalConstraint: _pt__default["default"].oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
152
165
|
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
166
|
+
warnings: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
153
167
|
renderError: _pt__default["default"].func,
|
|
168
|
+
renderWarning: _pt__default["default"].func,
|
|
154
169
|
isRequired: _pt__default["default"].bool,
|
|
155
170
|
touched: _pt__default["default"].bool,
|
|
156
171
|
name: _pt__default["default"].string,
|
|
@@ -173,7 +188,7 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
173
188
|
var RadioField$1 = RadioField;
|
|
174
189
|
|
|
175
190
|
// NOTE: This string will be replaced on build time with the package version.
|
|
176
|
-
var version = "17.0
|
|
191
|
+
var version = "17.1.0";
|
|
177
192
|
|
|
178
193
|
exports["default"] = RadioField$1;
|
|
179
194
|
exports.version = version;
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
7
7
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
8
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
9
8
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
10
9
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
10
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
11
11
|
require('prop-types');
|
|
12
12
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
13
13
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
@@ -27,6 +27,7 @@ var Stack = require('@commercetools-uikit/spacings-stack');
|
|
|
27
27
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
28
28
|
var FieldErrors = require('@commercetools-uikit/field-errors');
|
|
29
29
|
var RadioInput = require('@commercetools-uikit/radio-input');
|
|
30
|
+
var FieldWarnings = require('@commercetools-uikit/field-warnings');
|
|
30
31
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
31
32
|
|
|
32
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -47,27 +48,32 @@ var Stack__default = /*#__PURE__*/_interopDefault(Stack);
|
|
|
47
48
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
48
49
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
49
50
|
var RadioInput__default = /*#__PURE__*/_interopDefault(RadioInput);
|
|
51
|
+
var FieldWarnings__default = /*#__PURE__*/_interopDefault(FieldWarnings);
|
|
50
52
|
|
|
51
|
-
function ownKeys(
|
|
52
|
-
function _objectSpread(
|
|
53
|
-
function
|
|
54
|
-
function _isNativeReflectConstruct() {
|
|
53
|
+
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; }
|
|
54
|
+
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; }
|
|
55
|
+
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)); }
|
|
56
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
55
57
|
const sequentialId = utils.createSequentialId('radio-field-');
|
|
56
58
|
const sequentialErrorsId = utils.createSequentialId('radio-field-error-')();
|
|
59
|
+
const sequentialWarningsId = utils.createSequentialId('radio-field-warning-')();
|
|
57
60
|
const hasErrors = errors => {
|
|
58
61
|
var _context;
|
|
59
62
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
60
63
|
};
|
|
64
|
+
const hasWarnings = warnings => {
|
|
65
|
+
var _context2;
|
|
66
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
67
|
+
};
|
|
61
68
|
let RadioField = /*#__PURE__*/function (_Component) {
|
|
62
69
|
_inherits(RadioField, _Component);
|
|
63
|
-
var _super = _createSuper(RadioField);
|
|
64
70
|
function RadioField() {
|
|
65
71
|
var _this;
|
|
66
72
|
_classCallCheck(this, RadioField);
|
|
67
73
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
68
74
|
args[_key] = arguments[_key];
|
|
69
75
|
}
|
|
70
|
-
_this =
|
|
76
|
+
_this = _callSuper(this, RadioField, [...args]);
|
|
71
77
|
_this.state = {
|
|
72
78
|
// We generate an id in case no id is provided by the parent to attach the
|
|
73
79
|
// label to the input component.
|
|
@@ -79,6 +85,7 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
79
85
|
key: "render",
|
|
80
86
|
value: function render() {
|
|
81
87
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
88
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
82
89
|
if (!this.props.isReadOnly) ;
|
|
83
90
|
if (this.props.hintIcon) ;
|
|
84
91
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
@@ -104,6 +111,7 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
104
111
|
isDisabled: this.props.isDisabled,
|
|
105
112
|
isReadOnly: this.props.isReadOnly,
|
|
106
113
|
hasError: hasError,
|
|
114
|
+
hasWarning: hasWarning,
|
|
107
115
|
horizontalConstraint: this.props.horizontalConstraint,
|
|
108
116
|
direction: this.props.direction,
|
|
109
117
|
directionProps: this.props.directionProps
|
|
@@ -116,6 +124,11 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
116
124
|
errors: this.props.errors,
|
|
117
125
|
isVisible: hasError,
|
|
118
126
|
renderError: this.props.renderError
|
|
127
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
128
|
+
id: sequentialWarningsId,
|
|
129
|
+
warnings: this.props.warnings,
|
|
130
|
+
isVisible: hasWarning,
|
|
131
|
+
renderWarning: this.props.renderWarning
|
|
119
132
|
})]
|
|
120
133
|
})
|
|
121
134
|
});
|
|
@@ -145,7 +158,7 @@ RadioField.propTypes = {};
|
|
|
145
158
|
var RadioField$1 = RadioField;
|
|
146
159
|
|
|
147
160
|
// NOTE: This string will be replaced on build time with the package version.
|
|
148
|
-
var version = "17.0
|
|
161
|
+
var version = "17.1.0";
|
|
149
162
|
|
|
150
163
|
exports["default"] = RadioField$1;
|
|
151
164
|
exports.version = version;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
2
2
|
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
3
3
|
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
4
|
-
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
5
4
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
6
5
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
6
|
+
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
7
7
|
import _pt from 'prop-types';
|
|
8
8
|
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
9
9
|
import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
@@ -23,28 +23,33 @@ import Stack from '@commercetools-uikit/spacings-stack';
|
|
|
23
23
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
24
24
|
import FieldErrors from '@commercetools-uikit/field-errors';
|
|
25
25
|
import RadioInput from '@commercetools-uikit/radio-input';
|
|
26
|
+
import FieldWarnings from '@commercetools-uikit/field-warnings';
|
|
26
27
|
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
27
28
|
|
|
28
|
-
function ownKeys(
|
|
29
|
-
function _objectSpread(
|
|
30
|
-
function
|
|
31
|
-
function _isNativeReflectConstruct() {
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
31
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
32
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
32
33
|
const sequentialId = createSequentialId('radio-field-');
|
|
33
34
|
const sequentialErrorsId = createSequentialId('radio-field-error-')();
|
|
35
|
+
const sequentialWarningsId = createSequentialId('radio-field-warning-')();
|
|
34
36
|
const hasErrors = errors => {
|
|
35
37
|
var _context;
|
|
36
38
|
return errors && _someInstanceProperty(_context = _Object$values(errors)).call(_context, Boolean);
|
|
37
39
|
};
|
|
40
|
+
const hasWarnings = warnings => {
|
|
41
|
+
var _context2;
|
|
42
|
+
return warnings && _someInstanceProperty(_context2 = _Object$values(warnings)).call(_context2, Boolean);
|
|
43
|
+
};
|
|
38
44
|
let RadioField = /*#__PURE__*/function (_Component) {
|
|
39
45
|
_inherits(RadioField, _Component);
|
|
40
|
-
var _super = _createSuper(RadioField);
|
|
41
46
|
function RadioField() {
|
|
42
47
|
var _this;
|
|
43
48
|
_classCallCheck(this, RadioField);
|
|
44
49
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
50
|
args[_key] = arguments[_key];
|
|
46
51
|
}
|
|
47
|
-
_this =
|
|
52
|
+
_this = _callSuper(this, RadioField, [...args]);
|
|
48
53
|
_this.state = {
|
|
49
54
|
// We generate an id in case no id is provided by the parent to attach the
|
|
50
55
|
// label to the input component.
|
|
@@ -56,6 +61,7 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
56
61
|
key: "render",
|
|
57
62
|
value: function render() {
|
|
58
63
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
64
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
59
65
|
if (!this.props.isReadOnly) {
|
|
60
66
|
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when field is not read only.') : void 0;
|
|
61
67
|
}
|
|
@@ -85,6 +91,7 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
85
91
|
isDisabled: this.props.isDisabled,
|
|
86
92
|
isReadOnly: this.props.isReadOnly,
|
|
87
93
|
hasError: hasError,
|
|
94
|
+
hasWarning: hasWarning,
|
|
88
95
|
horizontalConstraint: this.props.horizontalConstraint,
|
|
89
96
|
direction: this.props.direction,
|
|
90
97
|
directionProps: this.props.directionProps
|
|
@@ -97,6 +104,11 @@ let RadioField = /*#__PURE__*/function (_Component) {
|
|
|
97
104
|
errors: this.props.errors,
|
|
98
105
|
isVisible: hasError,
|
|
99
106
|
renderError: this.props.renderError
|
|
107
|
+
}), jsx(FieldWarnings, {
|
|
108
|
+
id: sequentialWarningsId,
|
|
109
|
+
warnings: this.props.warnings,
|
|
110
|
+
isVisible: hasWarning,
|
|
111
|
+
renderWarning: this.props.renderWarning
|
|
100
112
|
})]
|
|
101
113
|
})
|
|
102
114
|
});
|
|
@@ -126,7 +138,9 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
126
138
|
id: _pt.string,
|
|
127
139
|
horizontalConstraint: _pt.oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
128
140
|
errors: _pt.objectOf(_pt.bool),
|
|
141
|
+
warnings: _pt.objectOf(_pt.bool),
|
|
129
142
|
renderError: _pt.func,
|
|
143
|
+
renderWarning: _pt.func,
|
|
130
144
|
isRequired: _pt.bool,
|
|
131
145
|
touched: _pt.bool,
|
|
132
146
|
name: _pt.string,
|
|
@@ -149,6 +163,6 @@ RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
149
163
|
var RadioField$1 = RadioField;
|
|
150
164
|
|
|
151
165
|
// NOTE: This string will be replaced on build time with the package version.
|
|
152
|
-
var version = "17.0
|
|
166
|
+
var version = "17.1.0";
|
|
153
167
|
|
|
154
168
|
export { RadioField$1 as default, version };
|
|
@@ -2,6 +2,7 @@ import { Component, type ChangeEventHandler, type FocusEventHandler, type ReactE
|
|
|
2
2
|
import { type TStackProps } from '@commercetools-uikit/spacings-stack';
|
|
3
3
|
type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
4
4
|
type TFieldErrors = Record<string, boolean>;
|
|
5
|
+
type TFieldWarnings = Record<string, boolean>;
|
|
5
6
|
type TCustomFormErrors<Values> = {
|
|
6
7
|
[K in keyof Values]?: TFieldErrors;
|
|
7
8
|
};
|
|
@@ -9,7 +10,9 @@ export type TRadioFieldProps = {
|
|
|
9
10
|
id?: string;
|
|
10
11
|
horizontalConstraint?: 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
11
12
|
errors?: TFieldErrors;
|
|
13
|
+
warnings?: TFieldWarnings;
|
|
12
14
|
renderError?: TErrorRenderer;
|
|
15
|
+
renderWarning?: (key: string, warning?: boolean) => ReactNode;
|
|
13
16
|
isRequired?: boolean;
|
|
14
17
|
touched?: boolean;
|
|
15
18
|
name?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/radio-field",
|
|
3
3
|
"description": "A controlled radio input component with validation states and a label.",
|
|
4
|
-
"version": "17.0
|
|
4
|
+
"version": "17.1.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": "17.0
|
|
25
|
-
"@commercetools-uikit/design-system": "17.0
|
|
26
|
-
"@commercetools-uikit/field-errors": "17.0
|
|
27
|
-
"@commercetools-uikit/field-label": "17.0
|
|
28
|
-
"@commercetools-uikit/
|
|
29
|
-
"@commercetools-uikit/
|
|
30
|
-
"@commercetools-uikit/
|
|
24
|
+
"@commercetools-uikit/constraints": "17.1.0",
|
|
25
|
+
"@commercetools-uikit/design-system": "17.1.0",
|
|
26
|
+
"@commercetools-uikit/field-errors": "17.1.0",
|
|
27
|
+
"@commercetools-uikit/field-label": "17.1.0",
|
|
28
|
+
"@commercetools-uikit/field-warnings": "17.1.0",
|
|
29
|
+
"@commercetools-uikit/radio-input": "17.1.0",
|
|
30
|
+
"@commercetools-uikit/spacings-stack": "17.1.0",
|
|
31
|
+
"@commercetools-uikit/utils": "17.1.0",
|
|
31
32
|
"@emotion/react": "^11.10.5",
|
|
32
33
|
"@emotion/styled": "^11.10.5",
|
|
33
34
|
"prop-types": "15.8.1",
|