@commercetools-uikit/field-errors 13.0.2 → 13.0.4

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
@@ -73,6 +73,7 @@ export default Example;
73
73
 
74
74
  | Props | Type | Required | Default | Description |
75
75
  | -------------------- | -------------------------------------------------------------- | :------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
76
+ | `id` | `string` | | | ID of the error field. |
76
77
  | `errors` | `Record` | | | List of errors. Only entries with truthy values will count as active errors. |
77
78
  | `isVisible` | `boolean` | | | `true` when the error messages should be rendered. Usually you'd pass in a `touched` state of fields. |
78
79
  | `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Function which gets called with each error key (from the `errors` prop) and may render an error message or return `null` to hand the error handling off to `renderDefaultError`. |
@@ -84,22 +84,27 @@ var FieldErrors = function FieldErrors(props) {
84
84
  // Custom errors take precedence over the default errors
85
85
 
86
86
  if (errorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
87
+ id: props.id,
87
88
  children: errorElement
88
89
  }, key);
89
90
  var defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null; // Render a default error if one was provided.
90
91
  // Default errors take precedence over the known errors
91
92
 
92
93
  if (defaultErrorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
94
+ id: props.id,
93
95
  children: defaultErrorElement
94
96
  }, key); // Try to see if we know this error and render that error instead then
95
97
 
96
98
  if (key === FieldErrors.errorTypes.MISSING) return jsxRuntime.jsx(messages$1.ErrorMessage, {
99
+ id: props.id,
97
100
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.missingRequiredField))
98
101
  }, key);
99
102
  if (key === FieldErrors.errorTypes.NEGATIVE) return jsxRuntime.jsx(messages$1.ErrorMessage, {
103
+ id: props.id,
100
104
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidNegativeNumber))
101
105
  }, key);
102
106
  if (key === FieldErrors.errorTypes.FRACTIONS) return jsxRuntime.jsx(messages$1.ErrorMessage, {
107
+ id: props.id,
103
108
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
104
109
  }, key); // Render nothing in case the error is not known and no custom error
105
110
  // was returned
@@ -110,6 +115,7 @@ var FieldErrors = function FieldErrors(props) {
110
115
  };
111
116
 
112
117
  FieldErrors.propTypes = process.env.NODE_ENV !== "production" ? {
118
+ id: _pt__default["default"].string,
113
119
  errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
114
120
  isVisible: _pt__default["default"].bool,
115
121
  renderError: _pt__default["default"].func,
@@ -124,7 +130,7 @@ FieldErrors.errorTypes = {
124
130
  var FieldErrors$1 = FieldErrors;
125
131
 
126
132
  // NOTE: This string will be replaced on build time with the package version.
127
- var version = "13.0.2";
133
+ var version = "13.0.4";
128
134
 
129
135
  exports["default"] = FieldErrors$1;
130
136
  exports.version = version;
@@ -83,22 +83,27 @@ var FieldErrors = function FieldErrors(props) {
83
83
  // Custom errors take precedence over the default errors
84
84
 
85
85
  if (errorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
86
+ id: props.id,
86
87
  children: errorElement
87
88
  }, key);
88
89
  var defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null; // Render a default error if one was provided.
89
90
  // Default errors take precedence over the known errors
90
91
 
91
92
  if (defaultErrorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
93
+ id: props.id,
92
94
  children: defaultErrorElement
93
95
  }, key); // Try to see if we know this error and render that error instead then
94
96
 
95
97
  if (key === FieldErrors.errorTypes.MISSING) return jsxRuntime.jsx(messages$1.ErrorMessage, {
98
+ id: props.id,
96
99
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.missingRequiredField))
97
100
  }, key);
98
101
  if (key === FieldErrors.errorTypes.NEGATIVE) return jsxRuntime.jsx(messages$1.ErrorMessage, {
102
+ id: props.id,
99
103
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidNegativeNumber))
100
104
  }, key);
101
105
  if (key === FieldErrors.errorTypes.FRACTIONS) return jsxRuntime.jsx(messages$1.ErrorMessage, {
106
+ id: props.id,
102
107
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
103
108
  }, key); // Render nothing in case the error is not known and no custom error
104
109
  // was returned
@@ -118,7 +123,7 @@ FieldErrors.errorTypes = {
118
123
  var FieldErrors$1 = FieldErrors;
119
124
 
120
125
  // NOTE: This string will be replaced on build time with the package version.
121
- var version = "13.0.2";
126
+ var version = "13.0.4";
122
127
 
123
128
  exports["default"] = FieldErrors$1;
124
129
  exports.version = version;
@@ -66,22 +66,27 @@ var FieldErrors = function FieldErrors(props) {
66
66
  // Custom errors take precedence over the default errors
67
67
 
68
68
  if (errorElement) return jsx(ErrorMessage, {
69
+ id: props.id,
69
70
  children: errorElement
70
71
  }, key);
71
72
  var defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null; // Render a default error if one was provided.
72
73
  // Default errors take precedence over the known errors
73
74
 
74
75
  if (defaultErrorElement) return jsx(ErrorMessage, {
76
+ id: props.id,
75
77
  children: defaultErrorElement
76
78
  }, key); // Try to see if we know this error and render that error instead then
77
79
 
78
80
  if (key === FieldErrors.errorTypes.MISSING) return jsx(ErrorMessage, {
81
+ id: props.id,
79
82
  children: jsx(FormattedMessage, _objectSpread({}, messages.missingRequiredField))
80
83
  }, key);
81
84
  if (key === FieldErrors.errorTypes.NEGATIVE) return jsx(ErrorMessage, {
85
+ id: props.id,
82
86
  children: jsx(FormattedMessage, _objectSpread({}, messages.invalidNegativeNumber))
83
87
  }, key);
84
88
  if (key === FieldErrors.errorTypes.FRACTIONS) return jsx(ErrorMessage, {
89
+ id: props.id,
85
90
  children: jsx(FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
86
91
  }, key); // Render nothing in case the error is not known and no custom error
87
92
  // was returned
@@ -92,6 +97,7 @@ var FieldErrors = function FieldErrors(props) {
92
97
  };
93
98
 
94
99
  FieldErrors.propTypes = process.env.NODE_ENV !== "production" ? {
100
+ id: _pt.string,
95
101
  errors: _pt.objectOf(_pt.bool),
96
102
  isVisible: _pt.bool,
97
103
  renderError: _pt.func,
@@ -106,6 +112,6 @@ FieldErrors.errorTypes = {
106
112
  var FieldErrors$1 = FieldErrors;
107
113
 
108
114
  // NOTE: This string will be replaced on build time with the package version.
109
- var version = "13.0.2";
115
+ var version = "13.0.4";
110
116
 
111
117
  export { FieldErrors$1 as default, version };
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
  declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
3
3
  export declare type TFieldErrors = Record<string, boolean>;
4
4
  export declare type TFieldErrorsProps = {
5
+ id?: string;
5
6
  errors?: TFieldErrors;
6
7
  isVisible?: boolean;
7
8
  renderError?: TErrorRenderer;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/field-errors",
3
3
  "description": "Renders errors based on configuration.",
4
- "version": "13.0.2",
4
+ "version": "13.0.4",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,14 +21,14 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "7.17.2",
23
23
  "@babel/runtime-corejs3": "7.17.2",
24
- "@commercetools-uikit/messages": "13.0.2",
24
+ "@commercetools-uikit/messages": "13.0.4",
25
25
  "@emotion/react": "^11.4.0",
26
26
  "@emotion/styled": "^11.3.0",
27
27
  "prop-types": "15.8.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "react": "17.0.2",
31
- "react-intl": "5.24.6"
31
+ "react-intl": "^5.24.6"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": "17.x",