@atlaskit/datetime-picker 15.13.0 → 15.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/components/date-picker-class.js +685 -0
  3. package/dist/cjs/components/date-picker-fc.js +639 -0
  4. package/dist/cjs/components/date-picker.js +7 -639
  5. package/dist/cjs/components/date-time-picker-class.js +436 -0
  6. package/dist/cjs/components/date-time-picker-fc.js +394 -0
  7. package/dist/cjs/components/date-time-picker.js +9 -379
  8. package/dist/cjs/components/time-picker.js +2 -2
  9. package/dist/cjs/internal/ff-component.js +58 -0
  10. package/dist/es2019/components/date-picker-class.js +649 -0
  11. package/dist/es2019/components/date-picker-fc.js +563 -0
  12. package/dist/es2019/components/date-picker.js +5 -570
  13. package/dist/es2019/components/date-time-picker-class.js +400 -0
  14. package/dist/es2019/components/date-time-picker-fc.js +354 -0
  15. package/dist/es2019/components/date-time-picker.js +6 -347
  16. package/dist/es2019/components/time-picker.js +2 -2
  17. package/dist/es2019/internal/ff-component.js +47 -0
  18. package/dist/esm/components/date-picker-class.js +680 -0
  19. package/dist/esm/components/date-picker-fc.js +630 -0
  20. package/dist/esm/components/date-picker.js +7 -637
  21. package/dist/esm/components/date-time-picker-class.js +434 -0
  22. package/dist/esm/components/date-time-picker-fc.js +384 -0
  23. package/dist/esm/components/date-time-picker.js +8 -375
  24. package/dist/esm/components/time-picker.js +2 -2
  25. package/dist/esm/internal/ff-component.js +49 -0
  26. package/dist/types/components/date-picker-class.d.ts +110 -0
  27. package/dist/types/components/date-picker-fc.d.ts +20 -0
  28. package/dist/types/components/date-picker.d.ts +19 -18
  29. package/dist/types/components/date-time-picker-class.d.ts +85 -0
  30. package/dist/types/components/date-time-picker-fc.d.ts +15 -0
  31. package/dist/types/components/date-time-picker.d.ts +31 -14
  32. package/dist/types/internal/ff-component.d.ts +34 -0
  33. package/dist/types-ts4.5/components/date-picker-class.d.ts +110 -0
  34. package/dist/types-ts4.5/components/date-picker-fc.d.ts +20 -0
  35. package/dist/types-ts4.5/components/date-picker.d.ts +19 -18
  36. package/dist/types-ts4.5/components/date-time-picker-class.d.ts +85 -0
  37. package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +15 -0
  38. package/dist/types-ts4.5/components/date-time-picker.d.ts +31 -14
  39. package/dist/types-ts4.5/internal/ff-component.d.ts +34 -0
  40. package/package.json +9 -6
