@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,376 +1,9 @@
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
- });
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
376
9
  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.13.0";
20
+ var packageVersion = "16.0.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
- label: label || undefined,
309
+ "aria-label": label || undefined,
310
310
  appearance: appearance,
311
311
  autoFocus: autoFocus,
312
312
  clearControlLabel: clearControlLabel,
@@ -0,0 +1,49 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React, { forwardRef } from 'react';
3
+
4
+ /**
5
+ * Gets all available ref types from two prop sets and returns
6
+ * them in a ref prop
7
+ *
8
+ * @example
9
+ * ```
10
+ * type P1 = { ref: Ref(HTMLDivElement), ... };
11
+ * type P2 = { ref: Ref(HTMLSpanElement), ... };
12
+ *
13
+ * GetRefAttributes(P1, P2) // {ref: Ref(HTMLDivElement | HTMLSpanElement)}
14
+ * ```
15
+ */
16
+
17
+ /**
18
+ * Returns one of components depending on a boolean condition.
19
+ * The result component will be a union of the two props and
20
+ * an or on both ref types.
21
+ *
22
+ * @example
23
+ * ```
24
+ * const Component = componentWithCondition(
25
+ * isBooleanConditionMet,
26
+ * ComponentWithConditionMet,
27
+ * ComponentWithConditionNotMet,
28
+ * );
29
+ *
30
+ * @param condition Function returning boolean value
31
+ * @param componentTrue Component that will be returned if conditionGetter is "true"
32
+ * @param componentFalse Component that will be returned if conditionGetter is "false"
33
+ * @returns Component Depending on a Condition result
34
+ */
35
+ export function componentWithCondition(condition, ComponentTrue, ComponentFalse) {
36
+ var ComponentWithCondition = /*#__PURE__*/forwardRef(function (props, ref) {
37
+ return condition() ? /*#__PURE__*/React.createElement(ComponentTrue, _extends({}, props, {
38
+ ref: ref
39
+ })) : /*#__PURE__*/React.createElement(ComponentFalse, _extends({}, props, {
40
+ ref: ref
41
+ }));
42
+ });
43
+ if (ComponentTrue.name !== '') {
44
+ ComponentWithCondition.displayName = "ComponentWithCondition[".concat(condition.name, "]");
45
+ }
46
+
47
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
48
+ return ComponentWithCondition;
49
+ }
@@ -0,0 +1,110 @@
1
+ /**
2
+ * @jsxRuntime classic
3
+ * @jsx jsx
4
+ */
5
+ import { Component } from 'react';
6
+ import { jsx } from '@emotion/react';
7
+ import { type LocalizationProvider } from '@atlaskit/locale';
8
+ import { type ActionMeta, type InputActionMeta } from '@atlaskit/select';
9
+ import { type DatePickerBaseProps } from '../types';
10
+ type DatePickerProps = typeof datePickerDefaultProps & DatePickerBaseProps;
11
+ interface State {
12
+ isKeyDown: boolean;
13
+ isOpen: boolean;
14
+ /**
15
+ * When being cleared from the icon the DatePicker is blurred.
16
+ * This variable defines whether the default onSelectBlur or onSelectFocus
17
+ * events should behave as normal.
18
+ */
19
+ isFocused: boolean;
20
+ clearingFromIcon: boolean;
21
+ value: string;
22
+ calendarValue: string;
23
+ selectInputValue: string;
24
+ l10n: LocalizationProvider;
25
+ locale: string;
26
+ shouldSetFocusOnCurrentDay: boolean;
27
+ wasOpenedFromCalendarButton: boolean;
28
+ }
29
+ declare const datePickerDefaultProps: {
30
+ defaultIsOpen: boolean;
31
+ defaultValue: string;
32
+ disabled: string[];
33
+ disabledDateFilter: (_: string) => boolean;
34
+ locale: string;
35
+ onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
36
+ onChange: (_value: string) => void;
37
+ onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
38
+ };
39
+ declare class DatePickerComponent extends Component<DatePickerProps, State> {
40
+ static defaultProps: {
41
+ defaultIsOpen: boolean;
42
+ defaultValue: string;
43
+ disabled: string[];
44
+ disabledDateFilter: (_: string) => boolean;
45
+ locale: string;
46
+ onBlur: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
47
+ onChange: (_value: string) => void;
48
+ onFocus: (_event: import("react").FocusEvent<HTMLInputElement, Element>) => void;
49
+ };
50
+ containerRef: HTMLElement | null;
51
+ calendarRef: React.RefObject<HTMLDivElement | null>;
52
+ calendarButtonRef: React.RefObject<HTMLButtonElement>;
53
+ constructor(props: any);
54
+ static getDerivedStateFromProps(nextProps: Readonly<DatePickerProps>, prevState: State): {
55
+ l10n: LocalizationProvider;
56
+ locale: string;
57
+ } | null;
58
+ getValue: () => string;
59
+ getIsOpen: () => boolean;
60
+ onCalendarChange: ({ iso }: {
61
+ iso: string;
62
+ }) => void;
63
+ onCalendarSelect: ({ iso }: {
64
+ iso: string;
65
+ }) => void;
66
+ onInputClick: () => void;
67
+ onContainerBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
68
+ onContainerFocus: () => void;
69
+ onSelectBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
70
+ onSelectFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
71
+ onTextInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
72
+ onInputKeyDown: (event: React.KeyboardEvent<HTMLElement>) => void;
73
+ onCalendarButtonKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => void;
74
+ onCalendarButtonClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
75
+ onClear: () => void;
76
+ onSelectChange: (_value: unknown, action: ActionMeta) => void;
77
+ handleSelectInputChange: (selectInputValue: string, actionMeta: InputActionMeta) => void;
78
+ getContainerRef: (ref: HTMLElement | null) => void;
79
+ render(): jsx.JSX.Element;
80
+ }
81
+ export { DatePickerComponent as DatePickerWithoutAnalytics };
82
+ /**
83
+ * __Date picker__
84
+ *
85
+ * A date picker allows the user to select a particular date.
86
+ *
87
+ * - [Examples](https://atlassian.design/components/datetime-picker/date-picker/examples)
88
+ * - [Code](https://atlassian.design/components/datetime-picker/date-picker/code)
89
+ * - [Usage](https://atlassian.design/components/datetime-picker/date-picker/usage)
90
+ */
91
+ declare const DatePicker: import("react").ForwardRefExoticComponent<Omit<Pick<Omit<{
92
+ defaultIsOpen: boolean;
93
+ defaultValue: string;
94
+ disabled: string[];
95
+ disabledDateFilter: (_: string) => boolean;
96
+ locale: string;
97
+ onBlur: (_event: React.FocusEvent<HTMLInputElement>) => void;
98
+ onChange: (_value: string) => void;
99
+ onFocus: (_event: React.FocusEvent<HTMLInputElement>) => void;
100
+ } & DatePickerBaseProps, 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"> & {
101
+ disabled?: string[] | undefined;
102
+ defaultValue?: string | undefined;
103
+ onFocus?: (((_event: React.FocusEvent<HTMLInputElement>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
104
+ onBlur?: (((_event: React.FocusEvent<HTMLInputElement>) => void) & import("react").FocusEventHandler<HTMLInputElement>) | undefined;
105
+ onChange?: (((_value: string) => void) & ((value: string) => void)) | undefined;
106
+ disabledDateFilter?: (((_: string) => boolean) & ((date: string) => boolean)) | undefined;
107
+ locale?: string | undefined;
108
+ defaultIsOpen?: boolean | undefined;
109
+ } & {} & import("react").RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "ref"> & import("react").RefAttributes<any>>;
110
+ export default DatePicker;
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
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>>;
20
+ export default DatePicker;
@@ -1,20 +1,21 @@
1
1
  /// <reference types="react" />
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>>;
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>>;
20
21
  export default DatePicker;