@commercetools-uikit/date-time-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 +8 -0
- package/dist/commercetools-uikit-date-time-field.cjs.dev.js +23 -8
- package/dist/commercetools-uikit-date-time-field.cjs.prod.js +21 -8
- package/dist/commercetools-uikit-date-time-field.esm.js +22 -8
- package/dist/declarations/src/date-time-field.d.ts +3 -0
- package/package.json +9 -8
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, as renderWarning(key, warning). This function can return a message which will be wrapped in a WarningMessage.
<br />
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. |
|
|
@@ -77,6 +79,12 @@ export default Example;
|
|
|
77
79
|
(key: string, error?: boolean) => ReactNode;
|
|
78
80
|
```
|
|
79
81
|
|
|
82
|
+
### Signature `renderWarning`
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
(key: string, warning?: boolean) => ReactNode;
|
|
86
|
+
```
|
|
87
|
+
|
|
80
88
|
### Signature `onChange`
|
|
81
89
|
|
|
82
90
|
```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 DateTimeInput = require('@commercetools-uikit/date-time-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,27 +49,32 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
48
49
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
49
50
|
var DateTimeInput__default = /*#__PURE__*/_interopDefault(DateTimeInput);
|
|
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-time-field-');
|
|
57
59
|
const sequentialErrorsId = utils.createSequentialId('date-time-field-error-')();
|
|
60
|
+
const sequentialWarningsId = utils.createSequentialId('date-time-field-warning-')();
|
|
58
61
|
const hasErrors = errors => {
|
|
59
62
|
var _context;
|
|
60
63
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
61
64
|
};
|
|
65
|
+
const hasWarnings = warnings => {
|
|
66
|
+
var _context2;
|
|
67
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
68
|
+
};
|
|
62
69
|
let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
63
70
|
_inherits(DateTimeField, _Component);
|
|
64
|
-
var _super = _createSuper(DateTimeField);
|
|
65
71
|
function DateTimeField() {
|
|
66
72
|
var _this;
|
|
67
73
|
_classCallCheck(this, DateTimeField);
|
|
68
74
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
69
75
|
args[_key] = arguments[_key];
|
|
70
76
|
}
|
|
71
|
-
_this =
|
|
77
|
+
_this = _callSuper(this, DateTimeField, [...args]);
|
|
72
78
|
_this.state = {
|
|
73
79
|
// We generate an id in case no id is provided by the parent to attach the
|
|
74
80
|
// label to the input component.
|
|
@@ -86,6 +92,7 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
86
92
|
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'DateTimeField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
87
93
|
}
|
|
88
94
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
95
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
89
96
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
90
97
|
max: this.props.horizontalConstraint,
|
|
91
98
|
children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
|
|
@@ -110,6 +117,7 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
110
117
|
isDisabled: this.props.isDisabled,
|
|
111
118
|
isReadOnly: this.props.isReadOnly,
|
|
112
119
|
hasError: hasError,
|
|
120
|
+
hasWarning: hasWarning,
|
|
113
121
|
placeholder: this.props.placeholder,
|
|
114
122
|
horizontalConstraint: "scale"
|
|
115
123
|
}, utils.filterDataAttributes(this.props)), {}, {
|
|
@@ -120,6 +128,11 @@ let DateTimeField = /*#__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
|
});
|
|
@@ -150,6 +163,8 @@ DateTimeField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
150
163
|
horizontalConstraint: _pt__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
151
164
|
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
152
165
|
renderError: _pt__default["default"].func,
|
|
166
|
+
warnings: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
167
|
+
renderWarning: _pt__default["default"].func,
|
|
153
168
|
isRequired: _pt__default["default"].bool,
|
|
154
169
|
touched: _pt__default["default"].bool,
|
|
155
170
|
name: _pt__default["default"].string,
|
|
@@ -171,7 +186,7 @@ DateTimeField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
171
186
|
var DateTimeField$1 = DateTimeField;
|
|
172
187
|
|
|
173
188
|
// NOTE: This string will be replaced on build time with the package version.
|
|
174
|
-
var version = "17.0
|
|
189
|
+
var version = "17.1.0";
|
|
175
190
|
|
|
176
191
|
exports["default"] = DateTimeField$1;
|
|
177
192
|
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 DateTimeInput = require('@commercetools-uikit/date-time-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,27 +48,32 @@ var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
|
47
48
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
48
49
|
var DateTimeInput__default = /*#__PURE__*/_interopDefault(DateTimeInput);
|
|
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-time-field-');
|
|
56
58
|
const sequentialErrorsId = utils.createSequentialId('date-time-field-error-')();
|
|
59
|
+
const sequentialWarningsId = utils.createSequentialId('date-time-field-warning-')();
|
|
57
60
|
const hasErrors = errors => {
|
|
58
61
|
var _context;
|
|
59
62
|
return errors && _someInstanceProperty__default["default"](_context = _Object$values__default["default"](errors)).call(_context, Boolean);
|
|
60
63
|
};
|
|
64
|
+
const hasWarnings = warnings => {
|
|
65
|
+
var _context2;
|
|
66
|
+
return warnings && _someInstanceProperty__default["default"](_context2 = _Object$values__default["default"](warnings)).call(_context2, Boolean);
|
|
67
|
+
};
|
|
61
68
|
let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
62
69
|
_inherits(DateTimeField, _Component);
|
|
63
|
-
var _super = _createSuper(DateTimeField);
|
|
64
70
|
function DateTimeField() {
|
|
65
71
|
var _this;
|
|
66
72
|
_classCallCheck(this, DateTimeField);
|
|
67
73
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
68
74
|
args[_key] = arguments[_key];
|
|
69
75
|
}
|
|
70
|
-
_this =
|
|
76
|
+
_this = _callSuper(this, DateTimeField, [...args]);
|
|
71
77
|
_this.state = {
|
|
72
78
|
// We generate an id in case no id is provided by the parent to attach the
|
|
73
79
|
// label to the input component.
|
|
@@ -81,6 +87,7 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
81
87
|
if (!this.props.isReadOnly) ;
|
|
82
88
|
if (this.props.hintIcon) ;
|
|
83
89
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
90
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
84
91
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
85
92
|
max: this.props.horizontalConstraint,
|
|
86
93
|
children: jsxRuntime.jsxs(Spacings__default["default"].Stack, {
|
|
@@ -105,6 +112,7 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
105
112
|
isDisabled: this.props.isDisabled,
|
|
106
113
|
isReadOnly: this.props.isReadOnly,
|
|
107
114
|
hasError: hasError,
|
|
115
|
+
hasWarning: hasWarning,
|
|
108
116
|
placeholder: this.props.placeholder,
|
|
109
117
|
horizontalConstraint: "scale"
|
|
110
118
|
}, utils.filterDataAttributes(this.props)), {}, {
|
|
@@ -115,6 +123,11 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
115
123
|
errors: this.props.errors,
|
|
116
124
|
isVisible: hasError,
|
|
117
125
|
renderError: this.props.renderError
|
|
126
|
+
}), jsxRuntime.jsx(FieldWarnings__default["default"], {
|
|
127
|
+
id: sequentialWarningsId,
|
|
128
|
+
warnings: this.props.warnings,
|
|
129
|
+
isVisible: hasWarning,
|
|
130
|
+
renderWarning: this.props.renderWarning
|
|
118
131
|
})]
|
|
119
132
|
})
|
|
120
133
|
});
|
|
@@ -144,7 +157,7 @@ DateTimeField.propTypes = {};
|
|
|
144
157
|
var DateTimeField$1 = DateTimeField;
|
|
145
158
|
|
|
146
159
|
// NOTE: This string will be replaced on build time with the package version.
|
|
147
|
-
var version = "17.0
|
|
160
|
+
var version = "17.1.0";
|
|
148
161
|
|
|
149
162
|
exports["default"] = DateTimeField$1;
|
|
150
163
|
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,28 +23,33 @@ import Spacings from '@commercetools-uikit/spacings';
|
|
|
23
23
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
24
24
|
import DateTimeInput from '@commercetools-uikit/date-time-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-time-field-');
|
|
33
34
|
const sequentialErrorsId = createSequentialId('date-time-field-error-')();
|
|
35
|
+
const sequentialWarningsId = createSequentialId('date-time-field-warning-')();
|
|
34
36
|
const hasErrors = errors => {
|
|
35
37
|
var _context;
|
|
36
38
|
return errors && _someInstanceProperty(_context = _Object$values(errors)).call(_context, Boolean);
|
|
37
39
|
};
|
|
40
|
+
const hasWarnings = warnings => {
|
|
41
|
+
var _context2;
|
|
42
|
+
return warnings && _someInstanceProperty(_context2 = _Object$values(warnings)).call(_context2, Boolean);
|
|
43
|
+
};
|
|
38
44
|
let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
39
45
|
_inherits(DateTimeField, _Component);
|
|
40
|
-
var _super = _createSuper(DateTimeField);
|
|
41
46
|
function DateTimeField() {
|
|
42
47
|
var _this;
|
|
43
48
|
_classCallCheck(this, DateTimeField);
|
|
44
49
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
50
|
args[_key] = arguments[_key];
|
|
46
51
|
}
|
|
47
|
-
_this =
|
|
52
|
+
_this = _callSuper(this, DateTimeField, [...args]);
|
|
48
53
|
_this.state = {
|
|
49
54
|
// We generate an id in case no id is provided by the parent to attach the
|
|
50
55
|
// label to the input component.
|
|
@@ -62,6 +67,7 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
62
67
|
process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'DateTimeField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
63
68
|
}
|
|
64
69
|
const hasError = this.props.touched && hasErrors(this.props.errors);
|
|
70
|
+
const hasWarning = this.props.touched && hasWarnings(this.props.warnings);
|
|
65
71
|
return jsx(Constraints.Horizontal, {
|
|
66
72
|
max: this.props.horizontalConstraint,
|
|
67
73
|
children: jsxs(Spacings.Stack, {
|
|
@@ -86,6 +92,7 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
86
92
|
isDisabled: this.props.isDisabled,
|
|
87
93
|
isReadOnly: this.props.isReadOnly,
|
|
88
94
|
hasError: hasError,
|
|
95
|
+
hasWarning: hasWarning,
|
|
89
96
|
placeholder: this.props.placeholder,
|
|
90
97
|
horizontalConstraint: "scale"
|
|
91
98
|
}, filterDataAttributes(this.props)), {}, {
|
|
@@ -96,6 +103,11 @@ let DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
96
103
|
errors: this.props.errors,
|
|
97
104
|
isVisible: hasError,
|
|
98
105
|
renderError: this.props.renderError
|
|
106
|
+
}), jsx(FieldWarnings, {
|
|
107
|
+
id: sequentialWarningsId,
|
|
108
|
+
warnings: this.props.warnings,
|
|
109
|
+
isVisible: hasWarning,
|
|
110
|
+
renderWarning: this.props.renderWarning
|
|
99
111
|
})]
|
|
100
112
|
})
|
|
101
113
|
});
|
|
@@ -126,6 +138,8 @@ DateTimeField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
126
138
|
horizontalConstraint: _pt.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
127
139
|
errors: _pt.objectOf(_pt.bool),
|
|
128
140
|
renderError: _pt.func,
|
|
141
|
+
warnings: _pt.objectOf(_pt.bool),
|
|
142
|
+
renderWarning: _pt.func,
|
|
129
143
|
isRequired: _pt.bool,
|
|
130
144
|
touched: _pt.bool,
|
|
131
145
|
name: _pt.string,
|
|
@@ -147,6 +161,6 @@ DateTimeField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
|
147
161
|
var DateTimeField$1 = DateTimeField;
|
|
148
162
|
|
|
149
163
|
// NOTE: This string will be replaced on build time with the package version.
|
|
150
|
-
var version = "17.0
|
|
164
|
+
var version = "17.1.0";
|
|
151
165
|
|
|
152
166
|
export { DateTimeField$1 as default, version };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Component, type FocusEventHandler, type ReactNode, type MouseEvent, type KeyboardEvent, type ReactElement } from 'react';
|
|
2
2
|
type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
3
|
+
type TFieldWarnings = Record<string, boolean>;
|
|
3
4
|
type TFieldErrors = Record<string, boolean>;
|
|
4
5
|
type TCustomFormErrors<Values> = {
|
|
5
6
|
[K in keyof Values]?: TFieldErrors;
|
|
@@ -16,6 +17,8 @@ export type TDateTimeFieldProps = {
|
|
|
16
17
|
horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
17
18
|
errors?: TFieldErrors;
|
|
18
19
|
renderError?: TErrorRenderer;
|
|
20
|
+
warnings?: TFieldWarnings;
|
|
21
|
+
renderWarning?: (key: string, warning?: boolean) => ReactNode;
|
|
19
22
|
isRequired?: boolean;
|
|
20
23
|
touched?: boolean;
|
|
21
24
|
name?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/date-time-field",
|
|
3
3
|
"description": "A controlled date time 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-time-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-time-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",
|