@commercetools-uikit/radio-field 12.2.7 → 13.0.2

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
@@ -50,31 +50,46 @@ export default Example;
50
50
 
51
51
  ## Properties
52
52
 
53
- | Props | Type | Required | Default | Description |
54
- | ---------------------- | -------------------------------------------------------------------------------------- | :------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
- | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
56
- | `horizontalConstraint` | `enum`<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
- | `errors` | `object` | | | A map of errors. Error messages for known errors are rendered automatically. Unknown errors will be forwarded to `renderError`. |
58
- | `errors.missing` | `bool` | | | |
59
- | `renderError` | `func` | | | Called with custom errors.&#xA;<br/>&#xA;This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.&#xA;<br/>&#xA;Signature: `(key, error) => React.node` |
60
- | `isRequired` | `bool` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
61
- | `touched` | `bool` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
62
- | `name` | `string` | | | Used as HTML name of the input component. |
63
- | `value` | `string` || | Value of the input component. |
64
- | `onChange` | `custom` | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.&#xA;<br />&#xA;Signature: `(event) => void` |
65
- | `onBlur` | `func` | | | Called when input is blurred&#xA;<br />&#xA;Signature: `(event) => void` |
66
- | `onFocus` | `func` | | | Called when input is focused&#xA;<br />&#xA;Signature: `(event) => void` |
67
- | `isDisabled` | `bool` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
68
- | `isReadOnly` | `bool` | | | Indicates that the field is displaying read-only content |
69
- | `direction` | `enum`<br/>Possible values:<br/>`'stack', 'inline'` | | | Rendering direction of the radio `RadioInput.Option`s |
70
- | `directionProps` | `object` | | | Passes props of the `Spacings.Stack` or `Spacings.Inline`, dependeing on the chosen direction |
71
- | `children` | `node` | ✅ | | At least one `RadioInput.Option` component or another node (mixed children are allowed) |
72
- | `title` | `<string, node>` || | Title of the label |
73
- | `hint` | `custom` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth.&#xA;<br />&#xA;Can also receive a `hintIcon`. |
74
- | `description` | `<string, node>` | | | Provides a description for the title. |
75
- | `onInfoButtonClick` | `func` | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed.&#xA;<br />&#xA;Signature: `(event) => void` |
76
- | `hintIcon` | `node` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
77
- | `badge` | `node` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
53
+ | Props | Type | Required | Default | Description |
54
+ | ---------------------- | ----------------------------------------------------------------------------------------- | :------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
55
+ | `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
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
+ | `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically. Unknown errors will be forwarded to `renderError`. |
58
+ | `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors.&#xA;<br/>&#xA;This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
59
+ | `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
60
+ | `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
61
+ | `name` | `string` | | | Used as HTML name of the input component. |
62
+ | `value` | `string` || | Value of the input component. |
63
+ | `onChange` | `ChangeEventHandler` | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value. |
64
+ | `onBlur` | `FocusEventHandler` | | | Called when input is blurred |
65
+ | `onFocus` | `FocusEventHandler` | | | Called when input is focused |
66
+ | `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
67
+ | `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
68
+ | `direction` | `union`<br/>Possible values:<br/>`'stack' , 'inline'` | | | Rendering direction of the radio `RadioInput.Option`s |
69
+ | `directionProps` | `Partial` | | | Passes props of the `Spacings.Stack` or `Spacings.Inline`, depending on the chosen direction |
70
+ | `children` | `ReactNode` || | At least one `RadioInput.Option` component or another node (mixed children are allowed) |
71
+ | `title` | `union`<br/>Possible values:<br/>`string , ReactNode` | ✅ | | Title of the label |
72
+ | `hint` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth.&#xA;<br />&#xA;Can also receive a `hintIcon`. |
73
+ | `description` | `union`<br/>Possible values:<br/>`string , ReactNode` | | | Provides a description for the title. |
74
+ | `onInfoButtonClick` | `Function`<br/>[See signature.](#signature-onInfoButtonClick) | | | Function called when info button is pressed.&#xA;<br />&#xA;Info button will only be visible when this prop is passed. |
75
+ | `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text.&#xA;<br />&#xA;Will only get rendered when `hint` is passed as well. |
76
+ | `badge` | `ReactNode` | | | Badge to be displayed beside the label.&#xA;<br />&#xA;Might be used to display additional information about the content of the field (E.g verified email) |
77
+
78
+ ## Signatures
79
+
80
+ ### Signature `renderError`
81
+
82
+ ```ts
83
+ (key: string, error?: boolean) => ReactNode;
84
+ ```
85
+
86
+ ### Signature `onInfoButtonClick`
87
+
88
+ ```ts
89
+ (
90
+ event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
91
+ ) => void
92
+ ```
78
93
 
