@atlaskit/datetime-picker 15.1.4 → 15.3.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 +21 -0
- package/dist/cjs/components/date-picker.js +178 -30
- package/dist/cjs/components/date-time-picker.js +6 -1
- package/dist/cjs/components/time-picker.js +6 -2
- package/dist/cjs/internal/menu.js +1 -0
- package/dist/es2019/components/date-picker.js +171 -32
- package/dist/es2019/components/date-time-picker.js +5 -1
- package/dist/es2019/components/time-picker.js +5 -2
- package/dist/es2019/internal/menu.js +1 -0
- package/dist/esm/components/date-picker.js +180 -32
- package/dist/esm/components/date-time-picker.js +6 -1
- package/dist/esm/components/time-picker.js +6 -2
- package/dist/esm/internal/menu.js +1 -0
- package/dist/types/components/date-picker.d.ts +26 -2
- package/dist/types/components/date-time-picker.d.ts +1 -1
- package/dist/types/components/time-picker.d.ts +1 -1
- package/dist/types/types.d.ts +54 -0
- package/dist/types-ts4.5/components/date-picker.d.ts +26 -2
- package/dist/types-ts4.5/components/date-time-picker.d.ts +1 -1
- package/dist/types-ts4.5/components/time-picker.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +54 -0
- package/package.json +6 -4
|
@@ -4,22 +4,29 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
4
4
|
* @jsxRuntime classic
|
|
5
5
|
* @jsx jsx
|
|
6
6
|
*/
|
|
7
|
-
import { Component } from 'react';
|
|
7
|
+
import { Component, createRef } from 'react';
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
10
|
-
import { jsx } from '@emotion/react';
|
|
10
|
+
import { css, jsx } from '@emotion/react';
|
|
11
11
|
import { isValid, parseISO } from 'date-fns';
|
|
12
|
+
// This is a deprecated component but we will be able to use the actual hook
|
|
13
|
+
// version very soon from converting this to functional. And also React 18 is on
|
|
14
|
+
// the horizon
|
|
15
|
+
import { UID } from 'react-uid';
|
|
12
16
|
import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
13
17
|
import CalendarIcon from '@atlaskit/icon/glyph/calendar';
|
|
14
18
|
import { createLocalizationProvider } from '@atlaskit/locale';
|
|
19
|
+
import { Pressable, xcss } from '@atlaskit/primitives';
|
|
15
20
|
import Select, { mergeStyles } from '@atlaskit/select';
|
|
21
|
+
import { N500, N70 } from '@atlaskit/theme/colors';
|
|
22
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
16
23
|
import { EmptyComponent } from '../internal';
|
|
17
24
|
import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
|
|
18
25
|
import { Menu } from '../internal/menu';
|
|
19
26
|
import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
|
|
20
27
|
import { makeSingleValue } from '../internal/single-value';
|
|
21
28
|
const packageName = "@atlaskit/datetime-picker";
|
|
22
|
-
const packageVersion = "15.
|
|
29
|
+
const packageVersion = "15.3.0";
|
|
23
30
|
const datePickerDefaultProps = {
|
|
24
31
|
defaultIsOpen: false,
|
|
25
32
|
defaultValue: '',
|
|
@@ -36,11 +43,47 @@ const datePickerDefaultProps = {
|
|
|
36
43
|
// Not including a default prop for value as it will
|
|
37
44
|
// Make the component a controlled component
|
|
38
45
|
};
|
|
46
|
+
const pickerContainerStyles = css({
|
|
47
|
+
position: 'relative'
|
|
48
|
+
});
|
|
49
|
+
const iconContainerStyles = css({
|
|
50
|
+
display: 'flex',
|
|
51
|
+
height: '100%',
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
flexBasis: 'inherit',
|
|
55
|
+
color: `var(--ds-text-subtlest, ${N70})`,
|
|
56
|
+
insetBlockStart: 0,
|
|
57
|
+
insetInlineEnd: 0,
|
|
58
|
+
transition: `color 150ms`,
|
|
59
|
+
'&:hover': {
|
|
60
|
+
color: `var(--ds-text-subtle, ${N500})`
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const iconSpacingWithClearButtonStyles = css({
|
|
64
|
+
marginInlineEnd: "var(--ds-space-400, 2rem)"
|
|
65
|
+
});
|
|
66
|
+
const iconSpacingWithoutClearButtonStyles = css({
|
|
67
|
+
marginInlineEnd: "var(--ds-space-025, 0.125rem)"
|
|
68
|
+
});
|
|
69
|
+
const calendarButtonStyles = xcss({
|
|
70
|
+
borderRadius: 'border.radius',
|
|
71
|
+
':hover': {
|
|
72
|
+
backgroundColor: 'color.background.neutral.subtle.hovered'
|
|
73
|
+
},
|
|
74
|
+
':active': {
|
|
75
|
+
backgroundColor: 'color.background.neutral.subtle.pressed'
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
39
80
|
class DatePickerComponent extends Component {
|
|
40
81
|
constructor(props) {
|
|
41
82
|
var _this$props$selectPro2;
|
|
42
83
|
super(props);
|
|
43
84
|
_defineProperty(this, "containerRef", null);
|
|
85
|
+
_defineProperty(this, "calendarRef", /*#__PURE__*/createRef());
|
|
86
|
+
_defineProperty(this, "calendarButtonRef", /*#__PURE__*/createRef());
|
|
44
87
|
// All state needs to be accessed via this function so that the state is mapped from props
|
|
45
88
|
// correctly to allow controlled/uncontrolled usage.
|
|
46
89
|
_defineProperty(this, "getValue", () => {
|
|
@@ -63,22 +106,29 @@ class DatePickerComponent extends Component {
|
|
|
63
106
|
_defineProperty(this, "onCalendarSelect", ({
|
|
64
107
|
iso
|
|
65
108
|
}) => {
|
|
66
|
-
var _this$containerRef;
|
|
67
109
|
this.setState({
|
|
68
110
|
selectInputValue: '',
|
|
69
111
|
isOpen: false,
|
|
70
112
|
calendarValue: iso,
|
|
71
|
-
value: iso
|
|
113
|
+
value: iso,
|
|
114
|
+
wasOpenedFromCalendarButton: false
|
|
72
115
|
});
|
|
73
116
|
this.props.onChange(iso);
|
|
74
117
|
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
118
|
+
// Yes, this is not ideal. The alternative is to be able to place a ref
|
|
119
|
+
// on the inner input of Select itself, which would require a lot of
|
|
120
|
+
// extra stuff in the Select component for only this one thing. While
|
|
121
|
+
// this would be more "React-y", it doesn't seem to pose any other
|
|
122
|
+
// benefits. Performance-wise, we are only searching within the
|
|
123
|
+
// container, so it's quick.
|
|
124
|
+
if (this.state.wasOpenedFromCalendarButton) {
|
|
125
|
+
var _this$calendarButtonR;
|
|
126
|
+
(_this$calendarButtonR = this.calendarButtonRef.current) === null || _this$calendarButtonR === void 0 ? void 0 : _this$calendarButtonR.focus();
|
|
127
|
+
} else {
|
|
128
|
+
var _this$containerRef;
|
|
129
|
+
const innerCombobox = (_this$containerRef = this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.querySelector('[role="combobox"]');
|
|
130
|
+
innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
|
|
131
|
+
}
|
|
82
132
|
this.setState({
|
|
83
133
|
isOpen: false
|
|
84
134
|
});
|
|
@@ -86,7 +136,8 @@ class DatePickerComponent extends Component {
|
|
|
86
136
|
_defineProperty(this, "onInputClick", () => {
|
|
87
137
|
if (!this.props.isDisabled && !this.getIsOpen()) {
|
|
88
138
|
this.setState({
|
|
89
|
-
isOpen: true
|
|
139
|
+
isOpen: true,
|
|
140
|
+
wasOpenedFromCalendarButton: false
|
|
90
141
|
});
|
|
91
142
|
}
|
|
92
143
|
});
|
|
@@ -96,7 +147,8 @@ class DatePickerComponent extends Component {
|
|
|
96
147
|
if (!((_this$containerRef2 = this.containerRef) !== null && _this$containerRef2 !== void 0 && _this$containerRef2.contains(newlyFocusedElement))) {
|
|
97
148
|
this.setState({
|
|
98
149
|
isOpen: false,
|
|
99
|
-
shouldSetFocusOnCurrentDay: false
|
|
150
|
+
shouldSetFocusOnCurrentDay: false,
|
|
151
|
+
wasOpenedFromCalendarButton: false
|
|
100
152
|
});
|
|
101
153
|
this.props.onBlur(event);
|
|
102
154
|
}
|
|
@@ -119,7 +171,8 @@ class DatePickerComponent extends Component {
|
|
|
119
171
|
// container. Makes keyboard accessibility of calendar possible
|
|
120
172
|
this.setState({
|
|
121
173
|
isOpen: false,
|
|
122
|
-
isFocused: false
|
|
174
|
+
isFocused: false,
|
|
175
|
+
wasOpenedFromCalendarButton: false
|
|
123
176
|
});
|
|
124
177
|
}
|
|
125
178
|
});
|
|
@@ -135,9 +188,11 @@ class DatePickerComponent extends Component {
|
|
|
135
188
|
});
|
|
136
189
|
} else {
|
|
137
190
|
this.setState({
|
|
138
|
-
|
|
191
|
+
// Don't open when focused into via keyboard if the calendar button is present
|
|
192
|
+
isOpen: !this.props.shouldShowCalendarButton,
|
|
139
193
|
calendarValue: value,
|
|
140
|
-
isFocused: true
|
|
194
|
+
isFocused: true,
|
|
195
|
+
wasOpenedFromCalendarButton: false
|
|
141
196
|
});
|
|
142
197
|
}
|
|
143
198
|
this.props.onFocus(event);
|
|
@@ -160,11 +215,11 @@ class DatePickerComponent extends Component {
|
|
|
160
215
|
}
|
|
161
216
|
}
|
|
162
217
|
this.setState({
|
|
163
|
-
isOpen: true
|
|
218
|
+
isOpen: true,
|
|
219
|
+
wasOpenedFromCalendarButton: false
|
|
164
220
|
});
|
|
165
221
|
});
|
|
166
222
|
_defineProperty(this, "onInputKeyDown", event => {
|
|
167
|
-
var _this$containerRef4;
|
|
168
223
|
const {
|
|
169
224
|
calendarValue
|
|
170
225
|
} = this.state;
|
|
@@ -174,7 +229,8 @@ class DatePickerComponent extends Component {
|
|
|
174
229
|
// If the input is focused and the calendar is not visible, handle space and enter clicks
|
|
175
230
|
if (!this.state.isOpen && (keyPressed === 'enter' || keyPressed === ' ')) {
|
|
176
231
|
this.setState({
|
|
177
|
-
isOpen: true
|
|
232
|
+
isOpen: true,
|
|
233
|
+
wasOpenedFromCalendarButton: false
|
|
178
234
|
});
|
|
179
235
|
}
|
|
180
236
|
switch (keyPressed) {
|
|
@@ -185,11 +241,18 @@ class DatePickerComponent extends Component {
|
|
|
185
241
|
// this would be more "React-y", it doesn't seem to pose any other
|
|
186
242
|
// benefits. Performance-wise, we are only searching within the
|
|
187
243
|
// container, so it's quick.
|
|
188
|
-
|
|
189
|
-
|
|
244
|
+
if (this.state.wasOpenedFromCalendarButton) {
|
|
245
|
+
var _this$calendarButtonR2;
|
|
246
|
+
(_this$calendarButtonR2 = this.calendarButtonRef.current) === null || _this$calendarButtonR2 === void 0 ? void 0 : _this$calendarButtonR2.focus();
|
|
247
|
+
} else {
|
|
248
|
+
var _this$containerRef4;
|
|
249
|
+
const innerCombobox = (_this$containerRef4 = this.containerRef) === null || _this$containerRef4 === void 0 ? void 0 : _this$containerRef4.querySelector('[role="combobox"]');
|
|
250
|
+
innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
|
|
251
|
+
}
|
|
190
252
|
this.setState({
|
|
191
253
|
isOpen: false,
|
|
192
|
-
shouldSetFocusOnCurrentDay: false
|
|
254
|
+
shouldSetFocusOnCurrentDay: false,
|
|
255
|
+
wasOpenedFromCalendarButton: false
|
|
193
256
|
});
|
|
194
257
|
break;
|
|
195
258
|
case 'backspace':
|
|
@@ -224,7 +287,8 @@ class DatePickerComponent extends Component {
|
|
|
224
287
|
selectInputValue: '',
|
|
225
288
|
isOpen: false,
|
|
226
289
|
value: safeCalendarValue,
|
|
227
|
-
calendarValue: safeCalendarValue
|
|
290
|
+
calendarValue: safeCalendarValue,
|
|
291
|
+
wasOpenedFromCalendarButton: false
|
|
228
292
|
});
|
|
229
293
|
if (valueChanged) {
|
|
230
294
|
this.props.onChange(safeCalendarValue);
|
|
@@ -243,6 +307,38 @@ class DatePickerComponent extends Component {
|
|
|
243
307
|
break;
|
|
244
308
|
}
|
|
245
309
|
});
|
|
310
|
+
_defineProperty(this, "onCalendarButtonKeyDown", e => {
|
|
311
|
+
// We want to stop this from triggering other keydown events, particularly
|
|
312
|
+
// for space and enter presses. Otherwise, it opens and then closes
|
|
313
|
+
// immediately.
|
|
314
|
+
if (e.type === 'keydown') {
|
|
315
|
+
e.stopPropagation();
|
|
316
|
+
}
|
|
317
|
+
this.setState({
|
|
318
|
+
isKeyDown: true,
|
|
319
|
+
wasOpenedFromCalendarButton: true
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
// This event handler is triggered from both keydown and click. It's weird.
|
|
323
|
+
_defineProperty(this, "onCalendarButtonClick", e => {
|
|
324
|
+
this.setState({
|
|
325
|
+
isOpen: !this.state.isOpen,
|
|
326
|
+
wasOpenedFromCalendarButton: true
|
|
327
|
+
}, () => {
|
|
328
|
+
var _this$calendarRef, _this$calendarRef$cur, _this$calendarRef$cur2;
|
|
329
|
+
// We don't want the focus to move if this is a click event
|
|
330
|
+
if (!this.state.isKeyDown) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
this.setState({
|
|
334
|
+
isKeyDown: false
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// Focus on the first button within the calendar
|
|
338
|
+
(_this$calendarRef = this.calendarRef) === null || _this$calendarRef === void 0 ? void 0 : (_this$calendarRef$cur = _this$calendarRef.current) === null || _this$calendarRef$cur === void 0 ? void 0 : (_this$calendarRef$cur2 = _this$calendarRef$cur.querySelector('button')) === null || _this$calendarRef$cur2 === void 0 ? void 0 : _this$calendarRef$cur2.focus();
|
|
339
|
+
});
|
|
340
|
+
e.stopPropagation();
|
|
341
|
+
});
|
|
246
342
|
_defineProperty(this, "onClear", () => {
|
|
247
343
|
let changedState = {
|
|
248
344
|
value: '',
|
|
@@ -285,6 +381,7 @@ class DatePickerComponent extends Component {
|
|
|
285
381
|
}
|
|
286
382
|
});
|
|
287
383
|
this.state = {
|
|
384
|
+
isKeyDown: false,
|
|
288
385
|
isOpen: this.props.defaultIsOpen,
|
|
289
386
|
isFocused: false,
|
|
290
387
|
clearingFromIcon: false,
|
|
@@ -293,7 +390,8 @@ class DatePickerComponent extends Component {
|
|
|
293
390
|
calendarValue: this.props.value || this.props.defaultValue || getShortISOString(new Date()),
|
|
294
391
|
l10n: createLocalizationProvider(this.props.locale),
|
|
295
392
|
locale: this.props.locale,
|
|
296
|
-
shouldSetFocusOnCurrentDay: false
|
|
393
|
+
shouldSetFocusOnCurrentDay: false,
|
|
394
|
+
wasOpenedFromCalendarButton: false
|
|
297
395
|
};
|
|
298
396
|
}
|
|
299
397
|
static getDerivedStateFromProps(nextProps, prevState) {
|
|
@@ -311,15 +409,18 @@ class DatePickerComponent extends Component {
|
|
|
311
409
|
appearance = 'default',
|
|
312
410
|
'aria-describedby': ariaDescribedBy,
|
|
313
411
|
autoFocus = false,
|
|
412
|
+
hideIcon = false,
|
|
413
|
+
openCalendarLabel = 'Open calendar',
|
|
314
414
|
disabled,
|
|
315
415
|
disabledDateFilter,
|
|
316
|
-
hideIcon = false,
|
|
317
|
-
// TODO: Resolve this typing to be more intuitive
|
|
318
416
|
icon = CalendarIcon,
|
|
319
417
|
id = '',
|
|
320
418
|
innerProps = {},
|
|
419
|
+
inputLabel = 'Date picker',
|
|
420
|
+
inputLabelId,
|
|
321
421
|
isDisabled = false,
|
|
322
422
|
isInvalid = false,
|
|
423
|
+
isRequired = false,
|
|
323
424
|
label = '',
|
|
324
425
|
locale,
|
|
325
426
|
maxDate,
|
|
@@ -328,6 +429,7 @@ class DatePickerComponent extends Component {
|
|
|
328
429
|
nextMonthLabel,
|
|
329
430
|
previousMonthLabel,
|
|
330
431
|
selectProps = {},
|
|
432
|
+
shouldShowCalendarButton,
|
|
331
433
|
spacing = 'default',
|
|
332
434
|
testId,
|
|
333
435
|
weekStartDay
|
|
@@ -346,7 +448,7 @@ class DatePickerComponent extends Component {
|
|
|
346
448
|
lang: this.props.locale
|
|
347
449
|
});
|
|
348
450
|
const selectComponents = {
|
|
349
|
-
DropdownIndicator: dropDownIcon,
|
|
451
|
+
DropdownIndicator: shouldShowCalendarButton ? EmptyComponent : dropDownIcon,
|
|
350
452
|
Menu,
|
|
351
453
|
SingleValue,
|
|
352
454
|
...(!showClearIndicator && {
|
|
@@ -366,6 +468,7 @@ class DatePickerComponent extends Component {
|
|
|
366
468
|
calendarDisabledDateFilter: disabledDateFilter,
|
|
367
469
|
calendarMaxDate: maxDate,
|
|
368
470
|
calendarMinDate: minDate,
|
|
471
|
+
calendarRef: this.calendarRef,
|
|
369
472
|
calendarValue: value && getShortISOString(parseISO(value)),
|
|
370
473
|
calendarView: calendarValue,
|
|
371
474
|
onCalendarChange: this.onCalendarChange,
|
|
@@ -374,7 +477,8 @@ class DatePickerComponent extends Component {
|
|
|
374
477
|
calendarWeekStartDay: weekStartDay,
|
|
375
478
|
shouldSetFocusOnCurrentDay: this.state.shouldSetFocusOnCurrentDay
|
|
376
479
|
};
|
|
377
|
-
|
|
480
|
+
|
|
481
|
+
// @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
|
|
378
482
|
const mergedStyles = mergeStyles(selectStyles, {
|
|
379
483
|
control: base => ({
|
|
380
484
|
...base,
|
|
@@ -395,10 +499,14 @@ class DatePickerComponent extends Component {
|
|
|
395
499
|
}),
|
|
396
500
|
value
|
|
397
501
|
} : null;
|
|
502
|
+
|
|
503
|
+
// `label` takes precedence of the `inputLabel`
|
|
504
|
+
const fullopenCalendarLabel = label || inputLabel ? `${label || inputLabel} , ${openCalendarLabel}` : openCalendarLabel;
|
|
398
505
|
return (
|
|
399
506
|
// These event handlers must be on this element because the events come
|
|
400
507
|
// from different child elements.
|
|
401
508
|
jsx("div", _extends({}, innerProps, {
|
|
509
|
+
css: pickerContainerStyles,
|
|
402
510
|
role: "presentation",
|
|
403
511
|
onBlur: this.onContainerBlur,
|
|
404
512
|
onFocus: this.onContainerFocus,
|
|
@@ -417,12 +525,20 @@ class DatePickerComponent extends Component {
|
|
|
417
525
|
"aria-describedby": ariaDescribedBy,
|
|
418
526
|
"aria-label": label || undefined,
|
|
419
527
|
autoFocus: autoFocus,
|
|
420
|
-
closeMenuOnSelect: true
|
|
528
|
+
closeMenuOnSelect: true
|
|
529
|
+
// FOr some reason, this and the below `styles` type error _only_ show
|
|
530
|
+
// up when you alter some of the properties in the `selectComponents`
|
|
531
|
+
// object. These errors are still present, and I suspect have always
|
|
532
|
+
// been present, without changing the unrelated code. Ignoring as the
|
|
533
|
+
// component still works as expected despite this error. And also
|
|
534
|
+
// because the select refresh team may solve it later.
|
|
535
|
+
,
|
|
421
536
|
components: selectComponents,
|
|
422
537
|
enableAnimation: false,
|
|
423
538
|
inputId: id,
|
|
424
539
|
inputValue: actualSelectInputValue,
|
|
425
540
|
isDisabled: isDisabled,
|
|
541
|
+
isRequired: isRequired,
|
|
426
542
|
menuIsOpen: menuIsOpen,
|
|
427
543
|
onBlur: this.onSelectBlur,
|
|
428
544
|
onChange: this.onSelectChange,
|
|
@@ -442,7 +558,7 @@ class DatePickerComponent extends Component {
|
|
|
442
558
|
spacing: spacing,
|
|
443
559
|
testId: testId
|
|
444
560
|
// These aren't part of `Select`'s API, but we're using them here.
|
|
445
|
-
|
|
561
|
+
// @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<...> & { ...; }>'.
|
|
446
562
|
,
|
|
447
563
|
calendarContainerRef: calendarProps.calendarContainerRef,
|
|
448
564
|
calendarDisabled: calendarProps.calendarDisabled,
|
|
@@ -450,6 +566,7 @@ class DatePickerComponent extends Component {
|
|
|
450
566
|
calendarLocale: calendarProps.calendarLocale,
|
|
451
567
|
calendarMaxDate: calendarProps.calendarMaxDate,
|
|
452
568
|
calendarMinDate: calendarProps.calendarMinDate,
|
|
569
|
+
calendarRef: calendarProps.calendarRef,
|
|
453
570
|
calendarValue: calendarProps.calendarValue,
|
|
454
571
|
calendarView: calendarProps.calendarView,
|
|
455
572
|
calendarWeekStartDay: calendarProps.calendarWeekStartDay,
|
|
@@ -458,7 +575,29 @@ class DatePickerComponent extends Component {
|
|
|
458
575
|
onCalendarSelect: calendarProps.onCalendarSelect,
|
|
459
576
|
previousMonthLabel: previousMonthLabel,
|
|
460
577
|
shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay
|
|
461
|
-
}))
|
|
578
|
+
})), shouldShowCalendarButton && !isDisabled ? jsx(UID, {
|
|
579
|
+
name: id => `open-calendar-label--${id}`
|
|
580
|
+
}, openCalendarLabelId => jsx("div", {
|
|
581
|
+
css: [iconContainerStyles, value && !hideIcon ? iconSpacingWithClearButtonStyles : iconSpacingWithoutClearButtonStyles]
|
|
582
|
+
}, inputLabelId && jsx(VisuallyHidden, {
|
|
583
|
+
id: openCalendarLabelId
|
|
584
|
+
}, ", ", openCalendarLabel), jsx(Pressable, _extends({}, inputLabelId ? {
|
|
585
|
+
'aria-labelledby': `${inputLabelId} ${openCalendarLabelId}`
|
|
586
|
+
} : {
|
|
587
|
+
'aria-label': fullopenCalendarLabel
|
|
588
|
+
}, {
|
|
589
|
+
onClick: this.onCalendarButtonClick,
|
|
590
|
+
onKeyDown: this.onCalendarButtonKeyDown,
|
|
591
|
+
ref: this.calendarButtonRef,
|
|
592
|
+
testId: testId && `${testId}--open-calendar-button`,
|
|
593
|
+
type: "button",
|
|
594
|
+
backgroundColor: "color.background.neutral.subtle",
|
|
595
|
+
padding: "space.050",
|
|
596
|
+
xcss: calendarButtonStyles
|
|
597
|
+
}), jsx(CalendarIcon, {
|
|
598
|
+
label: "",
|
|
599
|
+
primaryColor: "var(--ds-icon, #44546F)"
|
|
600
|
+
})))) : null)
|
|
462
601
|
);
|
|
463
602
|
}
|
|
464
603
|
}
|
|
@@ -18,7 +18,7 @@ import { convertTokens } from '../internal/parse-tokens';
|
|
|
18
18
|
import DatePicker from './date-picker';
|
|
19
19
|
import TimePicker from './time-picker';
|
|
20
20
|
const packageName = "@atlaskit/datetime-picker";
|
|
21
|
-
const packageVersion = "15.
|
|
21
|
+
const packageVersion = "15.3.0";
|
|
22
22
|
// Make DatePicker 50% the width of DateTimePicker
|
|
23
23
|
// If rendering an icon container, shrink the TimePicker
|
|
24
24
|
const datePickerContainerStyles = css({
|
|
@@ -240,6 +240,7 @@ class DateTimePickerComponent extends React.Component {
|
|
|
240
240
|
innerProps = {},
|
|
241
241
|
isDisabled = false,
|
|
242
242
|
isInvalid = false,
|
|
243
|
+
isRequired = false,
|
|
243
244
|
locale = 'en-US',
|
|
244
245
|
name = '',
|
|
245
246
|
spacing = 'default',
|
|
@@ -301,6 +302,7 @@ class DateTimePickerComponent extends React.Component {
|
|
|
301
302
|
innerProps: datePickerProps.innerProps,
|
|
302
303
|
isDisabled: datePickerProps.isDisabled || isDisabled,
|
|
303
304
|
isInvalid: datePickerProps.isInvalid || isInvalid,
|
|
305
|
+
isRequired: datePickerProps.isRequired || isRequired,
|
|
304
306
|
isOpen: datePickerProps.isOpen,
|
|
305
307
|
label: datePickerLabel,
|
|
306
308
|
locale: datePickerProps.locale || locale,
|
|
@@ -315,6 +317,7 @@ class DateTimePickerComponent extends React.Component {
|
|
|
315
317
|
placeholder: datePickerProps.placeholder,
|
|
316
318
|
previousMonthLabel: datePickerProps.previousMonthLabel,
|
|
317
319
|
selectProps: mergedDatePickerSelectProps,
|
|
320
|
+
shouldShowCalendarButton: datePickerProps.shouldShowCalendarButton,
|
|
318
321
|
spacing: datePickerProps.spacing || spacing,
|
|
319
322
|
testId: testId && `${testId}--datepicker` || datePickerProps.testId,
|
|
320
323
|
value: dateValue,
|
|
@@ -334,6 +337,7 @@ class DateTimePickerComponent extends React.Component {
|
|
|
334
337
|
isDisabled: timePickerProps.isDisabled || isDisabled,
|
|
335
338
|
isInvalid: timePickerProps.isInvalid || isInvalid,
|
|
336
339
|
isOpen: timePickerProps.isOpen,
|
|
340
|
+
isRequired: timePickerProps.isRequired || isRequired,
|
|
337
341
|
label: timePickerLabel,
|
|
338
342
|
locale: timePickerProps.locale || locale,
|
|
339
343
|
name: timePickerProps.name,
|
|
@@ -11,7 +11,7 @@ import parseTime from '../internal/parse-time';
|
|
|
11
11
|
import { convertTokens } from '../internal/parse-tokens';
|
|
12
12
|
import { makeSingleValue } from '../internal/single-value';
|
|
13
13
|
const packageName = "@atlaskit/datetime-picker";
|
|
14
|
-
const packageVersion = "15.
|
|
14
|
+
const packageVersion = "15.3.0";
|
|
15
15
|
const menuStyles = {
|
|
16
16
|
/* Need to remove default absolute positioning as that causes issues with position fixed */
|
|
17
17
|
position: 'static',
|
|
@@ -47,6 +47,7 @@ const TimePicker = /*#__PURE__*/forwardRef(({
|
|
|
47
47
|
innerProps = {},
|
|
48
48
|
isDisabled = false,
|
|
49
49
|
isInvalid = false,
|
|
50
|
+
isRequired = false,
|
|
50
51
|
isOpen: providedIsOpen,
|
|
51
52
|
label = '',
|
|
52
53
|
locale = 'en-US',
|
|
@@ -230,7 +231,8 @@ const TimePicker = /*#__PURE__*/forwardRef(({
|
|
|
230
231
|
})
|
|
231
232
|
};
|
|
232
233
|
const renderIconContainer = Boolean(!hideIcon && value);
|
|
233
|
-
|
|
234
|
+
|
|
235
|
+
// @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
|
|
234
236
|
const mergedStyles = mergeStyles(selectStyles, {
|
|
235
237
|
control: base => ({
|
|
236
238
|
...base
|
|
@@ -266,6 +268,7 @@ const TimePicker = /*#__PURE__*/forwardRef(({
|
|
|
266
268
|
inputId: id,
|
|
267
269
|
isClearable: true,
|
|
268
270
|
isDisabled: isDisabled,
|
|
271
|
+
isRequired: isRequired,
|
|
269
272
|
menuIsOpen: isOpen && !isDisabled,
|
|
270
273
|
menuPlacement: "auto",
|
|
271
274
|
openMenuOnFocus: true,
|
|
@@ -69,6 +69,7 @@ export const Menu = ({
|
|
|
69
69
|
onChange: selectProps.onCalendarChange,
|
|
70
70
|
onSelect: selectProps.onCalendarSelect,
|
|
71
71
|
previousMonthLabel: selectProps.previousMonthLabel,
|
|
72
|
+
ref: selectProps.calendarRef,
|
|
72
73
|
selected: [selectProps.calendarValue],
|
|
73
74
|
shouldSetFocusOnCurrentDay: selectProps.shouldSetFocusOnCurrentDay,
|
|
74
75
|
locale: selectProps.calendarLocale,
|