@commercetools-uikit/date-time-field 12.2.8 → 13.0.2
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 +51 -24
- package/dist/commercetools-uikit-date-time-field.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-date-time-field.cjs.dev.js +34 -143
- package/dist/commercetools-uikit-date-time-field.cjs.prod.js +8 -5
- package/dist/commercetools-uikit-date-time-field.esm.js +35 -143
- package/dist/declarations/src/date-time-field.d.ts +46 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -45,30 +45,57 @@ export default Example;
|
|
|
45
45
|
|
|
46
46
|
## Properties
|
|
47
47
|
|
|
48
|
-
| Props | Type
|
|
49
|
-
| ---------------------- |
|
|
50
|
-
| `id` | `string`
|
|
51
|
-
| `horizontalConstraint` | `
|
|
52
|
-
| `errors` | `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
|
|
48
|
+
| Props | Type | Required | Default | Description |
|
|
49
|
+
| ---------------------- | -------------------------------------------------------------------------------------------- | :------: | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `id` | `string` | | | Used as HTML id property. An id is auto-generated when it is not specified. |
|
|
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
|
+
| `errors` | `Record` | | | A map of errors. Error messages for known errors are rendered automatically.
<br />
Unknown errors will be forwarded to `renderError` |
|
|
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
|
+
| `isRequired` | `boolean` | | | Indicates if the value is required. Shows an the "required asterisk" if so. |
|
|
55
|
+
| `touched` | `boolean` | | | Indicates whether the field was touched. Errors will only be shown when the field was touched. |
|
|
56
|
+
| `name` | `string` | | | Used as HTML name of the input component. |
|
|
57
|
+
| `value` | `string` | ✅ | | Value of the input |
|
|
58
|
+
| `onChange` | `Function`<br/>[See signature.](#signature-onChange) | ✅ | | Called with an event holding the new value.
<br/>
Required when input is not read only. Parent should pass it back as `value`- |
|
|
59
|
+
| `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Called when input is blurred |
|
|
60
|
+
| `onFocus` | `FocusEventHandler` | | | Called when input is focused |
|
|
61
|
+
| `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
|
|
62
|
+
| `isReadOnly` | `boolean` | | | Indicates that the field is displaying read-only content |
|
|
63
|
+
| `placeholder` | `string` | | | Placeholder text for the input |
|
|
64
|
+
| `timeZone` | `string` | ✅ | | Specifies the time zone in which the calendar and selected values are shown. It also influences how entered dates and times are parsed.
<br />
See the `DateTimeInput` docs for more information. |
|
|
65
|
+
| `title` | `ReactNode` | ✅ | | Title of the label |
|
|
66
|
+
| `hint` | `ReactNode` | | | Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`. |
|
|
67
|
+
| `description` | `ReactNode` | | | Provides a description for the title. |
|
|
68
|
+
| `onInfoButtonClick` | `Function`<br/>[See signature.](#signature-onInfoButtonClick) | | | Function called when info button is pressed.
<br />
Info button will only be visible when this prop is passed. |
|
|
69
|
+
| `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text.
<br />
Will only get rendered when `hint` is passed as well. |
|
|
70
|
+
| `badge` | `ReactNode` | | | Badge to be displayed beside the label.
<br />
Might be used to display additional information about the content of the field (E.g verified email) |
|
|
71
|
+
|
|
72
|
+
## Signatures
|
|
73
|
+
|
|
74
|
+
### Signature `renderError`
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
(key: string, error?: boolean) => ReactNode;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Signature `onChange`
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
(event: TEvent) => void
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Signature `onBlur`
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
(event: TEvent) => void
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Signature `onInfoButtonClick`
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
(
|
|
96
|
+
event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
|
|
97
|
+
) => void
|
|
98
|
+
```
|
|
72
99
|
|
|
73
100
|
## `data-*` props
|
|
74
101
|
|
|
@@ -17,12 +17,11 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
|
17
17
|
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
18
18
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
19
19
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
20
|
+
var _pt = require('prop-types');
|
|
20
21
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
21
22
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
22
23
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
23
24
|
var react = require('react');
|
|
24
|
-
var PropTypes = require('prop-types');
|
|
25
|
-
var requiredIf = require('react-required-if');
|
|
26
25
|
var utils = require('@commercetools-uikit/utils');
|
|
27
26
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
28
27
|
var Spacings = require('@commercetools-uikit/spacings');
|
|
@@ -42,20 +41,19 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
42
41
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
43
42
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
44
43
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
44
|
+
var _pt__default = /*#__PURE__*/_interopDefault(_pt);
|
|
45
45
|
var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
|
|
46
46
|
var _Object$values__default = /*#__PURE__*/_interopDefault(_Object$values);
|
|
47
47
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
48
|
-
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
49
|
-
var requiredIf__default = /*#__PURE__*/_interopDefault(requiredIf);
|
|
50
48
|
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
51
49
|
var Spacings__default = /*#__PURE__*/_interopDefault(Spacings);
|
|
52
50
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
53
51
|
var DateTimeInput__default = /*#__PURE__*/_interopDefault(DateTimeInput);
|
|
54
52
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
55
53
|
|
|
56
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
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; }
|
|
57
55
|
|
|
58
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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; }
|
|
59
57
|
|
|
60
58
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
61
59
|
|
|
@@ -96,6 +94,14 @@ var DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
96
94
|
_createClass(DateTimeField, [{
|
|
97
95
|
key: "render",
|
|
98
96
|
value: function render() {
|
|
97
|
+
if (!this.props.isReadOnly) {
|
|
98
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'DateTimeField: `onChange` is required when it is not read only.') : void 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (this.props.hintIcon) {
|
|
102
|
+
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;
|
|
103
|
+
}
|
|
104
|
+
|
|
99
105
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
100
106
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
101
107
|
max: this.props.horizontalConstraint,
|
|
@@ -148,147 +154,32 @@ DateTimeField.getDerivedStateFromProps = function (props, state) {
|
|
|
148
154
|
};
|
|
149
155
|
|
|
150
156
|
DateTimeField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 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.
|
|
174
|
-
* <br />
|
|
175
|
-
* Signature: `(key, error) => React.node`
|
|
176
|
-
*/
|
|
177
|
-
renderError: PropTypes__default["default"].func,
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* Indicates if the value is required. Shows an the "required asterisk" if so.
|
|
181
|
-
*/
|
|
182
|
-
isRequired: PropTypes__default["default"].bool,
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Indicates whether the field was touched. Errors will only be shown when the field was touched.
|
|
186
|
-
*/
|
|
187
|
-
touched: PropTypes__default["default"].bool,
|
|
188
|
-
// DateTimeInput
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Used as HTML name of the input component.
|
|
192
|
-
*/
|
|
193
|
-
name: PropTypes__default["default"].string,
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Value of the input
|
|
197
|
-
*/
|
|
198
|
-
value: PropTypes__default["default"].string.isRequired,
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Called with an event holding the new value.
|
|
202
|
-
* <br/>
|
|
203
|
-
* Required when input is not read only. Parent should pass it back as `value`-
|
|
204
|
-
* <br />
|
|
205
|
-
* Signature: `(event) => void`
|
|
206
|
-
*/
|
|
207
|
-
onChange: requiredIf__default["default"](PropTypes__default["default"].func, function (props) {
|
|
208
|
-
return !props.isReadOnly;
|
|
209
|
-
}),
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Called when input is blurred
|
|
213
|
-
* <br/>
|
|
214
|
-
* Signature: `(event) => void`
|
|
215
|
-
*/
|
|
216
|
-
onBlur: PropTypes__default["default"].func,
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Called when input is focused
|
|
220
|
-
* <br/>
|
|
221
|
-
* Signature: `(event) => void`
|
|
222
|
-
*/
|
|
223
|
-
onFocus: PropTypes__default["default"].func,
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
|
|
227
|
-
*/
|
|
228
|
-
isDisabled: PropTypes__default["default"].bool,
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Indicates that the field is displaying read-only content
|
|
232
|
-
*/
|
|
233
|
-
isReadOnly: PropTypes__default["default"].bool,
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Placeholder text for the input
|
|
237
|
-
*/
|
|
238
|
-
placeholder: PropTypes__default["default"].string,
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Specifies the time zone in which the calendar and selected values are shown. It also influences how entered dates and times are parsed.
|
|
242
|
-
* <br />
|
|
243
|
-
* See the `DateTimeInput` docs for more information.
|
|
244
|
-
*/
|
|
245
|
-
timeZone: PropTypes__default["default"].string.isRequired,
|
|
246
|
-
// LabelField
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Title of the label
|
|
250
|
-
*/
|
|
251
|
-
title: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]).isRequired,
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`.
|
|
255
|
-
*/
|
|
256
|
-
hint: requiredIf__default["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]), function (props) {
|
|
257
|
-
return props.hintIcon;
|
|
258
|
-
}),
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Provides a description for the title.
|
|
262
|
-
*/
|
|
263
|
-
description: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Function called when info button is pressed.
|
|
267
|
-
* <br />
|
|
268
|
-
* Info button will only be visible when this prop is passed.
|
|
269
|
-
* <br />
|
|
270
|
-
* Signature: `(event) => void`
|
|
271
|
-
*/
|
|
272
|
-
onInfoButtonClick: PropTypes__default["default"].func,
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Icon to be displayed beside the hint text.
|
|
276
|
-
* <br />
|
|
277
|
-
* Will only get rendered when `hint` is passed as well.
|
|
278
|
-
*/
|
|
279
|
-
hintIcon: PropTypes__default["default"].node,
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Badge to be displayed beside the label.
|
|
283
|
-
* <br />
|
|
284
|
-
* Might be used to display additional information about the content of the field (E.g verified email)
|
|
285
|
-
*/
|
|
286
|
-
badge: PropTypes__default["default"].node
|
|
157
|
+
id: _pt__default["default"].string,
|
|
158
|
+
horizontalConstraint: _pt__default["default"].oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
159
|
+
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
160
|
+
renderError: _pt__default["default"].func,
|
|
161
|
+
isRequired: _pt__default["default"].bool,
|
|
162
|
+
touched: _pt__default["default"].bool,
|
|
163
|
+
name: _pt__default["default"].string,
|
|
164
|
+
value: _pt__default["default"].string.isRequired,
|
|
165
|
+
onChange: _pt__default["default"].func.isRequired,
|
|
166
|
+
onBlur: _pt__default["default"].func,
|
|
167
|
+
onFocus: _pt__default["default"].func,
|
|
168
|
+
isDisabled: _pt__default["default"].bool,
|
|
169
|
+
isReadOnly: _pt__default["default"].bool,
|
|
170
|
+
placeholder: _pt__default["default"].string,
|
|
171
|
+
timeZone: _pt__default["default"].string.isRequired,
|
|
172
|
+
title: _pt__default["default"].node.isRequired,
|
|
173
|
+
hint: _pt__default["default"].node,
|
|
174
|
+
description: _pt__default["default"].node,
|
|
175
|
+
onInfoButtonClick: _pt__default["default"].func,
|
|
176
|
+
hintIcon: _pt__default["default"].element,
|
|
177
|
+
badge: _pt__default["default"].node
|
|
287
178
|
} : {};
|
|
288
179
|
var DateTimeField$1 = DateTimeField;
|
|
289
180
|
|
|
290
181
|
// NOTE: This string will be replaced on build time with the package version.
|
|
291
|
-
var version = "
|
|
182
|
+
var version = "13.0.2";
|
|
292
183
|
|
|
293
184
|
exports["default"] = DateTimeField$1;
|
|
294
185
|
exports.version = version;
|
|
@@ -17,12 +17,11 @@ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
|
|
|
17
17
|
var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
|
|
18
18
|
var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
|
|
19
19
|
var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
|
|
20
|
+
require('prop-types');
|
|
20
21
|
var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
|
|
21
22
|
var _Object$values = require('@babel/runtime-corejs3/core-js-stable/object/values');
|
|
22
23
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
23
24
|
var react = require('react');
|
|
24
|
-
require('prop-types');
|
|
25
|
-
require('react-required-if');
|
|
26
25
|
var utils = require('@commercetools-uikit/utils');
|
|
27
26
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
28
27
|
var Spacings = require('@commercetools-uikit/spacings');
|
|
@@ -51,9 +50,9 @@ var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
|
51
50
|
var DateTimeInput__default = /*#__PURE__*/_interopDefault(DateTimeInput);
|
|
52
51
|
var FieldErrors__default = /*#__PURE__*/_interopDefault(FieldErrors);
|
|
53
52
|
|
|
54
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object);
|
|
53
|
+
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
54
|
|
|
56
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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
56
|
|
|
58
57
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct__default["default"](Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
59
58
|
|
|
@@ -94,6 +93,10 @@ var DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
94
93
|
_createClass(DateTimeField, [{
|
|
95
94
|
key: "render",
|
|
96
95
|
value: function render() {
|
|
96
|
+
if (!this.props.isReadOnly) ;
|
|
97
|
+
|
|
98
|
+
if (this.props.hintIcon) ;
|
|
99
|
+
|
|
97
100
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
98
101
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
99
102
|
max: this.props.horizontalConstraint,
|
|
@@ -149,7 +152,7 @@ DateTimeField.propTypes = {};
|
|
|
149
152
|
var DateTimeField$1 = DateTimeField;
|
|
150
153
|
|
|
151
154
|
// NOTE: This string will be replaced on build time with the package version.
|
|
152
|
-
var version = "
|
|
155
|
+
var version = "13.0.2";
|
|
153
156
|
|
|
154
157
|
exports["default"] = DateTimeField$1;
|
|
155
158
|
exports.version = version;
|
|
@@ -13,13 +13,12 @@ import _createClass from '@babel/runtime-corejs3/helpers/esm/createClass';
|
|
|
13
13
|
import _inherits from '@babel/runtime-corejs3/helpers/esm/inherits';
|
|
14
14
|
import _possibleConstructorReturn from '@babel/runtime-corejs3/helpers/esm/possibleConstructorReturn';
|
|
15
15
|
import _getPrototypeOf from '@babel/runtime-corejs3/helpers/esm/getPrototypeOf';
|
|
16
|
+
import _pt from 'prop-types';
|
|
16
17
|
import _someInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/some';
|
|
17
18
|
import _Object$values from '@babel/runtime-corejs3/core-js-stable/object/values';
|
|
18
19
|
import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
|
|
19
|
-
import { Component } from 'react';
|
|
20
|
-
import
|
|
21
|
-
import requiredIf from 'react-required-if';
|
|
22
|
-
import { createSequentialId, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
|
|
20
|
+
import { isValidElement, Component } from 'react';
|
|
21
|
+
import { createSequentialId, warning, filterDataAttributes, getFieldId } from '@commercetools-uikit/utils';
|
|
23
22
|
import Constraints from '@commercetools-uikit/constraints';
|
|
24
23
|
import Spacings from '@commercetools-uikit/spacings';
|
|
25
24
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
@@ -27,9 +26,9 @@ import DateTimeInput from '@commercetools-uikit/date-time-input';
|
|
|
27
26
|
import FieldErrors from '@commercetools-uikit/field-errors';
|
|
28
27
|
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
29
28
|
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object);
|
|
29
|
+
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; }
|
|
31
30
|
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
31
|
+
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; }
|
|
33
32
|
|
|
34
33
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
35
34
|
|
|
@@ -70,6 +69,14 @@ var DateTimeField = /*#__PURE__*/function (_Component) {
|
|
|
70
69
|
_createClass(DateTimeField, [{
|
|
71
70
|
key: "render",
|
|
72
71
|
value: function render() {
|
|
72
|
+
if (!this.props.isReadOnly) {
|
|
73
|
+
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'DateTimeField: `onChange` is required when it is not read only.') : void 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (this.props.hintIcon) {
|
|
77
|
+
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;
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
74
81
|
return jsx(Constraints.Horizontal, {
|
|
75
82
|
max: this.props.horizontalConstraint,
|
|
@@ -122,146 +129,31 @@ DateTimeField.getDerivedStateFromProps = function (props, state) {
|
|
|
122
129
|
};
|
|
123
130
|
|
|
124
131
|
DateTimeField.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* 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.
|
|
148
|
-
* <br />
|
|
149
|
-
* Signature: `(key, error) => React.node`
|
|
150
|
-
*/
|
|
151
|
-
renderError: PropTypes.func,
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Indicates if the value is required. Shows an the "required asterisk" if so.
|
|
155
|
-
*/
|
|
156
|
-
isRequired: PropTypes.bool,
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Indicates whether the field was touched. Errors will only be shown when the field was touched.
|
|
160
|
-
*/
|
|
161
|
-
touched: PropTypes.bool,
|
|
162
|
-
// DateTimeInput
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Used as HTML name of the input component.
|
|
166
|
-
*/
|
|
167
|
-
name: PropTypes.string,
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Value of the input
|
|
171
|
-
*/
|
|
172
|
-
value: PropTypes.string.isRequired,
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Called with an event holding the new value.
|
|
176
|
-
* <br/>
|
|
177
|
-
* Required when input is not read only. Parent should pass it back as `value`-
|
|
178
|
-
* <br />
|
|
179
|
-
* Signature: `(event) => void`
|
|
180
|
-
*/
|
|
181
|
-
onChange: requiredIf(PropTypes.func, function (props) {
|
|
182
|
-
return !props.isReadOnly;
|
|
183
|
-
}),
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Called when input is blurred
|
|
187
|
-
* <br/>
|
|
188
|
-
* Signature: `(event) => void`
|
|
189
|
-
*/
|
|
190
|
-
onBlur: PropTypes.func,
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Called when input is focused
|
|
194
|
-
* <br/>
|
|
195
|
-
* Signature: `(event) => void`
|
|
196
|
-
*/
|
|
197
|
-
onFocus: PropTypes.func,
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
|
|
201
|
-
*/
|
|
202
|
-
isDisabled: PropTypes.bool,
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Indicates that the field is displaying read-only content
|
|
206
|
-
*/
|
|
207
|
-
isReadOnly: PropTypes.bool,
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Placeholder text for the input
|
|
211
|
-
*/
|
|
212
|
-
placeholder: PropTypes.string,
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Specifies the time zone in which the calendar and selected values are shown. It also influences how entered dates and times are parsed.
|
|
216
|
-
* <br />
|
|
217
|
-
* See the `DateTimeInput` docs for more information.
|
|
218
|
-
*/
|
|
219
|
-
timeZone: PropTypes.string.isRequired,
|
|
220
|
-
// LabelField
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Title of the label
|
|
224
|
-
*/
|
|
225
|
-
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired,
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Hint for the label. Provides a supplementary but important information regarding the behaviour of the input (e.g warn about uniqueness of a field, when it can only be set once), whereas `description` can describe it in more depth. Can also receive a `hintIcon`.
|
|
229
|
-
*/
|
|
230
|
-
hint: requiredIf(PropTypes.oneOfType([PropTypes.string, PropTypes.node]), function (props) {
|
|
231
|
-
return props.hintIcon;
|
|
232
|
-
}),
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* Provides a description for the title.
|
|
236
|
-
*/
|
|
237
|
-
description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Function called when info button is pressed.
|
|
241
|
-
* <br />
|
|
242
|
-
* Info button will only be visible when this prop is passed.
|
|
243
|
-
* <br />
|
|
244
|
-
* Signature: `(event) => void`
|
|
245
|
-
*/
|
|
246
|
-
onInfoButtonClick: PropTypes.func,
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Icon to be displayed beside the hint text.
|
|
250
|
-
* <br />
|
|
251
|
-
* Will only get rendered when `hint` is passed as well.
|
|
252
|
-
*/
|
|
253
|
-
hintIcon: PropTypes.node,
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Badge to be displayed beside the label.
|
|
257
|
-
* <br />
|
|
258
|
-
* Might be used to display additional information about the content of the field (E.g verified email)
|
|
259
|
-
*/
|
|
260
|
-
badge: PropTypes.node
|
|
132
|
+
id: _pt.string,
|
|
133
|
+
horizontalConstraint: _pt.oneOf([6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
134
|
+
errors: _pt.objectOf(_pt.bool),
|
|
135
|
+
renderError: _pt.func,
|
|
136
|
+
isRequired: _pt.bool,
|
|
137
|
+
touched: _pt.bool,
|
|
138
|
+
name: _pt.string,
|
|
139
|
+
value: _pt.string.isRequired,
|
|
140
|
+
onChange: _pt.func.isRequired,
|
|
141
|
+
onBlur: _pt.func,
|
|
142
|
+
onFocus: _pt.func,
|
|
143
|
+
isDisabled: _pt.bool,
|
|
144
|
+
isReadOnly: _pt.bool,
|
|
145
|
+
placeholder: _pt.string,
|
|
146
|
+
timeZone: _pt.string.isRequired,
|
|
147
|
+
title: _pt.node.isRequired,
|
|
148
|
+
hint: _pt.node,
|
|
149
|
+
description: _pt.node,
|
|
150
|
+
onInfoButtonClick: _pt.func,
|
|
151
|
+
hintIcon: _pt.element,
|
|
152
|
+
badge: _pt.node
|
|
261
153
|
} : {};
|
|
262
154
|
var DateTimeField$1 = DateTimeField;
|
|
263
155
|
|
|
264
156
|
// NOTE: This string will be replaced on build time with the package version.
|
|
265
|
-
var version = "
|
|
157
|
+
var version = "13.0.2";
|
|
266
158
|
|
|
267
159
|
export { DateTimeField$1 as default, version };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Component, type FocusEventHandler, type ReactNode, type MouseEvent, type KeyboardEvent, type ReactElement } from 'react';
|
|
2
|
+
declare type TErrorRenderer = (key: string, error?: boolean) => ReactNode;
|
|
3
|
+
declare type TFieldErrors = Record<string, boolean>;
|
|
4
|
+
declare type TEvent = {
|
|
5
|
+
target: {
|
|
6
|
+
id?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
declare type TDateTimeFieldProps = {
|
|
12
|
+
id?: string;
|
|
13
|
+
horizontalConstraint?: 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
14
|
+
errors?: TFieldErrors;
|
|
15
|
+
renderError?: TErrorRenderer;
|
|
16
|
+
isRequired?: boolean;
|
|
17
|
+
touched?: boolean;
|
|
18
|
+
name?: string;
|
|
19
|
+
value: string;
|
|
20
|
+
onChange: (event: TEvent) => void;
|
|
21
|
+
onBlur?: (event: TEvent) => void;
|
|
22
|
+
onFocus?: FocusEventHandler;
|
|
23
|
+
isDisabled?: boolean;
|
|
24
|
+
isReadOnly?: boolean;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
timeZone: string;
|
|
27
|
+
title: ReactNode;
|
|
28
|
+
hint?: ReactNode;
|
|
29
|
+
description?: ReactNode;
|
|
30
|
+
onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
|
|
31
|
+
hintIcon?: ReactElement;
|
|
32
|
+
badge?: ReactNode;
|
|
33
|
+
};
|
|
34
|
+
declare type TDateTimeFieldState = Pick<TDateTimeFieldProps, 'id'>;
|
|
35
|
+
declare class DateTimeField extends Component<TDateTimeFieldProps, TDateTimeFieldState> {
|
|
36
|
+
static displayName: string;
|
|
37
|
+
static defaultProps: Pick<TDateTimeFieldProps, 'horizontalConstraint'>;
|
|
38
|
+
state: {
|
|
39
|
+
id: string | undefined;
|
|
40
|
+
};
|
|
41
|
+
static getDerivedStateFromProps: (props: TDateTimeFieldProps, state: TDateTimeFieldState) => {
|
|
42
|
+
id: string;
|
|
43
|
+
};
|
|
44
|
+
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
45
|
+
}
|
|
46
|
+
export default DateTimeField;
|
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": "
|
|
4
|
+
"version": "13.0.2",
|
|
5
5
|
"bugs": "https://github.com/commercetools/ui-kit/issues",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"module": "dist/commercetools-uikit-date-time-field.esm.js",
|
|
20
20
|
"files": ["dist"],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/runtime": "7.
|
|
23
|
-
"@babel/runtime-corejs3": "7.
|
|
24
|
-
"@commercetools-uikit/constraints": "
|
|
25
|
-
"@commercetools-uikit/date-time-input": "
|
|
26
|
-
"@commercetools-uikit/design-system": "
|
|
27
|
-
"@commercetools-uikit/field-errors": "
|
|
28
|
-
"@commercetools-uikit/field-label": "
|
|
29
|
-
"@commercetools-uikit/spacings": "
|
|
30
|
-
"@commercetools-uikit/utils": "
|
|
22
|
+
"@babel/runtime": "7.17.2",
|
|
23
|
+
"@babel/runtime-corejs3": "7.17.2",
|
|
24
|
+
"@commercetools-uikit/constraints": "13.0.2",
|
|
25
|
+
"@commercetools-uikit/date-time-input": "13.0.2",
|
|
26
|
+
"@commercetools-uikit/design-system": "13.0.0",
|
|
27
|
+
"@commercetools-uikit/field-errors": "13.0.2",
|
|
28
|
+
"@commercetools-uikit/field-label": "13.0.2",
|
|
29
|
+
"@commercetools-uikit/spacings": "13.0.2",
|
|
30
|
+
"@commercetools-uikit/utils": "13.0.2",
|
|
31
31
|
"@emotion/react": "^11.4.0",
|
|
32
32
|
"@emotion/styled": "^11.3.0",
|
|
33
|
-
"prop-types": "15.
|
|
33
|
+
"prop-types": "15.8.1",
|
|
34
34
|
"react-required-if": "1.0.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|