79
94
  ## `data-*` props
80
95
 
@@ -0,0 +1,2 @@
1
+ export * from "./declarations/src/index";
2
+ export { default } from "./declarations/src/index";
@@ -17,12 +17,11 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
17
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
18
18
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
19
19
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
20
+ var _pt = require('prop-types');
20
21
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
21
22
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
22
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
23
24
  var react = require('react');
24
- var PropTypes = require('prop-types');
25
- var requiredIf = require('react-required-if');
26
25
  var utils = require('@commercetools-uikit/utils');
27
26
  var Constraints = require('@commercetools-uikit/constraints');
28
27
  var Stack = require('@commercetools-uikit/spacings-stack');
@@ -42,20 +41,19 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
42
41
  var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
43
42
  var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
44
43
  var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
44
+ var _pt__default = /*#__PURE__*/_interopDefault(_pt);
45
45
  var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
46
46
  var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
47
47
  var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
48
- var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
49
- var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
50
48
  var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
51
49
  var Stack__default = /*#__PURE__*/_interopDefault(Stack);
52
50
  var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
53
51
  var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
54
52
  var RadioInput__default = /*#__PURE__*/_interopDefault(RadioInput);
55
53
 
56
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
54
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
57
55
 
58
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
56
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
59
57
 
60
58
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
61
59
 
