@atlaskit/datetime-picker 12.3.8 → 12.3.10

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/datetime-picker
2
2
 
3
+ ## 12.3.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`1fc7949b336`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1fc7949b336) - [ux] Fixes a bug where the background for the calendar element was incorrectly set to 'elevation.surface'
8
+
9
+ ## 12.3.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [`5546747df1e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5546747df1e) - Refactoring of code to clean tech debt and make future maintenance easier
14
+ - Updated dependencies
15
+
3
16
  ## 12.3.8
4
17
 
5
18
  ### Patch Changes
@@ -36,24 +36,24 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
36
36
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
37
37
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
38
38
  var packageName = "@atlaskit/datetime-picker";
39
- var packageVersion = "12.3.8";
39
+ var packageVersion = "12.3.10";
40
40
 
41
41
  /* eslint-disable react/no-unused-prop-types */
42
42
 
43
- function getDateObj(date) {
44
- return {
43
+ function getValidDate(iso) {
44
+ var date = (0, _dateFns.parseISO)(iso);
45
+ return (0, _dateFns.isValid)(date) ? {
45
46
  day: date.getDate(),
46
47
  month: date.getMonth() + 1,
47
48
  year: date.getFullYear()
48
- };
49
+ } : {};
49
50
  }
50
- function getValidDate(iso) {
51
- var date = (0, _dateFns.parseISO)(iso);
52
- return (0, _dateFns.isValid)(date) ? getDateObj(date) : {};
51
+ function getShortISOString(date) {
52
+ return (0, _dateFns.format)(date, (0, _utils.convertTokens)('YYYY-MM-DD'));
53
53
  }
54
54
  var menuStyles = (0, _react2.css)({
55
55
  zIndex: _constants.layers.dialog(),
56
- backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N20, ")"),
56
+ backgroundColor: "var(--ds-surface-overlay, ".concat(_colors.N0, ")"),
57
57
  borderRadius: "".concat((0, _constants.borderRadius)(), "px"),
58
58
  boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(_colors.N50A, ", 0 0 1px ").concat(_colors.N60A), ")"),
59
59
  overflow: 'hidden'
@@ -144,16 +144,15 @@ var DatePicker = /*#__PURE__*/function (_Component) {
144
144
  newIso = "".concat(year, "-").concat((0, _internal.padToTwo)(parsedMonth), "-").concat((0, _internal.padToTwo)(parsedDate));
145
145
  }
146
146
  _this.setState({
147
- view: newIso
147
+ calendarValue: newIso
148
148
  });
149
149
  });
150
150
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCalendarSelect", function (_ref3) {
151
151
  var iso = _ref3.iso;
152
152
  _this.setState({
153
- inputValue: '',
153
+ selectInputValue: '',
154
154
  isOpen: false,
155
- selectedValue: iso,
156
- view: iso,
155
+ calendarValue: iso,
157
156
  value: iso
158
157
  });
159
158
  _this.props.onChange(iso);
@@ -191,13 +190,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
191
190
  } else {
192
191
  _this.setState({
193
192
  isOpen: true,
194
- view: value,
193
+ calendarValue: value,
195
194
  isFocused: true
196
195
  });
197
196
  }
198
197
  _this.props.onFocus(event);
199
198
  });
200
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectInput", function (event) {
199
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onTextInput", function (event) {
201
200
  var value = event.target.value;
202
201
  if (value) {
203
202
  var parsed = _this.parseDate(value);
@@ -206,7 +205,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
206
205
  // We format the parsed date to YYYY-MM-DD here because
207
206
  // this is the format expected by the @atlaskit/calendar component
208
207
  _this.setState({
209
- view: (0, _dateFns.format)(parsed, (0, _utils.convertTokens)('YYYY-MM-DD'))
208
+ calendarValue: getShortISOString(parsed)
210
209
  });
211
210
  }
212
211
  }
@@ -214,9 +213,10 @@ var DatePicker = /*#__PURE__*/function (_Component) {
214
213
  isOpen: true
215
214
  });
216
215
  });
217
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSafeView", function (view) {
218
- // If view has a year that is greater than 9999, default to today's date
219
- var yearIsOverLimit = view.match(/^\d{5,}/);
216
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getSafeCalendarValue", function (calendarValue) {
217
+ // If `calendarValue` has a year that is greater than 9999, default to
218
+ // today's date
219
+ var yearIsOverLimit = calendarValue.match(/^\d{5,}/);
220
220
  if (yearIsOverLimit) {
221
221
  var today = new Date();
222
222
  var year = today.getFullYear();
@@ -224,12 +224,12 @@ var DatePicker = /*#__PURE__*/function (_Component) {
224
224
  var day = today.getDate().toString().padStart(2, '0');
225
225
  return "".concat(year, "-").concat(month, "-").concat(day);
226
226
  }
227
- return view;
227
+ return calendarValue;
228
228
  });
229
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onSelectKeyDown", function (event) {
229
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputKeyDown", function (event) {
230
230
  var _this$getSafeState2 = _this.getSafeState(),
231
- view = _this$getSafeState2.view,
232
- selectedValue = _this$getSafeState2.selectedValue;
231
+ value = _this$getSafeState2.value,
232
+ calendarValue = _this$getSafeState2.calendarValue;
233
233
  var keyPressed = event.key.toLowerCase();
