@atlaskit/datetime-picker 15.12.1 → 15.13.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 (44) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/components/date-picker.js +639 -7
  3. package/dist/cjs/components/date-time-picker.js +379 -9
  4. package/dist/cjs/components/time-picker.js +2 -2
  5. package/dist/es2019/components/date-picker.js +570 -5
  6. package/dist/es2019/components/date-time-picker.js +347 -6
  7. package/dist/es2019/components/time-picker.js +2 -2
  8. package/dist/esm/components/date-picker.js +637 -7
  9. package/dist/esm/components/date-time-picker.js +375 -8
  10. package/dist/esm/components/time-picker.js +2 -2
  11. package/dist/types/components/date-picker.d.ts +18 -19
  12. package/dist/types/components/date-time-picker.d.ts +14 -31
  13. package/dist/types/internal/fixed-layer.d.ts +1 -1
  14. package/dist/types/internal/single-value.d.ts +2 -2
  15. package/dist/types-ts4.5/components/date-picker.d.ts +18 -19
  16. package/dist/types-ts4.5/components/date-time-picker.d.ts +14 -31
  17. package/dist/types-ts4.5/internal/fixed-layer.d.ts +1 -1
  18. package/dist/types-ts4.5/internal/single-value.d.ts +2 -2
  19. package/package.json +5 -11
  20. package/dist/cjs/components/date-picker-class.js +0 -696
  21. package/dist/cjs/components/date-picker-fc.js +0 -648
  22. package/dist/cjs/components/date-time-picker-class.js +0 -436
  23. package/dist/cjs/components/date-time-picker-fc.js +0 -394
  24. package/dist/cjs/internal/ff-component.js +0 -58
  25. package/dist/es2019/components/date-picker-class.js +0 -660
  26. package/dist/es2019/components/date-picker-fc.js +0 -572
  27. package/dist/es2019/components/date-time-picker-class.js +0 -400
  28. package/dist/es2019/components/date-time-picker-fc.js +0 -354
  29. package/dist/es2019/internal/ff-component.js +0 -47
  30. package/dist/esm/components/date-picker-class.js +0 -691
  31. package/dist/esm/components/date-picker-fc.js +0 -639
  32. package/dist/esm/components/date-time-picker-class.js +0 -434
  33. package/dist/esm/components/date-time-picker-fc.js +0 -384
  34. package/dist/esm/internal/ff-component.js +0 -49
  35. package/dist/types/components/date-picker-class.d.ts +0 -115
  36. package/dist/types/components/date-picker-fc.d.ts +0 -20
  37. package/dist/types/components/date-time-picker-class.d.ts +0 -85
  38. package/dist/types/components/date-time-picker-fc.d.ts +0 -15
  39. package/dist/types/internal/ff-component.d.ts +0 -34
  40. package/dist/types-ts4.5/components/date-picker-class.d.ts +0 -115
  41. package/dist/types-ts4.5/components/date-picker-fc.d.ts +0 -20
  42. package/dist/types-ts4.5/components/date-time-picker-class.d.ts +0 -85
  43. package/dist/types-ts4.5/components/date-time-picker-fc.d.ts +0 -15
  44. package/dist/types-ts4.5/internal/ff-component.d.ts +0 -34
