@commercetools-uikit/time-field 12.2.7 → 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 +58 -24
- package/dist/commercetools-uikit-time-field.cjs.d.ts +2 -0
- package/dist/commercetools-uikit-time-field.cjs.dev.js +38 -141
- package/dist/commercetools-uikit-time-field.cjs.prod.js +11 -6
- package/dist/commercetools-uikit-time-field.esm.js +39 -141
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/time-field.d.ts +47 -0
- package/dist/declarations/src/version.d.ts +2 -0
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -45,30 +45,64 @@ 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
|
-
| `placeholder` | `string`
|
|
66
|
-
| `title` |
|
|
67
|
-
| `hint` | `
|
|
68
|
-
| `description` |
|
|
69
|
-
| `onInfoButtonClick` | `
|
|
70
|
-
| `hintIcon` | `
|
|
71
|
-
| `badge` | `
|
|
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/>`, 3, 4, 5, 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, as renderError(key, error). This function can return a message which will be wrapped in an ErrorMessage.
<br />
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
|
+
| `autoComplete` | `string` | | | Used as HTML autocomplete of the input component. |
|
|
58
|
+
| `value` | `string` | ✅ | | Value of the input |
|
|
59
|
+
| `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`- |
|
|
60
|
+
| `onBlur` | `Function`<br/>[See signature.](#signature-onBlur) | | | Called when input is blurred |
|
|
61
|
+
| `onFocus` | `Function`<br/>[See signature.](#signature-onFocus) | | | Called when input is focused |
|
|
62
|
+
| `isAutofocussed` | `boolean` | | | Focus the input on initial render |
|
|
63
|
+
| `isDisabled` | `boolean` | | | Indicates that the input cannot be modified (e.g not authorized, or changes currently saving). |
|
|
64
|
+
| `isReadOnly` | `boolean` | | | Indicates that the input is read only (no changes allowed). |
|
|
65
|
+
| `placeholder` | `string` | | | Placeholder text for the input |
|
|
66
|
+
| `title` | `ReactNode` | ✅ | | Title of the label |
|
|
67
|
+
| `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. |
|
|
68
|
+
| `description` | `ReactNode` | | | Provides a description for the title. |
|
|
69
|
+
| `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. |
|
|
70
|
+
| `hintIcon` | `ReactElement` | | | Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well. |
|
|
71
|
+
| `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) |
|
|
72
|
+
|
|
73
|
+
## Signatures
|
|
74
|
+
|
|
75
|
+
### Signature `renderError`
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
(key: string, error?: boolean) => ReactNode;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Signature `onChange`
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
(event: TEvent) => void
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Signature `onBlur`
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
(event: TEvent) => void
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Signature `onFocus`
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
(event: TEvent) => void
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Signature `onInfoButtonClick`
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
(
|
|
103
|
+
event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>
|
|
104
|
+
) => void
|
|
105
|
+
```
|
|
72
106
|
|
|
73
107
|
## `data-*` props
|
|
74
108
|
|
|
@@ -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 Stack = require('@commercetools-uikit/spacings-stack');
|
|
@@ -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 Stack__default = /*#__PURE__*/_interopDefault(Stack);
|
|
52
50
|
var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
53
51
|
var TimeInput__default = /*#__PURE__*/_interopDefault(TimeInput);
|
|
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
|
|
|
@@ -97,6 +95,15 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
97
95
|
key: "render",
|
|
98
96
|
value: function render() {
|
|
99
97
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
98
|
+
|
|
99
|
+
if (!this.props.isReadOnly) {
|
|
100
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.onChange === 'function', 'TimeField: `onChange` is required when is not read only.') : void 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (this.props.hintIcon) {
|
|
104
|
+
process.env.NODE_ENV !== "production" ? utils.warning(typeof this.props.hint === 'string' || /*#__PURE__*/react.isValidElement(this.props.hint), 'TimeField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
100
107
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
101
108
|
max: this.props.horizontalConstraint,
|
|
102
109
|
children: jsxRuntime.jsxs(Stack__default["default"], {
|
|
@@ -122,7 +129,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
122
129
|
isDisabled: this.props.isDisabled,
|
|
123
130
|
hasError: hasError,
|
|
124
131
|
placeholder: this.props.placeholder,
|
|
125
|
-
horizontalConstraint: "scale"
|
|
132
|
+
horizontalConstraint: "scale",
|
|
133
|
+
isReadOnly: this.props.isReadOnly
|
|
126
134
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
127
135
|
errors: this.props.errors,
|
|
128
136
|
isVisible: hasError,
|
|
@@ -148,144 +156,33 @@ TimeField.getDerivedStateFromProps = function (props, state) {
|
|
|
148
156
|
};
|
|
149
157
|
|
|
150
158
|
TimeField.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, as renderError(key, error). This function can return a message which will be wrapped in an ErrorMessage.
|
|
174
|
-
* <br />
|
|
175
|
-
* It can also return null to show no error.
|
|
176
|
-
* <br />
|
|
177
|
-
* Signature: `(key, error) => React.node`
|
|
178
|
-
*/
|
|
179
|
-
renderError: PropTypes__default["default"].func,
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Indicates if the value is required. Shows an the "required asterisk" if so.
|
|
183
|
-
*/
|
|
184
|
-
isRequired: PropTypes__default["default"].bool,
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Indicates whether the field was touched. Errors will only be shown when the field was touched.
|
|
188
|
-
*/
|
|
189
|
-
touched: PropTypes__default["default"].bool,
|
|
190
|
-
// TimeInput
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Used as HTML name of the input component.
|
|
194
|
-
*/
|
|
195
|
-
name: PropTypes__default["default"].string,
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Used as HTML autocomplete of the input component.
|
|
199
|
-
*/
|
|
200
|
-
autoComplete: PropTypes__default["default"].string,
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* Value of the input
|
|
204
|
-
*/
|
|
205
|
-
value: PropTypes__default["default"].string.isRequired,
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Called with an event holding the new value.
|
|
209
|
-
* <br/>
|
|
210
|
-
* Required when input is not read only. Parent should pass it back as `value`-
|
|
211
|
-
* <br />
|
|
212
|
-
* Signature: `(event) => void`
|
|
213
|
-
*/
|
|
214
|
-
onChange: requiredIf__default["default"](PropTypes__default["default"].func, function (props) {
|
|
215
|
-
return !props.isReadOnly;
|
|
216
|
-
}),
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Called when input is blurred
|
|
220
|
-
* <br/>
|
|
221
|
-
* Signature: `(event) => void`
|
|
222
|
-
*/
|
|
223
|
-
onBlur: PropTypes__default["default"].func,
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Called when input is focused
|
|
227
|
-
* <br/>
|
|
228
|
-
* Signature: `(event) => void`
|
|
229
|
-
*/
|
|
230
|
-
onFocus: PropTypes__default["default"].func,
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Focus the input on initial render
|
|
234
|
-
*/
|
|
235
|
-
isAutofocussed: PropTypes__default["default"].bool,
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
|
|
239
|
-
*/
|
|
240
|
-
isDisabled: PropTypes__default["default"].bool,
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Placeholder text for the input
|
|
244
|
-
*/
|
|
245
|
-
placeholder: PropTypes__default["default"].string,
|
|
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),
|
|
255
|
-
* whereas description can describe it in more depth. Can also receive a hintIcon.
|
|
256
|
-
*/
|
|
257
|
-
hint: requiredIf__default["default"](PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]), function (props) {
|
|
258
|
-
return props.hintIcon;
|
|
259
|
-
}),
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Provides a description for the title.
|
|
263
|
-
*/
|
|
264
|
-
description: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].node]),
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Function called when info button is pressed.
|
|
268
|
-
* <br/>
|
|
269
|
-
* Info button will only be visible when this prop is passed.
|
|
270
|
-
*/
|
|
271
|
-
onInfoButtonClick: PropTypes__default["default"].func,
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well.
|
|
275
|
-
*/
|
|
276
|
-
hintIcon: PropTypes__default["default"].node,
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Badge to be displayed beside the label.
|
|
280
|
-
* <br/>
|
|
281
|
-
* Might be used to display additional information about the content of the field (E.g verified email)
|
|
282
|
-
*/
|
|
283
|
-
badge: PropTypes__default["default"].node
|
|
159
|
+
id: _pt__default["default"].string,
|
|
160
|
+
horizontalConstraint: _pt__default["default"].oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
161
|
+
errors: _pt__default["default"].objectOf(_pt__default["default"].bool),
|
|
162
|
+
renderError: _pt__default["default"].func,
|
|
163
|
+
isRequired: _pt__default["default"].bool,
|
|
164
|
+
touched: _pt__default["default"].bool,
|
|
165
|
+
name: _pt__default["default"].string,
|
|
166
|
+
autoComplete: _pt__default["default"].string,
|
|
167
|
+
value: _pt__default["default"].string.isRequired,
|
|
168
|
+
onChange: _pt__default["default"].func.isRequired,
|
|
169
|
+
onBlur: _pt__default["default"].func,
|
|
170
|
+
onFocus: _pt__default["default"].func,
|
|
171
|
+
isAutofocussed: _pt__default["default"].bool,
|
|
172
|
+
isDisabled: _pt__default["default"].bool,
|
|
173
|
+
isReadOnly: _pt__default["default"].bool,
|
|
174
|
+
placeholder: _pt__default["default"].string,
|
|
175
|
+
title: _pt__default["default"].node.isRequired,
|
|
176
|
+
hint: _pt__default["default"].node,
|
|
177
|
+
description: _pt__default["default"].node,
|
|
178
|
+
onInfoButtonClick: _pt__default["default"].func,
|
|
179
|
+
hintIcon: _pt__default["default"].element,
|
|
180
|
+
badge: _pt__default["default"].node
|
|
284
181
|
} : {};
|
|
285
182
|
var TimeField$1 = TimeField;
|
|
286
183
|
|
|
287
184
|
// NOTE: This string will be replaced on build time with the package version.
|
|
288
|
-
var version = "
|
|
185
|
+
var version = "13.0.2";
|
|
289
186
|
|
|
290
187
|
exports["default"] = TimeField$1;
|
|
291
188
|
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 Stack = require('@commercetools-uikit/spacings-stack');
|
|
@@ -51,9 +50,9 @@ var FieldLabel__default = /*#__PURE__*/_interopDefault(FieldLabel);
|
|
|
51
50
|
var TimeInput__default = /*#__PURE__*/_interopDefault(TimeInput);
|
|
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
|
|
|
@@ -95,6 +94,11 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
95
94
|
key: "render",
|
|
96
95
|
value: function render() {
|
|
97
96
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
97
|
+
|
|
98
|
+
if (!this.props.isReadOnly) ;
|
|
99
|
+
|
|
100
|
+
if (this.props.hintIcon) ;
|
|
101
|
+
|
|
98
102
|
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
99
103
|
max: this.props.horizontalConstraint,
|
|
100
104
|
children: jsxRuntime.jsxs(Stack__default["default"], {
|
|
@@ -120,7 +124,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
120
124
|
isDisabled: this.props.isDisabled,
|
|
121
125
|
hasError: hasError,
|
|
122
126
|
placeholder: this.props.placeholder,
|
|
123
|
-
horizontalConstraint: "scale"
|
|
127
|
+
horizontalConstraint: "scale",
|
|
128
|
+
isReadOnly: this.props.isReadOnly
|
|
124
129
|
}, utils.filterDataAttributes(this.props))), jsxRuntime.jsx(FieldErrors__default["default"], {
|
|
125
130
|
errors: this.props.errors,
|
|
126
131
|
isVisible: hasError,
|
|
@@ -149,7 +154,7 @@ TimeField.propTypes = {};
|
|
|
149
154
|
var TimeField$1 = TimeField;
|
|
150
155
|
|
|
151
156
|
// NOTE: This string will be replaced on build time with the package version.
|
|
152
|
-
var version = "
|
|
157
|
+
var version = "13.0.2";
|
|
153
158
|
|
|
154
159
|
exports["default"] = TimeField$1;
|
|
155
160
|
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 Stack from '@commercetools-uikit/spacings-stack';
|
|
25
24
|
import FieldLabel from '@commercetools-uikit/field-label';
|
|
@@ -27,9 +26,9 @@ import TimeInput from '@commercetools-uikit/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
|
|
|
@@ -71,6 +70,15 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
71
70
|
key: "render",
|
|
72
71
|
value: function render() {
|
|
73
72
|
var hasError = this.props.touched && hasErrors(this.props.errors);
|
|
73
|
+
|
|
74
|
+
if (!this.props.isReadOnly) {
|
|
75
|
+
process.env.NODE_ENV !== "production" ? warning(typeof this.props.onChange === 'function', 'TimeField: `onChange` is required when is not read only.') : void 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (this.props.hintIcon) {
|
|
79
|
+
process.env.NODE_ENV !== "production" ? warning(typeof this.props.hint === 'string' || /*#__PURE__*/isValidElement(this.props.hint), 'TimeField: `hint` is required to be string or ReactNode if hintIcon is present') : void 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
74
82
|
return jsx(Constraints.Horizontal, {
|
|
75
83
|
max: this.props.horizontalConstraint,
|
|
76
84
|
children: jsxs(Stack, {
|
|
@@ -96,7 +104,8 @@ var TimeField = /*#__PURE__*/function (_Component) {
|
|
|
96
104
|
isDisabled: this.props.isDisabled,
|
|
97
105
|
hasError: hasError,
|
|
98
106
|
placeholder: this.props.placeholder,
|
|
99
|
-
horizontalConstraint: "scale"
|
|
107
|
+
horizontalConstraint: "scale",
|
|
108
|
+
isReadOnly: this.props.isReadOnly
|
|
100
109
|
}, filterDataAttributes(this.props))), jsx(FieldErrors, {
|
|
101
110
|
errors: this.props.errors,
|
|
102
111
|
isVisible: hasError,
|
|
@@ -122,143 +131,32 @@ TimeField.getDerivedStateFromProps = function (props, state) {
|
|
|
122
131
|
};
|
|
123
132
|
|
|
124
133
|
TimeField.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, as renderError(key, error). This function can return a message which will be wrapped in an ErrorMessage.
|
|
148
|
-
* <br />
|
|
149
|
-
* It can also return null to show no error.
|
|
150
|
-
* <br />
|
|
151
|
-
* Signature: `(key, error) => React.node`
|
|
152
|
-
*/
|
|
153
|
-
renderError: PropTypes.func,
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Indicates if the value is required. Shows an the "required asterisk" if so.
|
|
157
|
-
*/
|
|
158
|
-
isRequired: PropTypes.bool,
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Indicates whether the field was touched. Errors will only be shown when the field was touched.
|
|
162
|
-
*/
|
|
163
|
-
touched: PropTypes.bool,
|
|
164
|
-
// TimeInput
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Used as HTML name of the input component.
|
|
168
|
-
*/
|
|
169
|
-
name: PropTypes.string,
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Used as HTML autocomplete of the input component.
|
|
173
|
-
*/
|
|
174
|
-
autoComplete: PropTypes.string,
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Value of the input
|
|
178
|
-
*/
|
|
179
|
-
value: PropTypes.string.isRequired,
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Called with an event holding the new value.
|
|
183
|
-
* <br/>
|
|
184
|
-
* Required when input is not read only. Parent should pass it back as `value`-
|
|
185
|
-
* <br />
|
|
186
|
-
* Signature: `(event) => void`
|
|
187
|
-
*/
|
|
188
|
-
onChange: requiredIf(PropTypes.func, function (props) {
|
|
189
|
-
return !props.isReadOnly;
|
|
190
|
-
}),
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Called when input is blurred
|
|
194
|
-
* <br/>
|
|
195
|
-
* Signature: `(event) => void`
|
|
196
|
-
*/
|
|
197
|
-
onBlur: PropTypes.func,
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Called when input is focused
|
|
201
|
-
* <br/>
|
|
202
|
-
* Signature: `(event) => void`
|
|
203
|
-
*/
|
|
204
|
-
onFocus: PropTypes.func,
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Focus the input on initial render
|
|
208
|
-
*/
|
|
209
|
-
isAutofocussed: PropTypes.bool,
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Indicates that the input cannot be modified (e.g not authorized, or changes currently saving).
|
|
213
|
-
*/
|
|
214
|
-
isDisabled: PropTypes.bool,
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Placeholder text for the input
|
|
218
|
-
*/
|
|
219
|
-
placeholder: PropTypes.string,
|
|
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),
|
|
229
|
-
* whereas description can describe it in more depth. Can also receive a hintIcon.
|
|
230
|
-
*/
|
|
231
|
-
hint: requiredIf(PropTypes.oneOfType([PropTypes.string, PropTypes.node]), function (props) {
|
|
232
|
-
return props.hintIcon;
|
|
233
|
-
}),
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Provides a description for the title.
|
|
237
|
-
*/
|
|
238
|
-
description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Function called when info button is pressed.
|
|
242
|
-
* <br/>
|
|
243
|
-
* Info button will only be visible when this prop is passed.
|
|
244
|
-
*/
|
|
245
|
-
onInfoButtonClick: PropTypes.func,
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* Icon to be displayed beside the hint text. Will only get rendered when hint is passed as well.
|
|
249
|
-
*/
|
|
250
|
-
hintIcon: PropTypes.node,
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Badge to be displayed beside the label.
|
|
254
|
-
* <br/>
|
|
255
|
-
* Might be used to display additional information about the content of the field (E.g verified email)
|
|
256
|
-
*/
|
|
257
|
-
badge: PropTypes.node
|
|
134
|
+
id: _pt.string,
|
|
135
|
+
horizontalConstraint: _pt.oneOf([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto']),
|
|
136
|
+
errors: _pt.objectOf(_pt.bool),
|
|
137
|
+
renderError: _pt.func,
|
|
138
|
+
isRequired: _pt.bool,
|
|
139
|
+
touched: _pt.bool,
|
|
140
|
+
name: _pt.string,
|
|
141
|
+
autoComplete: _pt.string,
|
|
142
|
+
value: _pt.string.isRequired,
|
|
143
|
+
onChange: _pt.func.isRequired,
|
|
144
|
+
onBlur: _pt.func,
|
|
145
|
+
onFocus: _pt.func,
|
|
146
|
+
isAutofocussed: _pt.bool,
|
|
147
|
+
isDisabled: _pt.bool,
|
|
148
|
+
isReadOnly: _pt.bool,
|
|
149
|
+
placeholder: _pt.string,
|
|
150
|
+
title: _pt.node.isRequired,
|
|
151
|
+
hint: _pt.node,
|
|
152
|
+
description: _pt.node,
|
|
153
|
+
onInfoButtonClick: _pt.func,
|
|
154
|
+
hintIcon: _pt.element,
|
|
155
|
+
badge: _pt.node
|
|
258
156
|
} : {};
|
|
259
157
|
var TimeField$1 = TimeField;
|
|
260
158
|
|
|
261
159
|
// NOTE: This string will be replaced on build time with the package version.
|
|
262
|
-
var version = "
|
|
160
|
+
var version = "13.0.2";
|
|
263
161
|
|
|
264
162
|
export { TimeField$1 as default, version };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Component, type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
declare type TEvent = {
|
|
3
|
+
target: {
|
|
4
|
+
id?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: unknown;
|
|
7
|
+
};
|
|
8
|
+
persist?: () => void;
|
|
9
|
+
};
|
|
10
|
+
declare type TFieldErrors = Record<string, boolean>;
|
|
11
|
+
declare type TTimeFieldProps = {
|
|
12
|
+
id?: string;
|
|
13
|
+
horizontalConstraint?: 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 'scale' | 'auto';
|
|
14
|
+
errors?: TFieldErrors;
|
|
15
|
+
renderError?: (key: string, error?: boolean) => ReactNode;
|
|
16
|
+
isRequired?: boolean;
|
|
17
|
+
touched?: boolean;
|
|
18
|
+
name?: string;
|
|
19
|
+
autoComplete?: string;
|
|
20
|
+
value: string;
|
|
21
|
+
onChange: (event: TEvent) => void;
|
|
22
|
+
onBlur?: (event: TEvent) => void;
|
|
23
|
+
onFocus?: (event: TEvent) => void;
|
|
24
|
+
isAutofocussed?: boolean;
|
|
25
|
+
isDisabled?: boolean;
|
|
26
|
+
isReadOnly?: boolean;
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
title: ReactNode;
|
|
29
|
+
hint?: ReactNode;
|
|
30
|
+
description?: ReactNode;
|
|
31
|
+
onInfoButtonClick?: (event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>) => void;
|
|
32
|
+
hintIcon?: ReactElement;
|
|
33
|
+
badge?: ReactNode;
|
|
34
|
+
};
|
|
35
|
+
declare type TTimeFieldState = Pick<TTimeFieldProps, 'id'>;
|
|
36
|
+
declare class TimeField extends Component<TTimeFieldProps, TTimeFieldState> {
|
|
37
|
+
static displayName: string;
|
|
38
|
+
static defaultProps: Pick<TTimeFieldProps, 'horizontalConstraint'>;
|
|
39
|
+
state: {
|
|
40
|
+
id: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
static getDerivedStateFromProps: (props: TTimeFieldProps, state: TTimeFieldState) => {
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
45
|
+
render(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
46
|
+
}
|
|
47
|
+
export default TimeField;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercetools-uikit/time-field",
|
|
3
3
|
"description": "A controlled date input component for single date.",
|
|
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-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/design-system": "
|
|
26
|
-
"@commercetools-uikit/field-errors": "
|
|
27
|
-
"@commercetools-uikit/field-label": "
|
|
28
|
-
"@commercetools-uikit/spacings-stack": "
|
|
29
|
-
"@commercetools-uikit/time-input": "
|
|
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/design-system": "13.0.0",
|
|
26
|
+
"@commercetools-uikit/field-errors": "13.0.2",
|
|
27
|
+
"@commercetools-uikit/field-label": "13.0.2",
|
|
28
|
+
"@commercetools-uikit/spacings-stack": "13.0.2",
|
|
29
|
+
"@commercetools-uikit/time-input": "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": {
|