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