@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.
@@ -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.1.4";
39
+ var packageVersion = "15.3.0";
33
40
  var datePickerDefaultProps = {
34
41
  defaultIsOpen: false,
35
42
  defaultValue: '',
@@ -48,6 +55,40 @@ 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
+ });
90
+
91
+ // eslint-disable-next-line @repo/internal/react/no-class-components
51
92
  var DatePickerComponent = /*#__PURE__*/function (_Component) {
52
93
  _inherits(DatePickerComponent, _Component);
53
94
  var _super = _createSuper(DatePickerComponent);
@@ -57,6 +98,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
57
98
  _classCallCheck(this, DatePickerComponent);
58
99
  _this = _super.call(this, props);
59
100
  _defineProperty(_assertThisInitialized(_this), "containerRef", null);
101
+ _defineProperty(_assertThisInitialized(_this), "calendarRef", /*#__PURE__*/createRef());
102
+ _defineProperty(_assertThisInitialized(_this), "calendarButtonRef", /*#__PURE__*/createRef());
60
103
  // All state needs to be accessed via this function so that the state is mapped from props
61
104
  // correctly to allow controlled/uncontrolled usage.
62
105
  _defineProperty(_assertThisInitialized(_this), "getValue", function () {
@@ -76,23 +119,30 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
76
119
  });
77
120
  });
78
121
  _defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (_ref2) {
79
- var _this$containerRef;
80
122
  var iso = _ref2.iso;
81
123
  _this.setState({
82
124
  selectInputValue: '',
83
125
  isOpen: false,
84
126
  calendarValue: iso,
85
- value: iso
127
+ value: iso,
128
+ wasOpenedFromCalendarButton: false
86
129
  });
87
130
  _this.props.onChange(iso);
88
131
 
89
- // Not ideal, and the alternative is to place a ref on the inner input of the Select
90
- // but that would require a lot of extra work on the Select component just for this
91
- // focus functionality. While that would be the 'right react' way to do it, it doesnt
92
- // post any other benefits; performance wise, we are only searching within the
93
- // container, making it quick.
94
- var innerCombobox = (_this$containerRef = _this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.querySelector('[role="combobox"]');
95
- innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
132
+ // Yes, this is not ideal. The alternative is to be able to place a ref
133
+ // on the inner input of Select itself, which would require a lot of
134
+ // extra stuff in the Select component for only this one thing. While
135
+ // this would be more "React-y", it doesn't seem to pose any other
136
+ // benefits. Performance-wise, we are only searching within the
137
+ // container, so it's quick.
138
+ if (_this.state.wasOpenedFromCalendarButton) {
139
+ var _this$calendarButtonR;
140
+ (_this$calendarButtonR = _this.calendarButtonRef.current) === null || _this$calendarButtonR === void 0 || _this$calendarButtonR.focus();
141
+ } else {
142
+ var _this$containerRef;
143
+ var innerCombobox = (_this$containerRef = _this.containerRef) === null || _this$containerRef === void 0 ? void 0 : _this$containerRef.querySelector('[role="combobox"]');
144
+ innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
145
+ }
96
146
  _this.setState({
97
147
  isOpen: false
98
148
  });
@@ -100,7 +150,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
100
150
  _defineProperty(_assertThisInitialized(_this), "onInputClick", function () {
101
151
  if (!_this.props.isDisabled && !_this.getIsOpen()) {
102
152
  _this.setState({
103
- isOpen: true
153
+ isOpen: true,
154
+ wasOpenedFromCalendarButton: false
104
155
  });
105
156
  }
106
157
  });
@@ -110,7 +161,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
110
161
  if (!((_this$containerRef2 = _this.containerRef) !== null && _this$containerRef2 !== void 0 && _this$containerRef2.contains(newlyFocusedElement))) {
111
162
  _this.setState({
112
163
  isOpen: false,
113
- shouldSetFocusOnCurrentDay: false
164
+ shouldSetFocusOnCurrentDay: false,
165
+ wasOpenedFromCalendarButton: false
114
166
  });
115
167
  _this.props.onBlur(event);
116
168
  }
@@ -133,7 +185,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
133
185
  // container. Makes keyboard accessibility of calendar possible
134
186
  _this.setState({
135
187
  isOpen: false,
136
- isFocused: false
188
+ isFocused: false,
189
+ wasOpenedFromCalendarButton: false
137
190
  });
138
191
  }
139
192
  });
