@commercetools-uikit/field-errors 19.12.1 → 19.14.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.
@@ -59,7 +59,9 @@ const FieldErrors = props => {
59
59
  var _context, _context2;
60
60
  if (!props.isVisible) return null;
61
61
  if (!props.errors || !isObject(props.errors)) return null;
62
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
62
+ return jsxRuntime.jsx("div", {
63
+ id: props.id,
64
+ role: "alert",
63
65
  children: _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.errors)
64
66
  // Only render errors which have truthy values, to avoid
65
67
  // rendering an error for, e.g. { missing: false }
@@ -77,28 +79,23 @@ const FieldErrors = props => {
77
79
  // Render a custom error if one was provided.
78
80
  // Custom errors take precedence over the default errors
79
81
  if (errorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
80
- id: props.id,
81
82
  children: errorElement
82
83
  }, key);
83
84
  const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
84
85
  // Render a default error if one was provided.
85
86
  // Default errors take precedence over the known errors
86
87
  if (defaultErrorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
87
- id: props.id,
88
88
  children: defaultErrorElement
89
89
  }, key);
90
90
 
91
91
  // Try to see if we know this error and render that error instead then
92
92
  if (key === FieldErrors.errorTypes.MISSING) return jsxRuntime.jsx(messages$1.ErrorMessage, {
93
- id: props.id,
94
93
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.missingRequiredField))
95
94
  }, key);
96
95
  if (key === FieldErrors.errorTypes.NEGATIVE) return jsxRuntime.jsx(messages$1.ErrorMessage, {
97
- id: props.id,
98
96
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidNegativeNumber))
99
97
  }, key);
100
98
  if (key === FieldErrors.errorTypes.FRACTIONS) return jsxRuntime.jsx(messages$1.ErrorMessage, {
101
- id: props.id,
102
99
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
103
100
  }, key);
104
101
  // Render nothing in case the error is not known and no custom error
@@ -123,7 +120,7 @@ FieldErrors.errorTypes = {
123
120
  var FieldErrors$1 = FieldErrors;
124
121
 
125
122
  // NOTE: This string will be replaced on build time with the package version.
126
- var version = "19.12.1";
123
+ var version = "19.14.0";
127
124
 
128
125
  exports["default"] = FieldErrors$1;
129
126
  exports.version = version;
@@ -58,7 +58,9 @@ const FieldErrors = props => {
58
58
  var _context, _context2;
59
59
  if (!props.isVisible) return null;
60
60
  if (!props.errors || !isObject(props.errors)) return null;
61
- return jsxRuntime.jsx(jsxRuntime.Fragment, {
61
+ return jsxRuntime.jsx("div", {
62
+ id: props.id,
63
+ role: "alert",
62
64
  children: _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.errors)
63
65
  // Only render errors which have truthy values, to avoid
64
66
  // rendering an error for, e.g. { missing: false }
@@ -76,28 +78,23 @@ const FieldErrors = props => {
76
78
  // Render a custom error if one was provided.
77
79
  // Custom errors take precedence over the default errors
78
80
  if (errorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
79
- id: props.id,
80
81
  children: errorElement
81
82
  }, key);
82
83
  const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
83
84
  // Render a default error if one was provided.
84
85
  // Default errors take precedence over the known errors
85
86
  if (defaultErrorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
86
- id: props.id,
87
87
  children: defaultErrorElement
88
88
  }, key);
89
89
 
90
90
  // Try to see if we know this error and render that error instead then
91
91
  if (key === FieldErrors.errorTypes.MISSING) return jsxRuntime.jsx(messages$1.ErrorMessage, {
92
- id: props.id,
93
92
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.missingRequiredField))
94
93
  }, key);
95
94
  if (key === FieldErrors.errorTypes.NEGATIVE) return jsxRuntime.jsx(messages$1.ErrorMessage, {
96
- id: props.id,
97
95
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidNegativeNumber))
98
96
  }, key);