@@ -1,9 +1,376 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
- import { componentWithCondition } from '../internal/ff-component';
3
- import DateTimePickerOld from './date-time-picker-class';
4
- import DateTimePickerNew from './date-time-picker-fc';
5
- var DateTimePicker = componentWithCondition(function () {
6
- return fg('dst-date-time-picker-use-functional-component');
7
- }, DateTimePickerNew, DateTimePickerOld);
8
- // eslint-disable-next-line @repo/internal/react/require-jsdoc
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
+ var _excluded = ["selectProps"],
6
+ _excluded2 = ["selectProps"];
7
+ 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; }
8
+ 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) { _defineProperty(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; }
9
+ import React, { forwardRef, useCallback, useEffect, useState } from 'react';
10
+ import { format, isValid, parseISO } from 'date-fns';
11
+ import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next';
12
+ import { IconButton } from '@atlaskit/button/new';
13
+ import SelectClearIcon from '@atlaskit/icon/utility/migration/cross-circle--select-clear';
14
+ import { Box, Inline, xcss } from '@atlaskit/primitives';
15
+ import { mergeStyles } from '@atlaskit/select';
16
+ import { formatDateTimeZoneIntoIso } from '../internal';
17
+ import { DateTimePickerContainer } from '../internal/date-time-picker-container';
18
+ import { convertTokens } from '../internal/parse-tokens';
19
+ import DatePicker from './date-picker';
20
+ import TimePicker from './time-picker';
21
+ var packageName = "@atlaskit/datetime-picker";
22
+ var packageVersion = "15.13.0";
23
+ var analyticsAttributes = {
24
+ componentName: 'dateTimePicker',
25
+ packageName: packageName,
26
+ packageVersion: packageVersion
27
+ };
28
+
29
+ // Make DatePicker 50% the width of DateTimePicker
30
+ // If rendering an icon container, shrink the TimePicker
31
+ var datePickerContainerStyles = xcss({
32
+ flexBasis: '50%',
33
+ flexGrow: 1,
34
+ flexShrink: 0
35
+ });
36
+ var timePickerContainerStyles = xcss({
37
+ flexBasis: '50%',
38
+ flexGrow: 1
39
+ });
40
+ var iconContainerStyles = xcss({
41
+ display: 'flex',
42
+ alignItems: 'center',
43
+ flexBasis: 'inherit'
44
+ });
45
+
46
+ // react-select overrides (via @atlaskit/select).
47
+ var styles = {
48
+ control: function control(style) {
49
+ return _objectSpread(_objectSpread({}, style), {}, {
50
+ backgroundColor: 'transparent',
51
+ border: 2,
52
+ borderRadius: 0,
53
+ paddingLeft: 0,
54
+ ':hover': {
55
+ backgroundColor: 'transparent',
56
+ cursor: 'inherit'
57
+ }
58
+ });
59
+ }
60
+ };
61
+ export var datePickerDefaultAriaLabel = 'Date';
62
+ export var timePickerDefaultAriaLabel = 'Time';
63
+
64
+ /**
65
+ * __Date time picker__
66
+ *
67
+ * A date time picker allows the user to select an associated date and time.
68
+ *
69
+ * - [Examples](https://atlassian.design/components/datetime-picker/examples)
70
+ * - [Code](https://atlassian.design/components/datetime-picker/code)
71
+ * - [Usage](https://atlassian.design/components/datetime-picker/usage)
72
+ */
73
+ var DateTimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
74
+ var ariaDescribedBy = _ref['aria-describedby'],
75
+ _ref$appearance = _ref.appearance,
76
+ appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
77
+ _ref$autoFocus = _ref.autoFocus,
78
+ autoFocus = _ref$autoFocus === void 0 ? false : _ref$autoFocus,
79
+ _ref$clearControlLabe = _ref.clearControlLabel,
80
+ clearControlLabel = _ref$clearControlLabe === void 0 ? 'clear' : _ref$clearControlLabe,
81
+ _ref$datePickerProps = _ref.datePickerProps,
82
+ datePickerPropsWithSelectProps = _ref$datePickerProps === void 0 ? {} : _ref$datePickerProps,
83
+ _ref$defaultValue = _ref.defaultValue,
84
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
85
+ _ref$id = _ref.id,
86
+ id = _ref$id === void 0 ? '' : _ref$id,
87
+ _ref$innerProps = _ref.innerProps,
88
+ innerProps = _ref$innerProps === void 0 ? {} : _ref$innerProps,
89
+ _ref$isDisabled = _ref.isDisabled,
90
+ isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
91
+ _ref$isInvalid = _ref.isInvalid,
92
+ isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
93
+ _ref$isRequired = _ref.isRequired,
94
+ isRequired = _ref$isRequired === void 0 ? false : _ref$isRequired,
95
+ _ref$name = _ref.name,
96
+ name = _ref$name === void 0 ? '' : _ref$name,
97
+ _ref$onBlur = _ref.onBlur,
98
+ onBlur = _ref$onBlur === void 0 ? function (_event) {} : _ref$onBlur,
99
+ _ref$onChange = _ref.onChange,
100
+ onChangeProp = _ref$onChange === void 0 ? function (_value) {} : _ref$onChange,
101
+ _ref$onFocus = _ref.onFocus,
102
+ onFocus = _ref$onFocus === void 0 ? function (_event) {} : _ref$onFocus,
103
+ providedParseValue = _ref.parseValue,
104
+ _ref$spacing = _ref.spacing,
105
+ spacing = _ref$spacing === void 0 ? 'default' : _ref$spacing,
106
+ _ref$locale = _ref.locale,
107
+ locale = _ref$locale === void 0 ? 'en-US' : _ref$locale,
108
+ testId = _ref.testId,
109
+ _ref$timePickerProps = _ref.timePickerProps,
110
+ timePickerPropsWithSelectProps = _ref$timePickerProps === void 0 ? {} : _ref$timePickerProps,
111
+ providedValue = _ref.value;
112
+ var _useState = useState((datePickerPropsWithSelectProps === null || datePickerPropsWithSelectProps === void 0 ? void 0 : datePickerPropsWithSelectProps.defaultValue) || ''),
113
+ _useState2 = _slicedToArray(_useState, 2),
114
+ dateValue = _useState2[0],
115
+ setDateValue = _useState2[1];
116
+ var _useState3 = useState(false),
117
+ _useState4 = _slicedToArray(_useState3, 2),
118
+ isFocused = _useState4[0],
119
+ setIsFocused = _useState4[1];
120
+ var _useState5 = useState((timePickerPropsWithSelectProps === null || timePickerPropsWithSelectProps === void 0 ? void 0 : timePickerPropsWithSelectProps.defaultValue) || ''),
121
+ _useState6 = _slicedToArray(_useState5, 2),
122
+ timeValue = _useState6[0],
123
+ setTimeValue = _useState6[1];
124
+ var _useState7 = useState(defaultValue || ''),
125
+ _useState8 = _slicedToArray(_useState7, 2),
126
+ value = _useState8[0],
127
+ setValue = _useState8[1];
128
+ var _useState9 = useState(''),
129
+ _useState10 = _slicedToArray(_useState9, 2),
130
+ zoneValue = _useState10[0],
131
+ setZoneValue = _useState10[1];
132
+ useEffect(function () {
133
+ if (providedValue) {
134
+ setValue(providedValue);
135
+ }
136
+ }, [providedValue]);
137
+ var parseValue = useCallback(function (value, providedDateValue, providedTimeValue, providedZoneValue) {
138
+ if (providedParseValue) {
139
+ var parsedFromFn = providedParseValue(value, providedDateValue, providedTimeValue, providedZoneValue);
140
+ // This handles cases found in Jira where the parse function actually does
141
+ // nothing and returns undefined. The previous `getSafeState` function
142
+ // just spread the values over the state, but if it returned `undefined`,
143
+ // it would just rely on the previous state values. Considering this is
144
+ // what is input to this function anyway, this is a safe way to handle
145
+ // this, colocate the behavior, and not rely on `getSafeState`.
146
+ return parsedFromFn || {
147
+ dateValue: providedDateValue,
148
+ timeValue: providedTimeValue,
149
+ zoneValue: providedZoneValue
150
+ };
151
+ }
152
+ var parsed = parseISO(value);
153
+ return isValid(parsed) ? {
154
+ dateValue: format(parsed, convertTokens('YYYY-MM-DD')),
155
+ timeValue: format(parsed, convertTokens('HH:mm')),
156
+ zoneValue: format(parsed, convertTokens('ZZ'))
157
+ } : {
158
+ dateValue: dateValue,
159
+ timeValue: timeValue,
160
+ zoneValue: zoneValue
161
+ };
162
+ }, [providedParseValue, dateValue, timeValue, zoneValue]);
163
+ useEffect(function () {
164
+ var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
165
+ setDateValue(parsedValues.dateValue);
166
+ setTimeValue(parsedValues.timeValue);
167
+ setZoneValue(parsedValues.zoneValue);
168
+ }, [value, dateValue, timeValue, zoneValue, parseValue]);
169
+ var onDateBlur = function onDateBlur(event) {
170
+ setIsFocused(false);
171
+ onBlur(event);
172
+ if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onBlur) {
173
+ datePickerPropsWithSelectProps.onBlur(event);
174
+ }
175
+ };
176
+ var onTimeBlur = function onTimeBlur(event) {
177
+ setIsFocused(false);
178
+ onBlur(event);
179
+ if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onBlur) {
180
+ timePickerPropsWithSelectProps.onBlur(event);
181
+ }
182
+ };
183
+ var onDateFocus = function onDateFocus(event) {
184
+ setIsFocused(false);
185
+ onFocus(event);
186
+ if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onFocus) {
187
+ datePickerPropsWithSelectProps.onFocus(event);
188
+ }
189
+ };
190
+ var onTimeFocus = function onTimeFocus(event) {
191
+ setIsFocused(false);
192
+ onFocus(event);
193
+ if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onFocus) {
194
+ timePickerPropsWithSelectProps.onFocus(event);
195
+ }
196
+ };
197
+ var onDateChange = function onDateChange(dateValue) {
198
+ var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
199
+ onValueChange({
200
+ providedDateValue: dateValue,
201
+ providedTimeValue: parsedValues.timeValue,
202
+ providedZoneValue: parsedValues.zoneValue
203
+ });
204
+ if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onChange) {
205
+ datePickerPropsWithSelectProps.onChange(dateValue);
206
+ }
207
+ };
208
+ var onTimeChange = function onTimeChange(timeValue) {
209
+ var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
210
+ onValueChange({
211
+ providedDateValue: parsedValues.dateValue,
212
+ providedTimeValue: timeValue,
213
+ providedZoneValue: parsedValues.zoneValue
214
+ });
215
+ if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onChange) {
216
+ timePickerPropsWithSelectProps.onChange(timeValue);
217
+ }
218
+ };
219
+ var onClear = function onClear() {
220
+ var parsedValues = parseValue(value, dateValue, timeValue, zoneValue);
221
+ onValueChange({
222
+ providedDateValue: '',
223
+ providedTimeValue: '',
224
+ providedZoneValue: parsedValues.zoneValue
225
+ });
226
+ if (datePickerPropsWithSelectProps !== null && datePickerPropsWithSelectProps !== void 0 && datePickerPropsWithSelectProps.onChange) {
227
+ datePickerPropsWithSelectProps.onChange('');
228
+ }
229
+ if (timePickerPropsWithSelectProps !== null && timePickerPropsWithSelectProps !== void 0 && timePickerPropsWithSelectProps.onChange) {
230
+ timePickerPropsWithSelectProps.onChange('');
231
+ }
232
+ };
233
+ var onChangePropWithAnalytics = usePlatformLeafEventHandler(_objectSpread({
234
+ fn: onChangeProp,
235
+ action: 'selectedDate',
236
+ actionSubject: 'datePicker'
237
+ }, analyticsAttributes));
238
+ var onValueChange = function onValueChange(_ref2) {
239
+ var providedDateValue = _ref2.providedDateValue,
240
+ providedTimeValue = _ref2.providedTimeValue,
241
+ providedZoneValue = _ref2.providedZoneValue;
242
+ setDateValue(providedDateValue);
243
+ setTimeValue(providedTimeValue);
244
+ setZoneValue(providedZoneValue);
245
+ if (providedDateValue && providedTimeValue) {
246
+ var _value2 = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, providedZoneValue);
247
+ var _parseValue = parseValue(_value2, providedDateValue, providedTimeValue, providedZoneValue),
248
+ parsedZone = _parseValue.zoneValue;
249
+ var valueWithValidZone = formatDateTimeZoneIntoIso(providedDateValue, providedTimeValue, parsedZone);
250
+ setValue(valueWithValidZone);
251
+ onChangePropWithAnalytics(valueWithValidZone);
252
+ // If the date or time value was cleared when there is an existing datetime value, then clear the value.
253
+ } else if (value) {
254
+ setValue('');
255
+ onChangePropWithAnalytics('');
256
+ }
257
+ };
258
+ var datePickerSelectProps = datePickerPropsWithSelectProps.selectProps,
259
+ datePickerProps = _objectWithoutProperties(datePickerPropsWithSelectProps, _excluded);
260
+ var datePickerAriaDescribedBy = datePickerProps['aria-describedby'] || ariaDescribedBy;
261
+ var datePickerLabel = datePickerProps.label || datePickerDefaultAriaLabel;
262
+ var mergedDatePickerSelectProps = _objectSpread(_objectSpread({}, datePickerSelectProps), {}, {
263
+ styles: mergeStyles(styles, datePickerSelectProps === null || datePickerSelectProps === void 0 ? void 0 : datePickerSelectProps.styles)
264
+ });
265
+ var timePickerSelectProps = timePickerPropsWithSelectProps.selectProps,
266
+ timePickerProps = _objectWithoutProperties(timePickerPropsWithSelectProps, _excluded2);
267
+ var timePickerAriaDescribedBy = timePickerProps['aria-describedby'] || ariaDescribedBy;
268
+ var timePickerLabel = timePickerProps.label || timePickerDefaultAriaLabel;
269
+ var mergedTimePickerSelectProps = _objectSpread(_objectSpread({}, timePickerSelectProps), {}, {
270
+ styles: mergeStyles(styles, timePickerSelectProps === null || timePickerSelectProps === void 0 ? void 0 : timePickerSelectProps.styles)
271
+ });
272
+
273
+ // Render DateTimePicker's IconContainer when a value has been filled
274
+ // Don't use Date or TimePicker's because they can't be customised
275
+ var isClearable = Boolean(dateValue || timeValue);
276
+ return /*#__PURE__*/React.createElement(DateTimePickerContainer, {
277
+ appearance: appearance,
278
+ isDisabled: isDisabled,
279
+ isFocused: isFocused,
280
+ isInvalid: isInvalid,
281
+ testId: testId,
282
+ innerProps: innerProps
283
+ }, /*#__PURE__*/React.createElement("input", {
284
+ name: name,
285
+ type: "hidden",
286
+ value: value,
287
+ "data-testid": testId && "".concat(testId, "--input")
288
+ }), /*#__PURE__*/React.createElement(Box, {
289
+ xcss: datePickerContainerStyles
290
+ }, /*#__PURE__*/React.createElement(DatePicker, {
291
+ appearance: appearance,
292
+ "aria-describedby": datePickerAriaDescribedBy,
293
+ autoFocus: datePickerProps.autoFocus || autoFocus,
294
+ dateFormat: datePickerProps.dateFormat,
295
+ defaultIsOpen: datePickerProps.defaultIsOpen,
296
+ defaultValue: datePickerProps.defaultValue,
297
+ disabled: datePickerProps.disabled,
298
+ disabledDateFilter: datePickerProps.disabledDateFilter,
299
+ formatDisplayLabel: datePickerProps.formatDisplayLabel,
300
+ hideIcon: datePickerProps.hideIcon || true,
301
+ icon: datePickerProps.icon,
302
+ id: datePickerProps.id || id,
303
+ innerProps: datePickerProps.innerProps,
304
+ inputLabel: datePickerProps.inputLabel,
305
+ inputLabelId: datePickerProps.inputLabelId,
306
+ isDisabled: datePickerProps.isDisabled || isDisabled,
307
+ isInvalid: datePickerProps.isInvalid || isInvalid,
308
+ isOpen: datePickerProps.isOpen,
309
+ isRequired: datePickerProps.isRequired || isRequired,
310
+ label: datePickerLabel,
311
+ locale: datePickerProps.locale || locale,
312
+ maxDate: datePickerProps.maxDate,
313
+ minDate: datePickerProps.minDate,
314
+ name: datePickerProps.name,
315
+ nextMonthLabel: datePickerProps.nextMonthLabel,
316
+ onBlur: onDateBlur,
317
+ onChange: onDateChange,
318
+ onFocus: onDateFocus,
319
+ openCalendarLabel: datePickerProps.openCalendarLabel,
320
+ parseInputValue: datePickerProps.parseInputValue,
321
+ placeholder: datePickerProps.placeholder,
322
+ previousMonthLabel: datePickerProps.previousMonthLabel,
323
+ selectProps: mergedDatePickerSelectProps,
324
+ shouldShowCalendarButton: datePickerProps.shouldShowCalendarButton,
325
+ spacing: datePickerProps.spacing || spacing,
326
+ testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
327
+ value: dateValue,
328
+ weekStartDay: datePickerProps.weekStartDay
329
+ })), /*#__PURE__*/React.createElement(Box, {
330
+ xcss: timePickerContainerStyles
331
+ }, /*#__PURE__*/React.createElement(TimePicker, {
332
+ appearance: timePickerProps.appearance || appearance,
333
+ "aria-describedby": timePickerAriaDescribedBy,
334
+ autoFocus: timePickerProps.autoFocus,
335
+ defaultIsOpen: timePickerProps.defaultIsOpen,
336
+ defaultValue: timePickerProps.defaultValue,
337
+ formatDisplayLabel: timePickerProps.formatDisplayLabel,
338
+ hideIcon: timePickerProps.hideIcon || true,
339
+ id: timePickerProps.id,
340
+ innerProps: timePickerProps.innerProps,
341
+ isDisabled: timePickerProps.isDisabled || isDisabled,
342
+ isInvalid: timePickerProps.isInvalid || isInvalid,
343
+ isOpen: timePickerProps.isOpen,
344
+ isRequired: timePickerProps.isRequired || isRequired,
345
+ label: timePickerLabel,
346
+ locale: timePickerProps.locale || locale,
347
+ name: timePickerProps.name,
348
+ onBlur: onTimeBlur,
349
+ onChange: onTimeChange,
350
+ onFocus: onTimeFocus,
351
+ parseInputValue: timePickerProps.parseInputValue,
352
+ placeholder: timePickerProps.placeholder,
353
+ selectProps: mergedTimePickerSelectProps,
354
+ spacing: timePickerProps.spacing || spacing,
355
+ testId: timePickerProps.testId || testId && "".concat(testId, "--timepicker"),
356
+ timeFormat: timePickerProps.timeFormat,
357
+ timeIsEditable: timePickerProps.timeIsEditable,
358
+ times: timePickerProps.times,
359
+ value: timeValue
360
+ })), isClearable && !isDisabled ? /*#__PURE__*/React.createElement(Inline, {
361
+ xcss: iconContainerStyles
362
+ }, /*#__PURE__*/React.createElement(IconButton, {
363
+ appearance: "subtle",
364
+ label: clearControlLabel,
365
+ icon: function icon(iconProps) {
366
+ return /*#__PURE__*/React.createElement(SelectClearIcon, _extends({}, iconProps, {
367
+ color: "var(--ds-text-subtlest, #626F86)",
368
+ LEGACY_size: "small"
369
+ }));
370
+ },
371
+ onClick: onClear,
372
+ testId: testId && "".concat(testId, "--icon--container"),
373
+ tabIndex: -1
374
+ })) : null);
375
+ });
9
376
  export default DateTimePicker;