@@ -147,9 +200,11 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
147
200
  });
148
201
  } else {
149
202
  _this.setState({
150
- isOpen: true,
203
+ // Don't open when focused into via keyboard if the calendar button is present
204
+ isOpen: !_this.props.shouldShowCalendarButton,
151
205
  calendarValue: value,
152
- isFocused: true
206
+ isFocused: true,
207
+ wasOpenedFromCalendarButton: false
153
208
  });
154
209
  }
155
210
  _this.props.onFocus(event);
@@ -172,11 +227,11 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
172
227
  }
173
228
  }
174
229
  _this.setState({
175
- isOpen: true
230
+ isOpen: true,
231
+ wasOpenedFromCalendarButton: false
176
232
  });
177
233
  });
178
234
  _defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (event) {
179
- var _this$containerRef4;
180
235
  var calendarValue = _this.state.calendarValue;
181
236
  var value = _this.getValue();
182
237
  var keyPressed = event.key.toLowerCase();
@@ -184,7 +239,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
184
239
  // If the input is focused and the calendar is not visible, handle space and enter clicks
185
240
  if (!_this.state.isOpen && (keyPressed === 'enter' || keyPressed === ' ')) {
186
241
  _this.setState({
187
- isOpen: true
242
+ isOpen: true,
243
+ wasOpenedFromCalendarButton: false
188
244
  });
189
245
  }
190
246
  switch (keyPressed) {
@@ -195,11 +251,18 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
195
251
  // this would be more "React-y", it doesn't seem to pose any other
196
252
  // benefits. Performance-wise, we are only searching within the
197
253
  // container, so it's quick.
198
- var innerCombobox = (_this$containerRef4 = _this.containerRef) === null || _this$containerRef4 === void 0 ? void 0 : _this$containerRef4.querySelector('[role="combobox"]');
199
- innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
254
+ if (_this.state.wasOpenedFromCalendarButton) {
255
+ var _this$calendarButtonR2;
256
+ (_this$calendarButtonR2 = _this.calendarButtonRef.current) === null || _this$calendarButtonR2 === void 0 || _this$calendarButtonR2.focus();
257
+ } else {
258
+ var _this$containerRef4;
259
+ var innerCombobox = (_this$containerRef4 = _this.containerRef) === null || _this$containerRef4 === void 0 ? void 0 : _this$containerRef4.querySelector('[role="combobox"]');
260
+ innerCombobox === null || innerCombobox === void 0 || innerCombobox.focus();
261
+ }
200
262
  _this.setState({
201
263
  isOpen: false,
202
- shouldSetFocusOnCurrentDay: false
264
+ shouldSetFocusOnCurrentDay: false,
265
+ wasOpenedFromCalendarButton: false
203
266
  });
204
267
  break;
205
268
  case 'backspace':
@@ -234,7 +297,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
234
297
  selectInputValue: '',
235
298
  isOpen: false,
236
299
  value: safeCalendarValue,
237
- calendarValue: safeCalendarValue
300
+ calendarValue: safeCalendarValue,
301
+ wasOpenedFromCalendarButton: false
238
302
  });
239
303
  if (valueChanged) {
240
304
  _this.props.onChange(safeCalendarValue);
@@ -253,6 +317,38 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
253
317
  break;
254
318
  }
255
319
  });