234
234
  switch (keyPressed) {
235
235
  case 'arrowup':
@@ -259,7 +259,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
259
259
  break;
260
260
  case 'backspace':
261
261
  case 'delete':
262
- if (selectedValue && event.target instanceof HTMLInputElement && event.target.value.length < 1) {
262
+ if (value && event.target instanceof HTMLInputElement && event.target.value.length < 1) {
263
263
  // If being cleared from keyboard, don't change behaviour
264
264
  _this.setState({
265
265
  clearingFromIcon: false
@@ -274,22 +274,21 @@ var DatePicker = /*#__PURE__*/function (_Component) {
274
274
  // using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
275
275
  // for more details.
276
276
  event.preventDefault();
277
- if (!_this.isDateDisabled(view)) {
277
+ if (!_this.isDateDisabled(calendarValue)) {
278
278
  var _this$getSafeState3 = _this.getSafeState(),
279
279
  _value = _this$getSafeState3.value;
280
- // Get a safe `view` value in case the value exceeds the maximum
280
+ // Get a safe `calendarValue` in case the value exceeds the maximum
281
281
  // allowed by ISO 8601
282
- var safeView = _this.getSafeView(view);
283
- var valueChanged = safeView !== _value;
282
+ var safeCalendarValue = _this.getSafeCalendarValue(calendarValue);
283
+ var valueChanged = safeCalendarValue !== _value;
284
284
  _this.setState({
285
- inputValue: '',
285
+ selectInputValue: '',
286
286
  isOpen: false,
287
- selectedValue: safeView,
288
- value: safeView,
289
- view: safeView
287
+ value: safeCalendarValue,
288
+ calendarValue: safeCalendarValue
290
289
  });
291
290
  if (valueChanged) {
292
- _this.props.onChange(safeView);
291
+ _this.props.onChange(safeCalendarValue);
293
292
  }
294
293
  }
295
294
  break;
@@ -299,9 +298,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
299
298
  });
300
299
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onClear", function () {
301
300
  var changedState = {
302
- selectedValue: '',
303
301
  value: '',
304
- view: _this.props.defaultValue || (0, _dateFns.format)(new Date(), (0, _utils.convertTokens)('YYYY-MM-DD'))
302
+ calendarValue: _this.props.defaultValue || getShortISOString(new Date())
305
303
  };
306
304
  if (!_this.props.hideIcon) {
307
305
  changedState = _objectSpread(_objectSpread({}, changedState), {}, {
@@ -321,13 +319,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
321
319
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "refCalendar", function (ref) {
322
320
  _this.calendarRef = ref;
323
321
  });
324
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleInputChange", function (inputValue, actionMeta) {
322
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSelectInputChange", function (selectInputValue, actionMeta) {
325
323
  var onInputChange = _this.props.selectProps.onInputChange;
326
324
  if (onInputChange) {
327
- onInputChange(inputValue, actionMeta);
325
+ onInputChange(selectInputValue, actionMeta);
328
326
  }
329
327
  _this.setState({
330
- inputValue: inputValue
328
+ selectInputValue: selectInputValue
331
329
  });
332
330
  });
333
331
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getContainerRef", function (ref) {
@@ -371,18 +369,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
371
369
  l10n = _this$getSafeState6.l10n;
372
370
  return l10n.formatDate(_internal.placeholderDatetime);
373
371
  });
374
- var _getDateObj = getDateObj(new Date()),
375
- _day = _getDateObj.day,
376
- _month = _getDateObj.month,
377
- _year = _getDateObj.year;
378
372
  _this.state = {
379
373
  isOpen: _this.props.defaultIsOpen,
380
374
  isFocused: false,
381
375
  clearingFromIcon: false,
382
- inputValue: _this.props.selectProps.inputValue,
383
- selectedValue: _this.props.value || _this.props.defaultValue,
384
- value: _this.props.defaultValue,
385
- view: _this.props.value || _this.props.defaultValue || "".concat(_year, "-").concat((0, _internal.padToTwo)(_month), "-").concat((0, _internal.padToTwo)(_day)),
376
+ selectInputValue: _this.props.selectProps.inputValue,
377
+ value: _this.props.value || _this.props.defaultValue,
378
+ calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
386
379
  l10n: (0, _locale.createLocalizationProvider)(_this.props.locale)
387
380
  };
388
381
  return _this;
@@ -426,11 +419,11 @@ var DatePicker = /*#__PURE__*/function (_Component) {
426
419
  var ICON_PADDING = 2;
427
420
  var _this$getSafeState7 = this.getSafeState(),
428
421
  value = _this$getSafeState7.value,
429
- view = _this$getSafeState7.view,
422
+ calendarValue = _this$getSafeState7.calendarValue,
430
423
  isOpen = _this$getSafeState7.isOpen,
431
- inputValue = _this$getSafeState7.inputValue;
424
+ selectInputValue = _this$getSafeState7.selectInputValue;
432
425
  var menuIsOpen = isOpen && !isDisabled;
433
- var showClearIndicator = Boolean((value || inputValue) && !hideIcon);
426
+ var showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
434
427
  var dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
435
428
  var selectComponents = _objectSpread({
436
429
  DropdownIndicator: dropDownIcon,
@@ -451,8 +444,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
451
444
  calendarDisabledDateFilter: disabledDateFilter,
452
445
  calendarMaxDate: maxDate,
453
446
  calendarMinDate: minDate,
454
- calendarValue: value && (0, _dateFns.format)((0, _dateFns.parseISO)(value), (0, _utils.convertTokens)('YYYY-MM-DD')),
455
- calendarView: view,
447
+ calendarValue: value && getShortISOString((0, _dateFns.parseISO)(value)),
448
+ calendarView: calendarValue,
456
449
  onCalendarChange: this.onCalendarChange,
457
450
  onCalendarSelect: this.onCalendarSelect,
458
451
  calendarLocale: locale,
@@ -463,8 +456,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
463
456
  return (0, _react2.jsx)("div", (0, _extends2.default)({}, innerProps, {
464
457
  role: "presentation",
465
458
  onClick: this.onInputClick,
466
- onInput: this.onSelectInput,
467
- onKeyDown: this.onSelectKeyDown,
459
+ onInput: this.onTextInput,
460
+ onKeyDown: this.onInputKeyDown,
468
461
  ref: this.getContainerRef,
469
462
  "data-testid": testId && "".concat(testId, "--container")
470
463
  }), (0, _react2.jsx)("input", {
@@ -483,8 +476,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
483
476
  isDisabled: isDisabled,
484
477
  onBlur: this.onSelectBlur,
485
478
  onFocus: this.onSelectFocus,
486
- inputValue: inputValue,
487
- onInputChange: this.handleInputChange,
479
+ inputValue: selectInputValue,
480
+ onInputChange: this.handleSelectInputChange,
488
481
  components: selectComponents,
489
482
  onChange: this.onSelectChange,
490
483
  styles: (0, _select.mergeStyles)(selectStyles, {
@@ -31,7 +31,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
31
31
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
32
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
33
  var packageName = "@atlaskit/datetime-picker";
34
- var packageVersion = "12.3.8";
34
+ var packageVersion = "12.3.10";
35
35
 
36
36
  /* eslint-disable react/no-unused-prop-types */
37
37
 
@@ -35,7 +35,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
35
35
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
36
36
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
37
37
  var packageName = "@atlaskit/datetime-picker";
38
- var packageVersion = "12.3.8";
38
+ var packageVersion = "12.3.10";
39
39
  var menuStyles = {
40
40
  /* Need to remove default absolute positioning as that causes issues with position fixed */
41
41
  position: 'static',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "12.3.8",
3
+ "version": "12.3.10",
4
4
  "sideEffects": false
5
5
  }
@@ -12,30 +12,30 @@ import Calendar from '@atlaskit/calendar';
12
12
  import CalendarIcon from '@atlaskit/icon/glyph/calendar';
13
13
  import { createLocalizationProvider } from '@atlaskit/locale';
14
14
  import Select, { mergeStyles } from '@atlaskit/select';
15
- import { N20, N50A, N60A } from '@atlaskit/theme/colors';
15
+ import { N0, N50A, N60A } from '@atlaskit/theme/colors';
16
16
  import { borderRadius, gridSize, layers } from '@atlaskit/theme/constants';
17
17
  import { defaultDateFormat, EmptyComponent, padToTwo, placeholderDatetime } from '../internal';
18
18
  import FixedLayer from '../internal/fixed-layer';
19
19
  import { convertTokens } from './utils';
20
20
  const packageName = "@atlaskit/datetime-picker";
21
- const packageVersion = "12.3.8";
21
+ const packageVersion = "12.3.10";
22
22
 
23
23
  /* eslint-disable react/no-unused-prop-types */
24
24
 
25
- function getDateObj(date) {
26
- return {
25
+ function getValidDate(iso) {
26
+ const date = parseISO(iso);
27
+ return isValid(date) ? {
27
28
  day: date.getDate(),
28
29
  month: date.getMonth() + 1,
29
30
  year: date.getFullYear()
30
- };
31
+ } : {};
31
32
  }
32
- function getValidDate(iso) {
33
- const date = parseISO(iso);
34
- return isValid(date) ? getDateObj(date) : {};
33
+ function getShortISOString(date) {
34
+ return format(date, convertTokens('YYYY-MM-DD'));
35
35
  }
36
36
  const menuStyles = css({
37
37
  zIndex: layers.dialog(),
38
- backgroundColor: `var(--ds-surface-overlay, ${N20})`,
38
+ backgroundColor: `var(--ds-surface-overlay, ${N0})`,
39
39
  borderRadius: `${borderRadius()}px`,
40
40
  boxShadow: `var(--ds-shadow-overlay, ${`0 4px 8px -2px ${N50A}, 0 0 1px ${N60A}`})`,
41
41
  overflow: 'hidden'
@@ -121,17 +121,16 @@ class DatePicker extends Component {
121
121
  newIso = `${year}-${padToTwo(parsedMonth)}-${padToTwo(parsedDate)}`;
122
122
  }
123
123
  this.setState({
124
- view: newIso
124
+ calendarValue: newIso
125
125
  });
126
126
  });
127
127
  _defineProperty(this, "onCalendarSelect", ({
128
128
  iso
129
129
  }) => {
130
130
  this.setState({
131
- inputValue: '',
131
+ selectInputValue: '',
132
132
  isOpen: false,
133
- selectedValue: iso,
134
- view: iso,
133
+ calendarValue: iso,
135
134
  value: iso
136
135
  });
137
136
  this.props.onChange(iso);
@@ -170,13 +169,13 @@ class DatePicker extends Component {
170
169
  } else {
171
170
  this.setState({
172
171
  isOpen: true,
173
- view: value,
172
+ calendarValue: value,
174
173
  isFocused: true
175
174
  });
176
175
  }
177
176
  this.props.onFocus(event);
178
177
  });
179
- _defineProperty(this, "onSelectInput", event => {
178
+ _defineProperty(this, "onTextInput", event => {
180
179
  const value = event.target.value;
181
180
  if (value) {
182
181
  const parsed = this.parseDate(value);
@@ -185,7 +184,7 @@ class DatePicker extends Component {
185
184
  // We format the parsed date to YYYY-MM-DD here because
186
185
  // this is the format expected by the @atlaskit/calendar component
187
186
  this.setState({
188
- view: format(parsed, convertTokens('YYYY-MM-DD'))
187
+ calendarValue: getShortISOString(parsed)
189
188
  });
190
189
  }
191
190
  }
@@ -193,9 +192,10 @@ class DatePicker extends Component {
193
192
  isOpen: true
194
193
  });
195
194
  });
196
- _defineProperty(this, "getSafeView", view => {
197
- // If view has a year that is greater than 9999, default to today's date
198
- const yearIsOverLimit = view.match(/^\d{5,}/);
195
+ _defineProperty(this, "getSafeCalendarValue", calendarValue => {
196
+ // If `calendarValue` has a year that is greater than 9999, default to
197
+ // today's date
198
+ const yearIsOverLimit = calendarValue.match(/^\d{5,}/);
199
199
  if (yearIsOverLimit) {
200
200
  const today = new Date();
201
201
  const year = today.getFullYear();
@@ -203,12 +203,12 @@ class DatePicker extends Component {
203
203
  const day = today.getDate().toString().padStart(2, '0');
204
204
  return `${year}-${month}-${day}`;
205
205
  }
206
- return view;
206
+ return calendarValue;
207
207
  });
208
- _defineProperty(this, "onSelectKeyDown", event => {
208
+ _defineProperty(this, "onInputKeyDown", event => {
209
209
  const {
210
- view,
211
- selectedValue
210
+ value,
211
+ calendarValue
212
212
  } = this.getSafeState();
213
213
  const keyPressed = event.key.toLowerCase();
214
214
  switch (keyPressed) {
@@ -239,7 +239,7 @@ class DatePicker extends Component {
239
239
  break;
240
240
  case 'backspace':
241
241
  case 'delete':
242
- if (selectedValue && event.target instanceof HTMLInputElement && event.target.value.length < 1) {
242
+ if (value && event.target instanceof HTMLInputElement && event.target.value.length < 1) {
243
243
  // If being cleared from keyboard, don't change behaviour
244
244
  this.setState({
245
245
  clearingFromIcon: false
@@ -254,23 +254,22 @@ class DatePicker extends Component {
254
254
  // using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
255
255
  // for more details.
256
256
  event.preventDefault();
257
- if (!this.isDateDisabled(view)) {
257
+ if (!this.isDateDisabled(calendarValue)) {
258
258
  const {
259
259
  value
260
260
  } = this.getSafeState();
261
- // Get a safe `view` value in case the value exceeds the maximum
261
+ // Get a safe `calendarValue` in case the value exceeds the maximum
262
262
  // allowed by ISO 8601
263
- const safeView = this.getSafeView(view);
264
- const valueChanged = safeView !== value;
263
+ const safeCalendarValue = this.getSafeCalendarValue(calendarValue);
264
+ const valueChanged = safeCalendarValue !== value;
265
265
  this.setState({
266
- inputValue: '',
266
+ selectInputValue: '',
267
267
  isOpen: false,
268
- selectedValue: safeView,
269
- value: safeView,
270
- view: safeView
268
+ value: safeCalendarValue,
269
+ calendarValue: safeCalendarValue
271
270
  });
272
271
  if (valueChanged) {
273
- this.props.onChange(safeView);
272
+ this.props.onChange(safeCalendarValue);
274
273
  }
275
274
  }
276
275
  break;
@@ -280,9 +279,8 @@ class DatePicker extends Component {
280
279
  });
281
280
  _defineProperty(this, "onClear", () => {
282
281
  let changedState = {
283
- selectedValue: '',
284
282
  value: '',
285
- view: this.props.defaultValue || format(new Date(), convertTokens('YYYY-MM-DD'))
283
+ calendarValue: this.props.defaultValue || getShortISOString(new Date())
286
284
  };
287
285
  if (!this.props.hideIcon) {
288
286
  changedState = {
@@ -303,15 +301,15 @@ class DatePicker extends Component {
303
301
  _defineProperty(this, "refCalendar", ref => {
304
302
  this.calendarRef = ref;
305
303
  });
306
- _defineProperty(this, "handleInputChange", (inputValue, actionMeta) => {
304
+ _defineProperty(this, "handleSelectInputChange", (selectInputValue, actionMeta) => {
307
305
  const {
308
306
  onInputChange
309
307
  } = this.props.selectProps;
310
308
  if (onInputChange) {
311
- onInputChange(inputValue, actionMeta);
309
+ onInputChange(selectInputValue, actionMeta);
312
310
  }
313
311
  this.setState({
314
- inputValue
312
+ selectInputValue
315
313
  });
316
314
  });
317
315
  _defineProperty(this, "getContainerRef", ref => {
@@ -362,19 +360,13 @@ class DatePicker extends Component {
362
360
  } = this.getSafeState();
363
361
  return l10n.formatDate(placeholderDatetime);
364
362
  });
365
- const {
366
- day: _day,
367
- month: _month,
368
- year: _year
369
- } = getDateObj(new Date());
370
363
  this.state = {
371
364
  isOpen: this.props.defaultIsOpen,
372
365
  isFocused: false,
373
366
  clearingFromIcon: false,
374
- inputValue: this.props.selectProps.inputValue,
375
- selectedValue: this.props.value || this.props.defaultValue,
376
- value: this.props.defaultValue,
377
- view: this.props.value || this.props.defaultValue || `${_year}-${padToTwo(_month)}-${padToTwo(_day)}`,
367
+ selectInputValue: this.props.selectProps.inputValue,
368
+ value: this.props.value || this.props.defaultValue,
369
+ calendarValue: this.props.value || this.props.defaultValue || getShortISOString(new Date()),
378
370
  l10n: createLocalizationProvider(this.props.locale)
379
371
  };
380
372
  }
@@ -415,12 +407,12 @@ class DatePicker extends Component {
415
407
  const ICON_PADDING = 2;
416
408
  const {
417
409
  value,
418
- view,
410
+ calendarValue,
419
411
  isOpen,
420
- inputValue
412
+ selectInputValue
421
413
  } = this.getSafeState();
422
414
  const menuIsOpen = isOpen && !isDisabled;
423
- const showClearIndicator = Boolean((value || inputValue) && !hideIcon);
415
+ const showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
424
416
  const dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
425
417
  const selectComponents = {
426
418
  DropdownIndicator: dropDownIcon,
@@ -443,8 +435,8 @@ class DatePicker extends Component {
443
435
  calendarDisabledDateFilter: disabledDateFilter,
444
436
  calendarMaxDate: maxDate,
445
437
  calendarMinDate: minDate,
446
- calendarValue: value && format(parseISO(value), convertTokens('YYYY-MM-DD')),
447
- calendarView: view,
438
+ calendarValue: value && getShortISOString(parseISO(value)),
439
+ calendarView: calendarValue,
448
440
  onCalendarChange: this.onCalendarChange,
449
441
  onCalendarSelect: this.onCalendarSelect,
450
442
  calendarLocale: locale,
@@ -455,8 +447,8 @@ class DatePicker extends Component {
455
447
  return jsx("div", _extends({}, innerProps, {
456
448
  role: "presentation",
457
449
  onClick: this.onInputClick,
458
- onInput: this.onSelectInput,
459
- onKeyDown: this.onSelectKeyDown,
450
+ onInput: this.onTextInput,
451
+ onKeyDown: this.onInputKeyDown,
460
452
  ref: this.getContainerRef,
461
453
  "data-testid": testId && `${testId}--container`
462
454
  }), jsx("input", {
@@ -475,8 +467,8 @@ class DatePicker extends Component {
475
467
  isDisabled: isDisabled,
476
468
  onBlur: this.onSelectBlur,
477
469
  onFocus: this.onSelectFocus,
478
- inputValue: inputValue,
479
- onInputChange: this.handleInputChange,
470
+ inputValue: selectInputValue,
471
+ onInputChange: this.handleSelectInputChange,
480
472
  components: selectComponents,
481
473
  onChange: this.onSelectChange,
482
474
  styles: mergeStyles(selectStyles, {
@@ -17,7 +17,7 @@ import DatePicker from './date-picker';
17
17
  import TimePicker from './time-picker';
18
18
  import { convertTokens } from './utils';
19
19
  const packageName = "@atlaskit/datetime-picker";
20
- const packageVersion = "12.3.8";
20
+ const packageVersion = "12.3.10";
21
21
 
22
22
  /* eslint-disable react/no-unused-prop-types */
23
23
 
@@ -15,7 +15,7 @@ import FixedLayer from '../internal/fixed-layer';
15
15
  import parseTime from '../internal/parse-time';
16
16
  import { convertTokens } from './utils';
17
17
  const packageName = "@atlaskit/datetime-picker";
18
- const packageVersion = "12.3.8";
18
+ const packageVersion = "12.3.10";
19
19
  const menuStyles = {
20
20
  /* Need to remove default absolute positioning as that causes issues with position fixed */
21
21
  position: 'static',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "12.3.8",
3
+ "version": "12.3.10",
4
4
  "sideEffects": false
5
5
  }
@@ -23,30 +23,30 @@ import Calendar from '@atlaskit/calendar';
23
23
  import CalendarIcon from '@atlaskit/icon/glyph/calendar';
24
24
  import { createLocalizationProvider } from '@atlaskit/locale';
25
25
  import Select, { mergeStyles } from '@atlaskit/select';
26
- import { N20, N50A, N60A } from '@atlaskit/theme/colors';
26
+ import { N0, N50A, N60A } from '@atlaskit/theme/colors';
27
27
  import { borderRadius, gridSize, layers } from '@atlaskit/theme/constants';
28
28
  import { defaultDateFormat, EmptyComponent, padToTwo, placeholderDatetime } from '../internal';
29
29
  import FixedLayer from '../internal/fixed-layer';
30
30
  import { convertTokens } from './utils';
31
31
  var packageName = "@atlaskit/datetime-picker";
32
- var packageVersion = "12.3.8";
32
+ var packageVersion = "12.3.10";
33
33
 
34
34
  /* eslint-disable react/no-unused-prop-types */
35
35
 
36
- function getDateObj(date) {
37
- return {
36
+ function getValidDate(iso) {
37
+ var date = parseISO(iso);
38
+ return isValid(date) ? {
38
39
  day: date.getDate(),
39
40
  month: date.getMonth() + 1,
40
41
  year: date.getFullYear()
41
- };
42
+ } : {};
42
43
  }
43
- function getValidDate(iso) {
44
- var date = parseISO(iso);
45
- return isValid(date) ? getDateObj(date) : {};
44
+ function getShortISOString(date) {
45
+ return format(date, convertTokens('YYYY-MM-DD'));
46
46
  }
47
47
  var menuStyles = css({
48
48
  zIndex: layers.dialog(),
49
- backgroundColor: "var(--ds-surface-overlay, ".concat(N20, ")"),
49
+ backgroundColor: "var(--ds-surface-overlay, ".concat(N0, ")"),
50
50
  borderRadius: "".concat(borderRadius(), "px"),
51
51
  boxShadow: "var(--ds-shadow-overlay, ".concat("0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A), ")"),
52
52
  overflow: 'hidden'
@@ -137,16 +137,15 @@ var DatePicker = /*#__PURE__*/function (_Component) {
137
137
  newIso = "".concat(year, "-").concat(padToTwo(parsedMonth), "-").concat(padToTwo(parsedDate));
138
138
  }
139
139
  _this.setState({
140
- view: newIso
140
+ calendarValue: newIso
141
141
  });
142
142
  });
143
143
  _defineProperty(_assertThisInitialized(_this), "onCalendarSelect", function (_ref3) {
144
144
  var iso = _ref3.iso;
145
145
  _this.setState({
146
- inputValue: '',
146
+ selectInputValue: '',
147
147
  isOpen: false,
148
- selectedValue: iso,
149
- view: iso,
148
+ calendarValue: iso,
150
149
  value: iso
151
150
  });
152
151
  _this.props.onChange(iso);
@@ -184,13 +183,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
184
183
  } else {
185
184
  _this.setState({
186
185
  isOpen: true,
187
- view: value,
186
+ calendarValue: value,
188
187
  isFocused: true
189
188
  });
190
189
  }
191
190
  _this.props.onFocus(event);
192
191
  });
193
- _defineProperty(_assertThisInitialized(_this), "onSelectInput", function (event) {
192
+ _defineProperty(_assertThisInitialized(_this), "onTextInput", function (event) {
194
193
  var value = event.target.value;
195
194
  if (value) {
196
195
  var parsed = _this.parseDate(value);
@@ -199,7 +198,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
199
198
  // We format the parsed date to YYYY-MM-DD here because
200
199
  // this is the format expected by the @atlaskit/calendar component
201
200
  _this.setState({
202
- view: format(parsed, convertTokens('YYYY-MM-DD'))
201
+ calendarValue: getShortISOString(parsed)
203
202
  });
204
203
  }
205
204
  }
@@ -207,9 +206,10 @@ var DatePicker = /*#__PURE__*/function (_Component) {
207
206
  isOpen: true
208
207
  });
209
208
  });
210
- _defineProperty(_assertThisInitialized(_this), "getSafeView", function (view) {
211
- // If view has a year that is greater than 9999, default to today's date
212
- var yearIsOverLimit = view.match(/^\d{5,}/);
209
+ _defineProperty(_assertThisInitialized(_this), "getSafeCalendarValue", function (calendarValue) {
210
+ // If `calendarValue` has a year that is greater than 9999, default to
211
+ // today's date
212
+ var yearIsOverLimit = calendarValue.match(/^\d{5,}/);
213
213
  if (yearIsOverLimit) {
214
214
  var today = new Date();
215
215
  var year = today.getFullYear();
@@ -217,12 +217,12 @@ var DatePicker = /*#__PURE__*/function (_Component) {
217
217
  var day = today.getDate().toString().padStart(2, '0');
218
218
  return "".concat(year, "-").concat(month, "-").concat(day);
219
219
  }
220
- return view;
220
+ return calendarValue;
221
221
  });
222
- _defineProperty(_assertThisInitialized(_this), "onSelectKeyDown", function (event) {
222
+ _defineProperty(_assertThisInitialized(_this), "onInputKeyDown", function (event) {
223
223
  var _this$getSafeState2 = _this.getSafeState(),
224
- view = _this$getSafeState2.view,
225
- selectedValue = _this$getSafeState2.selectedValue;
224
+ value = _this$getSafeState2.value,
225
+ calendarValue = _this$getSafeState2.calendarValue;
226
226
  var keyPressed = event.key.toLowerCase();
227
227
  switch (keyPressed) {
228
228
  case 'arrowup':
@@ -252,7 +252,7 @@ var DatePicker = /*#__PURE__*/function (_Component) {
252
252
  break;
253
253
  case 'backspace':
254
254
  case 'delete':
255
- if (selectedValue && event.target instanceof HTMLInputElement && event.target.value.length < 1) {
255
+ if (value && event.target instanceof HTMLInputElement && event.target.value.length < 1) {
256
256
  // If being cleared from keyboard, don't change behaviour
257
257
  _this.setState({
258
258
  clearingFromIcon: false
@@ -267,22 +267,21 @@ var DatePicker = /*#__PURE__*/function (_Component) {
267
267
  // using enter. See https://product-fabric.atlassian.net/browse/DSP-2501
268
268
  // for more details.
269
269
  event.preventDefault();
270
- if (!_this.isDateDisabled(view)) {
270
+ if (!_this.isDateDisabled(calendarValue)) {
271
271
  var _this$getSafeState3 = _this.getSafeState(),
272
272
  _value = _this$getSafeState3.value;
273
- // Get a safe `view` value in case the value exceeds the maximum
273
+ // Get a safe `calendarValue` in case the value exceeds the maximum
274
274
  // allowed by ISO 8601
275
- var safeView = _this.getSafeView(view);
276
- var valueChanged = safeView !== _value;
275
+ var safeCalendarValue = _this.getSafeCalendarValue(calendarValue);
276
+ var valueChanged = safeCalendarValue !== _value;
277
277
  _this.setState({
278
- inputValue: '',
278
+ selectInputValue: '',
279
279
  isOpen: false,
280
- selectedValue: safeView,
281
- value: safeView,
282
- view: safeView
280
+ value: safeCalendarValue,
281
+ calendarValue: safeCalendarValue
283
282
  });
284
283
  if (valueChanged) {
285
- _this.props.onChange(safeView);
284
+ _this.props.onChange(safeCalendarValue);
286
285
  }
287
286
  }
288
287
  break;
@@ -292,9 +291,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
292
291
  });
293
292
  _defineProperty(_assertThisInitialized(_this), "onClear", function () {
294
293
  var changedState = {
295
- selectedValue: '',
296
294
  value: '',
297
- view: _this.props.defaultValue || format(new Date(), convertTokens('YYYY-MM-DD'))
295
+ calendarValue: _this.props.defaultValue || getShortISOString(new Date())
298
296
  };
299
297
  if (!_this.props.hideIcon) {
300
298
  changedState = _objectSpread(_objectSpread({}, changedState), {}, {
@@ -314,13 +312,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
314
312
  _defineProperty(_assertThisInitialized(_this), "refCalendar", function (ref) {
315
313
  _this.calendarRef = ref;
316
314
  });
317
- _defineProperty(_assertThisInitialized(_this), "handleInputChange", function (inputValue, actionMeta) {
315
+ _defineProperty(_assertThisInitialized(_this), "handleSelectInputChange", function (selectInputValue, actionMeta) {
318
316
  var onInputChange = _this.props.selectProps.onInputChange;
319
317
  if (onInputChange) {
320
- onInputChange(inputValue, actionMeta);
318
+ onInputChange(selectInputValue, actionMeta);
321
319
  }
322
320
  _this.setState({
323
- inputValue: inputValue
321
+ selectInputValue: selectInputValue
324
322
  });
325
323
  });
326
324
  _defineProperty(_assertThisInitialized(_this), "getContainerRef", function (ref) {
@@ -364,18 +362,13 @@ var DatePicker = /*#__PURE__*/function (_Component) {
364
362
  l10n = _this$getSafeState6.l10n;
365
363
  return l10n.formatDate(placeholderDatetime);
366
364
  });
367
- var _getDateObj = getDateObj(new Date()),
368
- _day = _getDateObj.day,
369
- _month = _getDateObj.month,
370
- _year = _getDateObj.year;
371
365
  _this.state = {
372
366
  isOpen: _this.props.defaultIsOpen,
373
367
  isFocused: false,
374
368
  clearingFromIcon: false,
375
- inputValue: _this.props.selectProps.inputValue,
376
- selectedValue: _this.props.value || _this.props.defaultValue,
377
- value: _this.props.defaultValue,
378
- view: _this.props.value || _this.props.defaultValue || "".concat(_year, "-").concat(padToTwo(_month), "-").concat(padToTwo(_day)),
369
+ selectInputValue: _this.props.selectProps.inputValue,
370
+ value: _this.props.value || _this.props.defaultValue,
371
+ calendarValue: _this.props.value || _this.props.defaultValue || getShortISOString(new Date()),
379
372
  l10n: createLocalizationProvider(_this.props.locale)
380
373
  };
381
374
  return _this;
@@ -419,11 +412,11 @@ var DatePicker = /*#__PURE__*/function (_Component) {
419
412
  var ICON_PADDING = 2;
420
413
  var _this$getSafeState7 = this.getSafeState(),
421
414
  value = _this$getSafeState7.value,
422
- view = _this$getSafeState7.view,
415
+ calendarValue = _this$getSafeState7.calendarValue,
423
416
  isOpen = _this$getSafeState7.isOpen,
424
- inputValue = _this$getSafeState7.inputValue;
417
+ selectInputValue = _this$getSafeState7.selectInputValue;
425
418
  var menuIsOpen = isOpen && !isDisabled;
426
- var showClearIndicator = Boolean((value || inputValue) && !hideIcon);
419
+ var showClearIndicator = Boolean((value || selectInputValue) && !hideIcon);
427
420
  var dropDownIcon = appearance === 'subtle' || hideIcon || showClearIndicator ? null : icon;
428
421
  var selectComponents = _objectSpread({
429
422
  DropdownIndicator: dropDownIcon,
@@ -444,8 +437,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
444
437
  calendarDisabledDateFilter: disabledDateFilter,
445
438
  calendarMaxDate: maxDate,
446
439
  calendarMinDate: minDate,
447
- calendarValue: value && format(parseISO(value), convertTokens('YYYY-MM-DD')),
448
- calendarView: view,
440
+ calendarValue: value && getShortISOString(parseISO(value)),
441
+ calendarView: calendarValue,
449
442
  onCalendarChange: this.onCalendarChange,
450
443
  onCalendarSelect: this.onCalendarSelect,
451
444
  calendarLocale: locale,
@@ -456,8 +449,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
456
449
  return jsx("div", _extends({}, innerProps, {
457
450
  role: "presentation",
458
451
  onClick: this.onInputClick,
459
- onInput: this.onSelectInput,
460
- onKeyDown: this.onSelectKeyDown,
452
+ onInput: this.onTextInput,
453
+ onKeyDown: this.onInputKeyDown,
461
454
  ref: this.getContainerRef,
462
455
  "data-testid": testId && "".concat(testId, "--container")
463
456
  }), jsx("input", {
@@ -476,8 +469,8 @@ var DatePicker = /*#__PURE__*/function (_Component) {
476
469
  isDisabled: isDisabled,
477
470
  onBlur: this.onSelectBlur,
478
471
  onFocus: this.onSelectFocus,
479
- inputValue: inputValue,
480
- onInputChange: this.handleInputChange,
472
+ inputValue: selectInputValue,
473
+ onInputChange: this.handleSelectInputChange,
481
474
  components: selectComponents,
482
475
  onChange: this.onSelectChange,
483
476
  styles: mergeStyles(selectStyles, {
@@ -27,7 +27,7 @@ import DatePicker from './date-picker';
27
27
  import TimePicker from './time-picker';
28
28
  import { convertTokens } from './utils';
29
29
  var packageName = "@atlaskit/datetime-picker";
30
- var packageVersion = "12.3.8";
30
+ var packageVersion = "12.3.10";
31
31
 
32
32
  /* eslint-disable react/no-unused-prop-types */
33
33
 
@@ -28,7 +28,7 @@ import FixedLayer from '../internal/fixed-layer';
28
28
  import parseTime from '../internal/parse-time';
29
29
  import { convertTokens } from './utils';
30
30
  var packageName = "@atlaskit/datetime-picker";
31
- var packageVersion = "12.3.8";
31
+ var packageVersion = "12.3.10";
32
32
  var menuStyles = {
33
33
  /* Need to remove default absolute positioning as that causes issues with position fixed */
34
34
  position: 'static',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "12.3.8",
3
+ "version": "12.3.10",
4
4
  "sideEffects": false
5
5
  }
@@ -163,12 +163,8 @@ interface State {
163
163
  isFocused: boolean;
164
164
  clearingFromIcon: boolean;
165
165
  value: string;
166
- /**
167
- * Value to be shown in the calendar as selected.
168
- */
169
- selectedValue: string;
170
- view: string;
171
- inputValue: string;
166
+ calendarValue: string;
167
+ selectInputValue: string;
172
168
  l10n: LocalizationProvider;
173
169
  }
174
170
  declare const datePickerDefaultProps: {
@@ -224,8 +220,8 @@ declare class DatePicker extends Component<DatePickerProps, State> {
224
220
  value: string;
225
221
  isFocused: boolean;
226
222
  clearingFromIcon: boolean;
227
- selectedValue: string;
228
- view: string;
223
+ calendarValue: string;
224
+ selectInputValue: string;
229
225
  l10n: LocalizationProvider;
230
226
  };
231
227
  isDateDisabled: (date: string) => boolean;
@@ -238,13 +234,13 @@ declare class DatePicker extends Component<DatePickerProps, State> {
238
234
  onInputClick: () => void;
239
235
  onSelectBlur: (event: React.FocusEvent<HTMLInputElement>) => void;
240
236
  onSelectFocus: (event: React.FocusEvent<HTMLInputElement>) => void;
241
- onSelectInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
242
- getSafeView: (view: string) => string;
243
- onSelectKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
237
+ onTextInput: (event: React.ChangeEvent<HTMLInputElement>) => void;
238
+ getSafeCalendarValue: (calendarValue: string) => string;
239
+ onInputKeyDown: (event: React.KeyboardEvent<HTMLInputElement>) => void;
244
240
  onClear: () => void;
245
241
  onSelectChange: (value: ValueType<OptionType>, action: ActionMeta) => void;
246
242
  refCalendar: (ref: CalendarRef | null) => void;
247
- handleInputChange: (inputValue: string, actionMeta: {}) => void;
243
+ handleSelectInputChange: (selectInputValue: string, actionMeta: {}) => void;
248
244
  getContainerRef: (ref: HTMLElement | null) => void;
249
245
  /**
250
246
  * There are two props that can change how the date is parsed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "12.3.8",
3
+ "version": "12.3.10",
4
4
  "description": "A date time picker allows the user to select an associated date and time.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -15,7 +15,6 @@
15
15
  "sideEffects": false,
16
16
  "atlaskit:src": "src/index.tsx",
17
17
  "atlassian": {
18
- "disableProductCI": true,
19
18
  "team": "Design System Team",
20
19
  "deprecatedAutoEntryPoints": true,
21
20
  "releaseModel": "scheduled",
@@ -25,7 +24,7 @@
25
24
  }
26
25
  },
27
26
  "dependencies": {
28
- "@atlaskit/analytics-next": "^8.2.0",
27
+ "@atlaskit/analytics-next": "^9.0.0",
29
28
  "@atlaskit/calendar": "^13.0.0",
30
29
  "@atlaskit/ds-lib": "^2.1.0",
31
30
  "@atlaskit/icon": "^21.11.0",
@@ -33,7 +32,7 @@
33
32
  "@atlaskit/popper": "^5.4.0",
34
33
  "@atlaskit/select": "^16.1.0",
35
34
  "@atlaskit/theme": "^12.2.0",
36
- "@atlaskit/tokens": "^1.0.0",
35
+ "@atlaskit/tokens": "^1.2.0",
37
36
  "@babel/runtime": "^7.0.0",
38
37
  "@emotion/react": "^11.7.1",
39
38
  "date-fns": "^2.17.0",
@@ -79,7 +78,9 @@
79
78
  "emotion",
80
79
  "emotion"
81
80
  ],
82
- "theming": "tokens",
81
+ "design-tokens": [
82
+ "color"
83
+ ],
83
84
  "deprecation": "no-deprecated-imports"
84
85
  }
85
86
  },