@atlaskit/datetime-picker 10.4.2 → 11.1.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.
@@ -7,9 +7,6 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
9
  import _extends from "@babel/runtime/helpers/extends";
10
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
11
-
12
- var _templateObject;
13
10
 
14
11
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
15
12
 
@@ -19,23 +16,25 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
19
16
 
20
17
  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; } }
21
18
 
22
- import React from 'react';
23
- import styled from '@emotion/styled'; // eslint-disable-next-line no-restricted-imports
19
+ /** @jsx jsx */
20
+ import { Component } from 'react';
21
+ import { css, jsx } from '@emotion/core'; // eslint-disable-next-line no-restricted-imports
24
22
 
25
- import { format, isValid, lastDayOfMonth, parse } from 'date-fns';
23
+ import { format, isValid, lastDayOfMonth, parseISO } from 'date-fns';
26
24
  import pick from 'lodash/pick';
27
25
  import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
28
26
  import Calendar from '@atlaskit/calendar';
29
27
  import CalendarIcon from '@atlaskit/icon/glyph/calendar';
30
28
  import { createLocalizationProvider } from '@atlaskit/locale';
31
29
  import Select, { mergeStyles } from '@atlaskit/select';
32
- import { B100, N20 } from '@atlaskit/theme/colors';
30
+ import { B100, N20, N50A, N60A } from '@atlaskit/theme/colors';
33
31
  import { borderRadius, gridSize, layers } from '@atlaskit/theme/constants';
34
- import { e200 } from '@atlaskit/theme/elevation';
32
+ import { token } from '@atlaskit/tokens';
35
33
  import { defaultDateFormat, EmptyClearIndicator, padToTwo, placeholderDatetime } from '../internal';
36
34
  import FixedLayer from '../internal/FixedLayer';
35
+ import { convertTokens } from './utils';
37
36
  var packageName = "@atlaskit/datetime-picker";
38
- var packageVersion = "10.4.2";
37
+ var packageVersion = "11.1.0";
39
38
  /* eslint-disable react/no-unused-prop-types */
40
39
 