320
+ _defineProperty(_assertThisInitialized(_this), "onCalendarButtonKeyDown", function (e) {
321
+ // We want to stop this from triggering other keydown events, particularly
322
+ // for space and enter presses. Otherwise, it opens and then closes
323
+ // immediately.
324
+ if (e.type === 'keydown') {
325
+ e.stopPropagation();
326
+ }
327
+ _this.setState({
328
+ isKeyDown: true,
329
+ wasOpenedFromCalendarButton: true
330
+ });
331
+ });
332
+ // This event handler is triggered from both keydown and click. It's weird.
333
+ _defineProperty(_assertThisInitialized(_this), "onCalendarButtonClick", function (e) {
334
+ _this.setState({
335
+ isOpen: !_this.state.isOpen,
336
+ wasOpenedFromCalendarButton: true
337
+ }, function () {
338
+ var _this$calendarRef;
339
+ // We don't want the focus to move if this is a click event
340
+ if (!_this.state.isKeyDown) {
341
+ return;
342
+ }
343
+ _this.setState({
344
+ isKeyDown: false
345
+ });
346
+
347
+ // Focus on the first button within the calendar
348
+ (_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();
349
+ });
350
+ e.stopPropagation();
351
+ });
256
352
  _defineProperty(_assertThisInitialized(_this), "onClear", function () {
257
353
  var changedState = {
258
354
  value: '',
@@ -294,6 +390,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
294
390
  }
295
391
  });
296
392
  _this.state = {
393
+ isKeyDown: false,
297
394
  isOpen: _this.props.defaultIsOpen,
298
395
  isFocused: false,
299
396
  clearingFromIcon: false,
@@ -302,33 +399,42 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
302
399
  calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
303
400
  l10n: createLocalizationProvider(_this.props.locale),
304
401
  locale: _this.props.locale,
305
- shouldSetFocusOnCurrentDay: false
402
+ shouldSetFocusOnCurrentDay: false,
403
+ wasOpenedFromCalendarButton: false
306
404
  };
307
405
  return _this;
308
406
  }
