@atlaskit/datetime-picker 15.1.4 → 15.2.0
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 +7 -0
- package/dist/cjs/components/date-picker.js +172 -30
- package/dist/cjs/components/date-time-picker.js +2 -1
- package/dist/cjs/components/time-picker.js +3 -2
- package/dist/cjs/internal/menu.js +1 -0
- package/dist/es2019/components/date-picker.js +166 -32
- package/dist/es2019/components/date-time-picker.js +2 -1
- package/dist/es2019/components/time-picker.js +3 -2
- package/dist/es2019/internal/menu.js +1 -0
- package/dist/esm/components/date-picker.js +174 -32
- package/dist/esm/components/date-time-picker.js +2 -1
- package/dist/esm/components/time-picker.js +3 -2
- package/dist/esm/internal/menu.js +1 -0
- package/dist/types/components/date-picker.d.ts +26 -2
- package/dist/types/types.d.ts +42 -0
- package/dist/types-ts4.5/components/date-picker.d.ts +26 -2
- package/dist/types-ts4.5/types.d.ts +42 -0
- package/package.json +5 -3
|
@@ -14,22 +14,29 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
14
14
|
* @jsxRuntime classic
|
|
15
15
|
* @jsx jsx
|
|
16
16
|
*/
|
|
17
|
-
import { Component } from 'react';
|
|
17
|
+
import { Component, createRef } from 'react';
|
|
18
18
|
|
|
19
19
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
20
|
-
import { jsx } from '@emotion/react';
|
|
20
|
+
import { css, jsx } from '@emotion/react';
|
|
21
21
|
import { isValid, parseISO } from 'date-fns';
|
|
22
|
+
// This is a deprecated component but we will be able to use the actual hook
|
|
23
|
+
// version very soon from converting this to functional. And also React 18 is on
|
|
24
|
+
// the horizon
|
|
25
|
+
import { UID } from 'react-uid';
|
|
22
26
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
23
27
|
import CalendarIcon from '@atlaskit/icon/glyph/calendar';
|
|
24
28
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
29
|
+
import { Pressable, xcss } from '@atlaskit/primitives';
|
|
25
30
|
import Select, { mergeStyles } from '@atlaskit/select';
|
|
31
|
+
import { N500, N70 } from '@atlaskit/theme/colors';
|
|
32
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
26
33
|
import { EmptyComponent } from '../internal';
|
|
27
34
|
import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
|
|
28
35
|
import { Menu } from '../internal/menu';
|
|
29
36
|
import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
|
|
30
37
|
import { makeSingleValue } from '../internal/single-value';
|
|
31
38
|
var packageName = "@atlaskit/datetime-picker";
|
|
32
|
-
var packageVersion = "15.
|
|
39
|
+
var packageVersion = "15.2.0";
|
|
33
40
|
var datePickerDefaultProps = {
|
|
34
41
|
defaultIsOpen: false,
|
|
35
42
|
defaultValue: '',
|
|
@@ -48,6 +55,38 @@ var datePickerDefaultProps = {
|
|
|
48
55
|
// Not including a default prop for value as it will
|
|
49
56
|
// Make the component a controlled component
|
|
50
57
|
};
|
|
58
|
+
var pickerContainerStyles = css({
|
|
59
|
+
position: 'relative'
|
|
60
|
+
});
|
|
61
|
+
var iconContainerStyles = css({
|
|
62
|
+
display: 'flex',
|
|
63
|
+
height: '100%',
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
flexBasis: 'inherit',
|
|
67
|
+
color: "var(--ds-text-subtlest, ".concat(N70, ")"),
|
|
68
|
+
insetBlockStart: 0,
|
|
69
|
+
insetInlineEnd: 0,
|
|
70
|
+
transition: "color 150ms",
|
|
71
|
+
'&:hover': {
|
|
72
|
+
color: "var(--ds-text-subtle, ".concat(N500, ")")
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
var iconSpacingWithClearButtonStyles = css({
|
|
76
|
+
marginInlineEnd: "var(--ds-space-400, 2rem)"
|
|
77
|
+
});
|
|
78
|
+
var iconSpacingWithoutClearButtonStyles = css({
|
|
79
|
+
marginInlineEnd: "var(--ds-space-025, 0.125rem)"
|
|
80
|
+
});
|
|
81
|
+
var calendarButtonStyles = xcss({
|
|
82
|
+
borderRadius: 'border.radius',
|
|
83
|
+
':hover': {
|
|
84
|
+
backgroundColor: 'color.background.neutral.subtle.hovered'
|
|
85
|
+
},
|
|
86
|
+
':active': {
|
|
87
|
+
backgroundColor: 'color.background.neutral.subtle.pressed'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
51
90
|
var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
52
91
|
_inherits(DatePickerComponent, _Component);
|
|
53
92
|
var _super = _createSuper(DatePickerComponent);
|
|
@@ -57,6 +96,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
57
96
|
_classCallCheck(this, DatePickerComponent);
|
|
58
97
|
_this = _super.call(this, props);
|
|
59
98
|
_defineProperty(_assertThisInitialized(_this), "containerRef", null);
|
|
99
|
+
_defineProperty(_assertThisInitialized(_this), "calendarRef", /*#__PURE__*/createRef());
|
|
100
|
+
_defineProperty(_assertThisInitialized(_this), "calendarButtonRef", /*#__PURE__*/createRef());
|
|
60
101
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
61
102
|
// correctly to allow controlled/uncontrolled usage.
|
|
62
103
|
_defineProperty(_assertThisInitialized(_this), "getValue", function () {
|
|
@@ -76,23 +117,30 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
76
117
|
});
|
|
77
118
|
});
|
|
78
119
|
_defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (_ref2) {
|
|
79
|
-
var _this$containerRef;
|
|
80
120
|
var iso = _ref2.iso;
|
|
81
121
|
_this.setState({
|
|
82
122
|
selectInputValue: '',
|
|
83
123
|
isOpen: false,
|
|
84
124
|
calendarValue: iso,
|
|
85
|
-
value: iso
|
|
125
|
+
value: iso,
|
|
126
|
+
wasOpenedFromCalendarButton: false
|
|
86
127
|
});
|
|
87
128
|
_this.props.onChange(iso);
|
|
88
129
|
|
|
89
|
-
//
|
|
90
|
-
//
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
//
|
|
94
|
-
|
|
95
|
-
|
|
130
|
+
// Yes, this is not ideal. The alternative is to be able to place a ref
|
|
131
|
+
// on the inner input of Select itself, which would require a lot of
|
|
132
|
+
// extra stuff in the Select component for only this one thing. While
|
|
133
|
+
// this would be more "React-y", it doesn't seem to pose any other
|
|
134
|
+
// benefits. Performance-wise, we are only searching within the
|
|
135
|
+
// container, so it's quick.
|
|
136
|
+
if (_this.state.wasOpenedFromCalendarButton) {
|
|
137
|
+
var _this$calendarButtonR;
|
|
138
|
+
(_this$calendarButtonR = _this.calendarButtonRef.current) === null || _this$calendarButtonR === void 0 || _this$calendarButtonR.focus();
|
|
139
|
+
} else {
|
|
140
|
+
var _this$containerRef;
|
|
141
|
+
var innerCombobox = (_this$containerRef = _this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.querySelector('[role="combobox"]');
|
|
142
|
+
innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
|
|
143
|
+
}
|
|
96
144
|
_this.setState({
|
|
97
145
|
isOpen: false
|
|
98
146
|
});
|
|
@@ -100,7 +148,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
100
148
|
_defineProperty(_assertThisInitialized(_this), "onInputClick", function () {
|
|
101
149
|
if (!_this.props.isDisabled && !_this.getIsOpen()) {
|
|
102
150
|
_this.setState({
|
|
103
|
-
isOpen: true
|
|
151
|
+
isOpen: true,
|
|
152
|
+
wasOpenedFromCalendarButton: false
|
|
104
153
|
});
|
|
105
154
|
}
|
|
106
155
|
});
|
|
@@ -110,7 +159,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
110
159
|
if (!((_this$containerRef2 = _this.containerRef) !== null && _this$containerRef2 !== void 0 && _this$containerRef2.contains(newlyFocusedElement))) {
|
|
111
160
|
_this.setState({
|
|
112
161
|
isOpen: false,
|
|
113
|
-
shouldSetFocusOnCurrentDay: false
|
|
162
|
+
shouldSetFocusOnCurrentDay: false,
|
|
163
|
+
wasOpenedFromCalendarButton: false
|
|
114
164
|
});
|
|
115
165
|
_this.props.onBlur(event);
|
|
116
166
|
}
|
|
@@ -133,7 +183,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
133
183
|
// container. Makes keyboard accessibility of calendar possible
|
|
134
184
|
_this.setState({
|
|
135
185
|
isOpen: false,
|
|
136
|
-
isFocused: false
|
|
186
|
+
isFocused: false,
|
|
187
|
+
wasOpenedFromCalendarButton: false
|
|
137
188
|
});
|
|
138
189
|
}
|
|
139
190
|
});
|
|
@@ -147,9 +198,11 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
147
198
|
});
|
|
148
199
|
} else {
|
|
149
200
|
_this.setState({
|
|
150
|
-
|
|
201
|
+
// Don't open when focused into via keyboard if the calendar button is present
|
|
202
|
+
isOpen: !_this.props.shouldShowCalendarButton,
|
|
151
203
|
calendarValue: value,
|
|
152
|
-
isFocused: true
|
|
204
|
+
isFocused: true,
|
|
205
|
+
wasOpenedFromCalendarButton: false
|
|
153
206
|
});
|
|
154
207
|
}
|
|
155
208
|
_this.props.onFocus(event);
|
|
@@ -172,11 +225,11 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
172
225
|
}
|
|
173
226
|
}
|
|
174
227
|
_this.setState({
|
|
175
|
-
isOpen: true
|
|
228
|
+
isOpen: true,
|
|
229
|
+
wasOpenedFromCalendarButton: false
|
|
176
230
|
});
|
|
177
231
|
});
|
|
178
232
|
_defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (event) {
|
|
179
|
-
var _this$containerRef4;
|
|
180
233
|
var calendarValue = _this.state.calendarValue;
|
|
181
234
|
var value = _this.getValue();
|
|
182
235
|
var keyPressed = event.key.toLowerCase();
|
|
@@ -184,7 +237,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
184
237
|
// If the input is focused and the calendar is not visible, handle space and enter clicks
|
|
185
238
|
if (!_this.state.isOpen && (keyPressed === 'enter' || keyPressed === ' ')) {
|
|
186
239
|
_this.setState({
|
|
187
|
-
isOpen: true
|
|
240
|
+
isOpen: true,
|
|
241
|
+
wasOpenedFromCalendarButton: false
|
|
188
242
|
});
|
|
189
243
|
}
|
|
190
244
|
switch (keyPressed) {
|
|
@@ -195,11 +249,18 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
195
249
|
// this would be more "React-y", it doesn't seem to pose any other
|
|
196
250
|
// benefits. Performance-wise, we are only searching within the
|
|
197
251
|
// container, so it's quick.
|
|
198
|
-
|
|
199
|
-
|
|
252
|
+
if (_this.state.wasOpenedFromCalendarButton) {
|
|
253
|
+
var _this$calendarButtonR2;
|
|
254
|
+
(_this$calendarButtonR2 = _this.calendarButtonRef.current) === null || _this$calendarButtonR2 === void 0 || _this$calendarButtonR2.focus();
|
|
255
|
+
} else {
|
|
256
|
+
var _this$containerRef4;
|
|
257
|
+
var innerCombobox = (_this$containerRef4 = _this.containerRef) === null || _this$containerRef4 === void 0 ? void 0 : _this$containerRef4.querySelector('[role="combobox"]');
|
|
258
|
+
innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
|
|
259
|
+
}
|
|
200
260
|
_this.setState({
|
|
201
261
|
isOpen: false,
|
|
202
|
-
shouldSetFocusOnCurrentDay: false
|
|
262
|
+
shouldSetFocusOnCurrentDay: false,
|
|
263
|
+
wasOpenedFromCalendarButton: false
|
|
203
264
|
});
|
|
204
265
|
break;
|
|
205
266
|
case 'backspace':
|
|
@@ -234,7 +295,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
234
295
|
selectInputValue: '',
|
|
235
296
|
isOpen: false,
|
|
236
297
|
value: safeCalendarValue,
|
|
237
|
-
calendarValue: safeCalendarValue
|
|
298
|
+
calendarValue: safeCalendarValue,
|
|
299
|
+
wasOpenedFromCalendarButton: false
|
|
238
300
|
});
|
|
239
301
|
if (valueChanged) {
|
|
240
302
|
_this.props.onChange(safeCalendarValue);
|
|
@@ -253,6 +315,38 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
253
315
|
break;
|
|
254
316
|
}
|
|
255
317
|
});
|
|
318
|
+
_defineProperty(_assertThisInitialized(_this), "onCalendarButtonKeyDown", function (e) {
|
|
319
|
+
// We want to stop this from triggering other keydown events, particularly
|
|
320
|
+
// for space and enter presses. Otherwise, it opens and then closes
|
|
321
|
+
// immediately.
|
|
322
|
+
if (e.type === 'keydown') {
|
|
323
|
+
e.stopPropagation();
|
|
324
|
+
}
|
|
325
|
+
_this.setState({
|
|
326
|
+
isKeyDown: true,
|
|
327
|
+
wasOpenedFromCalendarButton: true
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
// This event handler is triggered from both keydown and click. It's weird.
|
|
331
|
+
_defineProperty(_assertThisInitialized(_this), "onCalendarButtonClick", function (e) {
|
|
332
|
+
_this.setState({
|
|
333
|
+
isOpen: !_this.state.isOpen,
|
|
334
|
+
wasOpenedFromCalendarButton: true
|
|
335
|
+
}, function () {
|
|
336
|
+
var _this$calendarRef;
|
|
337
|
+
// We don't want the focus to move if this is a click event
|
|
338
|
+
if (!_this.state.isKeyDown) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
_this.setState({
|
|
342
|
+
isKeyDown: false
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
// Focus on the first button within the calendar
|
|
346
|
+
(_this$calendarRef = _this.calendarRef) === null || _this$calendarRef === void 0 || (_this$calendarRef = _this$calendarRef.current) === null || _this$calendarRef === void 0 || (_this$calendarRef = _this$calendarRef.querySelector('button')) === null || _this$calendarRef === void 0 || _this$calendarRef.focus();
|
|
347
|
+
});
|
|
348
|
+
e.stopPropagation();
|
|
349
|
+
});
|
|
256
350
|
_defineProperty(_assertThisInitialized(_this), "onClear", function () {
|
|
257
351
|
var changedState = {
|
|
258
352
|
value: '',
|
|
@@ -294,6 +388,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
294
388
|
}
|
|
295
389
|
});
|
|
296
390
|
_this.state = {
|
|
391
|
+
isKeyDown: false,
|
|
297
392
|
isOpen: _this.props.defaultIsOpen,
|
|
298
393
|
isFocused: false,
|
|
299
394
|
clearingFromIcon: false,
|
|
@@ -302,29 +397,36 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
302
397
|
calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
|
|
303
398
|
l10n: createLocalizationProvider(_this.props.locale),
|
|
304
399
|
locale: _this.props.locale,
|
|
305
|
-
shouldSetFocusOnCurrentDay: false
|
|
400
|
+
shouldSetFocusOnCurrentDay: false,
|
|
401
|
+
wasOpenedFromCalendarButton: false
|
|
306
402
|
};
|
|
307
403
|
return _this;
|
|
308
404
|
}
|
|
309
405
|
_createClass(DatePickerComponent, [{
|
|
310
406
|
key: "render",
|
|
311
407
|
value: function render() {
|
|
408
|
+
var _this2 = this;
|
|
312
409
|
var _this$props = this.props,
|
|
313
410
|
_this$props$appearanc = _this$props.appearance,
|
|
314
411
|
appearance = _this$props$appearanc === void 0 ? 'default' : _this$props$appearanc,
|
|
315
412
|
ariaDescribedBy = _this$props['aria-describedby'],
|
|
316
413
|
_this$props$autoFocus = _this$props.autoFocus,
|
|
317
414
|
autoFocus = _this$props$autoFocus === void 0 ? false : _this$props$autoFocus,
|
|
318
|
-
disabled = _this$props.disabled,
|
|
319
|
-
disabledDateFilter = _this$props.disabledDateFilter,
|
|
320
415
|
_this$props$hideIcon = _this$props.hideIcon,
|
|
321
416
|
hideIcon = _this$props$hideIcon === void 0 ? false : _this$props$hideIcon,
|
|
417
|
+
_this$props$openCalen = _this$props.openCalendarLabel,
|
|
418
|
+
openCalendarLabel = _this$props$openCalen === void 0 ? 'Open calendar' : _this$props$openCalen,
|
|
419
|
+
disabled = _this$props.disabled,
|
|
420
|
+
disabledDateFilter = _this$props.disabledDateFilter,
|
|
322
421
|
_this$props$icon = _this$props.icon,
|
|
323
422
|
icon = _this$props$icon === void 0 ? CalendarIcon : _this$props$icon,
|
|
324
423
|
_this$props$id = _this$props.id,
|
|
325
424
|
id = _this$props$id === void 0 ? '' : _this$props$id,
|
|
326
425
|
_this$props$innerProp = _this$props.innerProps,
|
|
327
426
|
innerProps = _this$props$innerProp === void 0 ? {} : _this$props$innerProp,
|
|
427
|
+
_this$props$inputLabe = _this$props.inputLabel,
|
|
428
|
+
inputLabel = _this$props$inputLabe === void 0 ? 'Date picker' : _this$props$inputLabe,
|
|
429
|
+
inputLabelId = _this$props.inputLabelId,
|
|
328
430
|
_this$props$isDisable = _this$props.isDisabled,
|
|
329
431
|
isDisabled = _this$props$isDisable === void 0 ? false : _this$props$isDisable,
|
|
330
432
|
_this$props$isInvalid = _this$props.isInvalid,
|
|
@@ -340,6 +442,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
340
442
|
previousMonthLabel = _this$props.previousMonthLabel,
|
|
341
443
|
_this$props$selectPro3 = _this$props.selectProps,
|
|
342
444
|
selectProps = _this$props$selectPro3 === void 0 ? {} : _this$props$selectPro3,
|
|
445
|
+
shouldShowCalendarButton = _this$props.shouldShowCalendarButton,
|
|
343
446
|
_this$props$spacing = _this$props.spacing,
|
|
344
447
|
spacing = _this$props$spacing === void 0 ? 'default' : _this$props$spacing,
|
|
345
448
|
testId = _this$props.testId,
|
|
@@ -357,7 +460,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
357
460
|
lang: this.props.locale
|
|
358
461
|
});
|
|
359
462
|
var selectComponents = _objectSpread({
|
|
360
|
-
DropdownIndicator: dropDownIcon,
|
|
463
|
+
DropdownIndicator: shouldShowCalendarButton ? EmptyComponent : dropDownIcon,
|
|
361
464
|
Menu: Menu,
|
|
362
465
|
SingleValue: SingleValue
|
|
363
466
|
}, !showClearIndicator && {
|
|
@@ -375,6 +478,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
375
478
|
calendarDisabledDateFilter: disabledDateFilter,
|
|
376
479
|
calendarMaxDate: maxDate,
|
|
377
480
|
calendarMinDate: minDate,
|
|
481
|
+
calendarRef: this.calendarRef,
|
|
378
482
|
calendarValue: value && getShortISOString(parseISO(value)),
|
|
379
483
|
calendarView: calendarValue,
|
|
380
484
|
onCalendarChange: this.onCalendarChange,
|
|
@@ -383,7 +487,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
383
487
|
calendarWeekStartDay: weekStartDay,
|
|
384
488
|
shouldSetFocusOnCurrentDay: this.state.shouldSetFocusOnCurrentDay
|
|
385
489
|
};
|
|
386
|
-
|
|
490
|
+
|
|
491
|
+
// @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
|
|
387
492
|
var mergedStyles = mergeStyles(selectStyles, {
|
|
388
493
|
control: function control(base) {
|
|
389
494
|
return _objectSpread(_objectSpread({}, base), disabledStyle);
|
|
@@ -404,10 +509,14 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
404
509
|
}),
|
|
405
510
|
value: value
|
|
406
511
|
} : null;
|
|
512
|
+
|
|
513
|
+
// `label` takes precedence of the `inputLabel`
|
|
514
|
+
var fullopenCalendarLabel = label || inputLabel ? "".concat(label || inputLabel, " , ").concat(openCalendarLabel) : openCalendarLabel;
|
|
407
515
|
return (
|
|
408
516
|
// These event handlers must be on this element because the events come
|
|
409
517
|
// from different child elements.
|
|
410
518
|
jsx("div", _extends({}, innerProps, {
|
|
519
|
+
css: pickerContainerStyles,
|
|
411
520
|
role: "presentation",
|
|
412
521
|
onBlur: this.onContainerBlur,
|
|
413
522
|
onFocus: this.onContainerFocus,
|
|
@@ -426,7 +535,14 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
426
535
|
"aria-describedby": ariaDescribedBy,
|
|
427
536
|
"aria-label": label || undefined,
|
|
428
537
|
autoFocus: autoFocus,
|
|
429
|
-
closeMenuOnSelect: true
|
|
538
|
+
closeMenuOnSelect: true
|
|
539
|
+
// FOr some reason, this and the below `styles` type error _only_ show
|
|
540
|
+
// up when you alter some of the properties in the `selectComponents`
|
|
541
|
+
// object. These errors are still present, and I suspect have always
|
|
542
|
+
// been present, without changing the unrelated code. Ignoring as the
|
|
543
|
+
// component still works as expected despite this error. And also
|
|
544
|
+
// because the select refresh team may solve it later.
|
|
545
|
+
,
|
|
430
546
|
components: selectComponents,
|
|
431
547
|
enableAnimation: false,
|
|
432
548
|
inputId: id,
|
|
@@ -451,7 +567,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
451
567
|
spacing: spacing,
|
|
452
568
|
testId: testId
|
|
453
569
|
// These aren't part of `Select`'s API, but we're using them here.
|
|
454
|
-
|
|
570
|
+
// @ts-ignore -- Property 'calendarContainerRef' does not exist on type 'IntrinsicAttributes & LibraryManagedAttributes<(<Option extends unknown = OptionType, IsMulti extends boolean = false>(props: AtlaskitSelectProps<Option, IsMulti> & { ...; }) => Element), AtlaskitSelectProps<...> & { ...; }>'.
|
|
455
571
|
,
|
|
456
572
|
calendarContainerRef: calendarProps.calendarContainerRef,
|
|
457
573
|
calendarDisabled: calendarProps.calendarDisabled,
|
|
@@ -459,6 +575,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
459
575
|
calendarLocale: calendarProps.calendarLocale,
|
|
460
576
|
calendarMaxDate: calendarProps.calendarMaxDate,
|
|
461
577
|
calendarMinDate: calendarProps.calendarMinDate,
|
|
578
|
+
calendarRef: calendarProps.calendarRef,
|
|
462
579
|
calendarValue: calendarProps.calendarValue,
|
|
463
580
|
calendarView: calendarProps.calendarView,
|
|
464
581
|
calendarWeekStartDay: calendarProps.calendarWeekStartDay,
|
|
@@ -467,7 +584,32 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
|
|
|
467
584
|
onCalendarSelect: calendarProps.onCalendarSelect,
|
|
468
585
|
previousMonthLabel: previousMonthLabel,
|
|
469
586
|
shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay
|
|
470
|
-
}))
|
|
587
|
+
})), shouldShowCalendarButton && !isDisabled ? jsx(UID, {
|
|
588
|
+
name: function name(id) {
|
|
589
|
+
return "open-calendar-label--".concat(id);
|
|
590
|
+
}
|
|
591
|
+
}, function (openCalendarLabelId) {
|
|
592
|
+
return jsx("div", {
|
|
593
|
+
css: [iconContainerStyles, value && !hideIcon ? iconSpacingWithClearButtonStyles : iconSpacingWithoutClearButtonStyles]
|
|
594
|
+
}, inputLabelId && jsx(VisuallyHidden, {
|
|
595
|
+
id: openCalendarLabelId
|
|
596
|
+
}, ", ", openCalendarLabel), jsx(Pressable, _extends({}, inputLabelId ? {
|
|
597
|
+
'aria-labelledby': "".concat(inputLabelId, " ").concat(openCalendarLabelId)
|
|
598
|
+
} : {
|
|
599
|
+
'aria-label': fullopenCalendarLabel
|
|
600
|
+
}, {
|
|
601
|
+
onClick: _this2.onCalendarButtonClick,
|
|
602
|
+
onKeyDown: _this2.onCalendarButtonKeyDown,
|
|
603
|
+
ref: _this2.calendarButtonRef,
|
|
604
|
+
testId: testId && "".concat(testId, "--open-calendar-button"),
|
|
605
|
+
type: "button",
|
|
606
|
+
backgroundColor: "color.background.neutral.subtle",
|
|
607
|
+
padding: "space.050",
|
|
608
|
+
xcss: calendarButtonStyles
|
|
609
|
+
}), jsx(CalendarIcon, {
|
|
610
|
+
label: ""
|
|
611
|
+
})));
|
|
612
|
+
}) : null)
|
|
471
613
|
);
|
|
472
614
|
}
|
|
473
615
|
}], [{
|
|
@@ -28,7 +28,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
28
28
|
import DatePicker from './date-picker';
|
|
29
29
|
import TimePicker from './time-picker';
|
|
30
30
|
var packageName = "@atlaskit/datetime-picker";
|
|
31
|
-
var packageVersion = "15.
|
|
31
|
+
var packageVersion = "15.2.0";
|
|
32
32
|
// Make DatePicker 50% the width of DateTimePicker
|
|
33
33
|
// If rendering an icon container, shrink the TimePicker
|
|
34
34
|
var datePickerContainerStyles = css({
|
|
@@ -347,6 +347,7 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
347
347
|
placeholder: datePickerProps.placeholder,
|
|
348
348
|
previousMonthLabel: datePickerProps.previousMonthLabel,
|
|
349
349
|
selectProps: mergedDatePickerSelectProps,
|
|
350
|
+
shouldShowCalendarButton: datePickerProps.shouldShowCalendarButton,
|
|
350
351
|
spacing: datePickerProps.spacing || spacing,
|
|
351
352
|
testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
|
|
352
353
|
value: dateValue,
|
|
@@ -17,7 +17,7 @@ import parseTime from '../internal/parse-time';
|
|
|
17
17
|
import { convertTokens } from '../internal/parse-tokens';
|
|
18
18
|
import { makeSingleValue } from '../internal/single-value';
|
|
19
19
|
var packageName = "@atlaskit/datetime-picker";
|
|
20
|
-
var packageVersion = "15.
|
|
20
|
+
var packageVersion = "15.2.0";
|
|
21
21
|
var menuStyles = {
|
|
22
22
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
23
23
|
position: 'static',
|
|
@@ -271,7 +271,8 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
271
271
|
ClearIndicator: EmptyComponent
|
|
272
272
|
});
|
|
273
273
|
var renderIconContainer = Boolean(!hideIcon && value);
|
|
274
|
-
|
|
274
|
+
|
|
275
|
+
// @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
|
|
275
276
|
var mergedStyles = mergeStyles(selectStyles, {
|
|
276
277
|
control: function control(base) {
|
|
277
278
|
return _objectSpread({}, base);
|
|
@@ -65,6 +65,7 @@ export var Menu = function Menu(_ref) {
|
|
|
65
65
|
onChange: selectProps.onCalendarChange,
|
|
66
66
|
onSelect: selectProps.onCalendarSelect,
|
|
67
67
|
previousMonthLabel: selectProps.previousMonthLabel,
|
|
68
|
+
ref: selectProps.calendarRef,
|
|
68
69
|
selected: [selectProps.calendarValue],
|
|
69
70
|
shouldSetFocusOnCurrentDay: selectProps.shouldSetFocusOnCurrentDay,
|
|
70
71
|
locale: selectProps.calendarLocale,
|
|
@@ -9,6 +9,7 @@ import { type ActionMeta, type InputActionMeta } from '@atlaskit/select';
|
|
|
9
9
|
import { type DatePickerBaseProps } from '../types';
|
|
10
10
|
type DatePickerProps = typeof datePickerDefaultProps & DatePickerBaseProps;
|
|
11
11
|
interface State {
|
|
12
|
+
isKeyDown: boolean;
|
|
12
13
|
isOpen: boolean;
|
|
13
14
|
/**
|
|
14
15
|
* When being cleared from the icon the DatePicker is blurred.
|
|
@@ -23,6 +24,7 @@ interface State {
|
|
|
23
24
|
l10n: LocalizationProvider;
|
|
24
25
|
locale: string;
|
|
25
26
|
shouldSetFocusOnCurrentDay: boolean;
|
|
27
|
+
wasOpenedFromCalendarButton: boolean;
|
|
26
28
|
}
|
|
27
29
|
declare const datePickerDefaultProps: {
|
|
28
30
|
defaultIsOpen: boolean;
|
|
@@ -46,6 +48,8 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
|
|
|
46
48
|
onFocus: (_event: import("react").FocusEvent<HTMLInputElement>) => void;
|
|
47
49
|
};
|
|
48
50
|
containerRef: HTMLElement | null;
|
|
51
|
+
calendarRef: React.RefObject<HTMLDivElement | null>;
|
|
52
|
+
calendarButtonRef: React.RefObject<HTMLButtonElement>;
|
|
49
53
|
constructor(props: any);
|
|
50
54
|
static getDerivedStateFromProps(nextProps: Readonly<DatePickerProps>, prevState: State): {
|
|
51
55
|
l10n: LocalizationProvider;
|
|
@@ -66,6 +70,8 @@ declare class DatePickerComponent extends Component<DatePickerProps, State> {
|
|
|
66
70
|
onSelectFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
67
71
|
onTextInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
68
72
|
onInputKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
|
|
73
|
+
onCalendarButtonKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
74
|
+
onCalendarButtonClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
69
75
|
onClear: () => void;
|
|
70
76
|
onSelectChange: (_value: unknown, action: ActionMeta) => void;
|
|
71
77
|
handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
|
|
@@ -82,7 +88,7 @@ export { DatePickerComponent as DatePickerWithoutAnalytics };
|
|
|
82
88
|
* - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
|
|
83
89
|
* - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
|
|
84
90
|
*/
|
|
85
|
-
declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<
|
|
91
|
+
declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Omit<{
|
|
86
92
|
defaultIsOpen: boolean;
|
|
87
93
|
defaultValue: string;
|
|
88
94
|
disabled: string[];
|
|
@@ -91,5 +97,23 @@ declare const DatePicker: import("react").ForwardRefExoticComponent<Pick<Pick<Om
|
|
|
91
97
|
onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
|
|
92
98
|
onChange: (_value: string) => void;
|
|
93
99
|
onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
|
|
94
|
-
}
|
|
100
|
+
} & DatePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "id" | "aria-describedby" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & Partial<Pick<Omit<{
|
|
101
|
+
defaultIsOpen: boolean;
|
|
102
|
+
defaultValue: string;
|
|
103
|
+
disabled: string[];
|
|
104
|
+
disabledDateFilter: (_: string) => boolean;
|
|
105
|
+
locale: string;
|
|
106
|
+
onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
|
|
107
|
+
onChange: (_value: string) => void;
|
|
108
|
+
onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
|
|
109
|
+
} & DatePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "disabled" | "defaultValue" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "defaultIsOpen">> & Partial<Pick<{
|
|
110
|
+
defaultIsOpen: boolean;
|
|
111
|
+
defaultValue: string;
|
|
112
|
+
disabled: string[];
|
|
113
|
+
disabledDateFilter: (_: string) => boolean;
|
|
114
|
+
locale: string;
|
|
115
|
+
onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
|
|
116
|
+
onChange: (_value: string) => void;
|
|
117
|
+
onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
|
|
118
|
+
}, never>> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "disabled" | "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "icon" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "locale" | "analyticsContext" | "weekStartDay" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & import("react").RefAttributes<any>>;
|
|
95
119
|
export default DatePicker;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -142,6 +142,37 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
|
|
|
142
142
|
* Called when the field is focused.
|
|
143
143
|
*/
|
|
144
144
|
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
|
145
|
+
/**
|
|
146
|
+
* The name of the input, used when `shouldShowCalendarButton` is true. See `shouldShowCalendarButton` description for more details.
|
|
147
|
+
*
|
|
148
|
+
* @default 'Date picker'
|
|
149
|
+
*/
|
|
150
|
+
inputLabel?: string;
|
|
151
|
+
/**
|
|
152
|
+
* The ID of the label for the input, used when `shouldShowCalendarButton` is
|
|
153
|
+
* true. See `shouldShowCalendarButton` description for more details.
|
|
154
|
+
*/
|
|
155
|
+
inputLabelId?: string;
|
|
156
|
+
/**
|
|
157
|
+
* The label associated with the button to open the calendar, rendered via the
|
|
158
|
+
* `shouldShowCalendarButton` prop. If a `label` prop is provided, this
|
|
159
|
+
* calendar button label will be prefixed by the value of `label`. If no
|
|
160
|
+
* `label` prop is provided, this prefix should be manually added. For
|
|
161
|
+
* example,
|
|
162
|
+
*
|
|
163
|
+
* ```tsx
|
|
164
|
+
* <label id="label" htmlFor="datepicker">Desired Appointment Date</label>
|
|
165
|
+
* <DatePicker
|
|
166
|
+
* id="datepicker"
|
|
167
|
+
* shouldShowCalendarButton
|
|
168
|
+
* inputLabel="Desired Appointment Date"
|
|
169
|
+
* openCalendarLabel="open calendar"
|
|
170
|
+
* />
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* @default 'open calendar'
|
|
174
|
+
*/
|
|
175
|
+
openCalendarLabel?: string;
|
|
145
176
|
/**
|
|
146
177
|
* A function for parsing input characters and transforming them into a Date object.
|
|
147
178
|
* By default parses the date string based off the locale.
|
|
@@ -155,6 +186,17 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
|
|
|
155
186
|
* The aria-label attribute associated with the previous-month arrow.
|
|
156
187
|
*/
|
|
157
188
|
previousMonthLabel?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Provides a functional calendar button that opens the calendar picker that
|
|
191
|
+
* lives on the right side of the date picker.
|
|
192
|
+
*
|
|
193
|
+
* The accessible name for this button is caculated using either the `label`,
|
|
194
|
+
* `inputLabel`, or `inputLabelId` props, along with the `openCalendarLabel`
|
|
195
|
+
* prop.
|
|
196
|
+
*
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
shouldShowCalendarButton?: boolean;
|
|
158
200
|
/**
|
|
159
201
|
* The spacing for the select control.
|
|
160
202
|
*
|