@@ -97,6 +95,15 @@ var RadioField = /*#__PURE__*/function (_Component) {
97
95
  key: "render",
98
96
  value: function render() {
99
97
  var hasError = this.props.touched && hasErrors(this.props.errors);
98
+
99
+ if (!this.props.isReadOnly) {
100
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when it is not read only.') : void 0;
101
+ }
102
+
103
+ if (this.props.hintIcon) {
104
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'RadioField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
105
+ }
106
+
100
107
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
101
108
  max: this.props.horizontalConstraint,
102
109
  children: jsxRuntime.jsxs(Stack__default["default"], {
@@ -150,150 +157,33 @@ RadioField.getDerivedStateFromProps = function (props, state) {
150
157
  };
151
158
 
152
159
  RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
153
- // RadioField
154
-
155
- /**
156
- * Used as HTML id property. An id is auto-generated when it is not specified.
157
- */
158
- id: PropTypes__default["default"].string,
159
-
160
- /**
161
- * Horizontal size limit of the input fields.
162
- */
163
- horizontalConstraint: PropTypes__default["default"].oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
164
-
165
- /**
166
- * A map of errors. Error messages for known errors are rendered automatically. Unknown errors will be forwarded to `renderError`.
167
- */
168
- errors: PropTypes__default["default"].shape({
169
- missing: PropTypes__default["default"].bool
170
- }),
171
-
172
- /**
173
- * Called with custom errors.
174
- * <br/>
175
- * This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
176
- * <br/>
177
- * Signature: `(key, error) => React.node`
178
- */
179
- renderError: PropTypes__default["default"].func,
180
-
181
- /**
182
- * Indicates if the value is required. Shows an the "required asterisk" if so.
183
- */
184
- isRequired: PropTypes__default["default"].bool,
185
-
186
- /**
187
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
188
- */
189
- touched: PropTypes__default["default"].bool,
190
- // RadioInput
191
-
192
- /**
193
- * Used as HTML name of the input component.
194
- */
195
- name: PropTypes__default["default"].string,
196
-
197
- /**
198
- * Value of the input component.
199
- */
200
- value: PropTypes__default["default"].string.isRequired,
201
-
202
- /**
203
- * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
204
- * <br />
205
- * Signature: `(event) => void`
206
- */
207
- onChange: requiredIf__default["default"](PropTypes__default["default"].func, function (props) {
208
- return !props.isReadOnly;
209
- }),
210
-
211
- /**
212
- * Called when input is blurred
213
- * <br />
214
- * Signature: `(event) => void`
215
- */
216
- onBlur: PropTypes__default["default"].func,
217
-
218
- /**
219
- * Called when input is focused
220
- * <br />
221
- * Signature: `(event) => void`
222
- */
223
- onFocus: PropTypes__default["default"].func,
224
-
225
- /**
226
- * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
227
- */
228
- isDisabled: PropTypes__default["default"].bool,
229
-
230
- /**
231
- * Indicates that the field is displaying read-only content
232
- */
233
- isReadOnly: PropTypes__default["default"].bool,
234
-
235
- /**
236
- * Rendering direction of the radio `RadioInput.Option`s
237
- */
238
- direction: PropTypes__default["default"].oneOf(['stack', 'inline']),
239
-
240
- /**
241
- * Passes props of the `Spacings.Stack` or `Spacings.Inline`, dependeing on the chosen direction
242
- */
243
- directionProps: PropTypes__default["default"].object,
244
-
245
- /**
246
- * At least one `RadioInput.Option` component or another node (mixed children are allowed)
247
- */
248
- children: PropTypes__default["default"].node.isRequired,
249
- // LabelField
250
-
251
- /**
252
- * Title of the label
253
- */
254
- title: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]).isRequired,
255
-
256
- /**
257
- * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth.
258
- * <br />
259
- * Can also receive a `hintIcon`.
260
- */
261
- hint: requiredIf__default["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]), function (props) {
262
- return props.hintIcon;
263
- }),
264
-
265
- /**
266
- * Provides a description for the title.
267
- */
268
- description: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
269
-
270
- /**
271
- * Function called when info button is pressed.
272
- * <br />
273
- * Info button will only be visible when this prop is passed.
274
- * <br />
275
- * Signature: `(event) => void`
276
- */
277
- onInfoButtonClick: PropTypes__default["default"].func,
278
-
279
- /**
280
- * Icon to be displayed beside the hint text.
281
- * <br />
282
- * Will only get rendered when `hint` is passed as well.
283
- */
284
- hintIcon: PropTypes__default["default"].node,
285
-
286
- /**
287
- * Badge to be displayed beside the label.
288
- * <br />
289
- * Might be used to display additional information about the content of the field (E.g verified email)
290
- */
291
- badge: PropTypes__default["default"].node
160
+ id: _pt__default["default"].string,
161
+ horizontalConstraint: _pt__default["default"].oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
162
+ errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
163
+ renderError: _pt__default["default"].func,
164
+ isRequired: _pt__default["default"].bool,
165
+ touched: _pt__default["default"].bool,
166
+ name: _pt__default["default"].string,
167
+ value: _pt__default["default"].string.isRequired,
168
+ onChange: _pt__default["default"].func,
169
+ onBlur: _pt__default["default"].func,
170
+ onFocus: _pt__default["default"].func,
171
+ isDisabled: _pt__default["default"].bool,
172
+ isReadOnly: _pt__default["default"].bool,
173
+ direction: _pt__default["default"].oneOf(['stack', 'inline']),
174
+ directionProps: _pt__default["default"].any,
175
+ children: _pt__default["default"].node.isRequired,
176
+ title: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]).isRequired,
177
+ hint: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
178
+ description: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
179
+ onInfoButtonClick: _pt__default["default"].func,
180
+ hintIcon: _pt__default["default"].element,
181
+ badge: _pt__default["default"].node
292
182
  } : {};
293
183
  var RadioField$1 = RadioField;
294
184
 
295
185
  // NOTE: This string will be replaced on build time with the package version.
296
- var version = "12.2.7";
186
+ var version = "13.0.2";
297
187
 
298
188
  exports["default"] = RadioField$1;
299
189
  exports.version = version;
@@ -17,12 +17,11 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
17
17
  var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
18
18
  var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
19
19
  var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
20
+ require('prop-types');
20
21
  var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
21
22
  var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
22
23
  var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
23
24
  var react = require('react');
24
- require('prop-types');
25
- require('react-required-if');
26
25
  var utils = require('@commercetools-uikit/utils');
27
26
  var Constraints = require('@commercetools-uikit/constraints');
28
27
  var Stack = require('@commercetools-uikit/spacings-stack');