@@ -0,0 +1,563 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ /**
3
+ * @jsxRuntime classic
4
+ * @jsx jsx
5
+ */
6
+ import { forwardRef, useCallback, useEffect, useReducer, useRef, useState } from 'react';
7
+
8
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
+ import { css, jsx } from '@emotion/react';
10
+ import { isValid, parseISO } from 'date-fns';
11
+ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
12
+ import { IconButton } from '@atlaskit/button/new';
13
+ import { useId } from '@atlaskit/ds-lib/use-id';
14
+ import CalendarIcon from '@atlaskit/icon/core/migration/calendar';
15
+ import { createLocalizationProvider } from '@atlaskit/locale';
16
+ import { fg } from '@atlaskit/platform-feature-flags';
17
+ import { Box, xcss } from '@atlaskit/primitives';
18
+ import Select, { mergeStyles } from '@atlaskit/select';
19
+ import { EmptyComponent } from '../internal';
20
+ import { formatDate, getParsedISO, getPlaceholder, isDateDisabled, parseDate } from '../internal/date-picker-migration';
21
+ import { IndicatorsContainer } from '../internal/indicators-container';
22
+ import { Menu } from '../internal/menu';
23
+ import { getSafeCalendarValue, getShortISOString } from '../internal/parse-date';
24
+ import { makeSingleValue } from '../internal/single-value';
25
+ const packageName = "@atlaskit/datetime-picker";
26
+ const packageVersion = "15.13.1";
27
+ const analyticsAttributes = {
28
+ componentName: 'datePicker',
29
+ packageName,
30
+ packageVersion
31
+ };
32
+ const pickerContainerStyles = css({
33
+ position: 'relative'
34
+ });
35
+ const dropdownIndicatorStyles = xcss({
36
+ minWidth: "var(--ds-space-300, 24px)",
37
+ minHeight: "var(--ds-space-300, 24px)",
38
+ display: 'flex',
39
+ alignItems: 'center',
40
+ justifyContent: 'center'
41
+ });
42
+ const iconContainerStyles = xcss({
43
+ display: 'flex',
44
+ height: '100%',
45
+ position: 'absolute',
46
+ alignItems: 'center',
47
+ flexBasis: 'inherit',
48
+ color: 'color.text.subtlest',
49
+ insetBlockStart: 'space.0',
50
+ insetInlineEnd: 'space.0',
51
+ transition: `color 150ms`,
52
+ ':hover': {
53
+ color: 'color.text.subtle'
54
+ }
55
+ });
56
+ const iconSpacingWithClearButtonStyles = xcss({
57
+ marginInlineEnd: 'space.400'
58
+ });
59
+ const iconSpacingWithoutClearButtonStyles = xcss({
60
+ marginInlineEnd: 'space.050'
61
+ });
62
+
63
+ /**
64
+ * __Date picker__
65
+ *
66
+ * A date picker allows the user to select a particular date.
67
+ *
68
+ * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
69
+ * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
70
+ * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
71
+ */
72
+ const DatePicker = /*#__PURE__*/forwardRef((props, forwardedRef) => {
73
+ const containerRef = useRef(null);
74
+ const calendarRef = useRef(null);
75
+ const calendarButtonRef = useRef(null);
76
+ const {
77
+ appearance = 'default',
78
+ autoFocus = false,
79
+ clearControlLabel = 'Clear',
80
+ hideIcon = false,
81
+ openCalendarLabel = 'Open calendar',
82
+ defaultIsOpen = false,
83
+ defaultValue = '',
84
+ disabled = [],
85
+ disabledDateFilter = _ => false,
86
+ icon: Icon = CalendarIcon,
87
+ id = '',
88
+ innerProps = {},
89
+ inputLabel = 'Date picker',
90
+ inputLabelId,
91
+ isDisabled = false,
92
+ isInvalid = false,
93
+ isRequired = false,
94
+ label = '',
95
+ name = '',
96
+ // eslint-disable-next-line @repo/internal/react/use-noop
97
+ onBlur = _event => {},
98
+ // eslint-disable-next-line @repo/internal/react/use-noop
99
+ onChange: onChangeProp = _value => {},
100
+ // eslint-disable-next-line @repo/internal/react/use-noop
101
+ onFocus = _event => {},
102
+ selectProps = {},
103
+ shouldShowCalendarButton,
104
+ spacing = 'default',
105
+ locale: propLocale = 'en-US',
106
+ value: propValue,
107
+ isOpen: isOpenProp,
108
+ maxDate,
109
+ minDate,
110
+ weekStartDay,
111
+ formatDisplayLabel,
112
+ testId,
113
+ 'aria-describedby': ariaDescribedBy,
114
+ placeholder,
115
+ nextMonthLabel,
116
+ previousMonthLabel,
117
+ ...rest
118
+ } = props;
119
+ const [isOpen, setIsOpen] = useState(defaultIsOpen);
120
+ const [_, setIsFocused] = useState(false);
121
+ const [clearingFromIcon, setClearingFromIcon] = useState(false);
122
+ const [selectInputValue, setSelectInputValue] = useState(selectProps.inputValue);
123
+ const [value, setValue] = useState(propValue || defaultValue);
124
+ const [calendarValue, setCalendarValue] = useState(propValue || defaultValue || getShortISOString(new Date()));
125
+ const [l10n, setL10n] = useState(createLocalizationProvider(propLocale));
126
+ const [locale, setLocale] = useState(propLocale);
127
+ const [shouldSetFocusOnCurrentDay, setShouldSetFocusOnCurrentDay] = useState(false);
128
+ const [isKeyDown, setIsKeyDown] = useState(false);
129
+ const [wasOpenedFromCalendarButton, setWasOpenedFromCalendarButton] = useState(false);
130
+
131
+ // Hack to force update: https://legacy.reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
132
+ const [, forceUpdate] = useReducer(x => !x, true);
133
+ const onChangePropWithAnalytics = usePlatformLeafEventHandler({
134
+ fn: onChangeProp,
135
+ action: 'selectedDate',
136
+ actionSubject: 'datePicker',
137
+ ...analyticsAttributes
138
+ });
139
+ if (propLocale !== locale) {
140
+ setL10n(createLocalizationProvider(propLocale));
141
+ setLocale(propLocale);
142
+ }
143
+ useEffect(() => {
144
+ // We don't want the focus to move if this is a click event
145
+ if (!isKeyDown) {
146
+ return;
147
+ }
148
+ if (isOpen && wasOpenedFromCalendarButton) {
149
+ var _calendarRef$current, _calendarRef$current$;
150
+ setIsKeyDown(false);
151
+ // Focus on the first button within the calendar
152
+ calendarRef === null || calendarRef === void 0 ? void 0 : (_calendarRef$current = calendarRef.current) === null || _calendarRef$current === void 0 ? void 0 : (_calendarRef$current$ = _calendarRef$current.querySelector('button')) === null || _calendarRef$current$ === void 0 ? void 0 : _calendarRef$current$.focus();
153
+ }
154
+ }, [isKeyDown, calendarRef, isOpen, wasOpenedFromCalendarButton]);
155
+ const getValue = () => propValue !== null && propValue !== void 0 ? propValue : value;
156
+ const getIsOpen = () => isOpenProp !== null && isOpenProp !== void 0 ? isOpenProp : isOpen;
157
+ const onCalendarChange = ({
158
+ iso
159
+ }) => {
160
+ setCalendarValue(getParsedISO({
161
+ iso
162
+ }));
163
+ };
164
+ const onCalendarSelect = ({
165
+ iso
166
+ }) => {
167
+ setSelectInputValue('');
168
+ setIsOpen(false);
169
+ setCalendarValue(iso);
170
+ setValue(iso);
171
+ setWasOpenedFromCalendarButton(false);
172
+ onChangePropWithAnalytics(iso);
173
+
174
+ // Yes, this is not ideal. The alternative is to be able to place a ref
175
+ // on the inner input of Select itself, which would require a lot of
176
+ // extra stuff in the Select component for only this one thing. While
177
+ // this would be more "React-y", it doesn't seem to pose any other
178
+ // benefits. Performance-wise, we are only searching within the
179
+ // container, so it's quick.
180
+ if (wasOpenedFromCalendarButton) {
181
+ var _calendarButtonRef$cu;
182
+ (_calendarButtonRef$cu = calendarButtonRef.current) === null || _calendarButtonRef$cu === void 0 ? void 0 : _calendarButtonRef$cu.focus();
183
+ } else {
184
+ var _containerRef$current;
185
+ const innerCombobox = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.querySelector('[role="combobox"]');
186
+ innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
187
+ }
188
+ setIsOpen(false);
189
+ };
190
+ const onInputClick = () => {
191
+ if (!isDisabled && !getIsOpen()) {
192
+ setIsOpen(true);
193
+ setWasOpenedFromCalendarButton(false);
194
+ }
195
+ };
196
+ const onContainerBlur = event => {
197
+ var _containerRef$current2;
198
+ const newlyFocusedElement = event.relatedTarget;
199
+ if (!(containerRef !== null && containerRef !== void 0 && (_containerRef$current2 = containerRef.current) !== null && _containerRef$current2 !== void 0 && _containerRef$current2.contains(newlyFocusedElement))) {
200
+ setIsOpen(false);
201
+ setShouldSetFocusOnCurrentDay(false);
202
+ setWasOpenedFromCalendarButton(false);
203
+ onBlur(event);
204
+ }
205
+ };
206
+ const onContainerFocus = () => {
207
+ setShouldSetFocusOnCurrentDay(false);
208
+ };
209
+ const onSelectBlur = event => {
210
+ var _containerRef$current3;
211
+ const newlyFocusedElement = event.relatedTarget;
212
+ if (clearingFromIcon) {
213
+ // Don't close menu if blurring after the user has clicked clear
214
+ setClearingFromIcon(false);
215
+ } else if (!(containerRef !== null && containerRef !== void 0 && (_containerRef$current3 = containerRef.current) !== null && _containerRef$current3 !== void 0 && _containerRef$current3.contains(newlyFocusedElement))) {
216
+ // Don't close menu if focus is staying within the date picker's
217
+ // container. Makes keyboard accessibility of calendar possible
218
+ setIsOpen(false);
219
+ setIsFocused(false);
220
+ setWasOpenedFromCalendarButton(false);
221
+ }
222
+ };
223
+ const onSelectFocus = event => {
224
+ const value = getValue();
225
+ if (clearingFromIcon) {
226
+ // Don't open menu if focussing after the user has clicked clear
227
+ setClearingFromIcon(false);
228
+ } else {
229
+ // Don't open when focused into via keyboard if the calendar button is present
230
+ setIsOpen(!shouldShowCalendarButton);
231
+ setCalendarValue(value);
232
+ setIsFocused(true);
233
+ setWasOpenedFromCalendarButton(false);
234
+ }
235
+ onFocus(event);
236
+ };
237
+ const onTextInput = event => {
238
+ const inputValue = event.target.value;
239
+ if (inputValue) {
240
+ const parsed = parseDate(inputValue, {
241
+ parseInputValue: rest === null || rest === void 0 ? void 0 : rest.parseInputValue,
242
+ dateFormat: rest === null || rest === void 0 ? void 0 : rest.dateFormat,
243
+ l10n: l10n
244
+ });
245
+ // Only try to set the date if we have month & day
246
+ if (parsed && isValid(parsed)) {
247
+ // We format the parsed date to YYYY-MM-DD here because
248
+ // this is the format expected by the @atlaskit/calendar component
249
+ setCalendarValue(getShortISOString(parsed));
250
+ }
251
+ }
252
+ setIsOpen(true);
253
+ setWasOpenedFromCalendarButton(false);
254
+ };
255
+ const onInputKeyDown = event => {
256
+ const value = getValue();
257
+ const keyPressed = event.key.toLowerCase();
258
+
259
+ // If the input is focused and the calendar is not visible, handle space and enter clicks
260
+ if (!isOpen && (keyPressed === 'enter' || keyPressed === ' ')) {
261
+ setIsOpen(true);
262
+ setWasOpenedFromCalendarButton(false);
263
+ }
264
+ switch (keyPressed) {
265
+ case 'escape':
266
+ // Yes, this is not ideal. The alternative is to be able to place a ref
267
+ // on the inner input of Select itself, which would require a lot of
268
+ // extra stuff in the Select component for only this one thing. While
269
+ // this would be more "React-y", it doesn't seem to pose any other
270
+ // benefits. Performance-wise, we are only searching within the
271
+ // container, so it's quick.
272
+ if (wasOpenedFromCalendarButton) {
273
+ var _calendarButtonRef$cu2;
274
+ (_calendarButtonRef$cu2 = calendarButtonRef.current) === null || _calendarButtonRef$cu2 === void 0 ? void 0 : _calendarButtonRef$cu2.focus();
275
+ } else {
276
+ var _containerRef$current4;
277
+ const innerCombobox = containerRef === null || containerRef === void 0 ? void 0 : (_containerRef$current4 = containerRef.current) === null || _containerRef$current4 === void 0 ? void 0 : _containerRef$current4.querySelector('[role="combobox"]');
278
+ innerCombobox === null || innerCombobox === void 0 ? void 0 : innerCombobox.focus();
279
+ }
280
+ setIsOpen(false);
281
+ setShouldSetFocusOnCurrentDay(false);
282
+ setWasOpenedFromCalendarButton(false);
283
+ break;
284
+ case 'backspace':
285
+ case 'delete':
286
+ {
287
+ const inputCount = 0;
288
+ if (value && event.target instanceof HTMLInputElement && event.target.value.length <= inputCount) {
289
+ // If being cleared from keyboard, don't change behaviour
290
+ setClearingFromIcon(false);
291
+ setValue('');
292
+ }
293
+ break;
294
+ }
295
+ case 'enter':
296
+ if (!isOpen) {
297
+ return;
298
+ }
299
+ // Prevent form submission when a date is selected
300
+ // using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
301
+ // for more details.
302
+ event.preventDefault();
303
+ if (!isDateDisabled(calendarValue, {
304
+ disabled
305
+ })) {
306
+ // Get a safe `calendarValue` in case the value exceeds the maximum
307
+ // allowed by ISO 8601
308
+ const safeCalendarValue = getSafeCalendarValue(calendarValue);
309
+ const valueChanged = safeCalendarValue !== value;
310
+ setSelectInputValue('');
311
+ setIsOpen(false);
312
+ setValue(safeCalendarValue);
313
+ setCalendarValue(safeCalendarValue);
314
+ setWasOpenedFromCalendarButton(wasOpenedFromCalendarButton);
315
+ if (valueChanged) {
316
+ onChangePropWithAnalytics(safeCalendarValue);
317
+ }
318
+ }
319
+ break;
320
+ case 'arrowdown':
321
+ case 'arrowup':
322
+ if (!shouldSetFocusOnCurrentDay) {
323
+ setIsOpen(true);
324
+ setShouldSetFocusOnCurrentDay(true);
325
+ }
326
+ break;
327
+ default:
328
+ break;
329
+ }
330
+ };
331
+ const onCalendarButtonKeyDown = e => {
332
+ // Don't allow an arrow up or down to open the menu, since the input key
333
+ // down handler is actually on the parent.
334
+ if (e.type === 'keydown' && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
335
+ e.stopPropagation();
336
+ }
337
+ // We want to stop this from triggering other keydown events, particularly
338
+ // for space and enter presses. Otherwise, it opens and then closes
339
+ // immediately.
340
+ if (e.type === 'keydown' && (e.key === ' ' || e.key === 'Enter')) {
341
+ e.stopPropagation();
342
+ setIsKeyDown(true);
343
+ setWasOpenedFromCalendarButton(true);
344
+ }
345
+ };
346
+
347
+ // This event handler is triggered from both keydown and click. It's weird.
348
+ const onCalendarButtonClick = e => {
349
+ setIsOpen(!isOpen);
350
+ setWasOpenedFromCalendarButton(true);
351
+ e.stopPropagation();
352
+ };
353
+ const onClear = () => {
354
+ setValue('');
355
+ setCalendarValue(defaultValue || getShortISOString(new Date()));
356
+ if (!hideIcon) {
357
+ setClearingFromIcon(true);
358
+ }
359
+ onChangePropWithAnalytics('');
360
+ };
361
+
362
+ // `unknown` is used because `value` is unused so it does not matter.
363
+ const onSelectChange = (_value, action) => {
364
+ // Used for native clear event in React Select
365
+ // Triggered when clicking ClearIndicator or backspace with no value
366
+ if (action.action === 'clear') {
367
+ onClear();
368
+ }
369
+ };
370
+ const handleSelectInputChange = (selectInputValue, actionMeta) => {
371
+ if (selectProps.onInputChange) {
372
+ selectProps.onInputChange(selectInputValue, actionMeta);
373
+ }
374
+ setSelectInputValue(selectInputValue);
375
+ };
376
+ const getContainerRef = useCallback(ref => {
377
+ const oldRef = containerRef.current;
378
+ containerRef.current = ref;
379
+
380
+ // Cause a re-render if we're getting the container ref for the first time
381
+ // as the layered menu requires it for dimension calculation
382
+ if (oldRef == null && ref != null) {
383
+ forceUpdate();
384
+ }
385
+ }, [containerRef]);
386
+ const getterValue = getValue();
387
+ let actualSelectInputValue;
388
+ actualSelectInputValue = selectInputValue;
389
+ const menuIsOpen = getIsOpen() && !isDisabled;
390
+ const showClearIndicator = Boolean((getterValue || selectInputValue) && !hideIcon);
391
+ let clearIndicator = Icon;
392
+
393
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
394
+ if (fg('platform-visual-refresh-icons')) {
395
+ clearIndicator = props => jsx(Box, {
396
+ xcss: dropdownIndicatorStyles
397
+ }, jsx(Icon, props));
398
+ }
399
+ const dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : clearIndicator;
400
+ const SingleValue = makeSingleValue({
401
+ lang: propLocale
402
+ });
403
+ const selectComponents = {
404
+ DropdownIndicator: shouldShowCalendarButton ? EmptyComponent : dropDownIcon,
405
+ // Only use this new container component if the calendar button is shown.
406
+ // Otherwise, it throws errors downstream for some reason
407
+ ...(shouldShowCalendarButton ? {
408
+ IndicatorsContainer: props => jsx(IndicatorsContainer, _extends({}, props, {
409
+ showClearIndicator: showClearIndicator
410
+ }))
411
+ } : {}),
412
+ Menu,
413
+ SingleValue,
414
+ ...(!showClearIndicator && {
415
+ ClearIndicator: EmptyComponent
416
+ })
417
+ };
418
+ const {
419
+ styles: selectStyles = {}
420
+ } = selectProps;
421
+ const disabledStyle = isDisabled ? {
422
+ pointerEvents: 'none',
423
+ color: "var(--ds-icon-disabled, inherit)"
424
+ } : {};
425
+ const calendarProps = {
426
+ calendarContainerRef: containerRef.current,
427
+ calendarDisabled: disabled,
428
+ calendarDisabledDateFilter: disabledDateFilter,
429
+ calendarMaxDate: maxDate,
430
+ calendarMinDate: minDate,
431
+ calendarRef: calendarRef,
432
+ calendarValue: getterValue && getShortISOString(parseISO(getterValue)),
433
+ calendarView: calendarValue,
434
+ onCalendarChange,
435
+ onCalendarSelect,
436
+ calendarLocale: locale,
437
+ calendarWeekStartDay: weekStartDay,
438
+ shouldSetFocusOnCurrentDay
439
+ };
440
+
441
+ // @ts-ignore -- Argument of type 'StylesConfig<OptionType, false, GroupBase<OptionType>>' is not assignable to parameter of type 'StylesConfig<OptionType, boolean, GroupBase<OptionType>>'.
442
+ const mergedStyles = mergeStyles(selectStyles, {
443
+ control: base => ({
444
+ ...base,
445
+ ...disabledStyle
446
+ }),
447
+ indicatorsContainer: base => ({
448
+ ...base,
449
+ paddingLeft: "var(--ds-space-025, 2px)",
450
+ // ICON_PADDING = 2
451
+ paddingRight: "var(--ds-space-075, 6px)" // 8 - ICON_PADDING = 6
452
+ })
453
+ });
454
+ const initialValue = getterValue ? {
455
+ label: formatDate(getterValue, {
456
+ formatDisplayLabel,
457
+ dateFormat: rest === null || rest === void 0 ? void 0 : rest.dateFormat,
458
+ l10n: l10n
459
+ }),
460
+ value: getterValue
461
+ } : null;
462
+
463
+ // `label` takes precedence of the `inputLabel`
464
+ const fullopenCalendarLabel = label || inputLabel ? `${label || inputLabel}, ${openCalendarLabel}` : openCalendarLabel;
465
+ const openCalendarLabelId = `open-calendar-label--${useId()}`;
466
+ return (
467
+ // These event handlers must be on this element because the events come
468
+ // from different child elements.
469
+ // Until innerProps is removed, it must remain a div rather than a primitive component.
470
+ jsx("div", _extends({}, innerProps, {
471
+ css: pickerContainerStyles,
472
+ "data-testid": testId && `${testId}--container`,
473
+ onBlur: onContainerBlur,
474
+ onFocus: onContainerFocus,
475
+ onClick: onInputClick,
476
+ onInput: onTextInput,
477
+ onKeyDown: onInputKeyDown,
478
+ ref: getContainerRef
479
+ // Since the onclick, onfocus are passed down, adding role="presentation" prevents typecheck errors.
480
+ ,
481
+ role: "presentation"
482
+ }), jsx("input", {
483
+ name: name,
484
+ type: "hidden",
485
+ value: getterValue,
486
+ "data-testid": testId && `${testId}--input`
487
+ }), jsx(Select, _extends({
488
+ appearance: appearance,
489
+ "aria-describedby": ariaDescribedBy,
490
+ label: label || undefined,
491
+ autoFocus: autoFocus,
492
+ clearControlLabel: clearControlLabel,
493
+ closeMenuOnSelect: true
494
+ // For some reason, this and the below `styles` type error _only_ show
495
+ // up when you alter some of the properties in the `selectComponents`
496
+ // object. These errors are still present, and I suspect have always
497
+ // been present, without changing the unrelated code. Ignoring as the
498
+ // component still works as expected despite this error. And also
499
+ // because the select refresh team may solve it later.
500
+ ,
501
+ components: selectComponents,
502
+ enableAnimation: false,
503
+ inputId: id,
504
+ inputValue: actualSelectInputValue,
505
+ isDisabled: isDisabled,
506
+ isRequired: isRequired,
507
+ menuIsOpen: menuIsOpen,
508
+ onBlur: onSelectBlur,
509
+ onChange: onSelectChange,
510
+ onFocus: onSelectFocus,
511
+ onInputChange: handleSelectInputChange,
512
+ placeholder: getPlaceholder({
513
+ placeholder: placeholder,
514
+ l10n: l10n
515
+ })
516
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
517
+ ,
518
+ styles: mergedStyles,
519
+ value: initialValue
520
+ }, selectProps, {
521
+ // These are below the spread because I don't know what is in
522
+ // selectProps or not and what wil be overwritten
523
+ isClearable: true,
524
+ isInvalid: isInvalid,
525
+ spacing: spacing,
526
+ testId: testId
527
+ // These aren't part of `Select`'s API, but we're using them here.
528
+ // @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<...> & { ...; }>'.
529
+ ,
530
+ calendarContainerRef: calendarProps.calendarContainerRef,
531
+ calendarDisabled: calendarProps.calendarDisabled,
532
+ calendarDisabledDateFilter: calendarProps.calendarDisabledDateFilter,
533
+ calendarLocale: calendarProps.calendarLocale,
534
+ calendarMaxDate: calendarProps.calendarMaxDate,
535
+ calendarMinDate: calendarProps.calendarMinDate,
536
+ calendarRef: calendarProps.calendarRef,
537
+ calendarValue: calendarProps.calendarValue,
538
+ calendarView: calendarProps.calendarView,
539
+ calendarWeekStartDay: calendarProps.calendarWeekStartDay,
540
+ nextMonthLabel: nextMonthLabel,
541
+ onCalendarChange: calendarProps.onCalendarChange,
542
+ onCalendarSelect: calendarProps.onCalendarSelect,
543
+ previousMonthLabel: previousMonthLabel,
544
+ shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay
545
+ })), shouldShowCalendarButton && !isDisabled ? jsx(Box, {
546
+ xcss: [iconContainerStyles, value && !hideIcon ? iconSpacingWithClearButtonStyles : iconSpacingWithoutClearButtonStyles]
547
+ }, jsx(IconButton, {
548
+ appearance: "subtle",
549
+ label: !inputLabelId ? fullopenCalendarLabel : openCalendarLabel,
550
+ "aria-labelledby": inputLabelId ? `${inputLabelId} ${openCalendarLabelId}` : undefined,
551
+ id: openCalendarLabelId,
552
+ icon: iconProps => jsx(CalendarIcon, _extends({}, iconProps, {
553
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
554
+ color: "var(--ds-icon, #44546F)"
555
+ })),
556
+ onClick: onCalendarButtonClick,
557
+ onKeyDown: onCalendarButtonKeyDown,
558
+ ref: calendarButtonRef,
559
+ testId: testId && `${testId}--open-calendar-button`
560
+ })) : null)
561
+ );
562
+ });
563
+ export default DatePicker;