@commercetools-uikit/field-errors 15.15.1 → 16.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.
|
@@ -53,46 +53,42 @@ var messages = reactIntl.defineMessages({
|
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
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; }
|
|
56
|
-
|
|
57
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; }
|
|
58
|
-
|
|
59
57
|
const isObject = obj => typeof obj === 'object';
|
|
60
|
-
|
|
61
58
|
const FieldErrors = props => {
|
|
62
59
|
var _context, _context2;
|
|
63
|
-
|
|
64
60
|
if (!props.isVisible) return null;
|
|
65
61
|
if (!props.errors || !isObject(props.errors)) return null;
|
|
66
62
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
67
|
-
children: _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.errors)
|
|
63
|
+
children: _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.errors)
|
|
64
|
+
// Only render errors which have truthy values, to avoid
|
|
68
65
|
// rendering an error for, e.g. { missing: false }
|
|
69
66
|
).call(_context2, _ref => {
|
|
70
67
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
error = _ref2[1];
|
|
73
69
|
return error;
|
|
74
70
|
})).call(_context, _ref3 => {
|
|
75
71
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
key = _ref4[0],
|
|
73
|
+
error = _ref4[1];
|
|
79
74
|
// We might not use a custom error renderer, so we fall back to null
|
|
80
75
|
// to enable the default errors to kick in
|
|
81
|
-
const errorElement = props.renderError ? props.renderError(key, error) : null;
|
|
76
|
+
const errorElement = props.renderError ? props.renderError(key, error) : null;
|
|
77
|
+
// Render a custom error if one was provided.
|
|
82
78
|
// Custom errors take precedence over the default errors
|
|
83
|
-
|
|
84
79
|
if (errorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
85
80
|
id: props.id,
|
|
86
81
|
children: errorElement
|
|
87
82
|
}, key);
|
|
88
|
-
const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
|
|
83
|
+
const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
|
|
84
|
+
// Render a default error if one was provided.
|
|
89
85
|
// Default errors take precedence over the known errors
|
|
90
|
-
|
|
91
86
|
if (defaultErrorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
92
87
|
id: props.id,
|
|
93
88
|
children: defaultErrorElement
|
|
94
|
-
}, key);
|
|
89
|
+
}, key);
|
|
95
90
|
|
|
91
|
+
// Try to see if we know this error and render that error instead then
|
|
96
92
|
if (key === FieldErrors.errorTypes.MISSING) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
97
93
|
id: props.id,
|
|
98
94
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.missingRequiredField))
|
|
@@ -104,14 +100,13 @@ const FieldErrors = props => {
|
|
|
104
100
|
if (key === FieldErrors.errorTypes.FRACTIONS) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
105
101
|
id: props.id,
|
|
106
102
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
|
|
107
|
-
}, key);
|
|
103
|
+
}, key);
|
|
104
|
+
// Render nothing in case the error is not known and no custom error
|
|
108
105
|
// was returned
|
|
109
|
-
|
|
110
106
|
return null;
|
|
111
107
|
})
|
|
112
108
|
});
|
|
113
109
|
};
|
|
114
|
-
|
|
115
110
|
FieldErrors.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
116
111
|
id: _pt__default["default"].string,
|
|
117
112
|
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
@@ -128,7 +123,7 @@ FieldErrors.errorTypes = {
|
|
|
128
123
|
var FieldErrors$1 = FieldErrors;
|
|
129
124
|
|
|
130
125
|
// NOTE: This string will be replaced on build time with the package version.
|
|
131
|
-
var version = "
|
|
126
|
+
var version = "16.1.0";
|
|
132
127
|
|
|
133
128
|
exports["default"] = FieldErrors$1;
|
|
134
129
|
exports.version = version;
|
|
@@ -52,46 +52,42 @@ var messages = reactIntl.defineMessages({
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
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; }
|
|
55
|
-
|
|
56
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
|
-
|
|
58
56
|
const isObject = obj => typeof obj === 'object';
|
|
59
|
-
|
|
60
57
|
const FieldErrors = props => {
|
|
61
58
|
var _context, _context2;
|
|
62
|
-
|
|
63
59
|
if (!props.isVisible) return null;
|
|
64
60
|
if (!props.errors || !isObject(props.errors)) return null;
|
|
65
61
|
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
66
|
-
children: _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.errors)
|
|
62
|
+
children: _mapInstanceProperty__default["default"](_context = _filterInstanceProperty__default["default"](_context2 = _Object$entries__default["default"](props.errors)
|
|
63
|
+
// Only render errors which have truthy values, to avoid
|
|
67
64
|
// rendering an error for, e.g. { missing: false }
|
|
68
65
|
).call(_context2, _ref => {
|
|
69
66
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
error = _ref2[1];
|
|
72
68
|
return error;
|
|
73
69
|
})).call(_context, _ref3 => {
|
|
74
70
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
71
|
+
key = _ref4[0],
|
|
72
|
+
error = _ref4[1];
|
|
78
73
|
// We might not use a custom error renderer, so we fall back to null
|
|
79
74
|
// to enable the default errors to kick in
|
|
80
|
-
const errorElement = props.renderError ? props.renderError(key, error) : null;
|
|
75
|
+
const errorElement = props.renderError ? props.renderError(key, error) : null;
|
|
76
|
+
// Render a custom error if one was provided.
|
|
81
77
|
// Custom errors take precedence over the default errors
|
|
82
|
-
|
|
83
78
|
if (errorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
84
79
|
id: props.id,
|
|
85
80
|
children: errorElement
|
|
86
81
|
}, key);
|
|
87
|
-
const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
|
|
82
|
+
const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
|
|
83
|
+
// Render a default error if one was provided.
|
|
88
84
|
// Default errors take precedence over the known errors
|
|
89
|
-
|
|
90
85
|
if (defaultErrorElement) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
91
86
|
id: props.id,
|
|
92
87
|
children: defaultErrorElement
|
|
93
|
-
}, key);
|
|
88
|
+
}, key);
|
|
94
89
|
|
|
90
|
+
// Try to see if we know this error and render that error instead then
|
|
95
91
|
if (key === FieldErrors.errorTypes.MISSING) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
96
92
|
id: props.id,
|
|
97
93
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.missingRequiredField))
|
|
@@ -103,14 +99,13 @@ const FieldErrors = props => {
|
|
|
103
99
|
if (key === FieldErrors.errorTypes.FRACTIONS) return jsxRuntime.jsx(messages$1.ErrorMessage, {
|
|
104
100
|
id: props.id,
|
|
105
101
|
children: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
|
|
106
|
-
}, key);
|
|
102
|
+
}, key);
|
|
103
|
+
// Render nothing in case the error is not known and no custom error
|
|
107
104
|
// was returned
|
|
108
|
-
|
|
109
105
|
return null;
|
|
110
106
|
})
|
|
111
107
|
});
|
|
112
108
|
};
|
|
113
|
-
|
|
114
109
|
FieldErrors.propTypes = {};
|
|
115
110
|
FieldErrors.displayName = 'FieldErrors';
|
|
116
111
|
FieldErrors.errorTypes = {
|
|
@@ -121,7 +116,7 @@ FieldErrors.errorTypes = {
|
|
|
121
116
|
var FieldErrors$1 = FieldErrors;
|
|
122
117
|
|
|
123
118
|
// NOTE: This string will be replaced on build time with the package version.
|
|
124
|
-
var version = "
|
|
119
|
+
var version = "16.1.0";
|
|
125
120
|
|
|
126
121
|
exports["default"] = FieldErrors$1;
|
|
127
122
|
exports.version = version;
|
|
@@ -35,46 +35,42 @@ var messages = defineMessages({
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
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; }
|
|
38
|
-
|
|
39
38
|
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; }
|
|
40
|
-
|
|
41
39
|
const isObject = obj => typeof obj === 'object';
|
|
42
|
-
|
|
43
40
|
const FieldErrors = props => {
|
|
44
41
|
var _context, _context2;
|
|
45
|
-
|
|
46
42
|
if (!props.isVisible) return null;
|
|
47
43
|
if (!props.errors || !isObject(props.errors)) return null;
|
|
48
44
|
return jsx(Fragment, {
|
|
49
|
-
children: _mapInstanceProperty(_context = _filterInstanceProperty(_context2 = _Object$entries(props.errors)
|
|
45
|
+
children: _mapInstanceProperty(_context = _filterInstanceProperty(_context2 = _Object$entries(props.errors)
|
|
46
|
+
// Only render errors which have truthy values, to avoid
|
|
50
47
|
// rendering an error for, e.g. { missing: false }
|
|
51
48
|
).call(_context2, _ref => {
|
|
52
49
|
let _ref2 = _slicedToArray(_ref, 2),
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
error = _ref2[1];
|
|
55
51
|
return error;
|
|
56
52
|
})).call(_context, _ref3 => {
|
|
57
53
|
let _ref4 = _slicedToArray(_ref3, 2),
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
key = _ref4[0],
|
|
55
|
+
error = _ref4[1];
|
|
61
56
|
// We might not use a custom error renderer, so we fall back to null
|
|
62
57
|
// to enable the default errors to kick in
|
|
63
|
-
const errorElement = props.renderError ? props.renderError(key, error) : null;
|
|
58
|
+
const errorElement = props.renderError ? props.renderError(key, error) : null;
|
|
59
|
+
// Render a custom error if one was provided.
|
|
64
60
|
// Custom errors take precedence over the default errors
|
|
65
|
-
|
|
66
61
|
if (errorElement) return jsx(ErrorMessage, {
|
|
67
62
|
id: props.id,
|
|
68
63
|
children: errorElement
|
|
69
64
|
}, key);
|
|
70
|
-
const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
|
|
65
|
+
const defaultErrorElement = props.renderDefaultError ? props.renderDefaultError(key, error) : null;
|
|
66
|
+
// Render a default error if one was provided.
|
|
71
67
|
// Default errors take precedence over the known errors
|
|
72
|
-
|
|
73
68
|
if (defaultErrorElement) return jsx(ErrorMessage, {
|
|
74
69
|
id: props.id,
|
|
75
70
|
children: defaultErrorElement
|
|
76
|
-
}, key);
|
|
71
|
+
}, key);
|
|
77
72
|
|
|
73
|
+
// Try to see if we know this error and render that error instead then
|
|
78
74
|
if (key === FieldErrors.errorTypes.MISSING) return jsx(ErrorMessage, {
|
|
79
75
|
id: props.id,
|
|
80
76
|
children: jsx(FormattedMessage, _objectSpread({}, messages.missingRequiredField))
|
|
@@ -86,14 +82,13 @@ const FieldErrors = props => {
|
|
|
86
82
|
if (key === FieldErrors.errorTypes.FRACTIONS) return jsx(ErrorMessage, {
|
|
87
83
|
id: props.id,
|
|
88
84
|
children: jsx(FormattedMessage, _objectSpread({}, messages.invalidFractionalNumber))
|
|
89
|
-
}, key);
|
|
85
|
+
}, key);
|
|
86
|
+
// Render nothing in case the error is not known and no custom error
|
|
90
87
|
// was returned
|
|
91
|
-
|
|
92
88
|
return null;
|
|
93
89
|
})
|
|
94
90
|
});
|
|
95
91
|
};
|
|
96
|
-
|
|
97
92
|
FieldErrors.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
98
93
|
id: _pt.string,
|
|
99
94
|
errors: _pt.objectOf(_pt.bool),
|
|
@@ -110,6 +105,6 @@ FieldErrors.errorTypes = {
|
|
|
110
105
|
var FieldErrors$1 = FieldErrors;
|
|
111
106
|
|
|
112
107
|
// NOTE: This string will be replaced on build time with the package version.
|
|
113
|
-
var version = "
|
|
108
|
+
var version = "16.1.0";
|
|
114
109
|
|
|
115
110
|
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": "
|
|
4
|
+
"version": "16.1.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/messages": "
|
|
24
|
+
"@commercetools-uikit/messages": "16.1.0",
|
|
25
25
|
"@emotion/react": "^11.10.5",
|
|
26
26
|
"@emotion/styled": "^11.10.5",
|
|
27
27
|
"prop-types": "15.8.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"react": "17.0.2",
|
|
31
|
-
"react-intl": "^
|
|
31
|
+
"react-intl": "^6.3.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "17.x",
|
|
35
|
-
"react-intl": "
|
|
35
|
+
"react-intl": "6.x"
|
|
36
36
|
}
|
|
37
37
|
}
|