99
97
  if (key === FieldErrors.errorTypes.FRACTIONS) return jsxRuntime.jsx(messages$1.ErrorMessage, {
100
- id: props.id,
101
98
  children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
102
99
  }, key);
103
100
  // Render nothing in case the error is not known and no custom error
@@ -116,7 +113,7 @@ FieldErrors.errorTypes = {
116
113
  var FieldErrors$1 = FieldErrors;
117
114
 
118
115
  // NOTE: This string will be replaced on build time with the package version.
119
- var version = "19.12.1";
116
+ var version = "19.14.0";
120
117
 
121
118
  exports["default"] = FieldErrors$1;
122
119
  exports.version = version;
@@ -14,7 +14,7 @@ import _Object$defineProperty from '@babel/runtime-corejs3/core-js-stable/object
14
14
  import 'react';
15
15
  import { defineMessages, FormattedMessage } from 'react-intl';
16
16
  import { ErrorMessage } from '@commercetools-uikit/messages';
17
- import { jsx, Fragment } from '@emotion/react/jsx-runtime';
17
+ import { jsx } from '@emotion/react/jsx-runtime';
18
18
 
19
19
  var messages = defineMessages({
20
20
  missingRequiredField: {
@@ -41,7 +41,9 @@ const FieldErrors = props => {
41
41
  var _context, _context2;
42
42
  if (!props.isVisible) return null;
43
43
  if (!props.errors || !isObject(props.errors)) return null;
44
- return jsx(Fragment, {
44
+ return jsx("div", {
45
+ id: props.id,
46
+ role: "alert",
45
47
  children: _mapInstanceProperty(_context = _filterInstanceProperty(_context2 = _Object$entries(props.errors)
46
48
  // Only render errors which have truthy values, to avoid
47
49
  // rendering an error for, e.g. { missing: false }
@@ -59,28 +61,23 @@ const FieldErrors = props => {
59
61
  // Render a custom error if one was provided.
60
62
  // Custom errors take precedence over the default errors
61
63
  if (errorElement) return jsx(ErrorMessage, {
62
- id: props.id,
63
64
  children: errorElement
64
65
  }, key);
65
66
  const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
66
67
  // Render a default error if one was provided.
67
68
  // Default errors take precedence over the known errors
68
69
  if (defaultErrorElement) return jsx(ErrorMessage, {
69
- id: props.id,
70
70
  children: defaultErrorElement
71
71
  }, key);
72
72
 
73
73
  // Try to see if we know this error and render that error instead then
74
74
  if (key === FieldErrors.errorTypes.MISSING) return jsx(ErrorMessage, {
75
- id: props.id,
76
75
  children: jsx(FormattedMessage, _objectSpread({}, messages.missingRequiredField))
77
76
  }, key);
78
77
  if (key === FieldErrors.errorTypes.NEGATIVE) return jsx(ErrorMessage, {
79
- id: props.id,
80
78
  children: jsx(FormattedMessage, _objectSpread({}, messages.invalidNegativeNumber))
81
79
  }, key);
82
80
  if (key === FieldErrors.errorTypes.FRACTIONS) return jsx(ErrorMessage, {
83
- id: props.id,
84
81
  children: jsx(FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
85
82
  }, key);
86
83
  // Render nothing in case the error is not known and no custom error
@@ -105,6 +102,6 @@ FieldErrors.errorTypes = {
105
102
  var FieldErrors$1 = FieldErrors;
106
103
 
107
104
  // NOTE: This string will be replaced on build time with the package version.
108
- var version = "19.12.1";
105
+ var version = "19.14.0";
109
106
 
110
107
  export { FieldErrors$1 as default, version };
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": "19.12.1",
4
+ "version": "19.14.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@commercetools-uikit/messages": "19.12.1",
24
+ "@commercetools-uikit/messages": "19.14.0",
25
25
  "@emotion/react": "^11.10.5",
26
26
  "@emotion/styled": "^11.10.5",
27
27
  "prop-types": "15.8.1"