@atlaskit/datetime-picker 13.11.1 → 13.11.3

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 (30) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/components/date-picker.js +51 -38
  3. package/dist/cjs/components/date-time-picker.js +98 -52
  4. package/dist/cjs/components/time-picker.js +14 -14
  5. package/dist/cjs/internal/fixed-layer-menu.js +50 -4
  6. package/dist/cjs/internal/menu.js +24 -9
  7. package/dist/cjs/internal/single-value.js +37 -4
  8. package/dist/es2019/components/date-picker.js +50 -36
  9. package/dist/es2019/components/date-time-picker.js +91 -55
  10. package/dist/es2019/components/time-picker.js +14 -17
  11. package/dist/es2019/internal/fixed-layer-menu.js +48 -2
  12. package/dist/es2019/internal/menu.js +53 -32
  13. package/dist/es2019/internal/single-value.js +36 -3
  14. package/dist/esm/components/date-picker.js +51 -38
  15. package/dist/esm/components/date-time-picker.js +98 -52
  16. package/dist/esm/components/time-picker.js +14 -14
  17. package/dist/esm/internal/fixed-layer-menu.js +50 -4
  18. package/dist/esm/internal/menu.js +25 -9
  19. package/dist/esm/internal/single-value.js +37 -4
  20. package/dist/types/components/date-picker.d.ts +2 -12
  21. package/dist/types/components/date-time-picker.d.ts +2 -3
  22. package/dist/types/components/time-picker.d.ts +2 -1
  23. package/dist/types/internal/fixed-layer-menu.d.ts +1 -1
  24. package/dist/types/internal/single-value.d.ts +1 -1
  25. package/dist/types-ts4.5/components/date-picker.d.ts +2 -12
  26. package/dist/types-ts4.5/components/date-time-picker.d.ts +2 -3
  27. package/dist/types-ts4.5/components/time-picker.d.ts +2 -1
  28. package/dist/types-ts4.5/internal/fixed-layer-menu.d.ts +1 -1
  29. package/dist/types-ts4.5/internal/single-value.d.ts +1 -1
  30. package/package.json +6 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/datetime-picker
2
2
 