309
407
  _createClass(DatePickerComponent, [{
310
408
  key: "render",
311
409
  value: function render() {
410
+ var _this2 = this;
312
411
  var _this$props = this.props,
313
412
  _this$props$appearanc = _this$props.appearance,
314
413
  appearance = _this$props$appearanc === void 0 ? 'default' : _this$props$appearanc,
315
414
  ariaDescribedBy = _this$props['aria-describedby'],
316
415
  _this$props$autoFocus = _this$props.autoFocus,
317
416
  autoFocus = _this$props$autoFocus === void 0 ? false : _this$props$autoFocus,
318
- disabled = _this$props.disabled,
319
- disabledDateFilter = _this$props.disabledDateFilter,
320
417
  _this$props$hideIcon = _this$props.hideIcon,
321
418
  hideIcon = _this$props$hideIcon === void 0 ? false : _this$props$hideIcon,
419
+ _this$props$openCalen = _this$props.openCalendarLabel,
420
+ openCalendarLabel = _this$props$openCalen === void 0 ? 'Open calendar' : _this$props$openCalen,
421
+ disabled = _this$props.disabled,
422
+ disabledDateFilter = _this$props.disabledDateFilter,
322
423
  _this$props$icon = _this$props.icon,
323
424
  icon = _this$props$icon === void 0 ? CalendarIcon : _this$props$icon,
324
425
  _this$props$id = _this$props.id,
325
426
  id = _this$props$id === void 0 ? '' : _this$props$id,
326
427
  _this$props$innerProp = _this$props.innerProps,
327
428
  innerProps = _this$props$innerProp === void 0 ? {} : _this$props$innerProp,
429
+ _this$props$inputLabe = _this$props.inputLabel,
430
+ inputLabel = _this$props$inputLabe === void 0 ? 'Date picker' : _this$props$inputLabe,
431
+ inputLabelId = _this$props.inputLabelId,
328
432
  _this$props$isDisable = _this$props.isDisabled,
329
433
  isDisabled = _this$props$isDisable === void 0 ? false : _this$props$isDisable,
330
434
  _this$props$isInvalid = _this$props.isInvalid,
331
435
  isInvalid = _this$props$isInvalid === void 0 ? false : _this$props$isInvalid,
436
+ _this$props$isRequire = _this$props.isRequired,
437
+ isRequired = _this$props$isRequire === void 0 ? false : _this$props$isRequire,
332
438
  _this$props$label = _this$props.label,
333
439
  label = _this$props$label === void 0 ? '' : _this$props$label,
334
440
  locale = _this$props.locale,
@@ -340,6 +446,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
340
446
  previousMonthLabel = _this$props.previousMonthLabel,
341
447
  _this$props$selectPro3 = _this$props.selectProps,
342
448
  selectProps = _this$props$selectPro3 === void 0 ? {} : _this$props$selectPro3,
449
+ shouldShowCalendarButton = _this$props.shouldShowCalendarButton,
343
450
  _this$props$spacing = _this$props.spacing,
344
451
  spacing = _this$props$spacing === void 0 ? 'default' : _this$props$spacing,
345
452
  testId = _this$props.testId,
@@ -357,7 +464,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
357
464
  lang: this.props.locale
358
465
  });
359
466
  var selectComponents = _objectSpread({
360
- DropdownIndicator: dropDownIcon,
467
+ DropdownIndicator: shouldShowCalendarButton ? EmptyComponent : dropDownIcon,
361
468
  Menu: Menu,
362
469
  SingleValue: SingleValue
363
470
  }, !showClearIndicator && {
@@ -375,6 +482,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
375
482
  calendarDisabledDateFilter: disabledDateFilter,
376
483
  calendarMaxDate: maxDate,
377
484
  calendarMinDate: minDate,
485
+ calendarRef: this.calendarRef,
378
486
  calendarValue: value && getShortISOString(parseISO(value)),
379
487
  calendarView: calendarValue,
380
488
  onCalendarChange: this.onCalendarChange,
@@ -383,7 +491,8 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
383
491
  calendarWeekStartDay: weekStartDay,
384
492
  shouldSetFocusOnCurrentDay: this.state.shouldSetFocusOnCurrentDay
385
493
  };
386
- //@ts-ignore react-select unsupported props
494
+
495
+ // @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
387
496
  var mergedStyles = mergeStyles(selectStyles, {
388
497
  control: function control(base) {
389
498
  return _objectSpread(_objectSpread({}, base), disabledStyle);
@@ -404,10 +513,14 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
404
513
  }),
405
514
  value: value
406
515
  } : null;
516
+
517
+ // `label` takes precedence of the `inputLabel`
518
+ var fullopenCalendarLabel = label || inputLabel ? "".concat(label || inputLabel, " , ").concat(openCalendarLabel) : openCalendarLabel;
407
519
  return (
408
520
  // These event handlers must be on this element because the events come
409
521
  // from different child elements.
410
522
  jsx("div", _extends({}, innerProps, {
523
+ css: pickerContainerStyles,
411
524
  role: "presentation",
412
525
  onBlur: this.onContainerBlur,
413
526
  onFocus: this.onContainerFocus,
@@ -426,12 +539,20 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
426
539
  "aria-describedby": ariaDescribedBy,
427
540
  "aria-label": label || undefined,
428
541
  autoFocus: autoFocus,
429
- closeMenuOnSelect: true,
542
+ closeMenuOnSelect: true
543
+ // FOr some reason, this and the below `styles` type error _only_ show
544
+ // up when you alter some of the properties in the `selectComponents`
545
+ // object. These errors are still present, and I suspect have always
546
+ // been present, without changing the unrelated code. Ignoring as the
547
+ // component still works as expected despite this error. And also
548
+ // because the select refresh team may solve it later.
549
+ ,
430
550
  components: selectComponents,
431
551
  enableAnimation: false,
432
552
  inputId: id,
433
553
  inputValue: actualSelectInputValue,
434
554
  isDisabled: isDisabled,
555
+ isRequired: isRequired,
435
556
  menuIsOpen: menuIsOpen,
436
557
  onBlur: this.onSelectBlur,
437
558
  onChange: this.onSelectChange,
@@ -451,7 +572,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
451
572
  spacing: spacing,
452
573
  testId: testId
453
574
  // These aren't part of `Select`'s API, but we're using them here.
454
- //@ts-ignore react-select unsupported props
575
+ // @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
576
  ,
456
577
  calendarContainerRef: calendarProps.calendarContainerRef,
457
578
  calendarDisabled: calendarProps.calendarDisabled,
@@ -459,6 +580,7 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
459
580
  calendarLocale: calendarProps.calendarLocale,
460
581
  calendarMaxDate: calendarProps.calendarMaxDate,
461
582
  calendarMinDate: calendarProps.calendarMinDate,
583
+ calendarRef: calendarProps.calendarRef,
462
584
  calendarValue: calendarProps.calendarValue,
463
585
  calendarView: calendarProps.calendarView,
464
586
  calendarWeekStartDay: calendarProps.calendarWeekStartDay,
@@ -467,7 +589,33 @@ var DatePickerComponent = /*#__PURE__*/function (_Component) {
467
589
  onCalendarSelect: calendarProps.onCalendarSelect,
468
590
  previousMonthLabel: previousMonthLabel,
469
591
  shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay
470
- })))
592
+ })), shouldShowCalendarButton && !isDisabled ? jsx(UID, {
593
+ name: function name(id) {
594
+ return "open-calendar-label--".concat(id);
595
+ }
596
+ }, function (openCalendarLabelId) {
597
+ return jsx("div", {
598
+ css: [iconContainerStyles, value && !hideIcon ? iconSpacingWithClearButtonStyles : iconSpacingWithoutClearButtonStyles]
599
+ }, inputLabelId && jsx(VisuallyHidden, {
600
+ id: openCalendarLabelId
601
+ }, ", ", openCalendarLabel), jsx(Pressable, _extends({}, inputLabelId ? {
602
+ 'aria-labelledby': "".concat(inputLabelId, " ").concat(openCalendarLabelId)
603
+ } : {
604
+ 'aria-label': fullopenCalendarLabel
605
+ }, {
606
+ onClick: _this2.onCalendarButtonClick,
607
+ onKeyDown: _this2.onCalendarButtonKeyDown,
608
+ ref: _this2.calendarButtonRef,
609
+ testId: testId && "".concat(testId, "--open-calendar-button"),
610
+ type: "button",
611
+ backgroundColor: "color.background.neutral.subtle",
612
+ padding: "space.050",
613
+ xcss: calendarButtonStyles
614
+ }), jsx(CalendarIcon, {
615
+ label: "",
616
+ primaryColor: "var(--ds-icon, #44546F)"
617
+ })));
618
+ }) : null)
471
619
  );
