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