3
+ ## 13.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#132041](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/132041)
8
+ [`ce77b41a18a18`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ce77b41a18a18) -
9
+ Refactoring internal state management within the pickers.
10
+
11
+ ## 13.11.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [#130953](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/130953)
16
+ [`a6c1f10b9f4b7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a6c1f10b9f4b7) -
17
+ Refactor internal types to make spread props explicit.
18
+
3
19
  ## 13.11.1
4
20
 
5
21
  ### Patch Changes
@@ -18,7 +18,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
18
18
  var _react = require("react");
19
19
  var _react2 = require("@emotion/react");
20
20
  var _dateFns = require("date-fns");
21
- var _pick = _interopRequireDefault(require("lodash/pick"));
22
21
  var _analyticsNext = require("@atlaskit/analytics-next");
23
22
  var _calendar = _interopRequireDefault(require("@atlaskit/icon/glyph/calendar"));
24
23
  var _locale = require("@atlaskit/locale");
@@ -38,7 +37,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
38
37
  * @jsx jsx
39
38
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
40
39
  var packageName = "@atlaskit/datetime-picker";
41
- var packageVersion = "13.11.1";
40
+ var packageVersion = "13.11.3";
42
41
  var datePickerDefaultProps = {
43
42
  appearance: 'default',
44
43
  autoFocus: false,
@@ -80,8 +79,13 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
80
79
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "containerRef", null);
81
80
  // All state needs to be accessed via this function so that the state is mapped from props
82
81
  // correctly to allow controlled/uncontrolled usage.
83
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSafeState", function () {
84
- return _objectSpread(_objectSpread(_objectSpread({}, _this.state), (0, _pick.default)(_this.props, ['value', 'isOpen'])), (0, _pick.default)(_this.props.selectProps, ['inputValue']));
82
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
83
+ var _this$props$value;
84
+ return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
85
+ });
86
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getIsOpen", function () {
87
+ var _this$props$isOpen;
88
+ return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
85
89
  });
86
90
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isDateDisabled", function (date) {
87
91
  return _this.props.disabled.indexOf(date) > -1;
@@ -131,7 +135,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
131
135
  });
132
136
  });
133
137
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputClick", function () {
134
- if (!_this.props.isDisabled && !_this.getSafeState().isOpen) {
138
+ if (!_this.props.isDisabled && !_this.getIsOpen()) {
135
139
  _this.setState({
136
140
  isOpen: true
137
141
  });
@@ -156,7 +160,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
156
160
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectBlur", function (event) {
157
161
  var _this$containerRef3;
158
162
  var newlyFocusedElement = event.relatedTarget;
159
- if (_this.getSafeState().clearingFromIcon) {
163
+ if (_this.state.clearingFromIcon) {
160
164
  // Don't close menu if blurring after the user has clicked clear
161
165
  _this.setState({
162
166
  clearingFromIcon: false
@@ -171,9 +175,8 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
171
175
  }
172
176
  });
173
177
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectFocus", function (event) {
174
- var _this$getSafeState = _this.getSafeState(),
175
- clearingFromIcon = _this$getSafeState.clearingFromIcon,
176
- value = _this$getSafeState.value;
178
+ var clearingFromIcon = _this.state.clearingFromIcon;
179
+ var value = _this.getValue();
177
180
  if (clearingFromIcon) {
178
181
  // Don't open menu if focussing after the user has clicked clear
179
182
  _this.setState({
@@ -207,9 +210,8 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
207
210
  });
208
211
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputKeyDown", function (event) {
209
212
  var _this$containerRef4;
210
- var _this$getSafeState2 = _this.getSafeState(),
211
- value = _this$getSafeState2.value,
212
- calendarValue = _this$getSafeState2.calendarValue;
213
+ var calendarValue = _this.state.calendarValue;
214
+ var value = _this.getValue();
213
215
  var keyPressed = event.key.toLowerCase();
214
216
 
215
217
  // If the input is focused and the calendar is not visible, handle space and enter clicks
@@ -337,8 +339,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
337
339
  if (parseInputValue) {
338
340
  return parseInputValue(date, dateFormat || _internal.defaultDateFormat);
339
341
  }
340
- var _this$getSafeState3 = _this.getSafeState(),
341
- l10n = _this$getSafeState3.l10n;
342
+ var l10n = _this.state.l10n;
342
343
  return l10n.parseDate(date);
343
344
  });
344
345
  /**
@@ -352,8 +353,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
352
353
  var _this$props2 = _this.props,
353
354
  formatDisplayLabel = _this$props2.formatDisplayLabel,
354
355
  dateFormat = _this$props2.dateFormat;
355
- var _this$getSafeState4 = _this.getSafeState(),
356
- l10n = _this$getSafeState4.l10n;
356
+ var l10n = _this.state.l10n;
357
357
  if (formatDisplayLabel) {
358
358
  return formatDisplayLabel(value, dateFormat || _internal.defaultDateFormat);
359
359
  }
@@ -365,8 +365,7 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
365
365
  if (placeholder) {
366
366
  return placeholder;
367
367
  }
368
- var _this$getSafeState5 = _this.getSafeState(),
369
- l10n = _this$getSafeState5.l10n;
368
+ var l10n = _this.state.l10n;
370
369
  return l10n.formatDate(_internal.placeholderDatetime);
371
370
  });
372
371
  _this.state = {
@@ -408,14 +407,13 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
408
407
  locale = _this$props3.locale,
409
408
  testId = _this$props3.testId,
410
409
  weekStartDay = _this$props3.weekStartDay;
411
- var _this$getSafeState6 = this.getSafeState(),
412
- value = _this$getSafeState6.value,
413
- calendarValue = _this$getSafeState6.calendarValue,
414
- isOpen = _this$getSafeState6.isOpen,
415
- selectInputValue = _this$getSafeState6.selectInputValue;
410
+ var _this$state = this.state,
411
+ calendarValue = _this$state.calendarValue,
412
+ selectInputValue = _this$state.selectInputValue;
413
+ var value = this.getValue();
416
414
  var actualSelectInputValue;
417
415
  actualSelectInputValue = selectInputValue;
418
- var menuIsOpen = isOpen && !isDisabled;
416
+ var menuIsOpen = this.getIsOpen() && !isDisabled;
419
417
  var showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
420
418
  var dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
421
419
  var SingleValue = (0, _singleValue.makeSingleValue)({
@@ -447,8 +445,6 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
447
445
  onCalendarSelect: this.onCalendarSelect,
448
446
  calendarLocale: locale,
449
447
  calendarWeekStartDay: weekStartDay,
450
- nextMonthLabel: nextMonthLabel,
451
- previousMonthLabel: previousMonthLabel,
452
448
  shouldSetFocusOnCurrentDay: this.state.shouldSetFocusOnCurrentDay
453
449
  };
454
450
  var mergedStyles = (0, _select.mergeStyles)(selectStyles, {
@@ -485,31 +481,48 @@ var DatePickerComponent = exports.DatePickerWithoutAnalytics = /*#__PURE__*/func
485
481
  value: value,
486
482
  "data-testid": testId && "".concat(testId, "--input")
487
483
  }), (0, _react2.jsx)(_select.default, (0, _extends2.default)({
484
+ appearance: this.props.appearance,
488
485
  "aria-describedby": ariaDescribedBy,
489
486
  "aria-label": label || undefined,
490
- appearance: this.props.appearance,
491
- enableAnimation: false,
492
- menuIsOpen: menuIsOpen,
493
- closeMenuOnSelect: true,
494
487
  autoFocus: autoFocus,
488
+ closeMenuOnSelect: true,
489
+ components: selectComponents,
490
+ enableAnimation: false,
495
491
  inputId: id,
492
+ inputValue: actualSelectInputValue,
496
493
  isDisabled: isDisabled,
494
+ menuIsOpen: menuIsOpen,
497
495
  onBlur: this.onSelectBlur,
496
+ onChange: this.onSelectChange,
498
497
  onFocus: this.onSelectFocus,
499
- inputValue: actualSelectInputValue,
500
498
  onInputChange: this.handleSelectInputChange,
501
- components: selectComponents,
502
- onChange: this.onSelectChange
503
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
504
- ,
505
- styles: mergedStyles,
506
499
  placeholder: this.getPlaceholder(),
500
+ styles: mergedStyles,
507
501
  value: initialValue
508
- }, selectProps, calendarProps, {
502
+ }, selectProps, {
503
+ // These are below the spread because I don't know what is in
504
+ // selectProps or not and what wil be overwritten
509
505
  isClearable: true,
510
- spacing: spacing,
511
506
  isInvalid: isInvalid,
507
+ spacing: spacing,
512
508
  testId: testId
509
+ // These aren't part of `Select`'s API, but we're using them here.
510
+ ,
511
+ calendarContainerRef: calendarProps.calendarContainerRef,
512
+ calendarDisabled: calendarProps.calendarDisabled,
513
+ calendarDisabledDateFilter: calendarProps.calendarDisabledDateFilter,
514
+ calendarLocale: calendarProps.calendarLocale,
515
+ calendarMaxDate: calendarProps.calendarMaxDate,
516
+ calendarMinDate: calendarProps.calendarMinDate,
517
+ calendarRef: calendarProps.calendarRef,
518
+ calendarValue: calendarProps.calendarValue,
519
+ calendarView: calendarProps.calendarView,
520
+ calendarWeekStartDay: calendarProps.calendarWeekStartDay,
521
+ nextMonthLabel: nextMonthLabel,
522
+ onCalendarChange: calendarProps.onCalendarChange,
523
+ onCalendarSelect: calendarProps.onCalendarSelect,
524
+ previousMonthLabel: previousMonthLabel,
525
+ shouldSetFocusOnCurrentDay: calendarProps.shouldSetFocusOnCurrentDay
513
526
  })))
514
527
  );
515
528
  }
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.timePickerDefaultAriaLabel = exports.default = exports.datePickerDefaultAriaLabel = exports.DateTimePickerWithoutAnalytics = void 0;
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
10
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
@@ -16,7 +15,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
16
15
  var _react = _interopRequireDefault(require("react"));
17
16
  var _react2 = require("@emotion/react");
18
17
  var _dateFns = require("date-fns");
19
- var _pick = _interopRequireDefault(require("lodash/pick"));
20
18
  var _analyticsNext = require("@atlaskit/analytics-next");
21
19
  var _selectClear = _interopRequireDefault(require("@atlaskit/icon/glyph/select-clear"));
22
20
  var _select = require("@atlaskit/select");
@@ -34,7 +32,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
34
32
  * @jsx jsx
35
33
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
36
34
  var packageName = "@atlaskit/datetime-picker";
37
- var packageVersion = "13.11.1";
35
+ var packageVersion = "13.11.3";
38
36
  // Make DatePicker 50% the width of DateTimePicker
39
37
  // If rendering an icon container, shrink the TimePicker
40
38
  var datePickerContainerStyles = (0, _react2.css)({
@@ -127,9 +125,12 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
127
125
  });
128
126
  // All state needs to be accessed via this function so that the state is mapped from props
129
127
  // correctly to allow controlled/uncontrolled usage.
130
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSafeState", function () {
131
- var mappedState = _objectSpread(_objectSpread({}, _this.state), (0, _pick.default)(_this.props, ['value']));
132
- return _objectSpread(_objectSpread({}, mappedState), _this.parseValue(mappedState.value, mappedState.dateValue, mappedState.timeValue, mappedState.zoneValue));
128
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getParsedValues", function () {
129
+ return _this.parseValue(_this.getValue(), _this.state.dateValue, _this.state.timeValue, _this.state.zoneValue);
130
+ });
131
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
132
+ var _this$props$value;
133
+ return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
133
134
  });
134
135
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onBlur", function (event) {
135
136
  _this.setState({
@@ -144,20 +145,28 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
144
145
  _this.props.onFocus(event);
145
146
  });
146
147
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDateChange", function (dateValue) {
147
- _this.onValueChange(_objectSpread(_objectSpread({}, _this.getSafeState()), {}, {
148
- dateValue: dateValue
149
- }));
148
+ var parsedValues = _this.getParsedValues();
149
+ _this.onValueChange({
150
+ dateValue: dateValue,
151
+ timeValue: parsedValues.timeValue,
152
+ zoneValue: parsedValues.zoneValue
153
+ });
150
154
  });
151
155
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTimeChange", function (timeValue) {
152
- _this.onValueChange(_objectSpread(_objectSpread({}, _this.getSafeState()), {}, {
153
- timeValue: timeValue
154
- }));
156
+ var parsedValues = _this.getParsedValues();
157
+ _this.onValueChange({
158
+ dateValue: parsedValues.dateValue,
159
+ timeValue: timeValue,
160
+ zoneValue: parsedValues.zoneValue
161
+ });
155
162
  });
156
163
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClear", function () {
157
- _this.onValueChange(_objectSpread(_objectSpread({}, _this.getSafeState()), {}, {
164
+ var parsedValues = _this.getParsedValues();
165
+ _this.onValueChange({
166
+ dateValue: '',
158
167
  timeValue: '',
159
- dateValue: ''
160
- }));
168
+ zoneValue: parsedValues.zoneValue
169
+ });
161
170
  });
162
171
  return _this;
163
172
  }
@@ -165,7 +174,18 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
165
174
  key: "parseValue",
166
175
  value: function parseValue(value, dateValue, timeValue, zoneValue) {
167
176
  if (this.props.parseValue) {
168
- return this.props.parseValue(value, dateValue, timeValue, zoneValue);
177
+ var parsedFromFn = this.props.parseValue(value, dateValue, timeValue, zoneValue);
178
+ // This handles cases found in Jira where the parse function actually does
179
+ // nothing and returns undefined. The previous `getSafeState` function
180
+ // just spread the values over the state, but if it returned `undefined`,
181
+ // it would just rely on the previous state values. Considering this is
182
+ // what is input to this function anyway, this is a safe way to handle
183
+ // this, colocate the behavior, and not rely on `getSafeState`.
184
+ return parsedFromFn || {
185
+ dateValue: dateValue,
186
+ timeValue: timeValue,
187
+ zoneValue: zoneValue
188
+ };
169
189
  }
170
190
  var parsed = (0, _dateFns.parseISO)(value);
171
191
  return (0, _dateFns.isValid)(parsed) ? {
@@ -199,7 +219,7 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
199
219
  });
200
220
  this.props.onChange(valueWithValidZone);
201
221
  // If the date or time value was cleared when there is an existing datetime value, then clear the value.
202
- } else if (this.getSafeState().value) {
222
+ } else if (this.getValue()) {
203
223
  this.setState({
204
224
  value: ''
205
225
  });
@@ -229,11 +249,11 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
229
249
  timePickerProps = _this$props.timePickerProps,
230
250
  timePickerSelectProps = _this$props.timePickerSelectProps,
231
251
  times = _this$props.times;
232
- var _this$getSafeState = this.getSafeState(),
233
- isFocused = _this$getSafeState.isFocused,
234
- value = _this$getSafeState.value,
235
- dateValue = _this$getSafeState.dateValue,
236
- timeValue = _this$getSafeState.timeValue;
252
+ var value = this.getValue();
253
+ var isFocused = this.state.isFocused;
254
+ var parsedValues = this.getParsedValues();
255
+ var dateValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.dateValue;
256
+ var timeValue = parsedValues === null || parsedValues === void 0 ? void 0 : parsedValues.timeValue;
237
257
  var _datePickerSelectProp = datePickerSelectProps.styles,
238
258
  datePickerStyles = _datePickerSelectProp === void 0 ? {} : _datePickerSelectProp;
239
259
  var _timePickerSelectProp = timePickerSelectProps.styles,
@@ -266,41 +286,67 @@ var DateTimePickerComponent = exports.DateTimePickerWithoutAnalytics = /*#__PURE
266
286
  "data-testid": testId && "".concat(testId, "--input")
267
287
  }), (0, _react2.jsx)("div", {
268
288
  css: datePickerContainerStyles
269
- }, (0, _react2.jsx)(_datePicker.default, (0, _extends2.default)({
289
+ }, (0, _react2.jsx)(_datePicker.default, {
270
290
  appearance: appearance,
271
- autoFocus: autoFocus,
272
- dateFormat: dateFormat,
273
- hideIcon: true,
274
- id: id,
275
- isDisabled: isDisabled,
276
- isInvalid: isInvalid,
277
- locale: locale,
278
- onBlur: this.onBlur,
279
- onChange: this.onDateChange,
280
- onFocus: this.onFocus,
291
+ autoFocus: datePickerProps.autoFocus || autoFocus,
292
+ dateFormat: datePickerProps.dateFormat || dateFormat,
293
+ defaultIsOpen: datePickerProps.defaultIsOpen,
294
+ defaultValue: datePickerProps.defaultValue,
295
+ disabled: datePickerProps.disabled,
296
+ disabledDateFilter: datePickerProps.disabledDateFilter,
297
+ formatDisplayLabel: datePickerProps.formatDisplayLabel,
298
+ hideIcon: datePickerProps.hideIcon || true,
299
+ icon: datePickerProps.icon,
300
+ id: datePickerProps.id || id,
301
+ innerProps: datePickerProps.innerProps,
302
+ isDisabled: datePickerProps.isDisabled || isDisabled,
303
+ isInvalid: datePickerProps.isInvalid || isInvalid,
304
+ isOpen: datePickerProps.isOpen,
305
+ locale: datePickerProps.locale || locale,
306
+ maxDate: datePickerProps.maxDate,
307
+ minDate: datePickerProps.minDate,
308
+ name: datePickerProps.name,
309
+ nextMonthLabel: datePickerProps.nextMonthLabel,
310
+ onBlur: datePickerProps.onBlur || this.onBlur,
311
+ onChange: datePickerProps.onChange || this.onDateChange,
312
+ onFocus: datePickerProps.onFocus || this.onFocus,
313
+ parseInputValue: datePickerProps.parseInputValue,
314
+ placeholder: datePickerProps.placeholder,
315
+ previousMonthLabel: datePickerProps.previousMonthLabel,
281
316
  selectProps: mergedDatePickerSelectProps,
282
- spacing: spacing,
283
- testId: testId && "".concat(testId, "--datepicker"),
284
- value: dateValue
285
- }, datePickerProps))), (0, _react2.jsx)("div", {
317
+ spacing: datePickerProps.spacing || spacing,
318
+ testId: testId && "".concat(testId, "--datepicker") || datePickerProps.testId,
319
+ value: dateValue,
320
+ weekStartDay: datePickerProps.weekStartDay
321
+ })), (0, _react2.jsx)("div", {
286
322
  css: timePickerContainerStyles
287
- }, (0, _react2.jsx)(_timePicker.default, (0, _extends2.default)({
288
- appearance: appearance,
289
- hideIcon: true,
290
- isDisabled: isDisabled,
291
- isInvalid: isInvalid,
292
- locale: locale,
293
- onBlur: this.onBlur,
294
- onChange: this.onTimeChange,
295
- onFocus: this.onFocus,
323
+ }, (0, _react2.jsx)(_timePicker.default, {
324
+ appearance: timePickerProps.appearance || appearance,
325
+ autoFocus: timePickerProps.autoFocus,
326
+ defaultIsOpen: timePickerProps.defaultIsOpen,
327
+ defaultValue: timePickerProps.defaultValue,
328
+ formatDisplayLabel: timePickerProps.formatDisplayLabel,
329
+ hideIcon: timePickerProps.hideIcon || true,
330
+ id: timePickerProps.id,
331
+ innerProps: timePickerProps.innerProps,
332
+ isDisabled: timePickerProps.isDisabled || isDisabled,
333
+ isInvalid: timePickerProps.isInvalid || isInvalid,
334
+ isOpen: timePickerProps.isOpen,
335
+ locale: timePickerProps.locale || locale,
336
+ name: timePickerProps.name,
337
+ onBlur: timePickerProps.onBlur || this.onBlur,
338
+ onChange: timePickerProps.onChange || this.onTimeChange,
339
+ onFocus: timePickerProps.onFocus || this.onFocus,
340
+ parseInputValue: timePickerProps.parseInputValue,
341
+ placeholder: timePickerProps.placeholder,
296
342
  selectProps: mergedTimePickerSelectProps,
297
- spacing: spacing,
298
- testId: testId && "".concat(testId, "--timepicker"),
299
- timeFormat: timeFormat,
300
- timeIsEditable: timeIsEditable,
301
- times: times,
343
+ spacing: timePickerProps.spacing || spacing,
344
+ testId: timePickerProps.testId || testId && "".concat(testId, "--timepicker"),
345
+ timeFormat: timePickerProps.timeFormat || timeFormat,
346
+ timeIsEditable: timePickerProps.timeIsEditable || timeIsEditable,
347
+ times: timePickerProps.times || times,
302
348
  value: timeValue
303
- }, timePickerProps))), isClearable && !isDisabled ? (0, _react2.jsx)("button", {
349
+ })), isClearable && !isDisabled ? (0, _react2.jsx)("button", {
304
350
  css: iconContainerStyles,
305
351
  onClick: this.onClear,
306
352
  "data-testid": testId && "".concat(testId, "--icon--container"),
@@ -17,7 +17,6 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
17
17
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
18
  var _react = _interopRequireDefault(require("react"));
19
19
  var _dateFns = require("date-fns");
20
- var _pick = _interopRequireDefault(require("lodash/pick"));
21
20
  var _analyticsNext = require("@atlaskit/analytics-next");
22
21
  var _locale = require("@atlaskit/locale");
23
22
  var _select = _interopRequireWildcard(require("@atlaskit/select"));
@@ -36,7 +35,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
36
35
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } // eslint-disable-next-line no-restricted-imports
37
36
  // eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
38
37
  var packageName = "@atlaskit/datetime-picker";
39
- var packageVersion = "13.11.1";
38
+ var packageVersion = "13.11.3";
40
39
  var menuStyles = {
41
40
  /* Need to remove default absolute positioning as that causes issues with position fixed */
42
41
  position: 'static',
@@ -94,8 +93,13 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
94
93
  });
95
94
  // All state needs to be accessed via this function so that the state is mapped from props
96
95
  // correctly to allow controlled/uncontrolled usage.
97
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSafeState", function () {
98
- return _objectSpread(_objectSpread({}, _this.state), (0, _pick.default)(_this.props, ['value', 'isOpen']));
96
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getValue", function () {
97
+ var _this$props$value;
98
+ return (_this$props$value = _this.props.value) !== null && _this$props$value !== void 0 ? _this$props$value : _this.state.value;
99
+ });
100
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getIsOpen", function () {
101
+ var _this$props$isOpen;
102
+ return (_this$props$isOpen = _this.props.isOpen) !== null && _this$props$isOpen !== void 0 ? _this$props$isOpen : _this.state.isOpen;
99
103
  });
100
104
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onChange", function (newValue, action) {
101
105
  var rawValue = newValue ? newValue.value || newValue : '';
@@ -138,7 +142,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
138
142
  });
139
143
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMenuOpen", function () {
140
144
  // Don't open menu after the user has clicked clear
141
- if (_this.getSafeState().clearingFromIcon) {
145
+ if (_this.state.clearingFromIcon) {
142
146
  _this.setState({
143
147
  clearingFromIcon: false
144
148
  });
@@ -150,7 +154,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
150
154
  });
151
155
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMenuClose", function () {
152
156
  // Don't close menu after the user has clicked clear
153
- if (_this.getSafeState().clearingFromIcon) {
157
+ if (_this.state.clearingFromIcon) {
154
158
  _this.setState({
155
159
  clearingFromIcon: false
156
160
  });
@@ -184,7 +188,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
184
188
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectKeyDown", function (event) {
185
189
  var key = event.key;
186
190
  var keyPressed = key.toLowerCase();
187
- if (_this.getSafeState().clearingFromIcon && (keyPressed === 'backspace' || keyPressed === 'delete')) {
191
+ if (_this.state.clearingFromIcon && (keyPressed === 'backspace' || keyPressed === 'delete')) {
188
192
  // If being cleared from keyboard, don't change behaviour
189
193
  _this.setState({
190
194
  clearingFromIcon: false
@@ -219,10 +223,8 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
219
223
  times = _this$props2.times;
220
224
  var ICON_PADDING = 2;
221
225
  var l10n = (0, _locale.createLocalizationProvider)(locale);
222
- var _this$getSafeState = this.getSafeState(),
223
- _this$getSafeState$va = _this$getSafeState.value,
224
- value = _this$getSafeState$va === void 0 ? '' : _this$getSafeState$va,
225
- isOpen = _this$getSafeState.isOpen;
226
+ var value = this.getValue() || '';
227
+ var isOpen = this.getIsOpen();
226
228
  var _selectProps$styles = selectProps.styles,
227
229
  selectStyles = _selectProps$styles === void 0 ? {} : _selectProps$styles,
228
230
  otherSelectProps = (0, _objectWithoutProperties2.default)(selectProps, _excluded);
@@ -321,9 +323,7 @@ var TimePickerComponent = exports.TimePickerWithoutAnalytics = /*#__PURE__*/func
321
323
  placeholder: placeholder || l10n.formatTime(_internal.placeholderDatetime),
322
324
  styles: mergedStyles,
323
325
  value: initialValue,
324
- spacing: spacing
325
- // @ts-ignore caused by prop not part of @atlaskit/select
326
- ,
326
+ spacing: spacing,
327
327
  fixedLayerRef: this.containerRef,
328
328
  isInvalid: isInvalid,
329
329
  testId: testId
@@ -10,7 +10,7 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
10
10
  var _react = require("@emotion/react");
11
11
  var _select = require("@atlaskit/select");
12
12
  var _fixedLayer = _interopRequireDefault(require("../internal/fixed-layer"));
13
- var _excluded = ["selectProps"];
13
+ var _excluded = ["className", "clearValue", "cx", "getStyles", "getValue", "hasValue", "innerProps", "innerRef", "isLoading", "isMulti", "isRtl", "maxMenuHeight", "menuPlacement", "menuPosition", "menuShouldScrollIntoView", "minMenuHeight", "options", "placement", "selectOption", "selectProps", "setValue", "theme", "children"];
14
14
  /**
15
15
  * @jsxRuntime classic
16
16
  * @jsx jsx
@@ -20,14 +20,60 @@ var _excluded = ["selectProps"];
20
20
  * This is the fixed layer menu used in the time picker.
21
21
  */
22
22
  var FixedLayerMenu = exports.FixedLayerMenu = function FixedLayerMenu(_ref) {
23
- var selectProps = _ref.selectProps,
23
+ var className = _ref.className,
24
+ clearValue = _ref.clearValue,
25
+ cx = _ref.cx,
26
+ getStyles = _ref.getStyles,
27
+ getValue = _ref.getValue,
28
+ hasValue = _ref.hasValue,
29
+ innerProps = _ref.innerProps,
30
+ innerRef = _ref.innerRef,
31
+ isLoading = _ref.isLoading,
32
+ isMulti = _ref.isMulti,
33
+ isRtl = _ref.isRtl,
34
+ maxMenuHeight = _ref.maxMenuHeight,
35
+ menuPlacement = _ref.menuPlacement,
36
+ menuPosition = _ref.menuPosition,
37
+ menuShouldScrollIntoView = _ref.menuShouldScrollIntoView,
38
+ minMenuHeight = _ref.minMenuHeight,
39
+ options = _ref.options,
40
+ placement = _ref.placement,
41
+ selectOption = _ref.selectOption,
42
+ selectProps = _ref.selectProps,
43
+ setValue = _ref.setValue,
44
+ theme = _ref.theme,
45
+ children = _ref.children,
24
46
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
25
47
  return (0, _react.jsx)(_fixedLayer.default, {
26
48
  inputValue: selectProps.inputValue,
27
49
  containerRef: selectProps.fixedLayerRef,
28
50
  content: (0, _react.jsx)(_select.components.Menu, (0, _extends2.default)({}, rest, {
29
- menuShouldScrollIntoView: false
30
- })),
51
+ // eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
52
+ className: className,
53
+ clearValue: clearValue,
54
+ cx: cx,
55
+ getStyles: getStyles,
56
+ getValue: getValue,
57
+ hasValue: hasValue,
58
+ innerProps: innerProps,
59
+ innerRef: innerRef,
60
+ isLoading: isLoading,
61
+ isMulti: isMulti,
62
+ isRtl: isRtl,
63
+ maxMenuHeight: maxMenuHeight,
64
+ menuPlacement: menuPlacement,
65
+ menuPosition: menuPosition,
66
+ menuShouldScrollIntoView: false || menuShouldScrollIntoView,
67
+ minMenuHeight: minMenuHeight,
68
+ options: options,
69
+ placement: placement,
70
+ selectOption: selectOption,
71
+ selectProps: selectProps,
72
+ setValue: setValue
73
+ // eslint-disable-next-line @repo/internal/react/no-unsafe-overrides, @atlaskit/design-system/no-unsafe-style-overrides
74
+ ,
75
+ theme: theme
76
+ }), children),
31
77
  testId: selectProps.testId
32
78
  });
33
79
  };
@@ -19,13 +19,19 @@ var _fixedLayer = _interopRequireDefault(require("../internal/fixed-layer"));
19
19
  */
20
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
21
21
 
22
- function getValidDate(iso) {
23
- var date = (0, _dateFns.parseISO)(iso);
24
- return (0, _dateFns.isValid)(date) ? {
25
- day: date.getDate(),
26
- month: date.getMonth() + 1,
27
- year: date.getFullYear()
28
- } : {};
22
+ /**
23
+ * @param isos A series of ISO dates.
24
+ * @returns The last valid date within the array of ISO strings.
25
+ */
26
+ function getValidDate(isos) {
27
+ return isos.reduce(function (acc, iso) {
28
+ var date = (0, _dateFns.parseISO)(iso);
29
+ return (0, _dateFns.isValid)(date) ? {
30
+ day: date.getDate(),
31
+ month: date.getMonth() + 1,
32
+ year: date.getFullYear()
33
+ } : acc;
34
+ }, {});
29
35
  }
30
36
  var menuStyles = (0, _react.css)({
31
37
  zIndex: _constants.layers.dialog(),
@@ -41,6 +47,12 @@ var menuStyles = (0, _react.css)({
41
47
  var Menu = exports.Menu = function Menu(_ref) {
42
48
  var selectProps = _ref.selectProps,
43
49
  innerProps = _ref.innerProps;
50
+ var calendarValue = selectProps.calendarValue,
51
+ calendarView = selectProps.calendarView;
52
+ var _getValidDate = getValidDate([calendarValue, calendarView]),
53
+ day = _getValidDate.day,
54
+ month = _getValidDate.month,
55
+ year = _getValidDate.year;
44
56
  return (0, _react.jsx)(_layering.UNSAFE_LAYERING, {
45
57
  isDisabled: false
46
58
  }, (0, _react.jsx)(_fixedLayer.default, {
@@ -48,7 +60,10 @@ var Menu = exports.Menu = function Menu(_ref) {
48
60
  containerRef: selectProps.calendarContainerRef,
49
61
  content: (0, _react.jsx)("div", (0, _extends2.default)({
50
62
  css: menuStyles
51
- }, innerProps), (0, _react.jsx)(_calendar.default, (0, _extends2.default)({}, getValidDate(selectProps.calendarValue), getValidDate(selectProps.calendarView), {
63
+ }, innerProps), (0, _react.jsx)(_calendar.default, {
64
+ day: day,
65
+ month: month,
66
+ year: year,
52
67
  disabled: selectProps.calendarDisabled,
53
68
  disabledDateFilter: selectProps.calendarDisabledDateFilter,
54
69
  minDate: selectProps.calendarMinDate,
@@ -63,7 +78,7 @@ var Menu = exports.Menu = function Menu(_ref) {
63
78
  locale: selectProps.calendarLocale,
64
79
  testId: selectProps.testId && "".concat(selectProps.testId, "--calendar"),
65
80
  weekStartDay: selectProps.calendarWeekStartDay
66
- }))),
81
+ })),
67
82
  testId: selectProps.testId
68
83
  }));
69
84
  };