@@ -51,9 +50,9 @@ var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
51
50
  var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
52
51
  var RadioInput__default = /*#__PURE__*/_interopDefault(RadioInput);
53
52
 
54
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (enumerableOnly) { symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
53
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); enumerableOnly && (symbols = _filterInstanceProperty__default["default"](symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor__default["default"](object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
55
54
 
56
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context4; _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
55
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } return target; }
57
56
 
58
57
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
59
58
 
@@ -95,6 +94,11 @@ var RadioField = /*#__PURE__*/function (_Component) {
95
94
  key: "render",
96
95
  value: function render() {
97
96
  var hasError = this.props.touched && hasErrors(this.props.errors);
97
+
98
+ if (!this.props.isReadOnly) ;
99
+
100
+ if (this.props.hintIcon) ;
101
+
98
102
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
99
103
  max: this.props.horizontalConstraint,
100
104
  children: jsxRuntime.jsxs(Stack__default["default"], {
@@ -151,7 +155,7 @@ RadioField.propTypes = {};
151
155
  var RadioField$1 = RadioField;
152
156
 
153
157
  // NOTE: This string will be replaced on build time with the package version.
154
- var version = "12.2.7";
158
+ var version = "13.0.2";
155
159
 
156
160
  exports["default"] = RadioField$1;
157
161
  exports.version = version;
@@ -13,13 +13,12 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
13
13
  import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
14
14
  import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
15
15
  import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
16
+ import _pt from 'prop-types';
16
17
  import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
17
18
  import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
18
19
  import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
19
- import { Component } from 'react';
20
- import PropTypes from 'prop-types';
21
- import requiredIf from 'react-required-if';
22
- import { createSequentialId, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
20
+ import { isValidElement, Component } from 'react';
21
+ import { createSequentialId, warning, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
23
22
  import Constraints from '@commercetools-uikit/constraints';
24
23
  import Stack from '@commercetools-uikit/spacings-stack';
25
24
  import FieldLabel from '@commercetools-uikit/field-label';
@@ -27,9 +26,9 @@ import FieldErrors from '@commercetools-uikit/field-errors';
27
26
  import RadioInput from '@commercetools-uikit/radio-input';
28
27
  import { jsx, jsxs } from '@emotion/react/jsx-runtime';
29
28
 
30
- function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); if (enumerableOnly) { symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
29
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
31
30
 
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; _forEachInstanceProperty(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors) { _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)); } else { var _context4; _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context3, _context4; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(source), !0)).call(_context3, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context4 = ownKeys(Object(source))).call(_context4, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
33
32
 
34
33
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
35
34
 
@@ -71,6 +70,15 @@ var RadioField = /*#__PURE__*/function (_Component) {
71
70
  key: "render",
72
71
  value: function render() {
73
72
  var hasError = this.props.touched && hasErrors(this.props.errors);
73
+
74
+ if (!this.props.isReadOnly) {
75
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'RadioField: `onChange` is required when it is not read only.') : void 0;
76
+ }
77
+
78
+ if (this.props.hintIcon) {
79
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'RadioField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
80
+ }
81
+
74
82
  return jsx(Constraints.Horizontal, {
75
83
  max: this.props.horizontalConstraint,
76
84
  children: jsxs(Stack, {
@@ -124,149 +132,32 @@ RadioField.getDerivedStateFromProps = function (props, state) {
124
132
  };
125
133
 
126
134
  RadioField.propTypes = process.env.NODE_ENV !== "production" ? {
127
- // RadioField
128
-
129
- /**
130
- * Used as HTML id property. An id is auto-generated when it is not specified.
131
- */
132
- id: PropTypes.string,
133
-
134
- /**
135
- * Horizontal size limit of the input fields.
136
- */
137
- horizontalConstraint: PropTypes.oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
138
-
139
- /**
140
- * A map of errors. Error messages for known errors are rendered automatically. Unknown errors will be forwarded to `renderError`.
141
- */
142
- errors: PropTypes.shape({
143
- missing: PropTypes.bool
144
- }),
145
-
146
- /**
147
- * Called with custom errors.
148
- * <br/>
149
- * This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error.
150
- * <br/>
151
- * Signature: `(key, error) => React.node`
152
- */
153
- renderError: PropTypes.func,
154
-
155
- /**
156
- * Indicates if the value is required. Shows an the "required asterisk" if so.
157
- */
158
- isRequired: PropTypes.bool,
159
-
160
- /**
161
- * Indicates whether the field was touched. Errors will only be shown when the field was touched.
162
- */
163
- touched: PropTypes.bool,
164
- // RadioInput
165
-
166
- /**
167
- * Used as HTML name of the input component.
168
- */
169
- name: PropTypes.string,
170
-
171
- /**
172
- * Value of the input component.
173
- */
174
- value: PropTypes.string.isRequired,
175
-
176
- /**
177
- * Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
178
- * <br />
179
- * Signature: `(event) => void`
180
- */
181
- onChange: requiredIf(PropTypes.func, function (props) {
182
- return !props.isReadOnly;
183
- }),
184
-
185
- /**
186
- * Called when input is blurred
187
- * <br />
188
- * Signature: `(event) => void`
189
- */
190
- onBlur: PropTypes.func,
191
-
192
- /**
193
- * Called when input is focused
194
- * <br />
195
- * Signature: `(event) => void`
196
- */
197
- onFocus: PropTypes.func,
198
-
199
- /**
200
- * Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
201
- */
202
- isDisabled: PropTypes.bool,
203
-
204
- /**
205
- * Indicates that the field is displaying read-only content
206
- */
207
- isReadOnly: PropTypes.bool,
208
-
209
- /**
210
- * Rendering direction of the radio `RadioInput.Option`s
211
- */
212
- direction: PropTypes.oneOf(['stack', 'inline']),
213
-
214
- /**
215
- * Passes props of the `Spacings.Stack` or `Spacings.Inline`, dependeing on the chosen direction
216
- */
217
- directionProps: PropTypes.object,
218
-
219
- /**
220
- * At least one `RadioInput.Option` component or another node (mixed children are allowed)
221
- */
222
- children: PropTypes.node.isRequired,
223
- // LabelField
224
-
225
- /**
226
- * Title of the label
227
- */
228
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
229
-
230
- /**
231
- * Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas description can describe it in more depth.
232
- * <br />
233
- * Can also receive a `hintIcon`.
234
- */
235
- hint: requiredIf(PropTypes.oneOfType([PropTypes.string, PropTypes.node]), function (props) {
236
- return props.hintIcon;
237
- }),
238
-
239
- /**
240
- * Provides a description for the title.
241
- */
242
- description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
243
-
244
- /**
245
- * Function called when info button is pressed.
246
- * <br />
247
- * Info button will only be visible when this prop is passed.
248
- * <br />
249
- * Signature: `(event) => void`
250
- */
251
- onInfoButtonClick: PropTypes.func,
252
-
253
- /**
254
- * Icon to be displayed beside the hint text.
255
- * <br />
256
- * Will only get rendered when `hint` is passed as well.
257
- */
258
- hintIcon: PropTypes.node,
259
-
260
- /**
261
- * Badge to be displayed beside the label.
262
- * <br />
263
- * Might be used to display additional information about the content of the field (E.g verified email)
264
- */
265
- badge: PropTypes.node
135
+ id: _pt.string,
136
+ horizontalConstraint: _pt.oneOf([7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
137
+ errors: _pt.objectOf(_pt.bool),
138
+ renderError: _pt.func,
139
+ isRequired: _pt.bool,
140
+ touched: _pt.bool,
141
+ name: _pt.string,
142
+ value: _pt.string.isRequired,
143
+ onChange: _pt.func,
144
+ onBlur: _pt.func,
145
+ onFocus: _pt.func,
146
+ isDisabled: _pt.bool,
147
+ isReadOnly: _pt.bool,
148
+ direction: _pt.oneOf(['stack', 'inline']),
149
+ directionProps: _pt.any,
150
+ children: _pt.node.isRequired,
151
+ title: _pt.oneOfType([_pt.string, _pt.node]).isRequired,
152
+ hint: _pt.oneOfType([_pt.string, _pt.node]),
153
+ description: _pt.oneOfType([_pt.string, _pt.node]),
154
+ onInfoButtonClick: _pt.func,
155
+ hintIcon: _pt.element,
156
+ badge: _pt.node
266
157
  } : {};
267
158
  var RadioField$1 = RadioField;
268
159
 
269
160
  // NOTE: This string will be replaced on build time with the package version.
270
- var version = "12.2.7";
161
+ var version = "13.0.2";
271
162
 
272
163
  export { RadioField$1 as default, version };
@@ -0,0 +1,2 @@
1
+ export { default } from './radio-field';
2
+ export { default as version } from './version';
@@ -0,0 +1,43 @@
1
+ import { Component, type ChangeEventHandler, type FocusEventHandler, type ReactElement, type ReactNode, type MouseEvent, type KeyboardEvent } from 'react';
2
+ import { type TStackProps } from '@commercetools-uikit/spacings-stack';
3
+ declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
4
+ declare type TFieldErrors = Record<string, boolean>;
5
+ declare type TRadioFieldProps = {
6
+ id?: string;
7
+ horizontalConstraint?: 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
8
+ errors?: TFieldErrors;
9
+ renderError?: TErrorRenderer;
10
+ isRequired?: boolean;
11
+ touched?: boolean;
12
+ name?: string;
13
+ value: string;
14
+ onChange?: ChangeEventHandler;
15
+ onBlur?: FocusEventHandler;
16
+ onFocus?: FocusEventHandler;
17
+ isDisabled?: boolean;
18
+ isReadOnly?: boolean;
19
+ direction?: 'stack' | 'inline';
20
+ directionProps?: Partial<TStackProps>;
21
+ children: ReactNode;
22
+ title: string | ReactNode;
23
+ hint?: string | ReactNode;
24
+ description?: string | ReactNode;
25
+ onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
26
+ hintIcon?: ReactElement;
27
+ badge?: ReactNode;
28
+ };
29
+ declare type TRadioFieldStates = Pick<TRadioFieldProps, 'id'>;
30
+ declare class RadioField extends Component<TRadioFieldProps, TRadioFieldStates> {
31
+ static displayName: string;
32
+ static defaultProps: {
33
+ horizontalConstraint: string;
34
+ };
35
+ state: {
36
+ id: string | undefined;
37
+ };
38
+ static getDerivedStateFromProps: (props: TRadioFieldProps, state: TRadioFieldStates) => {
39
+ id: string;
40
+ };
41
+ render(): import("@emotion/react/jsx-runtime").JSX.Element;
42
+ }
43
+ export default RadioField;
@@ -0,0 +1,2 @@
1
+ declare const _default: "__@UI_KIT_PACKAGE/VERSION_OF_RELEASE__";
2
+ export default _default;
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": "12.2.7",
4
+ "version": "13.0.2",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,18 +19,18 @@
19
19
  "module": "dist/commercetools-uikit-radio-field.esm.js",
20
20
  "files": ["dist"],
21
21
  "dependencies": {
22
- "@babel/runtime": "7.16.3",
23
- "@babel/runtime-corejs3": "7.16.3",
24
- "@commercetools-uikit/constraints": "12.2.5",
25
- "@commercetools-uikit/design-system": "12.2.5",
26
- "@commercetools-uikit/field-errors": "12.2.5",
27
- "@commercetools-uikit/field-label": "12.2.7",
28
- "@commercetools-uikit/radio-input": "12.2.7",
29
- "@commercetools-uikit/spacings-stack": "12.2.5",
30
- "@commercetools-uikit/utils": "12.2.5",
22
+ "@babel/runtime": "7.17.2",
23
+ "@babel/runtime-corejs3": "7.17.2",
24
+ "@commercetools-uikit/constraints": "13.0.2",
25
+ "@commercetools-uikit/design-system": "13.0.0",
26
+ "@commercetools-uikit/field-errors": "13.0.2",
27
+ "@commercetools-uikit/field-label": "13.0.2",
28
+ "@commercetools-uikit/radio-input": "13.0.2",
29
+ "@commercetools-uikit/spacings-stack": "13.0.2",
30
+ "@commercetools-uikit/utils": "13.0.2",
31
31
  "@emotion/react": "^11.4.0",
32
32
  "@emotion/styled": "^11.3.0",
33
- "prop-types": "15.7.2",
33
+ "prop-types": "15.8.1",
34
34
  "react-required-if": "1.0.3"
35
35
  },
36
36
  "devDependencies": {