@@ -17,7 +17,7 @@ import parseTime from '../internal/parse-time';
17
17
  import { convertTokens } from '../internal/parse-tokens';
18
18
  import { makeSingleValue } from '../internal/single-value';
19
19
  var packageName = "@atlaskit/datetime-picker";
20
- var packageVersion = "15.12.1";
20
+ var packageVersion = "15.13.0";
21
21
  var menuStyles = {
22
22
  /* Need to remove default absolute positioning as that causes issues with position fixed */
23
23
  position: 'static',
@@ -306,7 +306,7 @@ var TimePicker = /*#__PURE__*/forwardRef(function (_ref, ref) {
306
306
  onKeyDown: onSelectKeyDown
307
307
  }), /*#__PURE__*/React.createElement(SelectComponent, _extends({
308
308
  "aria-describedby": ariaDescribedBy,
309
- "aria-label": label || undefined,
309
+ label: label || undefined,
310
310
  appearance: appearance,
311
311
  autoFocus: autoFocus,
312
312
  clearControlLabel: clearControlLabel,
@@ -1,21 +1,20 @@
1
1
  /// <reference types="react" />
2
- declare const DatePicker: import("react").FC<Omit<Omit<import("./date-picker-fc").DatePickerProps, "ref"> & import("react").RefAttributes<unknown>, "ref"> & Omit<Omit<Pick<Omit<{
3
- defaultIsOpen: boolean;
4
- defaultValue: string;
5
- disabled: string[];
6
- disabledDateFilter: (_: string) => boolean;
7
- locale: string;
8
- onBlur: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
9
- onChange: (_value: string) => void;
10
- onFocus: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
11
- } & import("..").DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "label" | "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "appearance" | "isDisabled" | "innerProps" | "selectProps" | "autoFocus" | "id" | "aria-describedby" | "value" | "testId" | "icon" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "clearControlLabel" | "isInvalid" | "isRequired" | "name" | "spacing" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & {
12
- disabled?: string[] | undefined;
13
- defaultValue?: string | undefined;
14
- onFocus?: (((_event: import("react").FocusEvent<HTMLInputElement, Element>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
15
- onBlur?: (((_event: import("react").FocusEvent<HTMLInputElement, Element>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
16
- onChange?: (((_value: string) => void) & ((value: string) => void)) | undefined;
17
- disabledDateFilter?: (((_: string) => boolean) & ((date: string) => boolean)) | undefined;
18
- locale?: string | undefined;
19
- defaultIsOpen?: boolean | undefined;
20
- } & {} & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & import("react").RefAttributes<any>, "ref"> & import("react").RefAttributes<any>>;
2
+ import { type DropdownIndicatorProps, type OptionType } from '@atlaskit/select';
3
+ import { type DatePickerBaseProps, type DateTimePickerSelectProps } from '../types';
4
+ export type DatePickerProps = DatePickerBaseProps & {
5
+ icon?: React.ComponentType<DropdownIndicatorProps<OptionType>>;
6
+ selectProps?: DateTimePickerSelectProps & {
7
+ inputValue?: string;
8
+ };
9
+ };
10
+ /**
11
+ * __Date picker__
12
+ *
13
+ * A date picker allows the user to select a particular date.
14
+ *
15
+ * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
16
+ * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
17
+ * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
18
+ */
19
+ declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & import("react").RefAttributes<unknown>>;
21
20
  export default DatePicker;
@@ -1,32 +1,15 @@
1
- /// <reference types="react" />
2
- declare const DateTimePicker: import("react").FC<Omit<Omit<import("..").DateTimePickerProps, "ref"> & import("react").RefAttributes<unknown>, "ref"> & Omit<Omit<Omit<Pick<Omit<import("..").DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & {
3
- appearance?: import("..").Appearance | undefined;
4
- isDisabled?: boolean | undefined;
5
- innerProps?: import("react").AllHTMLAttributes<HTMLElement> | undefined;
6
- defaultValue?: string | undefined;
7
- autoFocus?: boolean | undefined;
8
- id?: string | undefined;
9
- 'aria-describedby'?: string | undefined;
10
- onFocus?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
11
- onBlur?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
12
- onChange?: ((value: string) => void) | undefined;
13
- value?: string | undefined;
14
- testId?: string | undefined;
15
- locale?: string | undefined;
16
- clearControlLabel?: string | undefined;
17
- isInvalid?: boolean | undefined;
18
- isRequired?: boolean | undefined;
19
- name?: string | undefined;
20
- spacing?: import("..").Spacing | undefined;
21
- datePickerProps?: import("..").DatePickerProps | undefined;
22
- timePickerProps?: import("..").TimePickerProps | undefined;
23
- parseValue?: ((dateTimeValue: string, date: string, time: string, timezone: string) => {
24
- dateValue: string;
25
- timeValue: string;
26
- zoneValue: string;
27
- }) | undefined;
28
- } & {
29
- ref?: import("react").Ref<any> | undefined;
30
- createAnalyticsEvent?: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | undefined;
31
- }, "ref"> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & import("react").RefAttributes<any>, "ref"> & import("react").RefAttributes<any>>;
1
+ import React from 'react';
2
+ import { type DateTimePickerBaseProps } from '../types';
3
+ export declare const datePickerDefaultAriaLabel = "Date";
4
+ export declare const timePickerDefaultAriaLabel = "Time";
5
+ /**
6
+ * __Date time picker__
7
+ *
8
+ * A date time picker allows the user to select an associated date and time.
9
+ *
10
+ * - [Examples](https://atlassian.design/components/datetime-picker/examples)
11
+ * - [Code](https://atlassian.design/components/datetime-picker/code)
12
+ * - [Usage](https://atlassian.design/components/datetime-picker/usage)
13
+ */
14
+ declare const DateTimePicker: React.ForwardRefExoticComponent<Omit<DateTimePickerBaseProps, "ref"> & React.RefAttributes<unknown>>;
32
15
  export default DateTimePicker;
@@ -28,6 +28,6 @@ interface FixedLayerProps {
28
28
  export default class FixedLayer extends React.Component<FixedLayerProps> {
29
29
  update: () => void;
30
30
  componentDidUpdate(prevProps: any): void;
31
- render(): JSX.Element;
31
+ render(): React.JSX.Element;
32
32
  }
33
33
  export {};
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type OptionType, type SingleValueProps } from '@atlaskit/select';
3
3
  /**
4
4
  * This creates a functional component that `react-select` will use to make the
@@ -6,4 +6,4 @@ import { type OptionType, type SingleValueProps } from '@atlaskit/select';
6
6
  */
7
7
  export declare const makeSingleValue: ({ lang }: {
8
8
  lang: string;
9
- }) => ({ children, className, clearValue, cx, data, getStyles, getValue, hasValue, isDisabled, isMulti, isRtl, options, selectOption, selectProps, setValue, ...rest }: SingleValueProps<OptionType, false>) => JSX.Element;
9
+ }) => ({ children, className, clearValue, cx, data, getStyles, getValue, hasValue, isDisabled, isMulti, isRtl, options, selectOption, selectProps, setValue, ...rest }: SingleValueProps<OptionType, false>) => React.JSX.Element;
@@ -1,21 +1,20 @@
1
1
  /// <reference types="react" />
2
- declare const DatePicker: import("react").FC<Omit<Omit<import("./date-picker-fc").DatePickerProps, "ref"> & import("react").RefAttributes<unknown>, "ref"> & Omit<Omit<Pick<Omit<{
3
- defaultIsOpen: boolean;
4
- defaultValue: string;
5
- disabled: string[];
6
- disabledDateFilter: (_: string) => boolean;
7
- locale: string;
8
- onBlur: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
9
- onChange: (_value: string) => void;
10
- onFocus: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
11
- } & import("..").DatePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, "label" | "parseInputValue" | "dateFormat" | "formatDisplayLabel" | "placeholder" | "appearance" | "isDisabled" | "innerProps" | "selectProps" | "autoFocus" | "id" | "aria-describedby" | "value" | "testId" | "icon" | "maxDate" | "minDate" | "nextMonthLabel" | "previousMonthLabel" | "weekStartDay" | "clearControlLabel" | "isInvalid" | "isRequired" | "name" | "spacing" | "isOpen" | "inputLabel" | "inputLabelId" | "openCalendarLabel" | "shouldShowCalendarButton" | "hideIcon"> & {
12
- disabled?: string[] | undefined;
13
- defaultValue?: string | undefined;
14
- onFocus?: (((_event: import("react").FocusEvent<HTMLInputElement, Element>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
15
- onBlur?: (((_event: import("react").FocusEvent<HTMLInputElement, Element>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
16
- onChange?: (((_value: string) => void) & ((value: string) => void)) | undefined;
17
- disabledDateFilter?: (((_: string) => boolean) & ((date: string) => boolean)) | undefined;
18
- locale?: string | undefined;
19
- defaultIsOpen?: boolean | undefined;
20
- } & {} & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & import("react").RefAttributes<any>, "ref"> & import("react").RefAttributes<any>>;
2
+ import { type DropdownIndicatorProps, type OptionType } from '@atlaskit/select';
3
+ import { type DatePickerBaseProps, type DateTimePickerSelectProps } from '../types';
4
+ export type DatePickerProps = DatePickerBaseProps & {
5
+ icon?: React.ComponentType<DropdownIndicatorProps<OptionType>>;
6
+ selectProps?: DateTimePickerSelectProps & {
7
+ inputValue?: string;
8
+ };
9
+ };
10
+ /**
11
+ * __Date picker__
12
+ *
13
+ * A date picker allows the user to select a particular date.
14
+ *
15
+ * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
16
+ * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
17
+ * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
18
+ */
19
+ declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<DatePickerProps, "ref"> & import("react").RefAttributes<unknown>>;
21
20
  export default DatePicker;
@@ -1,32 +1,15 @@
1
- /// <reference types="react" />
2
- declare const DateTimePicker: import("react").FC<Omit<Omit<import("..").DateTimePickerProps, "ref"> & import("react").RefAttributes<unknown>, "ref"> & Omit<Omit<Omit<Pick<Omit<import("..").DateTimePickerProps, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps>, never> & {
3
- appearance?: import("..").Appearance | undefined;
4
- isDisabled?: boolean | undefined;
5
- innerProps?: import("react").AllHTMLAttributes<HTMLElement> | undefined;
6
- defaultValue?: string | undefined;
7
- autoFocus?: boolean | undefined;
8
- id?: string | undefined;
9
- 'aria-describedby'?: string | undefined;
10
- onFocus?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
11
- onBlur?: import("react").FocusEventHandler<HTMLInputElement> | undefined;
12
- onChange?: ((value: string) => void) | undefined;
13
- value?: string | undefined;
14
- testId?: string | undefined;
15
- locale?: string | undefined;
16
- clearControlLabel?: string | undefined;
17
- isInvalid?: boolean | undefined;
18
- isRequired?: boolean | undefined;
19
- name?: string | undefined;
20
- spacing?: import("..").Spacing | undefined;
21
- datePickerProps?: import("..").DatePickerProps | undefined;
22
- timePickerProps?: import("..").TimePickerProps | undefined;
23
- parseValue?: ((dateTimeValue: string, date: string, time: string, timezone: string) => {
24
- dateValue: string;
25
- timeValue: string;
26
- zoneValue: string;
27
- }) | undefined;
28
- } & {
29
- ref?: import("react").Ref<any> | undefined;
30
- createAnalyticsEvent?: import("@atlaskit/analytics-next").CreateUIAnalyticsEvent | undefined;
31
- }, "ref"> & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & import("react").RefAttributes<any>, "ref"> & import("react").RefAttributes<any>>;
1
+ import React from 'react';
2
+ import { type DateTimePickerBaseProps } from '../types';
3
+ export declare const datePickerDefaultAriaLabel = "Date";
4
+ export declare const timePickerDefaultAriaLabel = "Time";
5
+ /**
6
+ * __Date time picker__
7
+ *
8
+ * A date time picker allows the user to select an associated date and time.
9
+ *
10
+ * - [Examples](https://atlassian.design/components/datetime-picker/examples)
11
+ * - [Code](https://atlassian.design/components/datetime-picker/code)
12
+ * - [Usage](https://atlassian.design/components/datetime-picker/usage)
13
+ */
14
+ declare const DateTimePicker: React.ForwardRefExoticComponent<Omit<DateTimePickerBaseProps, "ref"> & React.RefAttributes<unknown>>;
32
15
  export default DateTimePicker;
@@ -28,6 +28,6 @@ interface FixedLayerProps {
28
28
  export default class FixedLayer extends React.Component<FixedLayerProps> {
29
29
  update: () => void;
30
30
  componentDidUpdate(prevProps: any): void;
31
- render(): JSX.Element;
31
+ render(): React.JSX.Element;
32
32
  }
33
33
  export {};
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  import { type OptionType, type SingleValueProps } from '@atlaskit/select';
3
3
  /**
4
4
  * This creates a functional component that `react-select` will use to make the
@@ -6,4 +6,4 @@ import { type OptionType, type SingleValueProps } from '@atlaskit/select';
6
6
  */
7
7
  export declare const makeSingleValue: ({ lang }: {
8
8
  lang: string;
9
- }) => ({ children, className, clearValue, cx, data, getStyles, getValue, hasValue, isDisabled, isMulti, isRtl, options, selectOption, selectProps, setValue, ...rest }: SingleValueProps<OptionType, false>) => JSX.Element;
9
+ }) => ({ children, className, clearValue, cx, data, getStyles, getValue, hasValue, isDisabled, isMulti, isRtl, options, selectOption, selectProps, setValue, ...rest }: SingleValueProps<OptionType, false>) => React.JSX.Element;