@commercetools-uikit/money-field 14.0.1 → 14.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
@@ -77,7 +77,7 @@ export default Example;
77
77
  | `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
78
78
  | `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
79
79
  | `isAutofocussed` | `boolean` | | | Focus the input on initial render |
80
- | `onChange` | `Function`<br/>[See signature.](#signature-onChange) || | Called with the event of the input or dropdown when either the currency or the amount have changed. |
80
+ | `onChange` | `Function`<br/>[See signature.](#signature-onChange) | | | Called with the event of the input or dropdown when either the currency or the amount have changed. |
81
81
  | `menuPortalTarget` | `ReactSelectProps['menuPortalTarget']` | | | Dom element to portal the currency select menu to&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
82
82
  | `menuPortalZIndex` | `number` | | | z-index value for the currency select menu portal |
83
83
  | `menuShouldBlockScroll` | `ReactSelectProps['menuShouldBlockScroll']` | | | whether the menu should block scroll while open&#xA;<br>&#xA;[Props from React select was used](https://react-select.com/props) |
@@ -117,19 +117,19 @@ export default Example;
117
117
  ### Signature `onBlur`
118
118
 
119
119
  ```ts
120
- (event: TEvent) => void
120
+ (event: TCustomEvent) => void
121
121
  ```
122
122
 
123
123
  ### Signature `onFocus`
124
124
 
125
125
  ```ts
126
- (event: TEvent) => void
126
+ (event: TCustomEvent) => void
127
127
  ```
128
128
 
129
129
  ### Signature `onChange`
130
130
 
131
131
  ```ts
132
- (event: TEvent) => void
132
+ (event: TCustomEvent) => void
133
133
  ```
134
134
 
135
135
  ### Signature `onInfoButtonClick`
@@ -101,6 +101,11 @@ var MoneyField = /*#__PURE__*/function (_Component) {
101
101
  // This avoids showing an error when the user just selected a language but
102
102
  // didn't add an amount yet.
103
103
  var hasError = MoneyInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
104
+
105
+ if (!this.props.isReadOnly) {
106
+ process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'MoneyField: `onChange` is required when field is not read only.') : void 0;
107
+ }
108
+
104
109
  process.env.NODE_ENV !== "production" ? utils.warning(!has__default["default"](this.props, 'isTouched'), 'MoneyField: Invalid prop isTouched supplied to MoneyField. Use touched instead.') : void 0;
105
110
 
106
111
  if (this.props.hintIcon) {
@@ -200,7 +205,7 @@ MoneyField.propTypes = process.env.NODE_ENV !== "production" ? {
200
205
  isDisabled: _pt__default["default"].bool,
201
206
  isReadOnly: _pt__default["default"].bool,
202
207
  isAutofocussed: _pt__default["default"].bool,
203
- onChange: _pt__default["default"].func.isRequired,
208
+ onChange: _pt__default["default"].func,
204
209
  menuPortalZIndex: _pt__default["default"].number,
205
210
  title: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]).isRequired,
206
211
  hint: _pt__default["default"].oneOfType([_pt__default["default"].string, _pt__default["default"].node]),
@@ -212,7 +217,7 @@ MoneyField.propTypes = process.env.NODE_ENV !== "production" ? {
212
217
  var MoneyField$1 = MoneyField;
213
218
 
214
219
  // NOTE: This string will be replaced on build time with the package version.
215
- var version = "14.0.1";
220
+ var version = "14.0.2";
216
221
 
217
222
  exports["default"] = MoneyField$1;
218
223
  exports.version = version;
@@ -100,6 +100,8 @@ var MoneyField = /*#__PURE__*/function (_Component) {
100
100
  // didn't add an amount yet.
101
101
  var hasError = MoneyInput__default["default"].isTouched(this.props.touched) && hasErrors(this.props.errors);
102
102
 
103
+ if (!this.props.isReadOnly) ;
104
+
103
105
  if (this.props.hintIcon) ;
104
106
 
105
107
  return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
@@ -175,7 +177,7 @@ MoneyField.propTypes = {};
175
177
  var MoneyField$1 = MoneyField;
176
178
 
177
179
  // NOTE: This string will be replaced on build time with the package version.
178
- var version = "14.0.1";
180
+ var version = "14.0.2";
179
181
 
180
182
  exports["default"] = MoneyField$1;
181
183
  exports.version = version;
@@ -75,6 +75,11 @@ var MoneyField = /*#__PURE__*/function (_Component) {
75
75
  // This avoids showing an error when the user just selected a language but
76
76
  // didn't add an amount yet.
77
77
  var hasError = MoneyInput.isTouched(this.props.touched) && hasErrors(this.props.errors);
78
+
79
+ if (!this.props.isReadOnly) {
80
+ process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'MoneyField: `onChange` is required when field is not read only.') : void 0;
81
+ }
82
+
78
83
  process.env.NODE_ENV !== "production" ? warning(!has(this.props, 'isTouched'), 'MoneyField: Invalid prop isTouched supplied to MoneyField. Use touched instead.') : void 0;
79
84
 
80
85
  if (this.props.hintIcon) {
@@ -174,7 +179,7 @@ MoneyField.propTypes = process.env.NODE_ENV !== "production" ? {
174
179
  isDisabled: _pt.bool,
175
180
  isReadOnly: _pt.bool,
176
181
  isAutofocussed: _pt.bool,
177
- onChange: _pt.func.isRequired,
182
+ onChange: _pt.func,
178
183
  menuPortalZIndex: _pt.number,
179
184
  title: _pt.oneOfType([_pt.string, _pt.node]).isRequired,
180
185
  hint: _pt.oneOfType([_pt.string, _pt.node]),
@@ -186,6 +191,6 @@ MoneyField.propTypes = process.env.NODE_ENV !== "production" ? {
186
191
  var MoneyField$1 = MoneyField;
187
192
 
188
193
  // NOTE: This string will be replaced on build time with the package version.
189
- var version = "14.0.1";
194
+ var version = "14.0.2";
190
195
 
191
196
  export { MoneyField$1 as default, version };
@@ -14,7 +14,7 @@ declare type TValue = {
14
14
  amount: string;
15
15
  currencyCode: TCurrencyCode;
16
16
  };
17
- declare type TEvent = {
17
+ declare type TCustomEvent = {
18
18
  target: {
19
19
  id?: string;
20
20
  name?: string;
@@ -35,12 +35,12 @@ declare type TMoneyFieldProps = {
35
35
  value: TValue;
36
36
  currencies?: string[];
37
37
  placeholder?: string;
38
- onBlur?: (event: TEvent) => void;
39
- onFocus?: (event: TEvent) => void;
38
+ onBlur?: (event: TCustomEvent) => void;
39
+ onFocus?: (event: TCustomEvent) => void;
40
40
  isDisabled?: boolean;
41
41
  isReadOnly?: boolean;
42
42
  isAutofocussed?: boolean;
43
- onChange: (event: TEvent) => void;
43
+ onChange?: (event: TCustomEvent) => void;
44
44
  menuPortalTarget?: ReactSelectProps['menuPortalTarget'];
45
45
  menuPortalZIndex?: number;
46
46
  menuShouldBlockScroll?: ReactSelectProps['menuShouldBlockScroll'];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/money-field",
3
3
  "description": "A controlled input component for money values with validation states and a label.",
4
- "version": "14.0.1",
4
+ "version": "14.0.2",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -24,8 +24,8 @@
24
24
  "@commercetools-uikit/constraints": "14.0.1",
25
25
  "@commercetools-uikit/design-system": "14.0.0",
26
26
  "@commercetools-uikit/field-errors": "14.0.1",
27
- "@commercetools-uikit/field-label": "14.0.1",
28
- "@commercetools-uikit/money-input": "14.0.1",
27
+ "@commercetools-uikit/field-label": "14.0.2",
28
+ "@commercetools-uikit/money-input": "14.0.2",
29
29
  "@commercetools-uikit/spacings": "14.0.1",
30
30
  "@commercetools-uikit/utils": "14.0.1",
31
31
  "@emotion/react": "^11.4.0",