@atlaskit/datetime-picker 12.0.0 → 12.1.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/CHANGELOG.md +31 -0
- package/dist/cjs/components/{DatePicker.js → date-picker.js} +43 -27
- package/dist/cjs/components/{DateTimePicker.js → date-time-picker.js} +16 -10
- package/dist/cjs/components/{TimePicker.js → time-picker.js} +17 -9
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/internal/{FixedLayer.js → fixed-layer.js} +3 -1
- package/dist/cjs/internal/index.js +1 -0
- package/dist/cjs/internal/{parseTime.js → parse-time.js} +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/{DatePicker.js → date-picker.js} +33 -15
- package/dist/es2019/components/{DateTimePicker.js → date-time-picker.js} +16 -8
- package/dist/es2019/components/{TimePicker.js → time-picker.js} +18 -8
- package/dist/es2019/index.js +3 -3
- package/dist/es2019/internal/{FixedLayer.js → fixed-layer.js} +2 -1
- package/dist/es2019/internal/index.js +1 -0
- package/dist/es2019/internal/{parseTime.js → parse-time.js} +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/{DatePicker.js → date-picker.js} +44 -26
- package/dist/esm/components/{DateTimePicker.js → date-time-picker.js} +16 -8
- package/dist/esm/components/{TimePicker.js → time-picker.js} +17 -8
- package/dist/esm/index.js +3 -3
- package/dist/esm/internal/{FixedLayer.js → fixed-layer.js} +2 -1
- package/dist/esm/internal/index.js +1 -0
- package/dist/esm/internal/{parseTime.js → parse-time.js} +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/components/{DatePicker.d.ts → date-picker.d.ts} +99 -45
- package/dist/types/components/{DateTimePicker.d.ts → date-time-picker.d.ts} +67 -29
- package/dist/types/components/{TimePicker.d.ts → time-picker.d.ts} +76 -33
- package/dist/types/index.d.ts +6 -6
- package/dist/types/internal/{FixedLayer.d.ts → fixed-layer.d.ts} +7 -5
- package/dist/types/internal/{parseTime.d.ts → parse-time.d.ts} +0 -0
- package/extract-react-types/date-picker-props.tsx +2 -2
- package/extract-react-types/datetime-picker-props.tsx +2 -2
- package/extract-react-types/time-picker-props.tsx +2 -2
- package/package.json +7 -4
- package/report.api.md +636 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @atlaskit/datetime-picker
|
|
2
2
|
|
|
3
|
+
## 12.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`df3d5287649`](https://bitbucket.org/atlassian/atlassian-frontend/commits/df3d5287649) - Internal code change turning on new linting rules.
|
|
8
|
+
- [`429a576a4b2`](https://bitbucket.org/atlassian/atlassian-frontend/commits/429a576a4b2) - fix change-event firing for invalid inputs in datetime-picker select.
|
|
9
|
+
- [`84afee665fc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/84afee665fc) - [ux] Implemented missing functionality to submit forms on enter press after a date has been selected in DatePicker
|
|
10
|
+
- [`2a2dcc1cf91`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2a2dcc1cf91) - Updated styles to use new input design tokens. Fixed bug where border radius on datePicker rendered incorrectly.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 12.1.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`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
|
|
18
|
+
|
|
19
|
+
## 12.1.0
|
|
20
|
+
|
|
21
|
+
### Minor Changes
|
|
22
|
+
|
|
23
|
+
- [`58d4cd75f7a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/58d4cd75f7a) - Removed deprecated hideIcon prop from DateTimePicker because it is unused and serves no functionality.
|
|
24
|
+
Removed the deprecation notice for the formatDisplayLabel prop in TimePicker
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- [`c3a1b950d49`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c3a1b950d49) - DSP-3301 specifies label to input id
|
|
29
|
+
- [`c2f866d31d1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c2f866d31d1) - [ux] Fix timepicker clear icon alignment
|
|
30
|
+
- [`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.
|
|
31
|
+
- [`574b6c8ba7f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/574b6c8ba7f) - [ux] DSP-2987 Add code to catch console error
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
|
|
3
34
|
## 12.0.0
|
|
4
35
|
|
|
5
36
|
### Major Changes
|
|
@@ -51,7 +51,7 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
51
51
|
|
|
52
52
|
var _internal = require("../internal");
|
|
53
53
|
|
|
54
|
-
var
|
|
54
|
+
var _fixedLayer = _interopRequireDefault(require("../internal/fixed-layer"));
|
|
55
55
|
|
|
56
56
|
var _utils = require("./utils");
|
|
57
57
|
|
|
@@ -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 = "12.
|
|
71
|
+
var packageVersion = "12.1.2";
|
|
72
72
|
/* eslint-disable react/no-unused-prop-types */
|
|
73
73
|
|
|
74
74
|
function getDateObj(date) {
|
|
@@ -86,15 +86,16 @@ function getValidDate(iso) {
|
|
|
86
86
|
|
|
87
87
|
var menuStyles = (0, _core.css)({
|
|
88
88
|
zIndex: _constants.layers.dialog(),
|
|
89
|
-
backgroundColor: "var(--ds-surface, ".concat(_colors.N20, ")"),
|
|
89
|
+
backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N20, ")"),
|
|
90
90
|
borderRadius: "".concat((0, _constants.borderRadius)(), "px"),
|
|
91
|
-
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")")
|
|
91
|
+
boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"),
|
|
92
|
+
overflow: 'hidden'
|
|
92
93
|
});
|
|
93
94
|
|
|
94
95
|
var Menu = function Menu(_ref) {
|
|
95
96
|
var selectProps = _ref.selectProps,
|
|
96
97
|
innerProps = _ref.innerProps;
|
|
97
|
-
return (0, _core.jsx)(
|
|
98
|
+
return (0, _core.jsx)(_fixedLayer.default, {
|
|
98
99
|
inputValue: selectProps.inputValue,
|
|
99
100
|
containerRef: selectProps.calendarContainerRef,
|
|
100
101
|
content: (0, _core.jsx)("div", (0, _extends2.default)({
|
|
@@ -112,7 +113,8 @@ var Menu = function Menu(_ref) {
|
|
|
112
113
|
selected: [selectProps.calendarValue],
|
|
113
114
|
locale: selectProps.calendarLocale,
|
|
114
115
|
testId: selectProps.testId && "".concat(selectProps.testId, "--calendar"),
|
|
115
|
-
weekStartDay: selectProps.calendarWeekStartDay
|
|
116
|
+
weekStartDay: selectProps.calendarWeekStartDay,
|
|
117
|
+
tabIndex: -1
|
|
116
118
|
}))),
|
|
117
119
|
testId: selectProps.testId
|
|
118
120
|
});
|
|
@@ -215,7 +217,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
215
217
|
});
|
|
216
218
|
} else {
|
|
217
219
|
_this.setState({
|
|
218
|
-
isOpen: false
|
|
220
|
+
isOpen: false,
|
|
221
|
+
isFocused: false
|
|
219
222
|
});
|
|
220
223
|
}
|
|
221
224
|
|
|
@@ -234,7 +237,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
234
237
|
} else {
|
|
235
238
|
_this.setState({
|
|
236
239
|
isOpen: true,
|
|
237
|
-
view: value
|
|
240
|
+
view: value,
|
|
241
|
+
isFocused: true
|
|
238
242
|
});
|
|
239
243
|
}
|
|
240
244
|
|
|
@@ -315,12 +319,21 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
315
319
|
break;
|
|
316
320
|
|
|
317
321
|
case 'enter':
|
|
318
|
-
|
|
322
|
+
if (!_this.state.isOpen) {
|
|
323
|
+
return;
|
|
324
|
+
} // Prevent form submission when a date is selected
|
|
319
325
|
// using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
|
|
320
326
|
// for more details.
|
|
327
|
+
|
|
328
|
+
|
|
321
329
|
event.preventDefault();
|
|
322
330
|
|
|
323
331
|
if (!_this.isDateDisabled(view)) {
|
|
332
|
+
var _this$getSafeState3 = _this.getSafeState(),
|
|
333
|
+
_value = _this$getSafeState3.value;
|
|
334
|
+
|
|
335
|
+
var valueChanged = view !== _value;
|
|
336
|
+
|
|
324
337
|
_this.setState({
|
|
325
338
|
inputValue: '',
|
|
326
339
|
isOpen: false,
|
|
@@ -329,7 +342,9 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
329
342
|
view: view
|
|
330
343
|
});
|
|
331
344
|
|
|
332
|
-
|
|
345
|
+
if (valueChanged) {
|
|
346
|
+
_this.props.onChange(view);
|
|
347
|
+
}
|
|
333
348
|
}
|
|
334
349
|
|
|
335
350
|
break;
|
|
@@ -385,10 +400,10 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
385
400
|
_this.forceUpdate();
|
|
386
401
|
}
|
|
387
402
|
});
|
|
388
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSubtleControlStyles", function (
|
|
403
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSubtleControlStyles", function () {
|
|
389
404
|
return {
|
|
390
|
-
border: "2px solid ".concat(
|
|
391
|
-
backgroundColor: 'transparent',
|
|
405
|
+
border: "2px solid ".concat(_this.getSafeState().isFocused ? "var(--ds-border-focused, ".concat(_colors.B100, ")") : "transparent"),
|
|
406
|
+
backgroundColor: _this.getSafeState().isOpen ? "var(--ds-background-input-pressed, transparent)" : 'transparent',
|
|
392
407
|
padding: '1px'
|
|
393
408
|
};
|
|
394
409
|
});
|
|
@@ -401,8 +416,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
401
416
|
return parseInputValue(date, dateFormat || _internal.defaultDateFormat);
|
|
402
417
|
}
|
|
403
418
|
|
|
404
|
-
var _this$
|
|
405
|
-
l10n = _this$
|
|
419
|
+
var _this$getSafeState4 = _this.getSafeState(),
|
|
420
|
+
l10n = _this$getSafeState4.l10n;
|
|
406
421
|
|
|
407
422
|
return l10n.parseDate(date);
|
|
408
423
|
});
|
|
@@ -411,8 +426,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
411
426
|
formatDisplayLabel = _this$props2.formatDisplayLabel,
|
|
412
427
|
dateFormat = _this$props2.dateFormat;
|
|
413
428
|
|
|
414
|
-
var _this$
|
|
415
|
-
l10n = _this$
|
|
429
|
+
var _this$getSafeState5 = _this.getSafeState(),
|
|
430
|
+
l10n = _this$getSafeState5.l10n;
|
|
416
431
|
|
|
417
432
|
if (formatDisplayLabel) {
|
|
418
433
|
return formatDisplayLabel(value, dateFormat || _internal.defaultDateFormat);
|
|
@@ -428,8 +443,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
428
443
|
return placeholder;
|
|
429
444
|
}
|
|
430
445
|
|
|
431
|
-
var _this$
|
|
432
|
-
l10n = _this$
|
|
446
|
+
var _this$getSafeState6 = _this.getSafeState(),
|
|
447
|
+
l10n = _this$getSafeState6.l10n;
|
|
433
448
|
|
|
434
449
|
return l10n.formatDate(_internal.placeholderDatetime);
|
|
435
450
|
});
|
|
@@ -441,6 +456,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
441
456
|
|
|
442
457
|
_this.state = {
|
|
443
458
|
isOpen: _this.props.defaultIsOpen,
|
|
459
|
+
isFocused: false,
|
|
444
460
|
clearingFromIcon: false,
|
|
445
461
|
inputValue: _this.props.selectProps.inputValue,
|
|
446
462
|
selectedValue: _this.props.value || _this.props.defaultValue,
|
|
@@ -486,14 +502,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
486
502
|
locale = _this$props3.locale,
|
|
487
503
|
testId = _this$props3.testId,
|
|
488
504
|
weekStartDay = _this$props3.weekStartDay;
|
|
489
|
-
var BORDER_WIDTH = 2;
|
|
490
505
|
var ICON_PADDING = 2;
|
|
491
506
|
|
|
492
|
-
var _this$
|
|
493
|
-
value = _this$
|
|
494
|
-
view = _this$
|
|
495
|
-
isOpen = _this$
|
|
496
|
-
inputValue = _this$
|
|
507
|
+
var _this$getSafeState7 = this.getSafeState(),
|
|
508
|
+
value = _this$getSafeState7.value,
|
|
509
|
+
view = _this$getSafeState7.view,
|
|
510
|
+
isOpen = _this$getSafeState7.isOpen,
|
|
511
|
+
inputValue = _this$getSafeState7.inputValue;
|
|
497
512
|
|
|
498
513
|
var menuIsOpen = isOpen && !isDisabled;
|
|
499
514
|
var showClearIndicator = Boolean((value || inputValue) && !hideIcon);
|
|
@@ -509,7 +524,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
509
524
|
|
|
510
525
|
var _selectProps$styles = selectProps.styles,
|
|
511
526
|
selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles;
|
|
512
|
-
var controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles(
|
|
527
|
+
var controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles() : {};
|
|
513
528
|
var disabledStyle = isDisabled ? {
|
|
514
529
|
pointerEvents: 'none'
|
|
515
530
|
} : {};
|
|
@@ -537,6 +552,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
537
552
|
ref: this.getContainerRef,
|
|
538
553
|
"data-testid": testId && "".concat(testId, "--container")
|
|
539
554
|
}), (0, _core.jsx)("input", {
|
|
555
|
+
id: selectProps.inputId,
|
|
540
556
|
name: name,
|
|
541
557
|
type: "hidden",
|
|
542
558
|
value: value,
|
|
@@ -561,7 +577,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
|
|
|
561
577
|
indicatorsContainer: function indicatorsContainer(base) {
|
|
562
578
|
return _objectSpread(_objectSpread({}, base), {}, {
|
|
563
579
|
paddingLeft: ICON_PADDING,
|
|
564
|
-
paddingRight: (0, _constants.gridSize)() -
|
|
580
|
+
paddingRight: (0, _constants.gridSize)() - ICON_PADDING
|
|
565
581
|
});
|
|
566
582
|
}
|
|
567
583
|
}),
|
|
@@ -43,9 +43,9 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
43
43
|
|
|
44
44
|
var _internal = require("../internal");
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _datePicker = _interopRequireDefault(require("./date-picker"));
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _timePicker = _interopRequireDefault(require("./time-picker"));
|
|
49
49
|
|
|
50
50
|
var _utils = require("./utils");
|
|
51
51
|
|
|
@@ -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 = "12.
|
|
61
|
+
var packageVersion = "12.1.2";
|
|
62
62
|
/* eslint-disable react/no-unused-prop-types */
|
|
63
63
|
|
|
64
64
|
var isInvalidBorderStyles = (0, _core.css)({
|
|
@@ -68,16 +68,20 @@ var isFocusedBorderStyles = (0, _core.css)({
|
|
|
68
68
|
borderColor: "var(--ds-border-focused, ".concat(_colors.B100, ")")
|
|
69
69
|
});
|
|
70
70
|
var isFocusedStyles = (0, _core.css)({
|
|
71
|
-
backgroundColor: "var(--ds-
|
|
71
|
+
backgroundColor: "var(--ds-background-input-pressed, ".concat(_colors.N0, ")")
|
|
72
72
|
});
|
|
73
73
|
var subtleBgStyles = (0, _core.css)({
|
|
74
74
|
backgroundColor: 'transparent',
|
|
75
75
|
borderColor: 'transparent'
|
|
76
76
|
});
|
|
77
|
+
var subtleFocusedBgStyles = (0, _core.css)({
|
|
78
|
+
backgroundColor: "var(--ds-background-input-pressed, transparent)",
|
|
79
|
+
borderColor: 'transparent'
|
|
80
|
+
});
|
|
77
81
|
var hoverStyles = (0, _core.css)({
|
|
78
82
|
'&:hover': {
|
|
79
83
|
backgroundColor: "var(--ds-background-input-hovered, ".concat(_colors.N30, ")"),
|
|
80
|
-
borderColor: "var(--ds-border, ".concat(_colors.N30, ")")
|
|
84
|
+
borderColor: "var(--ds-border-input, ".concat(_colors.N30, ")")
|
|
81
85
|
}
|
|
82
86
|
});
|
|
83
87
|
var isInvalidHoverStyles = (0, _core.css)({
|
|
@@ -93,8 +97,8 @@ var isDisabledStyles = (0, _core.css)({
|
|
|
93
97
|
});
|
|
94
98
|
var baseContainerStyles = (0, _core.css)({
|
|
95
99
|
display: 'flex',
|
|
96
|
-
backgroundColor: "var(--ds-background-
|
|
97
|
-
border: "2px solid ".concat("var(--ds-border, ".concat(_colors.N20, ")")),
|
|
100
|
+
backgroundColor: "var(--ds-background-input, ".concat(_colors.N20, ")"),
|
|
101
|
+
border: "2px solid ".concat("var(--ds-border-input, ".concat(_colors.N20, ")")),
|
|
98
102
|
borderRadius: "".concat((0, _constants.borderRadius)(), "px"),
|
|
99
103
|
transition: 'background-color 200ms ease-in-out, border-color 200ms ease-in-out',
|
|
100
104
|
'&:hover': {
|
|
@@ -326,17 +330,19 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
326
330
|
|
|
327
331
|
var isClearable = Boolean(dateValue || timeValue);
|
|
328
332
|
var notFocusedOrIsDisabled = !(isFocused || isDisabled);
|
|
333
|
+
var labelId = (datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.inputId) || (timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.inputId) || '';
|
|
329
334
|
return (0, _core.jsx)("div", (0, _extends2.default)({
|
|
330
|
-
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && subtleBgStyles, isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
335
|
+
css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && (isFocused ? subtleFocusedBgStyles : subtleBgStyles), isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
|
|
331
336
|
}, innerProps, {
|
|
332
337
|
"data-testid": testId
|
|
333
338
|
}), (0, _core.jsx)("input", {
|
|
339
|
+
id: labelId,
|
|
334
340
|
name: name,
|
|
335
341
|
type: "hidden",
|
|
336
342
|
value: value
|
|
337
343
|
}), (0, _core.jsx)("div", {
|
|
338
344
|
css: datePickerContainerStyles
|
|
339
|
-
}, (0, _core.jsx)(
|
|
345
|
+
}, (0, _core.jsx)(_datePicker.default, (0, _extends2.default)({}, bothProps, {
|
|
340
346
|
autoFocus: autoFocus,
|
|
341
347
|
dateFormat: dateFormat,
|
|
342
348
|
hideIcon: true,
|
|
@@ -348,7 +354,7 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
348
354
|
testId: testId && "".concat(testId, "--datepicker")
|
|
349
355
|
}, datePickerProps))), (0, _core.jsx)("div", {
|
|
350
356
|
css: timePickerContainerStyles
|
|
351
|
-
}, (0, _core.jsx)(
|
|
357
|
+
}, (0, _core.jsx)(_timePicker.default, (0, _extends2.default)({}, bothProps, {
|
|
352
358
|
hideIcon: true,
|
|
353
359
|
onChange: this.onTimeChange,
|
|
354
360
|
selectProps: mergedTimePickerSelectProps,
|
|
@@ -45,9 +45,9 @@ var _constants = require("@atlaskit/theme/constants");
|
|
|
45
45
|
|
|
46
46
|
var _internal = require("../internal");
|
|
47
47
|
|
|
48
|
-
var
|
|
48
|
+
var _fixedLayer = _interopRequireDefault(require("../internal/fixed-layer"));
|
|
49
49
|
|
|
50
|
-
var _parseTime = _interopRequireDefault(require("../internal/
|
|
50
|
+
var _parseTime = _interopRequireDefault(require("../internal/parse-time"));
|
|
51
51
|
|
|
52
52
|
var _utils = require("./utils");
|
|
53
53
|
|
|
@@ -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 = "12.
|
|
70
|
+
var packageVersion = "12.1.2";
|
|
71
71
|
var menuStyles = {
|
|
72
72
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
73
73
|
position: 'static',
|
|
@@ -82,7 +82,7 @@ var menuStyles = {
|
|
|
82
82
|
var FixedLayerMenu = function FixedLayerMenu(_ref) {
|
|
83
83
|
var selectProps = _ref.selectProps,
|
|
84
84
|
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
85
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
85
|
+
return /*#__PURE__*/_react.default.createElement(_fixedLayer.default, {
|
|
86
86
|
inputValue: selectProps.inputValue,
|
|
87
87
|
containerRef: selectProps.fixedLayerRef,
|
|
88
88
|
content: /*#__PURE__*/_react.default.createElement(_select.components.Menu, (0, _extends2.default)({}, rest, {
|
|
@@ -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
|
|
@@ -237,7 +245,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
237
245
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSubtleControlStyles", function (selectStyles) {
|
|
238
246
|
return !selectStyles.control ? {
|
|
239
247
|
border: "2px solid ".concat(_this.getSafeState().isFocused ? "var(--ds-border-focused, ".concat(_colors.B100, ")") : "transparent"),
|
|
240
|
-
backgroundColor: 'transparent',
|
|
248
|
+
backgroundColor: _this.getSafeState().isFocused ? "var(--ds-background-input-pressed, transparent)" : 'transparent',
|
|
241
249
|
padding: '1px'
|
|
242
250
|
} : {};
|
|
243
251
|
});
|
|
@@ -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
|
package/dist/cjs/index.js
CHANGED
|
@@ -8,24 +8,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
Object.defineProperty(exports, "DatePicker", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
|
-
return
|
|
11
|
+
return _datePicker.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "DateTimePicker", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function get() {
|
|
17
|
-
return
|
|
17
|
+
return _dateTimePicker.default;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "TimePicker", {
|
|
21
21
|
enumerable: true,
|
|
22
22
|
get: function get() {
|
|
23
|
-
return
|
|
23
|
+
return _timePicker.default;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _datePicker = _interopRequireDefault(require("./components/date-picker"));
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _timePicker = _interopRequireDefault(require("./components/time-picker"));
|
|
30
30
|
|
|
31
|
-
var
|
|
31
|
+
var _dateTimePicker = _interopRequireDefault(require("./components/date-time-picker"));
|
|
@@ -25,6 +25,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
25
25
|
|
|
26
26
|
var _reactScrolllock = _interopRequireDefault(require("react-scrolllock"));
|
|
27
27
|
|
|
28
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
29
|
+
|
|
28
30
|
var _icon = require("@atlaskit/icon");
|
|
29
31
|
|
|
30
32
|
var _popper = require("@atlaskit/popper");
|
|
@@ -59,7 +61,7 @@ var FixedLayer = /*#__PURE__*/function (_React$Component) {
|
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
62
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update",
|
|
64
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update", _noop.default);
|
|
63
65
|
return _this;
|
|
64
66
|
}
|
|
65
67
|
|
|
@@ -12,6 +12,7 @@ exports.placeholderDatetime = void 0;
|
|
|
12
12
|
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
|
|
15
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
15
16
|
var EmptyClearIndicator = null; // This date was chosen to clearly show date and time formats (day > 12)
|
|
16
17
|
// e.g. 18/02/1993 vs. 2/18/1993 and 1:00 PM vs 13:00
|
|
17
18
|
|
|
@@ -123,14 +123,14 @@ function _default(time) {
|
|
|
123
123
|
var trimmedTime = time.toString().trim();
|
|
124
124
|
|
|
125
125
|
if (!isValid(trimmedTime)) {
|
|
126
|
-
|
|
126
|
+
throw RangeError('invalid time format');
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
var time1 = removeSpacer(trimmedTime);
|
|
130
130
|
var time2 = convertTo24hrTime(time1);
|
|
131
131
|
|
|
132
132
|
if (!time2) {
|
|
133
|
-
|
|
133
|
+
throw RangeError('invalid time format');
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
return assignToDate(time2);
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
|
|
4
|
+
/* eslint-disable @repo/internal/react/use-noop */
|
|
5
|
+
|
|
4
6
|
/** @jsx jsx */
|
|
5
7
|
import { Component } from 'react';
|
|
6
8
|
import { css, jsx } from '@emotion/core'; // eslint-disable-next-line no-restricted-imports
|
|
@@ -15,10 +17,10 @@ import Select, { mergeStyles } from '@atlaskit/select';
|
|
|
15
17
|
import { B100, N20, N50A, N60A } from '@atlaskit/theme/colors';
|
|
16
18
|
import { borderRadius, gridSize, layers } from '@atlaskit/theme/constants';
|
|
17
19
|
import { defaultDateFormat, EmptyClearIndicator, padToTwo, placeholderDatetime } from '../internal';
|
|
18
|
-
import FixedLayer from '../internal/
|
|
20
|
+
import FixedLayer from '../internal/fixed-layer';
|
|
19
21
|
import { convertTokens } from './utils';
|
|
20
22
|
const packageName = "@atlaskit/datetime-picker";
|
|
21
|
-
const packageVersion = "12.
|
|
23
|
+
const packageVersion = "12.1.2";
|
|
22
24
|
/* eslint-disable react/no-unused-prop-types */
|
|
23
25
|
|
|
24
26
|
function getDateObj(date) {
|
|
@@ -36,9 +38,10 @@ function getValidDate(iso) {
|
|
|
36
38
|
|
|
37
39
|
const menuStyles = css({
|
|
38
40
|
zIndex: layers.dialog(),
|
|
39
|
-
backgroundColor: `var(--ds-surface, ${N20})`,
|
|
41
|
+
backgroundColor: `var(--ds-surface-overlay, ${N20})`,
|
|
40
42
|
borderRadius: `${borderRadius()}px`,
|
|
41
|
-
boxShadow: `var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})
|
|
43
|
+
boxShadow: `var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})`,
|
|
44
|
+
overflow: 'hidden'
|
|
42
45
|
});
|
|
43
46
|
|
|
44
47
|
const Menu = ({
|
|
@@ -62,7 +65,8 @@ const Menu = ({
|
|
|
62
65
|
selected: [selectProps.calendarValue],
|
|
63
66
|
locale: selectProps.calendarLocale,
|
|
64
67
|
testId: selectProps.testId && `${selectProps.testId}--calendar`,
|
|
65
|
-
weekStartDay: selectProps.calendarWeekStartDay
|
|
68
|
+
weekStartDay: selectProps.calendarWeekStartDay,
|
|
69
|
+
tabIndex: -1
|
|
66
70
|
}))),
|
|
67
71
|
testId: selectProps.testId
|
|
68
72
|
});
|
|
@@ -160,7 +164,8 @@ class DatePicker extends Component {
|
|
|
160
164
|
});
|
|
161
165
|
} else {
|
|
162
166
|
this.setState({
|
|
163
|
-
isOpen: false
|
|
167
|
+
isOpen: false,
|
|
168
|
+
isFocused: false
|
|
164
169
|
});
|
|
165
170
|
}
|
|
166
171
|
|
|
@@ -181,7 +186,8 @@ class DatePicker extends Component {
|
|
|
181
186
|
} else {
|
|
182
187
|
this.setState({
|
|
183
188
|
isOpen: true,
|
|
184
|
-
view: value
|
|
189
|
+
view: value,
|
|
190
|
+
isFocused: true
|
|
185
191
|
});
|
|
186
192
|
}
|
|
187
193
|
|
|
@@ -258,12 +264,20 @@ class DatePicker extends Component {
|
|
|
258
264
|
break;
|
|
259
265
|
|
|
260
266
|
case 'enter':
|
|
261
|
-
|
|
267
|
+
if (!this.state.isOpen) {
|
|
268
|
+
return;
|
|
269
|
+
} // Prevent form submission when a date is selected
|
|
262
270
|
// using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
|
|
263
271
|
// for more details.
|
|
272
|
+
|
|
273
|
+
|
|
264
274
|
event.preventDefault();
|
|
265
275
|
|
|
266
276
|
if (!this.isDateDisabled(view)) {
|
|
277
|
+
const {
|
|
278
|
+
value
|
|
279
|
+
} = this.getSafeState();
|
|
280
|
+
const valueChanged = view !== value;
|
|
267
281
|
this.setState({
|
|
268
282
|
inputValue: '',
|
|
269
283
|
isOpen: false,
|
|
@@ -271,7 +285,10 @@ class DatePicker extends Component {
|
|
|
271
285
|
value: view,
|
|
272
286
|
view
|
|
273
287
|
});
|
|
274
|
-
|
|
288
|
+
|
|
289
|
+
if (valueChanged) {
|
|
290
|
+
this.props.onChange(view);
|
|
291
|
+
}
|
|
275
292
|
}
|
|
276
293
|
|
|
277
294
|
break;
|
|
@@ -334,9 +351,9 @@ class DatePicker extends Component {
|
|
|
334
351
|
}
|
|
335
352
|
});
|
|
336
353
|
|
|
337
|
-
_defineProperty(this, "getSubtleControlStyles",
|
|
338
|
-
border: `2px solid ${
|
|
339
|
-
backgroundColor: 'transparent',
|
|
354
|
+
_defineProperty(this, "getSubtleControlStyles", () => ({
|
|
355
|
+
border: `2px solid ${this.getSafeState().isFocused ? `var(--ds-border-focused, ${B100})` : `transparent`}`,
|
|
356
|
+
backgroundColor: this.getSafeState().isOpen ? "var(--ds-background-input-pressed, transparent)" : 'transparent',
|
|
340
357
|
padding: '1px'
|
|
341
358
|
}));
|
|
342
359
|
|
|
@@ -395,6 +412,7 @@ class DatePicker extends Component {
|
|
|
395
412
|
} = getDateObj(new Date());
|
|
396
413
|
this.state = {
|
|
397
414
|
isOpen: this.props.defaultIsOpen,
|
|
415
|
+
isFocused: false,
|
|
398
416
|
clearingFromIcon: false,
|
|
399
417
|
inputValue: this.props.selectProps.inputValue,
|
|
400
418
|
selectedValue: this.props.value || this.props.defaultValue,
|
|
@@ -437,7 +455,6 @@ class DatePicker extends Component {
|
|
|
437
455
|
testId,
|
|
438
456
|
weekStartDay
|
|
439
457
|
} = this.props;
|
|
440
|
-
const BORDER_WIDTH = 2;
|
|
441
458
|
const ICON_PADDING = 2;
|
|
442
459
|
const {
|
|
443
460
|
value,
|
|
@@ -460,7 +477,7 @@ class DatePicker extends Component {
|
|
|
460
477
|
const {
|
|
461
478
|
styles: selectStyles = {}
|
|
462
479
|
} = selectProps;
|
|
463
|
-
const controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles(
|
|
480
|
+
const controlStyles = appearance === 'subtle' ? this.getSubtleControlStyles() : {};
|
|
464
481
|
const disabledStyle = isDisabled ? {
|
|
465
482
|
pointerEvents: 'none'
|
|
466
483
|
} : {};
|
|
@@ -488,6 +505,7 @@ class DatePicker extends Component {
|
|
|
488
505
|
ref: this.getContainerRef,
|
|
489
506
|
"data-testid": testId && `${testId}--container`
|
|
490
507
|
}), jsx("input", {
|
|
508
|
+
id: selectProps.inputId,
|
|
491
509
|
name: name,
|
|
492
510
|
type: "hidden",
|
|
493
511
|
value: value,
|
|
@@ -512,7 +530,7 @@ class DatePicker extends Component {
|
|
|
512
530
|
}),
|
|
513
531
|
indicatorsContainer: base => ({ ...base,
|
|
514
532
|
paddingLeft: ICON_PADDING,
|
|
515
|
-
paddingRight: gridSize() -
|
|
533
|
+
paddingRight: gridSize() - ICON_PADDING
|
|
516
534
|
})
|
|
517
535
|
}),
|
|
518
536
|
placeholder: this.getPlaceholder(),
|