41
40
  function getDateObj(date) {
@@ -47,19 +46,26 @@ function getDateObj(date) {
47
46
  }
48
47
 
49
48
  function getValidDate(iso) {
50
- var date = parse(iso);
49
+ var date = parseISO(iso);
51
50
  return isValid(date) ? getDateObj(date) : {};
52
51
  }
53
52
 
54
- var StyledMenu = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border-radius: ", "px;\n z-index: ", ";\n ", ";\n"])), N20, borderRadius(), layers.dialog, e200());
53
+ var menuStyles = css({
54
+ zIndex: layers.dialog(),
55
+ backgroundColor: token('color.background.default', N20),
56
+ borderRadius: "".concat(borderRadius(), "px"),
57
+ boxShadow: token('shadow.overlay', "0 4px 8px -2px ".concat(N50A, ", 0 0 1px ").concat(N60A))
58
+ });
55
59
 
56
60
  var Menu = function Menu(_ref) {
57
61
  var selectProps = _ref.selectProps,
58
62
  innerProps = _ref.innerProps;
59
- return /*#__PURE__*/React.createElement(FixedLayer, {
63
+ return jsx(FixedLayer, {
60
64
  inputValue: selectProps.inputValue,
61
65
  containerRef: selectProps.calendarContainerRef,
62
- content: /*#__PURE__*/React.createElement(StyledMenu, innerProps, /*#__PURE__*/React.createElement(Calendar, _extends({}, getValidDate(selectProps.calendarValue), getValidDate(selectProps.calendarView), {
66
+ content: jsx("div", _extends({
67
+ css: menuStyles
68
+ }, innerProps), jsx(Calendar, _extends({}, getValidDate(selectProps.calendarValue), getValidDate(selectProps.calendarView), {
63
69
  disabled: selectProps.calendarDisabled,
64
70
  disabledDateFilter: selectProps.calendarDisabledDateFilter,
65
71
  minDate: selectProps.calendarMinDate,
@@ -102,8 +108,8 @@ var datePickerDefaultProps = {
102
108
 
103
109
  };
104
110
 
105
- var DatePicker = /*#__PURE__*/function (_React$Component) {
106
- _inherits(DatePicker, _React$Component);
111
+ var DatePicker = /*#__PURE__*/function (_Component) {
112
+ _inherits(DatePicker, _Component);
107
113
 
108
114
  var _super = _createSuper(DatePicker);
109
115
 
@@ -220,7 +226,7 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
220
226
  // We format the parsed date to YYYY-MM-DD here because
221
227
  // this is the format expected by the @atlaskit/calendar component
222
228
  _this.setState({
223
- view: format(parsed, 'YYYY-MM-DD')
229
+ view: format(parsed, convertTokens('YYYY-MM-DD'))
224
230
  });
225
231
  }
226
232
  }
@@ -308,7 +314,7 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
308
314
  var changedState = {
309
315
  selectedValue: '',
310
316
  value: '',
311
- view: _this.props.defaultValue || format(new Date(), 'YYYY-MM-DD')
317
+ view: _this.props.defaultValue || format(new Date(), convertTokens('YYYY-MM-DD'))
312
318
  };
313
319
 
314
320
  if (!_this.props.hideIcon) {
@@ -358,7 +364,7 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
358
364
 
359
365
  _defineProperty(_assertThisInitialized(_this), "getSubtleControlStyles", function (isOpen) {
360
366
  return {
361
- border: "2px solid ".concat(isOpen ? B100 : "transparent"),
367
+ border: "2px solid ".concat(isOpen ? token('color.border.focus', B100) : "transparent"),
362
368
  backgroundColor: 'transparent',
363
369
  padding: '1px'
364
370
  };
@@ -391,13 +397,8 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
391
397
  return formatDisplayLabel(value, dateFormat || defaultDateFormat);
392
398
  }
393
399
 
394
- var date = parse(value);
395
-
396
- if (dateFormat) {
397
- return format(date, dateFormat);
398
- }
399
-
400
- return l10n.formatDate(date);
400
+ var date = parseISO(value);
401
+ return dateFormat ? format(date, convertTokens(dateFormat)) : l10n.formatDate(date);
401
402
  });
402
403
 
403
404
  _defineProperty(_assertThisInitialized(_this), "getPlaceholder", function () {
@@ -497,26 +498,26 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
497
498
  calendarDisabledDateFilter: disabledDateFilter,
498
499
  calendarMaxDate: maxDate,
499
500
  calendarMinDate: minDate,
500
- calendarValue: value && format(parse(value), 'YYYY-MM-DD'),
501
+ calendarValue: value && format(parseISO(value), convertTokens('YYYY-MM-DD')),
501
502
  calendarView: view,
502
503
  onCalendarChange: this.onCalendarChange,
503
504
  onCalendarSelect: this.onCalendarSelect,
504
505
  calendarLocale: locale,
505
506
  calendarWeekStartDay: weekStartDay
506
507
  };
507
- return /*#__PURE__*/React.createElement("div", _extends({}, innerProps, {
508
+ return jsx("div", _extends({}, innerProps, {
508
509
  role: "presentation",
509
510
  onClick: this.onInputClick,
510
511
  onInput: this.onSelectInput,
511
512
  onKeyDown: this.onSelectKeyDown,
512
513
  ref: this.getContainerRef,
513
514
  "data-testid": testId && "".concat(testId, "--container")
514
- }), /*#__PURE__*/React.createElement("input", {
515
+ }), jsx("input", {
515
516
  name: name,
516
517
  type: "hidden",
517
518
  value: value,
518
519
  "data-testid": testId && "".concat(testId, "--input")
519
- }), /*#__PURE__*/React.createElement(Select, _extends({
520
+ }), jsx(Select, _extends({
520
521
  enableAnimation: false,
521
522
  menuIsOpen: menuIsOpen,
522
523
  closeMenuOnSelect: true,
@@ -555,7 +556,7 @@ var DatePicker = /*#__PURE__*/function (_React$Component) {
555
556
  }]);
556
557
 
557
558
  return DatePicker;
558
- }(React.Component);
559
+ }(Component);
559
560
 
560
561
  _defineProperty(DatePicker, "defaultProps", datePickerDefaultProps);
561
562
 
@@ -6,9 +6,6 @@ import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
10
-
11
- var _templateObject, _templateObject2, _templateObject3, _templateObject4;
12
9
 
13
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
11
 
@@ -18,103 +15,92 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
18
15
 
19
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
20
17
 
18
+ /** @jsx jsx */
21
19
  import React from 'react';
22
- import styled from '@emotion/styled'; // eslint-disable-next-line no-restricted-imports
20
+ import { css, jsx } from '@emotion/core'; // eslint-disable-next-line no-restricted-imports
23
21
 
24
- import { format, isValid, parse } from 'date-fns';
22
+ import { format, isValid, parseISO } from 'date-fns';
25
23
  import pick from 'lodash/pick';
26
24
  import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@atlaskit/analytics-next';
27
25
  import SelectClearIcon from '@atlaskit/icon/glyph/select-clear';
28
26
  import { mergeStyles } from '@atlaskit/select';
29
- import * as colors from '@atlaskit/theme/colors';
27
+ import { B100, N0, N20, N30, N500, N70, R400 } from '@atlaskit/theme/colors';
30
28
  import { borderRadius, gridSize } from '@atlaskit/theme/constants';
29
+ import { token } from '@atlaskit/tokens';
31
30
  import { defaultTimes, formatDateTimeZoneIntoIso } from '../internal';
32
31
  import DatePicker from './DatePicker';
33
32
  import TimePicker from './TimePicker';
33
+ import { convertTokens } from './utils';
34
34
  var packageName = "@atlaskit/datetime-picker";
35
- var packageVersion = "10.4.2";
35
+ var packageVersion = "11.1.0";
36
36
  /* eslint-disable react/no-unused-prop-types */
37
37
 
38
- var getBorder = function getBorder(_ref) {
39
- var appearance = _ref.appearance,
40
- isFocused = _ref.isFocused,
41
- isInvalid = _ref.isInvalid;
42
- var color = colors.N20;
43
-
44
- if (appearance === 'subtle') {
45
- color = 'transparent';
46
- }
47
-
48
- if (isFocused) {
49
- color = colors.B100;
50
- }
51
-
52
- if (isInvalid) {
53
- color = colors.R400;
54
- }
55
-
56
- return "border: 2px solid ".concat(color, ";");
57
- };
58
-
59
- var getBorderColorHover = function getBorderColorHover(_ref2) {
60
- var isFocused = _ref2.isFocused,
61
- isInvalid = _ref2.isInvalid,
62
- isDisabled = _ref2.isDisabled;
63
- var color = colors.N30;
64
-
65
- if (isFocused || isDisabled) {
66
- return "";
67
- }
68
-
69
- if (isInvalid) {
70
- color = colors.R400;
71
- }
72
-
73
- return "border-color: ".concat(color, ";");
74
- };
75
-
76
- var getBackgroundColor = function getBackgroundColor(_ref3) {
77
- var appearance = _ref3.appearance,
78
- isFocused = _ref3.isFocused;
79
- var color = colors.N20;
80
-
81
- if (isFocused) {
82
- color = colors.N0;
38
+ var isInvalidBorderStyles = css({
39
+ borderColor: token('color.iconBorder.danger', R400)
40
+ });
41
+ var isFocusedBorderStyles = css({
42
+ borderColor: token('color.border.focus', B100)
43
+ });
44
+ var isFocusedStyles = css({
45
+ backgroundColor: token('color.background.default', N0)
46
+ });
47
+ var subtleBgStyles = css({
48
+ backgroundColor: 'transparent',
49
+ borderColor: 'transparent'
50
+ });
51
+ var hoverStyles = css({
52
+ '&:hover': {
53
+ backgroundColor: token('color.background.default', N30),
54
+ borderColor: token('color.border.neutral', N30)
83
55
  }
84
-
85
- if (appearance === 'subtle') {
86
- color = 'transparent';
56
+ });
57
+ var isInvalidHoverStyles = css({
58
+ '&:hover': {
59
+ backgroundColor: token('color.background.default', N0),
60
+ borderColor: token('color.iconBorder.danger', R400)
87
61
  }
88
-
89
- return "background-color: ".concat(color, ";");
90
- };
91
-
92
- var getBackgroundColorHover = function getBackgroundColorHover(_ref4) {
93
- var isFocused = _ref4.isFocused,
94
- isInvalid = _ref4.isInvalid,
95
- isDisabled = _ref4.isDisabled;
96
- var color = colors.N30;
97
-
98
- if (isFocused || isDisabled) {
99
- return "";
62
+ });
63
+ var isDisabledStyles = css({
64
+ '&:hover': {
65
+ cursor: 'default'
100
66
  }
101
-
102
- if (isInvalid) {
103
- color = colors.N0;
67
+ });
68
+ var baseContainerStyles = css({
69
+ display: 'flex',
70
+ backgroundColor: token('color.background.subtleNeutral.resting', N20),
71
+ border: "2px solid ".concat(token('color.border.neutral', N20)),
72
+ borderRadius: "".concat(borderRadius(), "px"),
73
+ transition: 'background-color 200ms ease-in-out, border-color 200ms ease-in-out',
74
+ '&:hover': {
75
+ cursor: 'pointer'
104
76
  }
105
-
106
- return "background-color: ".concat(color, ";");
107
- };
108
-
109
- var Flex = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n ", "\n border-radius: ", "px;\n display: flex;\n transition: background-color 200ms ease-in-out, border-color 200ms ease-in-out;\n &:hover {\n cursor: ", ";\n ", "\n ", "\n }\n"])), getBackgroundColor, getBorder, borderRadius(), function (props) {
110
- return props.isDisabled ? 'default' : 'pointer';
111
- }, getBackgroundColorHover, getBorderColorHover); // Make DatePicker 50% the width of DateTimePicker
77
+ }); // Make DatePicker 50% the width of DateTimePicker
112
78
  // If rendering an icon container, shrink the TimePicker
113
79
 
114
- var DatePickerContainer = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex-basis: 50%;\n flex-grow: 1;\n flex-shrink: 0;\n"])));
115
- var TimePickerContainer = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n flex-basis: 50%;\n flex-grow: 1;\n"])));
80
+ var datePickerContainerStyles = css({
81
+ flexBasis: '50%',
82
+ flexGrow: 1,
83
+ flexShrink: 0
84
+ });
85
+ var timePickerContainerStyles = css({
86
+ flexBasis: '50%',
87
+ flexGrow: 1
88
+ });
116
89
  var ICON_PADDING = 2;
117
- var IconContainer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex-basis: inherit;\n padding-left: ", "px;\n padding-right: ", "px;\n padding-top: 6px;\n padding-bottom: 6px;\n display: flex;\n align-items: center;\n color: ", ";\n transition: color 150ms;\n &:hover {\n color: ", ";\n }\n"])), ICON_PADDING * 2, gridSize(), colors.N70, colors.N500); // react-select overrides (via @atlaskit/select).
90
+ var iconContainerStyles = css({
91
+ display: 'flex',
92
+ paddingTop: "6px",
93
+ paddingRight: "".concat(gridSize(), "px"),
94
+ paddingBottom: "6px",
95
+ paddingLeft: "".concat(ICON_PADDING * 2, "px"),
96
+ alignItems: 'center',
97
+ flexBasis: 'inherit',
98
+ color: token('color.text.lowEmphasis', N70),
99
+ transition: "color 150ms",
100
+ '&:hover': {
101
+ color: token('color.text.mediumEmphasis', N500)
102
+ }
103
+ }); // react-select overrides (via @atlaskit/select).
118
104
 
119
105
  var styles = {
120
106
  control: function control(style) {
@@ -230,12 +216,11 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
230
216
  return this.props.parseValue(value, dateValue, timeValue, zoneValue);
231
217
  }
232
218
 
233
- var parsed = parse(value);
234
- var valid = isValid(parsed);
235
- return valid ? {
236
- dateValue: format(parsed, 'YYYY-MM-DD'),
237
- timeValue: format(parsed, 'HH:mm'),
238
- zoneValue: format(parsed, 'ZZ')
219
+ var parsed = parseISO(value);
220
+ return isValid(parsed) ? {
221
+ dateValue: format(parsed, convertTokens('YYYY-MM-DD')),
222
+ timeValue: format(parsed, convertTokens('HH:mm')),
223
+ zoneValue: format(parsed, convertTokens('ZZ'))
239
224
  } : {
240
225
  dateValue: dateValue,
241
226
  timeValue: timeValue,
@@ -244,10 +229,10 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
244
229
  }
245
230
  }, {
246
231
  key: "onValueChange",
247
- value: function onValueChange(_ref5) {
248
- var dateValue = _ref5.dateValue,
249
- timeValue = _ref5.timeValue,
250
- zoneValue = _ref5.zoneValue;
232
+ value: function onValueChange(_ref) {
233
+ var dateValue = _ref.dateValue,
234
+ timeValue = _ref.timeValue,
235
+ zoneValue = _ref.zoneValue;
251
236
  this.setState({
252
237
  dateValue: dateValue,
253
238
  timeValue: timeValue,
@@ -322,16 +307,18 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
322
307
 
323
308
 
324
309
  var isClearable = Boolean(dateValue || timeValue);
325
- return /*#__PURE__*/React.createElement(Flex, _extends({}, innerProps, {
326
- isFocused: isFocused,
327
- isDisabled: isDisabled,
328
- isInvalid: this.props.isInvalid,
329
- appearance: this.props.appearance
330
- }), /*#__PURE__*/React.createElement("input", {
310
+ var notFocusedOrIsDisabled = !(isFocused || isDisabled);
311
+ return jsx("div", _extends({
312
+ css: [baseContainerStyles, isDisabled && isDisabledStyles, isFocused && isFocusedStyles, bothProps.appearance === 'subtle' && subtleBgStyles, isFocused && isFocusedBorderStyles, bothProps.isInvalid && isInvalidBorderStyles, notFocusedOrIsDisabled && (bothProps.isInvalid ? isInvalidHoverStyles : hoverStyles)]
313
+ }, innerProps, {
314
+ "data-testid": testId
315
+ }), jsx("input", {
331
316
  name: name,
332
317
  type: "hidden",
333
318
  value: value
334
- }), /*#__PURE__*/React.createElement(DatePickerContainer, null, /*#__PURE__*/React.createElement(DatePicker, _extends({}, bothProps, {
319
+ }), jsx("div", {
320
+ css: datePickerContainerStyles
321
+ }, jsx(DatePicker, _extends({}, bothProps, {
335
322
  autoFocus: autoFocus,
336
323
  dateFormat: dateFormat,
337
324
  hideIcon: true,
@@ -341,7 +328,9 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
341
328
  value: dateValue,
342
329
  locale: locale,
343
330
  testId: testId && "".concat(testId, "--datepicker")
344
- }, datePickerProps))), /*#__PURE__*/React.createElement(TimePickerContainer, null, /*#__PURE__*/React.createElement(TimePicker, _extends({}, bothProps, {
331
+ }, datePickerProps))), jsx("div", {
332
+ css: timePickerContainerStyles
333
+ }, jsx(TimePicker, _extends({}, bothProps, {
345
334
  hideIcon: true,
346
335
  onChange: this.onTimeChange,
347
336
  selectProps: mergedTimePickerSelectProps,
@@ -351,13 +340,12 @@ var DateTimePicker = /*#__PURE__*/function (_React$Component) {
351
340
  timeFormat: timeFormat,
352
341
  locale: locale,
353
342
  testId: testId && "".concat(testId, "--timepicker")
354
- }, timePickerProps))), isClearable && !isDisabled ?
355
- /*#__PURE__*/
356
- // eslint-disable-next-line styled-components-a11y/click-events-have-key-events,styled-components-a11y/no-static-element-interactions
357
- React.createElement(IconContainer, {
343
+ }, timePickerProps))), isClearable && !isDisabled ? // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
344
+ jsx("div", {
345
+ css: iconContainerStyles,
358
346
  onClick: this.onClear,
359
347
  "data-testid": testId && "".concat(testId, "--icon--container")
360
- }, /*#__PURE__*/React.createElement(SelectClearIcon, {
348
+ }, jsx(SelectClearIcon, {
361
349
  size: "small",
362
350
  primaryColor: "inherit",
363
351
  label: "clear"
@@ -25,11 +25,13 @@ import { createLocalizationProvider } from '@atlaskit/locale';
25
25
  import Select, { components, CreatableSelect, mergeStyles } from '@atlaskit/select';
26
26
  import { B100 } from '@atlaskit/theme/colors';
27
27
  import { gridSize } from '@atlaskit/theme/constants';
28
+ import { token } from '@atlaskit/tokens';
28
29
  import { defaultTimeFormat, defaultTimes, DropdownIndicator, EmptyClearIndicator, placeholderDatetime } from '../internal';
29
30
  import FixedLayer from '../internal/FixedLayer';
30
31
  import parseTime from '../internal/parseTime';
32
+ import { convertTokens } from './utils';
31
33
  var packageName = "@atlaskit/datetime-picker";
32
- var packageVersion = "10.4.2";
34
+ var packageVersion = "11.1.0";
33
35
  var menuStyles = {
34
36
  /* Need to remove default absolute positioning as that causes issues with position fixed */
35
37
  position: 'static',
@@ -132,15 +134,14 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
132
134
  if (_this.props.timeIsEditable) {
133
135
  var _this$props = _this.props,
134
136
  parseInputValue = _this$props.parseInputValue,
135
- _timeFormat = _this$props.timeFormat; // TODO parseInputValue doesn't accept `timeFormat` as an function arg yet...
136
-
137
- var _value = format(parseInputValue(inputValue, _timeFormat || defaultTimeFormat), 'HH:mm') || '';
137
+ _timeFormat = _this$props.timeFormat;
138
+ var formattedValue = format(parseInputValue(inputValue, _timeFormat || defaultTimeFormat), 'HH:mm') || '';
138
139
 
139
140
  _this.setState({
140
- value: _value
141
+ value: formattedValue
141
142
  });
142
143
 
143
- _this.props.onChange(_value);
144
+ _this.props.onChange(formattedValue);
144
145
  } else {
145
146
  _this.onChange(inputValue);
146
147
  }
@@ -212,7 +213,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
212
213
 
213
214
  _defineProperty(_assertThisInitialized(_this), "getSubtleControlStyles", function (selectStyles) {
214
215
  return !selectStyles.control ? {
215
- border: "2px solid ".concat(_this.getSafeState().isFocused ? "".concat(B100) : "transparent"),
216
+ border: "2px solid ".concat(_this.getSafeState().isFocused ? token('color.border.focus', B100) : "transparent"),
216
217
  backgroundColor: 'transparent',
217
218
  padding: '1px'
218
219
  } : {};
@@ -241,7 +242,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
241
242
  }
242
243
 
243
244
  if (timeFormat) {
244
- return format(date, timeFormat);
245
+ return format(date, convertTokens(timeFormat));
245
246
  }
246
247
 
247
248
  return l10n.formatTime(date);
@@ -336,7 +337,7 @@ var TimePicker = /*#__PURE__*/function (_React$Component) {
336
337
  return _objectSpread(_objectSpread({}, base), controlStyles);
337
338
  },
338
339
  menu: function menu(base) {
339
- return _objectSpread(_objectSpread(_objectSpread({}, base), menuStyles), {
340
+ return _objectSpread(_objectSpread(_objectSpread({}, base), menuStyles), {}, {
340
341
  // Fixed positioned elements no longer inherit width from their parent, so we must explicitly set the
341
342
  // menu width to the width of our container
342
343
  width: _this3.containerRef ? _this3.containerRef.getBoundingClientRect().width : 'auto'
@@ -0,0 +1,89 @@
1
+ // https://github.com/date-fns/date-fns-upgrade/blob/master/src/v2/convertTokens/index.ts
2
+ var tokensMap = {
3
+ // 'D MMMM': '',
4
+ // 'Do MMMM': '',
5
+ // 'DD MMMM': '',
6
+ M: 'L',
7
+ Mo: 'Mo',
8
+ MM: 'LL',
9
+ MMM: 'LLL',
10
+ MMMM: 'LLLL',
11
+ Q: 'q',
12
+ Qo: 'qo',
13
+ D: 'd',
14
+ Do: 'do',
15
+ DD: 'dd',
16
+ DDD: 'D',
17
+ DDDo: 'Do',
18
+ DDDD: 'DDD',
19
+ d: 'i',
20
+ do: 'io',
21
+ dd: 'iiiiii',
22
+ ddd: 'iii',
23
+ dddd: 'iiii',
24
+ A: 'a',
25
+ a: 'a',
26
+ aa: 'aaaa',
27
+ E: 'i',
28
+ W: 'I',
29
+ Wo: 'Io',
30
+ WW: 'II',
31
+ YY: 'yy',
32
+ YYYY: 'yyyy',
33
+ GG: 'RR',
34
+ GGGG: 'RRRR',
35
+ H: 'H',
36
+ HH: 'HH',
37
+ h: 'h',
38
+ hh: 'hh',
39
+ m: 'm',
40
+ mm: 'mm',
41
+ s: 's',
42
+ ss: 'ss',
43
+ S: 'S',
44
+ SS: 'SS',
45
+ SSS: 'SSS',
46
+ Z: 'xxx',
47
+ ZZ: 'xx',
48
+ X: 't',
49
+ x: 'T'
50
+ };
51
+ var v1tokens = Object.keys(tokensMap).sort().reverse();
52
+ var tokensRegExp = new RegExp('(\\[[^\\[]*\\])|(\\\\)?' + '(' + v1tokens.join('|') + '|.)', 'g');
53
+ export function convertTokens(format) {
54
+ var tokensCaptures = format.match(tokensRegExp);
55
+
56
+ if (tokensCaptures) {
57
+ return tokensCaptures.reduce(function (acc, tokenString, index) {
58
+ var v2token = tokensMap[tokenString];
59
+
60
+ if (!v2token) {
61
+ var escapedCaptures = tokenString.match(/^\[(.+)\]$/);
62
+
63
+ if (escapedCaptures) {
64
+ acc.textBuffer.push(escapedCaptures[1]);
65
+ } else {
66
+ acc.textBuffer.push(tokenString);
67
+ }
68
+ }
69
+
70
+ var endOfString = index === tokensCaptures.length - 1;
71
+
72
+ if (acc.textBuffer.length && (v2token || endOfString)) {
73
+ acc.formatBuffer.push("'".concat(acc.textBuffer.join(''), "'"));
74
+ acc.textBuffer = [];
75
+ }
76
+
77
+ if (v2token) {
78
+ acc.formatBuffer.push(v2token);
79
+ }
80
+
81
+ return acc;
82
+ }, {
83
+ formatBuffer: [],
84
+ textBuffer: []
85
+ }).formatBuffer.join('');
86
+ } else {
87
+ return format;
88
+ }
89
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "10.4.2",
3
+ "version": "11.1.0",
4
4
  "sideEffects": false
5
5
  }