@commercetools-uikit/time-input 12.2.2 → 12.2.6
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.
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
6
6
|
var _padStartInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/pad-start');
|
|
7
7
|
var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
|
|
8
|
-
var
|
|
8
|
+
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
9
|
+
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
10
|
+
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
11
|
+
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
12
|
+
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
13
|
+
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
14
|
+
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
15
|
+
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
16
|
+
var react$1 = require('react');
|
|
9
17
|
require('prop-types');
|
|
10
18
|
var reactIntl = require('react-intl');
|
|
11
19
|
var Constraints = require('@commercetools-uikit/constraints');
|
|
@@ -15,27 +23,15 @@ var react = require('@emotion/react');
|
|
|
15
23
|
var icons = require('@commercetools-uikit/icons');
|
|
16
24
|
var Inline = require('@commercetools-uikit/spacings-inline');
|
|
17
25
|
var AccessibleButton = require('@commercetools-uikit/accessible-button');
|
|
18
|
-
var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
|
|
19
|
-
var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
|
|
20
|
-
var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
|
|
21
|
-
var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
|
|
22
|
-
var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
|
|
23
|
-
var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
|
|
24
|
-
var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
|
|
25
|
-
var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
|
|
26
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
27
26
|
var _styled = require('@emotion/styled/base');
|
|
28
27
|
var designSystem = require('@commercetools-uikit/design-system');
|
|
29
28
|
var inputUtils = require('@commercetools-uikit/input-utils');
|
|
29
|
+
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
30
30
|
|
|
31
31
|
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
32
32
|
|
|
33
33
|
var _padStartInstanceProperty__default = /*#__PURE__*/_interopDefault(_padStartInstanceProperty);
|
|
34
34
|
var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
|
|
35
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
36
|
-
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
37
|
-
var Inline__default = /*#__PURE__*/_interopDefault(Inline);
|
|
38
|
-
var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
|
|
39
35
|
var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
|
|
40
36
|
var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
|
|
41
37
|
var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
|
|
@@ -44,19 +40,22 @@ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachIns
|
|
|
44
40
|
var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
|
|
45
41
|
var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
|
|
46
42
|
var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
|
|
43
|
+
var Constraints__default = /*#__PURE__*/_interopDefault(Constraints);
|
|
44
|
+
var Inline__default = /*#__PURE__*/_interopDefault(Inline);
|
|
45
|
+
var AccessibleButton__default = /*#__PURE__*/_interopDefault(AccessibleButton);
|
|
47
46
|
var _styled__default = /*#__PURE__*/_interopDefault(_styled);
|
|
48
47
|
|
|
49
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default[
|
|
48
|
+
function ownKeys$2(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
50
49
|
|
|
51
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default[
|
|
50
|
+
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
52
51
|
// * a disabled-field currently does not display warning/error-states so it takes precedence
|
|
53
52
|
// * a readonly-field cannot be changed, but it might be relevant for validation, so error and warning are checked first
|
|
54
53
|
// how you can interact with the field is controlled separately by the props, this only influences visuals
|
|
55
54
|
|
|
56
55
|
var getClearSectionStyles = function getClearSectionStyles(theme) {
|
|
57
|
-
var overwrittenVars = _objectSpread(_objectSpread({}, designSystem.customProperties), theme);
|
|
56
|
+
var overwrittenVars = _objectSpread$2(_objectSpread$2({}, designSystem.customProperties), theme);
|
|
58
57
|
|
|
59
|
-
return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;display:flex;margin:", overwrittenVars.spacingXs, ";cursor:pointer;&:hover svg *{fill:", overwrittenVars.colorWarning, ";}" + ("" ));
|
|
58
|
+
return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;display:flex;margin:", overwrittenVars.spacingXs, ";cursor:pointer;&:hover svg *{fill:", overwrittenVars.colorWarning, ";}" + ("" ), "" );
|
|
60
59
|
};
|
|
61
60
|
|
|
62
61
|
var getClockIconContainerColor = function getClockIconContainerColor(vars, props) {
|
|
@@ -92,9 +91,9 @@ var getClockIconContainerFontColor = function getClockIconContainerFontColor(var
|
|
|
92
91
|
};
|
|
93
92
|
|
|
94
93
|
var getClockIconContainerStyles = function getClockIconContainerStyles(props, theme) {
|
|
95
|
-
var overwrittenVars = _objectSpread(_objectSpread({}, designSystem.customProperties), theme);
|
|
94
|
+
var overwrittenVars = _objectSpread$2(_objectSpread$2({}, designSystem.customProperties), theme);
|
|
96
95
|
|
|
97
|
-
return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;background:none;background-color:", props.isDisabled ? overwrittenVars.backgroundColorForInputWhenDisabled : 'none', ";border:0;border-left:1px solid ", overwrittenVars.borderColorForInput, ";border-top-right-radius:", overwrittenVars.borderRadiusForInput, ";border-bottom-right-radius:", overwrittenVars.borderRadiusForInput, ";border-color:", getClockIconContainerColor(overwrittenVars, props), ";color:", getClockIconContainerFontColor(overwrittenVars, props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";height:100%;display:flex;padding:", overwrittenVars.spacingXs, ";outline:0;transition:color ", overwrittenVars.transitionStandard, ",border-color ", overwrittenVars.transitionStandard, ";&:hover:not(:disabled):not(:read-only),&:focus{border-color:", overwrittenVars.borderColorForInputWhenFocused, ";}" + ("" ));
|
|
96
|
+
return /*#__PURE__*/react.css("align-items:center;box-sizing:border-box;background:none;background-color:", props.isDisabled ? overwrittenVars.backgroundColorForInputWhenDisabled : 'none', ";border:0;border-left:1px solid ", overwrittenVars.borderColorForInput, ";border-top-right-radius:", overwrittenVars.borderRadiusForInput, ";border-bottom-right-radius:", overwrittenVars.borderRadiusForInput, ";border-color:", getClockIconContainerColor(overwrittenVars, props), ";color:", getClockIconContainerFontColor(overwrittenVars, props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";height:100%;display:flex;padding:", overwrittenVars.spacingXs, ";outline:0;transition:color ", overwrittenVars.transitionStandard, ",border-color ", overwrittenVars.transitionStandard, ";&:hover:not(:disabled):not(:read-only),&:focus{border-color:", overwrittenVars.borderColorForInputWhenFocused, ";}" + ("" ), "" );
|
|
98
97
|
};
|
|
99
98
|
|
|
100
99
|
var getInputContainerBorderColor = function getInputContainerBorderColor(vars, props) {
|
|
@@ -130,9 +129,9 @@ var getInputContainerFontColor = function getInputContainerFontColor(vars, props
|
|
|
130
129
|
};
|
|
131
130
|
|
|
132
131
|
var getInputContainerStyles = function getInputContainerStyles(props, theme) {
|
|
133
|
-
var overwrittenVars = _objectSpread(_objectSpread({}, designSystem.customProperties), theme);
|
|
132
|
+
var overwrittenVars = _objectSpread$2(_objectSpread$2({}, designSystem.customProperties), theme);
|
|
134
133
|
|
|
135
|
-
return /*#__PURE__*/react.css("appearance:none;background-color:", props.isDisabled ? overwrittenVars.backgroundColorForInputWhenDisabled : overwrittenVars.backgroundColorForInput, ";border:1px solid ", getInputContainerBorderColor(overwrittenVars, props), ";border-radius:", overwrittenVars.borderRadiusForInput, ";box-sizing:border-box;color:", getInputContainerFontColor(overwrittenVars, props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";width:100%;height:", overwrittenVars.sizeHeightInput, ";align-items:center;display:flex;font-size:", overwrittenVars.fontSizeDefault, ";font-family:inherit;transition:border-color ", overwrittenVars.transitionStandard, ",box-shadow ", overwrittenVars.transitionStandard, ";svg{fill:", props.isReadOnly ? overwrittenVars.fontColorForInputWhenReadonly : 'inherit', ";}&:focus-within{border-color:", overwrittenVars.borderColorForInputWhenFocused, ";box-shadow:inset 0 0 0 2px ", overwrittenVars.borderColorForInputWhenFocused, ";}:hover:not(:disabled):not(:read-only),:focus{border-color:", overwrittenVars.borderColorForInputWhenFocused, ";}" + ("" ));
|
|
134
|
+
return /*#__PURE__*/react.css("appearance:none;background-color:", props.isDisabled ? overwrittenVars.backgroundColorForInputWhenDisabled : overwrittenVars.backgroundColorForInput, ";border:1px solid ", getInputContainerBorderColor(overwrittenVars, props), ";border-radius:", overwrittenVars.borderRadiusForInput, ";box-sizing:border-box;color:", getInputContainerFontColor(overwrittenVars, props), ";cursor:", props.isDisabled ? 'not-allowed' : 'default', ";width:100%;height:", overwrittenVars.sizeHeightInput, ";align-items:center;display:flex;font-size:", overwrittenVars.fontSizeDefault, ";font-family:inherit;transition:border-color ", overwrittenVars.transitionStandard, ",box-shadow ", overwrittenVars.transitionStandard, ";svg{fill:", props.isReadOnly ? overwrittenVars.fontColorForInputWhenReadonly : 'inherit', ";}&:focus-within{border-color:", overwrittenVars.borderColorForInputWhenFocused, ";box-shadow:inset 0 0 0 2px ", overwrittenVars.borderColorForInputWhenFocused, ";}:hover:not(:disabled):not(:read-only),:focus{border-color:", overwrittenVars.borderColorForInputWhenFocused, ";}" + ("" ), "" );
|
|
136
135
|
};
|
|
137
136
|
|
|
138
137
|
var _ref = {
|
|
@@ -146,66 +145,72 @@ var getTimeInputStyles = function getTimeInputStyles(props) {
|
|
|
146
145
|
}; // This styled component is only useful because it's referenced in the `StyledInputContainer`.
|
|
147
146
|
|
|
148
147
|
|
|
149
|
-
var StyledClockIconContainer = _styled__default[
|
|
148
|
+
var StyledClockIconContainer = _styled__default["default"]("label", {
|
|
150
149
|
target: "ebw0ygn1"
|
|
151
|
-
} )();
|
|
150
|
+
} )("" );
|
|
152
151
|
|
|
153
|
-
var StyledInputContainer = _styled__default[
|
|
152
|
+
var StyledInputContainer = _styled__default["default"]("div", {
|
|
154
153
|
target: "ebw0ygn0"
|
|
155
|
-
} )("&:hover,&:hover ", StyledClockIconContainer, ",&:focus-within ", StyledClockIconContainer, "{border-color:", designSystem.customProperties.borderColorForInputWhenFocused, ";}");
|
|
154
|
+
} )("&:hover,&:hover ", StyledClockIconContainer, ",&:focus-within ", StyledClockIconContainer, "{border-color:", designSystem.customProperties.borderColorForInputWhenFocused, ";}" + ("" ));
|
|
156
155
|
|
|
156
|
+
function ownKeys$1(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
157
|
+
|
|
158
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context; _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(source), true)).call(_context, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context2; _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(source))).call(_context2, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
157
159
|
var ClearSection = function ClearSection(props) {
|
|
158
160
|
var theme = react.useTheme();
|
|
159
|
-
return
|
|
161
|
+
return jsxRuntime.jsx(AccessibleButton__default["default"], {
|
|
160
162
|
theme: theme,
|
|
161
163
|
css: getClearSectionStyles(theme),
|
|
162
164
|
label: "clear",
|
|
163
165
|
"aria-label": "clear",
|
|
164
166
|
onClick: props.onClear,
|
|
165
|
-
hasError: props.hasError
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
hasError: props.hasError,
|
|
168
|
+
children: jsxRuntime.jsx(icons.CloseIcon, {
|
|
169
|
+
size: "medium"
|
|
170
|
+
})
|
|
171
|
+
});
|
|
169
172
|
};
|
|
170
173
|
ClearSection.displayName = 'ClearSection';
|
|
171
174
|
ClearSection.propTypes = {};
|
|
172
175
|
|
|
173
176
|
var TimeInputBody = function TimeInputBody(props) {
|
|
174
177
|
var theme = react.useTheme();
|
|
175
|
-
return
|
|
176
|
-
alignItems: "center"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
178
|
+
return jsxRuntime.jsx(Inline__default["default"], {
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
children: jsxRuntime.jsxs(StyledInputContainer, {
|
|
181
|
+
css: getInputContainerStyles(props, theme),
|
|
182
|
+
children: [jsxRuntime.jsx("input", _objectSpread$1(_objectSpread$1({
|
|
183
|
+
css: getTimeInputStyles(props, theme),
|
|
184
|
+
id: props.id,
|
|
185
|
+
name: props.name,
|
|
186
|
+
autoComplete: props.autoComplete,
|
|
187
|
+
placeholder: props.placeholder,
|
|
188
|
+
autoFocus: props.isAutofocussed,
|
|
189
|
+
disabled: props.isDisabled,
|
|
190
|
+
readOnly: props.isReadOnly,
|
|
191
|
+
value: props.value,
|
|
192
|
+
onChange: props.onChange,
|
|
193
|
+
onFocus: props.onFocus,
|
|
194
|
+
onBlur: props.onBlur
|
|
195
|
+
}, utils.filterDataAttributes(props)), {}, {
|
|
196
|
+
/* ARIA */
|
|
197
|
+
"aria-readonly": props.isReadOnly,
|
|
198
|
+
contentEditable: !props.isReadOnly
|
|
199
|
+
})), !props.isDisabled && !props.isReadOnly && jsxRuntime.jsx(ClearSection, {
|
|
200
|
+
isDisabled: props.isDisabled,
|
|
201
|
+
hasError: props.hasError,
|
|
202
|
+
isReadOnly: props.isReadOnly,
|
|
203
|
+
onClear: props.onClear
|
|
204
|
+
}), jsxRuntime.jsx(StyledClockIconContainer, {
|
|
205
|
+
css: getClockIconContainerStyles(props, theme),
|
|
206
|
+
htmlFor: props.id,
|
|
207
|
+
"data-toggle": true,
|
|
208
|
+
children: jsxRuntime.jsx(icons.ClockIcon, {
|
|
209
|
+
color: props.isDisabled || props.isReadOnly ? 'neutral60' : 'solid'
|
|
210
|
+
})
|
|
211
|
+
})]
|
|
212
|
+
})
|
|
213
|
+
});
|
|
209
214
|
};
|
|
210
215
|
|
|
211
216
|
TimeInputBody.displayName = 'TimeInputBody';
|
|
@@ -220,13 +225,16 @@ var messages = reactIntl.defineMessages({
|
|
|
220
225
|
}
|
|
221
226
|
});
|
|
222
227
|
|
|
228
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys__default["default"](object); if (_Object$getOwnPropertySymbols__default["default"]) { var symbols = _Object$getOwnPropertySymbols__default["default"](object); if (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; }
|
|
229
|
+
|
|
230
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context6; _forEachInstanceProperty__default["default"](_context6 = ownKeys(Object(source), true)).call(_context6, function (key) { _defineProperty(target, key, source[key]); }); } else if (_Object$getOwnPropertyDescriptors__default["default"]) { _Object$defineProperties__default["default"](target, _Object$getOwnPropertyDescriptors__default["default"](source)); } else { var _context7; _forEachInstanceProperty__default["default"](_context7 = ownKeys(Object(source))).call(_context7, function (key) { _Object$defineProperty__default["default"](target, key, _Object$getOwnPropertyDescriptor__default["default"](source, key)); }); } } return target; }
|
|
223
231
|
var sequentialId = utils.createSequentialId('time-input-');
|
|
224
232
|
|
|
225
233
|
var leftPad = function leftPad(value) {
|
|
226
234
|
var _context;
|
|
227
235
|
|
|
228
236
|
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
229
|
-
return _padStartInstanceProperty__default[
|
|
237
|
+
return _padStartInstanceProperty__default["default"](_context = String(value)).call(_context, length, '0');
|
|
230
238
|
};
|
|
231
239
|
|
|
232
240
|
var format24hr = function format24hr(_ref) {
|
|
@@ -237,12 +245,12 @@ var format24hr = function format24hr(_ref) {
|
|
|
237
245
|
seconds = _ref.seconds,
|
|
238
246
|
milliseconds = _ref.milliseconds;
|
|
239
247
|
|
|
240
|
-
var base = _concatInstanceProperty__default[
|
|
248
|
+
var base = _concatInstanceProperty__default["default"](_context2 = "".concat(leftPad(hours), ":")).call(_context2, leftPad(minutes));
|
|
241
249
|
|
|
242
250
|
if (seconds === 0 && milliseconds === 0) return base;
|
|
243
|
-
if (milliseconds === 0) return _concatInstanceProperty__default[
|
|
251
|
+
if (milliseconds === 0) return _concatInstanceProperty__default["default"](_context3 = "".concat(base, ":")).call(_context3, leftPad(seconds)); // string representation of a time without timezone in ISO 8601 format
|
|
244
252
|
|
|
245
|
-
return _concatInstanceProperty__default[
|
|
253
|
+
return _concatInstanceProperty__default["default"](_context4 = _concatInstanceProperty__default["default"](_context5 = "".concat(base, ":")).call(_context5, leftPad(seconds), ".")).call(_context4, leftPad(milliseconds, 3));
|
|
246
254
|
};
|
|
247
255
|
|
|
248
256
|
var hasMilliseconds = function hasMilliseconds(parsedTime) {
|
|
@@ -257,7 +265,7 @@ var TimeInput = function TimeInput(props) {
|
|
|
257
265
|
value = props.value,
|
|
258
266
|
onBlur = props.onBlur,
|
|
259
267
|
onChange = props.onChange;
|
|
260
|
-
var emitChange =
|
|
268
|
+
var emitChange = react$1.useCallback(function (nextValue) {
|
|
261
269
|
var event = {
|
|
262
270
|
target: {
|
|
263
271
|
id: id,
|
|
@@ -267,14 +275,14 @@ var TimeInput = function TimeInput(props) {
|
|
|
267
275
|
};
|
|
268
276
|
onChange(event);
|
|
269
277
|
}, [id, name, onChange]);
|
|
270
|
-
var handleBlur =
|
|
278
|
+
var handleBlur = react$1.useCallback(function (event) {
|
|
271
279
|
// check formatting and reformat when necessary
|
|
272
280
|
var formattedTime = TimeInput.toLocaleTime(value, intl.locale);
|
|
273
281
|
if (formattedTime !== value) emitChange(formattedTime); // forward the onBlur call
|
|
274
282
|
|
|
275
283
|
if (onBlur) onBlur(event);
|
|
276
284
|
}, [intl.locale, value, onBlur, emitChange]);
|
|
277
|
-
var onClear =
|
|
285
|
+
var onClear = react$1.useCallback(function () {
|
|
278
286
|
return emitChange('');
|
|
279
287
|
}, [emitChange]); // if locale has changed
|
|
280
288
|
|
|
@@ -282,23 +290,24 @@ var TimeInput = function TimeInput(props) {
|
|
|
282
290
|
emitChange(TimeInput.toLocaleTime(value, intl.locale));
|
|
283
291
|
}
|
|
284
292
|
|
|
285
|
-
return
|
|
286
|
-
max: props.horizontalConstraint
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
return jsxRuntime.jsx(Constraints__default["default"].Horizontal, {
|
|
294
|
+
max: props.horizontalConstraint,
|
|
295
|
+
children: jsxRuntime.jsx(TimeInputBody$1, _objectSpread({
|
|
296
|
+
id: id,
|
|
297
|
+
name: props.name,
|
|
298
|
+
autoComplete: props.autoComplete,
|
|
299
|
+
value: props.value,
|
|
300
|
+
onChange: props.onChange,
|
|
301
|
+
onFocus: props.onFocus,
|
|
302
|
+
onBlur: handleBlur,
|
|
303
|
+
isAutofocussed: props.isAutofocussed,
|
|
304
|
+
isDisabled: props.isDisabled,
|
|
305
|
+
hasError: props.hasError,
|
|
306
|
+
isReadOnly: props.isReadOnly,
|
|
307
|
+
onClear: onClear,
|
|
308
|
+
placeholder: typeof props.placeholder === 'string' ? props.placeholder : intl.formatMessage(messages.placeholder)
|
|
309
|
+
}, utils.filterDataAttributes(props)))
|
|
310
|
+
});
|
|
302
311
|
};
|
|
303
312
|
|
|
304
313
|
TimeInput.displayName = 'TimeInput'; // Takes any input like 15:10, 3 AM, 3AM, 3:15AM, 3:5AM and turns it
|
|
@@ -339,8 +348,8 @@ TimeInput.toLocaleTime = function (time, locale) {
|
|
|
339
348
|
|
|
340
349
|
var TimeInput$1 = TimeInput;
|
|
341
350
|
|
|
342
|
-
// NOTE: This string will be replaced
|
|
343
|
-
var version =
|
|
351
|
+
// NOTE: This string will be replaced on build time with the package version.
|
|
352
|
+
var version = "12.2.6";
|
|
344
353
|
|
|
345
|
-
exports[
|
|
354
|
+
exports["default"] = TimeInput$1;
|
|
346
355
|
exports.version = version;
|