@commercetools-uikit/date-field 17.0.1 → 17.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.
package/README.md
CHANGED
|
@@ -51,6 +51,8 @@ export default Example;
|
|
|
51
51
|
| `horizontalConstraint` | `union`<br/>Possible values:<br/>`, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'` | | `'scale'` | Horizontal size limit of the input fields. |
|
|
52
52
|
| `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically.
<br />
Unknown errors will be forwarded to `renderError` |
|
|
53
53
|
| `renderError` | `Function`<br/>[See signature.](#signature-renderError) | | | Called with custom errors. This function can return a message which will be wrapped in an ErrorMessage. It can also return null to show no error. |
|
|
54
|
+
| `warnings` | `Record` | | | A map of warnings. Warning messages for known warnings are rendered automatically.
<br />
Unknown warnings will be forwarded to `renderWarning` |
|
|
55
|
+
| `renderWarning` | `Function`<br/>[See signature.](#signature-renderWarning) | | | Called with custom warnings. This function can return a message which will be wrapped in an WarningMessage. It can also return null to show no warning. |
|
|
54
56
|
| `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
|
|
55
57
|
| `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
|
|
56
58
|
| `name` | `string` | | | Used as HTML name of the input component. |
|
|
@@ -78,6 +80,12 @@ export default Example;
|
|
|
78
80
|
(key: string, error?: boolean) => ReactNode;
|
|
79
81
|
```
|
|
80
82
|
|
|
83
|
+
### Signature `renderWarning`
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
(key: string, warning?: boolean) => ReactNode;
|
|
87
|
+
```
|
|
88
|
+
|
|
81
89
|
### Signature `onChange`
|
|
82
90
|
|
|
83
91
|
```ts
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
7
7
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
8
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
9
8
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
10
9
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
10
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
11
11
|
var _pt = require('prop-types');
|
|
12
12
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
13
13
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
@@ -27,6 +27,7 @@ var Spacings = require('@commercetools-uikit/spacings');
|
|
|
27
27
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
28
28
|
var DateInput = require('@commercetools-uikit/date-input');
|
|
29
29
|
var FieldErrors = require('@commercetools-uikit/field-errors');
|
|
30
|
+
var FieldWarnings = require('@commercetools-uikit/field-warnings');
|
|
30
31
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
31
32
|
|
|
32
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -48,13 +49,15 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
48
49
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
49
50
|
var DateInput__default = /*#__PURE__*/_interopDefault(DateInput);
|
|
50
51
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
52
|
+
var FieldWarnings__default = /*#__PURE__*/_interopDefault(FieldWarnings);
|
|
51
53
|
|
|
52
|
-
function ownKeys(
|
|
53
|
-
function _objectSpread(
|
|
54
|
-
function
|
|
55
|
-
function _isNativeReflectConstruct() {
|
|
54
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
55
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
56
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
57
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
56
58
|
const sequentialId = utils.createSequentialId('date-field-');
|
|
57
59
|
const sequentialErrorsId = utils.createSequentialId('date-field-error-')();
|
|
60
|
+
const sequentialWarningsId = utils.createSequentialId('date-field-warning-')();
|
|
58
61
|
|
|
59
62
|
// Similar shape of `FormikErrors` but values are `TFieldErrors` objects.
|
|
60
63
|
|
|
@@ -62,16 +65,19 @@ const hasErrors = errors => {
|
|
|
62
65
|
var _context;
|
|
63
66
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
64
67
|
};
|
|
68
|
+
const hasWarnings = warnings => {
|
|
69
|
+
var _context2;
|
|
70
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
71
|
+
};
|
|
65
72
|
let DateField = /*#__PURE__*/function (_Component) {
|
|
66
73
|
_inherits(DateField, _Component);
|
|
67
|
-
var _super = _createSuper(DateField);
|
|
68
74
|
function DateField() {
|
|
69
75
|
var _this;
|
|
70
76
|
_classCallCheck(this, DateField);
|
|
71
77
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
78
|
args[_key] = arguments[_key];
|
|
73
79
|
}
|
|
74
|
-
_this =
|
|
80
|
+
_this = _callSuper(this, DateField, [...args]);
|
|
75
81
|
_this.state = {
|
|
76
82
|
// We generate an id in case no id is provided by the parent to attach the
|
|
77
83
|
// label to the input component.
|
|
@@ -83,6 +89,7 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
83
89
|
key: "render",
|
|
84
90
|
value: function render() {
|
|
85
91
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
92
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
86
93
|
if (!this.props.isReadOnly) {
|
|
87
94
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'DateField: `onChange` is required when field is not read only.') : void 0;
|
|
88
95
|
}
|
|
@@ -113,6 +120,7 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
113
120
|
onChange: this.props.onChange,
|
|
114
121
|
isDisabled: this.props.isDisabled,
|
|
115
122
|
isReadOnly: this.props.isReadOnly,
|
|
123
|
+
hasWarning: hasWarning,
|
|
116
124
|
hasError: hasError,
|
|
117
125
|
placeholder: this.props.placeholder,
|
|
118
126
|
horizontalConstraint: "scale"
|
|
@@ -125,6 +133,11 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
125
133
|
errors: this.props.errors,
|
|
126
134
|
isVisible: hasError,
|
|
127
135
|
renderError: this.props.renderError
|
|
136
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
137
|
+
id: sequentialWarningsId,
|
|
138
|
+
warnings: this.props.warnings,
|
|
139
|
+
isVisible: hasWarning,
|
|
140
|
+
renderWarning: this.props.renderWarning
|
|
128
141
|
})]
|
|
129
142
|
})
|
|
130
143
|
});
|
|
@@ -155,6 +168,8 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
155
168
|
horizontalConstraint: _pt__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
156
169
|
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
157
170
|
renderError: _pt__default["default"].func,
|
|
171
|
+
warnings: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
172
|
+
renderWarning: _pt__default["default"].func,
|
|
158
173
|
isRequired: _pt__default["default"].bool,
|
|
159
174
|
touched: _pt__default["default"].bool,
|
|
160
175
|
name: _pt__default["default"].string,
|
|
@@ -177,7 +192,7 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
177
192
|
var DateField$1 = DateField;
|
|
178
193
|
|
|
179
194
|
// NOTE: This string will be replaced on build time with the package version.
|
|
180
|
-
var version = "17.0
|
|
195
|
+
var version = "17.1.0";
|
|
181
196
|
|
|
182
197
|
exports["default"] = DateField$1;
|
|
183
198
|
exports.version = version;
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
|
|
7
7
|
var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
8
|
-
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
9
8
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
10
9
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
10
|
+
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
11
11
|
require('prop-types');
|
|
12
12
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
13
13
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
@@ -27,6 +27,7 @@ var Spacings = require('@commercetools-uikit/spacings');
|
|
|
27
27
|
var FieldLabel = require('@commercetools-uikit/field-label');
|
|
28
28
|
var DateInput = require('@commercetools-uikit/date-input');
|
|
29
29
|
var FieldErrors = require('@commercetools-uikit/field-errors');
|
|
30
|
+
var FieldWarnings = require('@commercetools-uikit/field-warnings');
|
|
30
31
|
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
31
32
|
|
|
32
33
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
@@ -47,13 +48,15 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
47
48
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
48
49
|
var DateInput__default = /*#__PURE__*/_interopDefault(DateInput);
|
|
49
50
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
51
|
+
var FieldWarnings__default = /*#__PURE__*/_interopDefault(FieldWarnings);
|
|
50
52
|
|
|
51
|
-
function ownKeys(
|
|
52
|
-
function _objectSpread(
|
|
53
|
-
function
|
|
54
|
-
function _isNativeReflectConstruct() {
|
|
53
|
+
function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
54
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
|
|
55
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
56
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
55
57
|
const sequentialId = utils.createSequentialId('date-field-');
|
|
56
58
|
const sequentialErrorsId = utils.createSequentialId('date-field-error-')();
|
|
59
|
+
const sequentialWarningsId = utils.createSequentialId('date-field-warning-')();
|
|
57
60
|
|
|
58
61
|
// Similar shape of `FormikErrors` but values are `TFieldErrors` objects.
|
|
59
62
|
|
|
@@ -61,16 +64,19 @@ const hasErrors = errors => {
|
|
|
61
64
|
var _context;
|
|
62
65
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
63
66
|
};
|
|
67
|
+
const hasWarnings = warnings => {
|
|
68
|
+
var _context2;
|
|
69
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
70
|
+
};
|
|
64
71
|
let DateField = /*#__PURE__*/function (_Component) {
|
|
65
72
|
_inherits(DateField, _Component);
|
|
66
|
-
var _super = _createSuper(DateField);
|
|
67
73
|
function DateField() {
|
|
68
74
|
var _this;
|
|
69
75
|
_classCallCheck(this, DateField);
|
|
70
76
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
71
77
|
args[_key] = arguments[_key];
|
|
72
78
|
}
|
|
73
|
-
_this =
|
|
79
|
+
_this = _callSuper(this, DateField, [...args]);
|
|
74
80
|
_this.state = {
|
|
75
81
|
// We generate an id in case no id is provided by the parent to attach the
|
|
76
82
|
// label to the input component.
|
|
@@ -82,6 +88,7 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
82
88
|
key: "render",
|
|
83
89
|
value: function render() {
|
|
84
90
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
91
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
85
92
|
if (!this.props.isReadOnly) ;
|
|
86
93
|
if (this.props.hintIcon) ;
|
|
87
94
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
@@ -108,6 +115,7 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
108
115
|
onChange: this.props.onChange,
|
|
109
116
|
isDisabled: this.props.isDisabled,
|
|
110
117
|
isReadOnly: this.props.isReadOnly,
|
|
118
|
+
hasWarning: hasWarning,
|
|
111
119
|
hasError: hasError,
|
|
112
120
|
placeholder: this.props.placeholder,
|
|
113
121
|
horizontalConstraint: "scale"
|
|
@@ -120,6 +128,11 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
120
128
|
errors: this.props.errors,
|
|
121
129
|
isVisible: hasError,
|
|
122
130
|
renderError: this.props.renderError
|
|
131
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
132
|
+
id: sequentialWarningsId,
|
|
133
|
+
warnings: this.props.warnings,
|
|
134
|
+
isVisible: hasWarning,
|
|
135
|
+
renderWarning: this.props.renderWarning
|
|
123
136
|
})]
|
|
124
137
|
})
|
|
125
138
|
});
|
|
@@ -149,7 +162,7 @@ DateField.propTypes = {};
|
|
|
149
162
|
var DateField$1 = DateField;
|
|
150
163
|
|
|
151
164
|
// NOTE: This string will be replaced on build time with the package version.
|
|
152
|
-
var version = "17.0
|
|
165
|
+
var version = "17.1.0";
|
|
153
166
|
|
|
154
167
|
exports["default"] = DateField$1;
|
|
155
168
|
exports.version = version;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime-corejs3/helpers/esm/defineProperty';
|
|
2
2
|
import _classCallCheck from '@babel/runtime-corejs3/helpers/esm/classCallCheck';
|
|
3
3
|
import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
4
|
-
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
5
4
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
6
5
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
6
|
+
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
7
7
|
import _pt from 'prop-types';
|
|
8
8
|
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
9
9
|
import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
@@ -23,14 +23,16 @@ import Spacings from '@commercetools-uikit/spacings';
|
|
|
23
23
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
24
24
|
import DateInput from '@commercetools-uikit/date-input';
|
|
25
25
|
import FieldErrors from '@commercetools-uikit/field-errors';
|
|
26
|
+
import FieldWarnings from '@commercetools-uikit/field-warnings';
|
|
26
27
|
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
27
28
|
|
|
28
|
-
function ownKeys(
|
|
29
|
-
function _objectSpread(
|
|
30
|
-
function
|
|
31
|
-
function _isNativeReflectConstruct() {
|
|
29
|
+
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
30
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context3 = ownKeys(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context4 = ownKeys(Object(t))).call(_context4, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
31
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
32
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
32
33
|
const sequentialId = createSequentialId('date-field-');
|
|
33
34
|
const sequentialErrorsId = createSequentialId('date-field-error-')();
|
|
35
|
+
const sequentialWarningsId = createSequentialId('date-field-warning-')();
|
|
34
36
|
|
|
35
37
|
// Similar shape of `FormikErrors` but values are `TFieldErrors` objects.
|
|
36
38
|
|
|
@@ -38,16 +40,19 @@ const hasErrors = errors => {
|
|
|
38
40
|
var _context;
|
|
39
41
|
return errors && _someInstanceProperty(_context = _Object$values(errors)).call(_context, Boolean);
|
|
40
42
|
};
|
|
43
|
+
const hasWarnings = warnings => {
|
|
44
|
+
var _context2;
|
|
45
|
+
return warnings && _someInstanceProperty(_context2 = _Object$values(warnings)).call(_context2, Boolean);
|
|
46
|
+
};
|
|
41
47
|
let DateField = /*#__PURE__*/function (_Component) {
|
|
42
48
|
_inherits(DateField, _Component);
|
|
43
|
-
var _super = _createSuper(DateField);
|
|
44
49
|
function DateField() {
|
|
45
50
|
var _this;
|
|
46
51
|
_classCallCheck(this, DateField);
|
|
47
52
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
48
53
|
args[_key] = arguments[_key];
|
|
49
54
|
}
|
|
50
|
-
_this =
|
|
55
|
+
_this = _callSuper(this, DateField, [...args]);
|
|
51
56
|
_this.state = {
|
|
52
57
|
// We generate an id in case no id is provided by the parent to attach the
|
|
53
58
|
// label to the input component.
|
|
@@ -59,6 +64,7 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
59
64
|
key: "render",
|
|
60
65
|
value: function render() {
|
|
61
66
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
67
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
62
68
|
if (!this.props.isReadOnly) {
|
|
63
69
|
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'DateField: `onChange` is required when field is not read only.') : void 0;
|
|
64
70
|
}
|
|
@@ -89,6 +95,7 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
89
95
|
onChange: this.props.onChange,
|
|
90
96
|
isDisabled: this.props.isDisabled,
|
|
91
97
|
isReadOnly: this.props.isReadOnly,
|
|
98
|
+
hasWarning: hasWarning,
|
|
92
99
|
hasError: hasError,
|
|
93
100
|
placeholder: this.props.placeholder,
|
|
94
101
|
horizontalConstraint: "scale"
|
|
@@ -101,6 +108,11 @@ let DateField = /*#__PURE__*/function (_Component) {
|
|
|
101
108
|
errors: this.props.errors,
|
|
102
109
|
isVisible: hasError,
|
|
103
110
|
renderError: this.props.renderError
|
|
111
|
+
}), jsx(FieldWarnings, {
|
|
112
|
+
id: sequentialWarningsId,
|
|
113
|
+
warnings: this.props.warnings,
|
|
114
|
+
isVisible: hasWarning,
|
|
115
|
+
renderWarning: this.props.renderWarning
|
|
104
116
|
})]
|
|
105
117
|
})
|
|
106
118
|
});
|
|
@@ -131,6 +143,8 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
131
143
|
horizontalConstraint: _pt.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
132
144
|
errors: _pt.objectOf(_pt.bool),
|
|
133
145
|
renderError: _pt.func,
|
|
146
|
+
warnings: _pt.objectOf(_pt.bool),
|
|
147
|
+
renderWarning: _pt.func,
|
|
134
148
|
isRequired: _pt.bool,
|
|
135
149
|
touched: _pt.bool,
|
|
136
150
|
name: _pt.string,
|
|
@@ -153,6 +167,6 @@ DateField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
153
167
|
var DateField$1 = DateField;
|
|
154
168
|
|
|
155
169
|
// NOTE: This string will be replaced on build time with the package version.
|
|
156
|
-
var version = "17.0
|
|
170
|
+
var version = "17.1.0";
|
|
157
171
|
|
|
158
172
|
export { DateField$1 as default, version };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Component, type FocusEventHandler, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
3
|
+
type TWarningRenderer = (key: string, warning?: boolean) => ReactNode;
|
|
3
4
|
type TFieldErrors = Record<string, boolean>;
|
|
5
|
+
type TFieldWarnings = Record<string, boolean>;
|
|
4
6
|
type TCustomFormErrors<Values> = {
|
|
5
7
|
[K in keyof Values]?: TFieldErrors;
|
|
6
8
|
};
|
|
@@ -16,6 +18,8 @@ export type TDateFieldProps = {
|
|
|
16
18
|
horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
17
19
|
errors?: TFieldErrors;
|
|
18
20
|
renderError?: TErrorRenderer;
|
|
21
|
+
warnings?: TFieldWarnings;
|
|
22
|
+
renderWarning?: TWarningRenderer;
|
|
19
23
|
isRequired?: boolean;
|
|
20
24
|
touched?: boolean;
|
|
21
25
|
name?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/date-field",
|
|
3
3
|
"description": "A controlled date input component for single date, with validation states and a label.",
|
|
4
|
-
"version": "17.0
|
|
4
|
+
"version": "17.1.0",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@babel/runtime": "^7.20.13",
|
|
23
23
|
"@babel/runtime-corejs3": "^7.20.13",
|
|
24
|
-
"@commercetools-uikit/constraints": "17.0
|
|
25
|
-
"@commercetools-uikit/date-input": "17.0
|
|
26
|
-
"@commercetools-uikit/design-system": "17.0
|
|
27
|
-
"@commercetools-uikit/field-errors": "17.0
|
|
28
|
-
"@commercetools-uikit/field-label": "17.0
|
|
29
|
-
"@commercetools-uikit/
|
|
30
|
-
"@commercetools-uikit/
|
|
24
|
+
"@commercetools-uikit/constraints": "17.1.0",
|
|
25
|
+
"@commercetools-uikit/date-input": "17.1.0",
|
|
26
|
+
"@commercetools-uikit/design-system": "17.1.0",
|
|
27
|
+
"@commercetools-uikit/field-errors": "17.1.0",
|
|
28
|
+
"@commercetools-uikit/field-label": "17.1.0",
|
|
29
|
+
"@commercetools-uikit/field-warnings": "17.1.0",
|
|
30
|
+
"@commercetools-uikit/spacings": "17.1.0",
|
|
31
|
+
"@commercetools-uikit/utils": "17.1.0",
|
|
31
32
|
"@emotion/react": "^11.10.5",
|
|
32
33
|
"@emotion/styled": "^11.10.5",
|
|
33
34
|
"prop-types": "15.8.1",
|