472
620
  }
473
621
  }], [{
@@ -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.1.4";
31
+ var packageVersion = "15.3.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({
@@ -273,6 +273,8 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
273
273
  isDisabled = _this$props7$isDisabl === void 0 ? false : _this$props7$isDisabl,
274
274
  _this$props7$isInvali = _this$props7.isInvalid,
275
275
  isInvalid = _this$props7$isInvali === void 0 ? false : _this$props7$isInvali,
276
+ _this$props7$isRequir = _this$props7.isRequired,
277
+ isRequired = _this$props7$isRequir === void 0 ? false : _this$props7$isRequir,
276
278
  _this$props7$locale = _this$props7.locale,
277
279
  locale = _this$props7$locale === void 0 ? 'en-US' : _this$props7$locale,
278
280
  _this$props7$name = _this$props7.name,
@@ -333,6 +335,7 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
333
335
  innerProps: datePickerProps.innerProps,
334
336
  isDisabled: datePickerProps.isDisabled || isDisabled,
335
337
  isInvalid: datePickerProps.isInvalid || isInvalid,
338
+ isRequired: datePickerProps.isRequired || isRequired,
336
339
  isOpen: datePickerProps.isOpen,
337
340
  label: datePickerLabel,
338
341
  locale: datePickerProps.locale || locale,
@@ -347,6 +350,7 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
347
350
  placeholder: datePickerProps.placeholder,
348
351
  previousMonthLabel: datePickerProps.previousMonthLabel,
349
352
  selectProps: mergedDatePickerSelectProps,
353
+ shouldShowCalendarButton: datePickerProps.shouldShowCalendarButton,
350
354
  spacing: datePickerProps.spacing || spacing,
351
355
  testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
352
356
  value: dateValue,
@@ -366,6 +370,7 @@ var DateTimePickerComponent = /*#__PURE__*/function (_React$Component) {
366
370
  isDisabled: timePickerProps.isDisabled || isDisabled,
367
371
  isInvalid: timePickerProps.isInvalid || isInvalid,
368
372
  isOpen: timePickerProps.isOpen,
373
+ isRequired: timePickerProps.isRequired || isRequired,
369
374
  label: timePickerLabel,
370
375
  locale: timePickerProps.locale || locale,
371
376
  name: timePickerProps.name,
@@ -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.1.4";
20
+ var packageVersion = "15.3.0";
21
21
  var menuStyles = {
22
22
  /* Need to remove default absolute positioning as that causes issues with position fixed */
23
23
  position: 'static',
@@ -62,6 +62,8 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
62
62
  isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
63
63
  _ref$isInvalid = _ref.isInvalid,
64
64
  isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
65
+ _ref$isRequired = _ref.isRequired,
66
+ isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
65
67
  providedIsOpen = _ref.isOpen,
66
68
  _ref$label = _ref.label,
67
69
  label = _ref$label === void 0 ? '' : _ref$label,
@@ -271,7 +273,8 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
271
273
  ClearIndicator: EmptyComponent
272
274
  });
273
275
  var renderIconContainer = Boolean(!hideIcon && value);
274
- // @ts-ignore - https://product-fabric.atlassian.net/browse/DSP-21000
276
+
277
+ // @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
275
278
  var mergedStyles = mergeStyles(selectStyles, {
276
279
  control: function control(base) {
277
280
  return _objectSpread({}, base);
@@ -308,6 +311,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
308
311
  inputId: id,
309
312
  isClearable: true,
310
313
  isDisabled: isDisabled,
314
+ isRequired: isRequired,
311
315
  menuIsOpen: isOpen && !isDisabled,
312
316
  menuPlacement: "auto",
313
317
  openMenuOnFocus: true,
@@ -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<DatePickerProps, 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" | "hideIcon"> & Partial<Pick<Omit<DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "disabled" | "defaultValue" | "onFocus" | "onBlur" | "onChange" | "disabledDateFilter" | "locale" | "defaultIsOpen">> & Partial<Pick<{
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
- }, 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" | "hideIcon"> & import("react").RefAttributes<any>>;
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" | "isRequired" | "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" | "isRequired" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & import("react").RefAttributes<any>>;
95
119
  export default DatePicker;
@@ -52,5 +52,5 @@ export { DateTimePickerComponent as DateTimePickerWithoutAnalytics };
52
52
  * - [Code](https://atlassian.design/components/datetime-picker/code)
53
53
  * - [Usage](https://atlassian.design/components/datetime-picker/usage)
54
54
  */
55
- declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue">> & Partial<Pick<DateTimePickerBaseProps, "ref" | "createAnalyticsEvent">>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "testId" | "appearance" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any>>;
55
+ declare const DateTimePicker: React.ForwardRefExoticComponent<Pick<Pick<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & Partial<Pick<Omit<DateTimePickerBaseProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue">> & Partial<Pick<DateTimePickerBaseProps, "ref" | "createAnalyticsEvent">>, "testId" | "appearance" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "testId" | "appearance" | "innerProps" | "isDisabled" | "key" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "analyticsContext" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "clearControlLabel" | "datePickerProps" | "timePickerProps" | "parseValue"> & React.RefAttributes<any>>;
56
56
  export default DateTimePicker;
@@ -9,5 +9,5 @@ import { type TimePickerBaseProps } from '../types';
9
9
  * - [Code](https://atlassian.design/components/datetime-picker/time-picker/code)
10
10
  * - [Usage](https://atlassian.design/components/datetime-picker/time-picker/usage)
11
11
  */
12
- declare const TimePicker: React.ForwardRefExoticComponent<Pick<TimePickerBaseProps, "times" | "parseInputValue" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<unknown>>;
12
+ declare const TimePicker: React.ForwardRefExoticComponent<Pick<TimePickerBaseProps, "times" | "parseInputValue" | "formatDisplayLabel" | "placeholder" | "testId" | "label" | "appearance" | "selectProps" | "innerProps" | "isDisabled" | "defaultValue" | "id" | "aria-describedby" | "onFocus" | "onBlur" | "onChange" | "locale" | "createAnalyticsEvent" | "value" | "autoFocus" | "isInvalid" | "isRequired" | "name" | "spacing" | "defaultIsOpen" | "isOpen" | "hideIcon" | "timeIsEditable" | "timeFormat"> & React.RefAttributes<unknown>>;
13
13
  export default TimePicker;