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