@atlaskit/datetime-picker 11.1.11 → 12.1.1
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/CHANGELOG.md +38 -0
- package/dist/cjs/components/DatePicker.js +20 -10
- package/dist/cjs/components/DateTimePicker.js +7 -5
- package/dist/cjs/components/TimePicker.js +13 -5
- package/dist/cjs/internal/parseTime.js +8 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/DatePicker.js +20 -10
- package/dist/es2019/components/DateTimePicker.js +5 -3
- package/dist/es2019/components/TimePicker.js +13 -5
- package/dist/es2019/internal/parseTime.js +8 -6
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/DatePicker.js +20 -10
- package/dist/esm/components/DateTimePicker.js +7 -5
- package/dist/esm/components/TimePicker.js +13 -5
- package/dist/esm/internal/parseTime.js +8 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/components/DatePicker.d.ts +9 -3
- package/dist/types/components/DateTimePicker.d.ts +2 -4
- package/dist/types/components/TimePicker.d.ts +4 -4
- package/package.json +7 -4
- package/report.api.md +636 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 12.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3fa327b5d01`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3fa327b5d01) - [ux] Border on a subtle appearance date-picker will now persist after a date is selected and field is in focus
|
|
8
|
+
|
|
9
|
+
## 12.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`58d4cd75f7a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/58d4cd75f7a) - Removed deprecated hideIcon prop from DateTimePicker because it is unused and serves no functionality.
|
|
14
|
+
Removed the deprecation notice for the formatDisplayLabel prop in TimePicker
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`c3a1b950d49`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c3a1b950d49) - DSP-3301 specifies label to input id
|
|
19
|
+
- [`c2f866d31d1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c2f866d31d1) - [ux] Fix timepicker clear icon alignment
|
|
20
|
+
- [`7566be18f20`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7566be18f20) - [ux] Time picker no longer loses focus to the document when tabbing through it in a popup.
|
|
21
|
+
- [`574b6c8ba7f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/574b6c8ba7f) - [ux] DSP-2987 Add code to catch console error
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
24
|
+
## 12.0.0
|
|
25
|
+
|
|
26
|
+
### Major Changes
|
|
27
|
+
|
|
28
|
+
- [`27d4f1e7121`](https://bitbucket.org/atlassian/atlassian-frontend/commits/27d4f1e7121) - [ux] Updating tokens
|
|
29
|
+
- [`d7542d1a7c2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d7542d1a7c2) - [ux] Update Tokens in the code with those that are a better fit. New tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).These changes are intended to be interoperable with the legacy theme implementation. Legacy dark mode users should expect no visual or breaking changes.
|
|
30
|
+
- [`c19fb116172`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c19fb116172) - [ux] Update Tokens in the code with those that are a better fit. New tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).These changes are intended to be interoperable with the legacy theme implementation. Legacy dark mode users should expect no visual or breaking changes.
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- [`6f7a4353204`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6f7a4353204) - Added ability to provide custom aria-labels for next- and previous-month buttons using `nextMonthLabel` and `previousMonthLabel`
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- [`3ec9ed2c4d0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3ec9ed2c4d0) - Fixed handling of custom times that included whitespace characters
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
|
|
3
41
|
## 11.1.11
|
|
4
42
|
|
|
5
43
|
### Patch Changes
|
|
@@ -68,7 +68,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
68
68
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
69
69
|
|
|
70
70
|
var packageName = "@atlaskit/datetime-picker";
|
|
71
|
-
var packageVersion = "
|
|
71
|
+
var packageVersion = "12.1.1";
|
|
72
72
|
/* eslint-disable react/no-unused-prop-types */
|
|
73
73
|
|
|
74
74
|
function getDateObj(date) {
|
|
@@ -104,13 +104,16 @@ var Menu = function Menu(_ref) {
|
|
|
104
104
|
disabledDateFilter: selectProps.calendarDisabledDateFilter,
|
|
105
105
|
minDate: selectProps.calendarMinDate,
|
|
106
106
|
maxDate: selectProps.calendarMaxDate,
|
|
107
|
+
nextMonthLabel: selectProps.nextMonthLabel,
|
|
107
108
|
onChange: selectProps.onCalendarChange,
|
|
108
109
|
onSelect: selectProps.onCalendarSelect,
|
|
110
|
+
previousMonthLabel: selectProps.previousMonthLabel,
|
|
109
111
|
calendarRef: selectProps.calendarRef,
|
|
110
112
|
selected: [selectProps.calendarValue],
|
|
111
113
|
locale: selectProps.calendarLocale,
|
|
112
114
|
testId: selectProps.testId && "".concat(selectProps.testId, "--calendar"),
|
|
113
|
-
weekStartDay: selectProps.calendarWeekStartDay
|
|
115
|
+
weekStartDay: selectProps.calendarWeekStartDay,
|
|
116
|
+
tabIndex: -1
|
|
114
117
|
}))),
|
|
115
118
|
testId: selectProps.testId
|
|
116
119
|
});
|
|
@@ -213,7 +216,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
213
216
|
});
|
|
214
217
|
} else {
|
|
215
218
|
_this.setState({
|
|
216
|
-
isOpen: false
|
|
219
|
+
isOpen: false,
|
|
220
|
+
isFocused: false
|
|
217
221
|
});
|
|
218
222
|
}
|
|
219
223
|
|
|
@@ -232,7 +236,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
232
236
|
} else {
|
|
233
237
|
_this.setState({
|
|
234
238
|
isOpen: true,
|
|
235
|
-
view: value
|
|
239
|
+
view: value,
|
|
240
|
+
isFocused: true
|
|
236
241
|
});
|
|
237
242
|
}
|
|
238
243
|
|
|
@@ -383,9 +388,9 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
383
388
|
_this.forceUpdate();
|
|
384
389
|
}
|
|
385
390
|
});
|
|
386
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSubtleControlStyles", function (
|
|
391
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSubtleControlStyles", function () {
|
|
387
392
|
return {
|
|
388
|
-
border: "2px solid ".concat(
|
|
393
|
+
border: "2px solid ".concat(_this.getSafeState().isFocused ? "var(--ds-border-focused, ".concat(_colors.B100, ")") : "transparent"),
|
|
389
394
|
backgroundColor: 'transparent',
|
|
390
395
|
padding: '1px'
|
|
391
396
|
};
|
|
@@ -439,6 +444,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
439
444
|
|
|
440
445
|
_this.state = {
|
|
441
446
|
isOpen: _this.props.defaultIsOpen,
|
|
447
|
+
isFocused: false,
|
|
442
448
|
clearingFromIcon: false,
|
|
443
449
|
inputValue: _this.props.selectProps.inputValue,
|
|
444
450
|
selectedValue: _this.props.value || _this.props.defaultValue,
|
|
@@ -477,12 +483,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
477
483
|
minDate = _this$props3.minDate,
|
|
478
484
|
isInvalid = _this$props3.isInvalid,
|
|
479
485
|
name = _this$props3.name,
|
|
486
|
+
nextMonthLabel = _this$props3.nextMonthLabel,
|
|
487
|
+
previousMonthLabel = _this$props3.previousMonthLabel,
|
|
480
488
|
selectProps = _this$props3.selectProps,
|
|
481
489
|
spacing = _this$props3.spacing,
|
|
482
490
|
locale = _this$props3.locale,
|
|
483
491
|
testId = _this$props3.testId,
|
|
484
492
|
weekStartDay = _this$props3.weekStartDay;
|
|
485
|
-
var BORDER_WIDTH = 2;
|
|
486
493
|
var ICON_PADDING = 2;
|
|
487
494
|
|
|
488
495
|
var _this$getSafeState6 = this.getSafeState(),
|
|
@@ -505,7 +512,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
505
512
|
|
|
506
513
|
var _selectProps$styles = selectProps.styles,
|
|
507
514
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles;
|
|
508
|
-
var controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles(
|
|
515
|
+
var controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles() : {};
|
|
509
516
|
var disabledStyle = isDisabled ? {
|
|
510
517
|
pointerEvents: 'none'
|
|
511
518
|
} : {};
|
|
@@ -521,7 +528,9 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
521
528
|
onCalendarChange: this.onCalendarChange,
|
|
522
529
|
onCalendarSelect: this.onCalendarSelect,
|
|
523
530
|
calendarLocale: locale,
|
|
524
|
-
calendarWeekStartDay: weekStartDay
|
|
531
|
+
calendarWeekStartDay: weekStartDay,
|
|
532
|
+
nextMonthLabel: nextMonthLabel,
|
|
533
|
+
previousMonthLabel: previousMonthLabel
|
|
525
534
|
};
|
|
526
535
|
return (0, _core.jsx)("div", (0, _extends2.default)({}, innerProps, {
|
|
527
536
|
role: "presentation",
|
|
@@ -531,6 +540,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
531
540
|
ref: this.getContainerRef,
|
|
532
541
|
"data-testid": testId && "".concat(testId, "--container")
|
|
533
542
|
}), (0, _core.jsx)("input", {
|
|
543
|
+
id: selectProps.inputId,
|
|
534
544
|
name: name,
|
|
535
545
|
type: "hidden",
|
|
536
546
|
value: value,
|
|
@@ -555,7 +565,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
555
565
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
556
566
|
return _objectSpread(_objectSpread({}, base), {}, {
|
|
557
567
|
paddingLeft: ICON_PADDING,
|
|
558
|
-
paddingRight: (0, _constants.gridSize)() -
|
|
568
|
+
paddingRight: (0, _constants.gridSize)() - ICON_PADDING
|
|
559
569
|
});
|
|
560
570
|
}
|
|
561
571
|
}),
|
|
@@ -58,7 +58,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
58
58
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
59
59
|
|
|
60
60
|
var packageName = "@atlaskit/datetime-picker";
|
|
61
|
-
var packageVersion = "
|
|
61
|
+
var packageVersion = "12.1.1";
|
|
62
62
|
/* eslint-disable react/no-unused-prop-types */
|
|
63
63
|
|
|
64
64
|
var isInvalidBorderStyles = (0, _core.css)({
|
|
@@ -76,13 +76,13 @@ var subtleBgStyles = (0, _core.css)({
|
|
|
76
76
|
});
|
|
77
77
|
var hoverStyles = (0, _core.css)({
|
|
78
78
|
'&:hover': {
|
|
79
|
-
backgroundColor: "var(--ds-
|
|
79
|
+
backgroundColor: "var(--ds-background-input-hovered, ".concat(_colors.N30, ")"),
|
|
80
80
|
borderColor: "var(--ds-border, ".concat(_colors.N30, ")")
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
var isInvalidHoverStyles = (0, _core.css)({
|
|
84
84
|
'&:hover': {
|
|
85
|
-
backgroundColor: "var(--ds-
|
|
85
|
+
backgroundColor: "var(--ds-background-input-hovered, ".concat(_colors.N0, ")"),
|
|
86
86
|
borderColor: "var(--ds-border-danger, ".concat(_colors.R400, ")")
|
|
87
87
|
}
|
|
88
88
|
});
|
|
@@ -258,9 +258,9 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
258
258
|
});
|
|
259
259
|
|
|
260
260
|
if (dateValue && timeValue) {
|
|
261
|
-
var
|
|
261
|
+
var _value = (0, _internal.formatDateTimeZoneIntoIso)(dateValue, timeValue, zoneValue);
|
|
262
262
|
|
|
263
|
-
var _this$parseValue = this.parseValue(
|
|
263
|
+
var _this$parseValue = this.parseValue(_value, dateValue, timeValue, zoneValue),
|
|
264
264
|
parsedZone = _this$parseValue.zoneValue;
|
|
265
265
|
|
|
266
266
|
var valueWithValidZone = (0, _internal.formatDateTimeZoneIntoIso)(dateValue, timeValue, parsedZone);
|
|
@@ -326,11 +326,13 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
326
326
|
|
|
327
327
|
var isClearable = Boolean(dateValue || timeValue);
|
|
328
328
|
var notFocusedOrIsDisabled = !(isFocused || isDisabled);
|
|
329
|
+
var labelId = (datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.inputId) || (timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.inputId) || '';
|
|
329
330
|
return (0, _core.jsx)("div", (0, _extends2.default)({
|
|
330
331
|
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && subtleBgStyles, isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
331
332
|
}, innerProps, {
|
|
332
333
|
"data-testid": testId
|
|
333
334
|
}), (0, _core.jsx)("input", {
|
|
335
|
+
id: labelId,
|
|
334
336
|
name: name,
|
|
335
337
|
type: "hidden",
|
|
336
338
|
value: value
|
|
@@ -67,7 +67,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
67
67
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
68
68
|
|
|
69
69
|
var packageName = "@atlaskit/datetime-picker";
|
|
70
|
-
var packageVersion = "
|
|
70
|
+
var packageVersion = "12.1.1";
|
|
71
71
|
var menuStyles = {
|
|
72
72
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
73
73
|
position: 'static',
|
|
@@ -165,7 +165,15 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
165
165
|
var _this$props = _this.props,
|
|
166
166
|
parseInputValue = _this$props.parseInputValue,
|
|
167
167
|
_timeFormat = _this$props.timeFormat;
|
|
168
|
-
var
|
|
168
|
+
var sanitizedInput;
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
sanitizedInput = parseInputValue(inputValue, _timeFormat || _internal.defaultTimeFormat);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return; // do nothing, the main validation should happen in the form
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
var formattedValue = (0, _dateFns.format)(sanitizedInput, 'HH:mm') || '';
|
|
169
177
|
|
|
170
178
|
_this.setState({
|
|
171
179
|
value: formattedValue
|
|
@@ -323,7 +331,6 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
323
331
|
spacing = _this$props3.spacing,
|
|
324
332
|
testId = _this$props3.testId;
|
|
325
333
|
var ICON_PADDING = 2;
|
|
326
|
-
var BORDER_WIDTH = 2;
|
|
327
334
|
|
|
328
335
|
var _this$getSafeState3 = this.getSafeState(),
|
|
329
336
|
_this$getSafeState3$v = _this$getSafeState3.value,
|
|
@@ -349,7 +356,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
349
356
|
selectComponents.ClearIndicator = _internal.EmptyClearIndicator;
|
|
350
357
|
}
|
|
351
358
|
|
|
352
|
-
var renderIconContainer = Boolean(hideIcon && value);
|
|
359
|
+
var renderIconContainer = Boolean(!hideIcon && value);
|
|
353
360
|
var mergedStyles = (0, _select.mergeStyles)(selectStyles, {
|
|
354
361
|
control: function control(base) {
|
|
355
362
|
return _objectSpread(_objectSpread({}, base), controlStyles);
|
|
@@ -364,7 +371,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
364
371
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
365
372
|
return _objectSpread(_objectSpread({}, base), {}, {
|
|
366
373
|
paddingLeft: renderIconContainer ? ICON_PADDING : 0,
|
|
367
|
-
paddingRight: renderIconContainer ? (0, _constants.gridSize)() -
|
|
374
|
+
paddingRight: renderIconContainer ? (0, _constants.gridSize)() - ICON_PADDING : 0
|
|
368
375
|
});
|
|
369
376
|
}
|
|
370
377
|
});
|
|
@@ -376,6 +383,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
376
383
|
"data-testid": testId && "".concat(testId, "--container"),
|
|
377
384
|
onKeyDown: this.onSelectKeyDown
|
|
378
385
|
}), /*#__PURE__*/_react.default.createElement("input", {
|
|
386
|
+
id: selectProps.inputId,
|
|
379
387
|
name: name,
|
|
380
388
|
type: "hidden",
|
|
381
389
|
value: value
|
|
@@ -95,9 +95,9 @@ function checkMinute(minute) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
function convertTo24hrTime(time) {
|
|
98
|
-
var timeArray = time.split(/(p|a)/);
|
|
98
|
+
var timeArray = time.toLowerCase().split(/(p|a)/i);
|
|
99
99
|
var meridiem = timeArray[1];
|
|
100
|
-
var semi24 = formatSemi24(timeArray[0]);
|
|
100
|
+
var semi24 = formatSemi24(timeArray[0].trim());
|
|
101
101
|
var hour = checkHour(semi24.substring(0, 2), meridiem);
|
|
102
102
|
var minute = checkMinute(semi24.substring(2, 4));
|
|
103
103
|
|
|
@@ -120,15 +120,17 @@ function assignToDate(time) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
function _default(time) {
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
var trimmedTime = time.toString().trim();
|
|
124
|
+
|
|
125
|
+
if (!isValid(trimmedTime)) {
|
|
126
|
+
throw RangeError('invalid time format');
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
var time1 = removeSpacer(
|
|
129
|
+
var time1 = removeSpacer(trimmedTime);
|
|
128
130
|
var time2 = convertTo24hrTime(time1);
|
|
129
131
|
|
|
130
132
|
if (!time2) {
|
|
131
|
-
|
|
133
|
+
throw RangeError('invalid time format');
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
return assignToDate(time2);
|
package/dist/cjs/version.json
CHANGED
|
@@ -18,7 +18,7 @@ import { defaultDateFormat, EmptyClearIndicator, padToTwo, placeholderDatetime }
|
|
|
18
18
|
import FixedLayer from '../internal/FixedLayer';
|
|
19
19
|
import { convertTokens } from './utils';
|
|
20
20
|
const packageName = "@atlaskit/datetime-picker";
|
|
21
|
-
const packageVersion = "
|
|
21
|
+
const packageVersion = "12.1.1";
|
|
22
22
|
/* eslint-disable react/no-unused-prop-types */
|
|
23
23
|
|
|
24
24
|
function getDateObj(date) {
|
|
@@ -54,13 +54,16 @@ const Menu = ({
|
|
|
54
54
|
disabledDateFilter: selectProps.calendarDisabledDateFilter,
|
|
55
55
|
minDate: selectProps.calendarMinDate,
|
|
56
56
|
maxDate: selectProps.calendarMaxDate,
|
|
57
|
+
nextMonthLabel: selectProps.nextMonthLabel,
|
|
57
58
|
onChange: selectProps.onCalendarChange,
|
|
58
59
|
onSelect: selectProps.onCalendarSelect,
|
|
60
|
+
previousMonthLabel: selectProps.previousMonthLabel,
|
|
59
61
|
calendarRef: selectProps.calendarRef,
|
|
60
62
|
selected: [selectProps.calendarValue],
|
|
61
63
|
locale: selectProps.calendarLocale,
|
|
62
64
|
testId: selectProps.testId && `${selectProps.testId}--calendar`,
|
|
63
|
-
weekStartDay: selectProps.calendarWeekStartDay
|
|
65
|
+
weekStartDay: selectProps.calendarWeekStartDay,
|
|
66
|
+
tabIndex: -1
|
|
64
67
|
}))),
|
|
65
68
|
testId: selectProps.testId
|
|
66
69
|
});
|
|
@@ -158,7 +161,8 @@ class DatePicker extends Component {
|
|
|
158
161
|
});
|
|
159
162
|
} else {
|
|
160
163
|
this.setState({
|
|
161
|
-
isOpen: false
|
|
164
|
+
isOpen: false,
|
|
165
|
+
isFocused: false
|
|
162
166
|
});
|
|
163
167
|
}
|
|
164
168
|
|
|
@@ -179,7 +183,8 @@ class DatePicker extends Component {
|
|
|
179
183
|
} else {
|
|
180
184
|
this.setState({
|
|
181
185
|
isOpen: true,
|
|
182
|
-
view: value
|
|
186
|
+
view: value,
|
|
187
|
+
isFocused: true
|
|
183
188
|
});
|
|
184
189
|
}
|
|
185
190
|
|
|
@@ -332,8 +337,8 @@ class DatePicker extends Component {
|
|
|
332
337
|
}
|
|
333
338
|
});
|
|
334
339
|
|
|
335
|
-
_defineProperty(this, "getSubtleControlStyles",
|
|
336
|
-
border: `2px solid ${
|
|
340
|
+
_defineProperty(this, "getSubtleControlStyles", () => ({
|
|
341
|
+
border: `2px solid ${this.getSafeState().isFocused ? `var(--ds-border-focused, ${B100})` : `transparent`}`,
|
|
337
342
|
backgroundColor: 'transparent',
|
|
338
343
|
padding: '1px'
|
|
339
344
|
}));
|
|
@@ -393,6 +398,7 @@ class DatePicker extends Component {
|
|
|
393
398
|
} = getDateObj(new Date());
|
|
394
399
|
this.state = {
|
|
395
400
|
isOpen: this.props.defaultIsOpen,
|
|
401
|
+
isFocused: false,
|
|
396
402
|
clearingFromIcon: false,
|
|
397
403
|
inputValue: this.props.selectProps.inputValue,
|
|
398
404
|
selectedValue: this.props.value || this.props.defaultValue,
|
|
@@ -427,13 +433,14 @@ class DatePicker extends Component {
|
|
|
427
433
|
minDate,
|
|
428
434
|
isInvalid,
|
|
429
435
|
name,
|
|
436
|
+
nextMonthLabel,
|
|
437
|
+
previousMonthLabel,
|
|
430
438
|
selectProps,
|
|
431
439
|
spacing,
|
|
432
440
|
locale,
|
|
433
441
|
testId,
|
|
434
442
|
weekStartDay
|
|
435
443
|
} = this.props;
|
|
436
|
-
const BORDER_WIDTH = 2;
|
|
437
444
|
const ICON_PADDING = 2;
|
|
438
445
|
const {
|
|
439
446
|
value,
|
|
@@ -456,7 +463,7 @@ class DatePicker extends Component {
|
|
|
456
463
|
const {
|
|
457
464
|
styles: selectStyles = {}
|
|
458
465
|
} = selectProps;
|
|
459
|
-
const controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles(
|
|
466
|
+
const controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles() : {};
|
|
460
467
|
const disabledStyle = isDisabled ? {
|
|
461
468
|
pointerEvents: 'none'
|
|
462
469
|
} : {};
|
|
@@ -472,7 +479,9 @@ class DatePicker extends Component {
|
|
|
472
479
|
onCalendarChange: this.onCalendarChange,
|
|
473
480
|
onCalendarSelect: this.onCalendarSelect,
|
|
474
481
|
calendarLocale: locale,
|
|
475
|
-
calendarWeekStartDay: weekStartDay
|
|
482
|
+
calendarWeekStartDay: weekStartDay,
|
|
483
|
+
nextMonthLabel,
|
|
484
|
+
previousMonthLabel
|
|
476
485
|
};
|
|
477
486
|
return jsx("div", _extends({}, innerProps, {
|
|
478
487
|
role: "presentation",
|
|
@@ -482,6 +491,7 @@ class DatePicker extends Component {
|
|
|
482
491
|
ref: this.getContainerRef,
|
|
483
492
|
"data-testid": testId && `${testId}--container`
|
|
484
493
|
}), jsx("input", {
|
|
494
|
+
id: selectProps.inputId,
|
|
485
495
|
name: name,
|
|
486
496
|
type: "hidden",
|
|
487
497
|
value: value,
|
|
@@ -506,7 +516,7 @@ class DatePicker extends Component {
|
|
|
506
516
|
}),
|
|
507
517
|
indicatorsContainer: base => ({ ...base,
|
|
508
518
|
paddingLeft: ICON_PADDING,
|
|
509
|
-
paddingRight: gridSize() -
|
|
519
|
+
paddingRight: gridSize() - ICON_PADDING
|
|
510
520
|
})
|
|
511
521
|
}),
|
|
512
522
|
placeholder: this.getPlaceholder(),
|
|
@@ -17,7 +17,7 @@ import DatePicker from './DatePicker';
|
|
|
17
17
|
import TimePicker from './TimePicker';
|
|
18
18
|
import { convertTokens } from './utils';
|
|
19
19
|
const packageName = "@atlaskit/datetime-picker";
|
|
20
|
-
const packageVersion = "
|
|
20
|
+
const packageVersion = "12.1.1";
|
|
21
21
|
/* eslint-disable react/no-unused-prop-types */
|
|
22
22
|
|
|
23
23
|
const isInvalidBorderStyles = css({
|
|
@@ -35,13 +35,13 @@ const subtleBgStyles = css({
|
|
|
35
35
|
});
|
|
36
36
|
const hoverStyles = css({
|
|
37
37
|
'&:hover': {
|
|
38
|
-
backgroundColor: `var(--ds-
|
|
38
|
+
backgroundColor: `var(--ds-background-input-hovered, ${N30})`,
|
|
39
39
|
borderColor: `var(--ds-border, ${N30})`
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
const isInvalidHoverStyles = css({
|
|
43
43
|
'&:hover': {
|
|
44
|
-
backgroundColor: `var(--ds-
|
|
44
|
+
backgroundColor: `var(--ds-background-input-hovered, ${N0})`,
|
|
45
45
|
borderColor: `var(--ds-border-danger, ${R400})`
|
|
46
46
|
}
|
|
47
47
|
});
|
|
@@ -273,11 +273,13 @@ class DateTimePicker extends React.Component {
|
|
|
273
273
|
|
|
274
274
|
const isClearable = Boolean(dateValue || timeValue);
|
|
275
275
|
const notFocusedOrIsDisabled = !(isFocused || isDisabled);
|
|
276
|
+
const labelId = (datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.inputId) || (timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.inputId) || '';
|
|
276
277
|
return jsx("div", _extends({
|
|
277
278
|
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && subtleBgStyles, isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
278
279
|
}, innerProps, {
|
|
279
280
|
"data-testid": testId
|
|
280
281
|
}), jsx("input", {
|
|
282
|
+
id: labelId,
|
|
281
283
|
name: name,
|
|
282
284
|
type: "hidden",
|
|
283
285
|
value: value
|
|
@@ -14,7 +14,7 @@ import FixedLayer from '../internal/FixedLayer';
|
|
|
14
14
|
import parseTime from '../internal/parseTime';
|
|
15
15
|
import { convertTokens } from './utils';
|
|
16
16
|
const packageName = "@atlaskit/datetime-picker";
|
|
17
|
-
const packageVersion = "
|
|
17
|
+
const packageVersion = "12.1.1";
|
|
18
18
|
const menuStyles = {
|
|
19
19
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
20
20
|
position: 'static',
|
|
@@ -104,7 +104,15 @@ class TimePicker extends React.Component {
|
|
|
104
104
|
parseInputValue,
|
|
105
105
|
timeFormat
|
|
106
106
|
} = this.props;
|
|
107
|
-
|
|
107
|
+
let sanitizedInput;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
sanitizedInput = parseInputValue(inputValue, timeFormat || defaultTimeFormat);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return; // do nothing, the main validation should happen in the form
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const formattedValue = format(sanitizedInput, 'HH:mm') || '';
|
|
108
116
|
this.setState({
|
|
109
117
|
value: formattedValue
|
|
110
118
|
});
|
|
@@ -262,7 +270,6 @@ class TimePicker extends React.Component {
|
|
|
262
270
|
testId
|
|
263
271
|
} = this.props;
|
|
264
272
|
const ICON_PADDING = 2;
|
|
265
|
-
const BORDER_WIDTH = 2;
|
|
266
273
|
const {
|
|
267
274
|
value = '',
|
|
268
275
|
isOpen
|
|
@@ -287,7 +294,7 @@ class TimePicker extends React.Component {
|
|
|
287
294
|
selectComponents.ClearIndicator = EmptyClearIndicator;
|
|
288
295
|
}
|
|
289
296
|
|
|
290
|
-
const renderIconContainer = Boolean(hideIcon && value);
|
|
297
|
+
const renderIconContainer = Boolean(!hideIcon && value);
|
|
291
298
|
const mergedStyles = mergeStyles(selectStyles, {
|
|
292
299
|
control: base => ({ ...base,
|
|
293
300
|
...controlStyles
|
|
@@ -300,7 +307,7 @@ class TimePicker extends React.Component {
|
|
|
300
307
|
}),
|
|
301
308
|
indicatorsContainer: base => ({ ...base,
|
|
302
309
|
paddingLeft: renderIconContainer ? ICON_PADDING : 0,
|
|
303
|
-
paddingRight: renderIconContainer ? gridSize() -
|
|
310
|
+
paddingRight: renderIconContainer ? gridSize() - ICON_PADDING : 0
|
|
304
311
|
})
|
|
305
312
|
});
|
|
306
313
|
return (
|
|
@@ -311,6 +318,7 @@ class TimePicker extends React.Component {
|
|
|
311
318
|
"data-testid": testId && `${testId}--container`,
|
|
312
319
|
onKeyDown: this.onSelectKeyDown
|
|
313
320
|
}), /*#__PURE__*/React.createElement("input", {
|
|
321
|
+
id: selectProps.inputId,
|
|
314
322
|
name: name,
|
|
315
323
|
type: "hidden",
|
|
316
324
|
value: value
|
|
@@ -76,9 +76,9 @@ export function checkMinute(minute) {
|
|
|
76
76
|
return minute;
|
|
77
77
|
}
|
|
78
78
|
export function convertTo24hrTime(time) {
|
|
79
|
-
const timeArray = time.split(/(p|a)/);
|
|
79
|
+
const timeArray = time.toLowerCase().split(/(p|a)/i);
|
|
80
80
|
const meridiem = timeArray[1];
|
|
81
|
-
const semi24 = formatSemi24(timeArray[0]);
|
|
81
|
+
const semi24 = formatSemi24(timeArray[0].trim());
|
|
82
82
|
const hour = checkHour(semi24.substring(0, 2), meridiem);
|
|
83
83
|
const minute = checkMinute(semi24.substring(2, 4));
|
|
84
84
|
|
|
@@ -99,15 +99,17 @@ export function assignToDate(time) {
|
|
|
99
99
|
return dateTime;
|
|
100
100
|
}
|
|
101
101
|
export default function (time) {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
const trimmedTime = time.toString().trim();
|
|
103
|
+
|
|
104
|
+
if (!isValid(trimmedTime)) {
|
|
105
|
+
throw RangeError('invalid time format');
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
const time1 = removeSpacer(
|
|
108
|
+
const time1 = removeSpacer(trimmedTime);
|
|
107
109
|
const time2 = convertTo24hrTime(time1);
|
|
108
110
|
|
|
109
111
|
if (!time2) {
|
|
110
|
-
|
|
112
|
+
throw RangeError('invalid time format');
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
return assignToDate(time2);
|
package/dist/es2019/version.json
CHANGED