@synerise/ds-date-picker 0.13.2 → 0.13.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.13.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.13.2...@synerise/ds-date-picker@0.13.3) (2024-11-28)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-date-picker
9
+
10
+
11
+
12
+
13
+
6
14
  ## [0.13.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.13.1...@synerise/ds-date-picker@0.13.2) (2024-11-21)
7
15
 
8
16
 
@@ -1,9 +1,6 @@
1
1
  var _excluded = ["autoFocus", "disabled", "texts", "format", "valueFormatOptions", "value", "onApply", "showTime", "onValueChange", "onClear", "errorText", "popoverPlacement", "prefixel", "error", "onDropdownVisibleChange", "dropdownProps", "suffixel", "hideNow", "readOnly", "renderTrigger", "inputProps", "allowClear"];
2
-
3
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
-
5
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
4
  import React, { useCallback, useEffect, useRef, useState } from 'react';
8
5
  import { useIntl } from 'react-intl';
9
6
  import Dropdown from '@synerise/ds-dropdown';
@@ -12,41 +9,37 @@ import RawDatePicker from './RawDatePicker/RawDatePicker';
12
9
  import PickerInput from './Elements/PickerInput/PickerInput';
13
10
  import * as S from './DatePicker.styles';
14
11
  import { getDefaultTexts } from './utils/getDefaultTexts';
15
-
16
12
  var DatePicker = function DatePicker(_ref) {
17
13
  var autoFocus = _ref.autoFocus,
18
- disabled = _ref.disabled,
19
- texts = _ref.texts,
20
- format = _ref.format,
21
- valueFormatOptions = _ref.valueFormatOptions,
22
- value = _ref.value,
23
- onApply = _ref.onApply,
24
- showTime = _ref.showTime,
25
- onValueChange = _ref.onValueChange,
26
- onClear = _ref.onClear,
27
- errorText = _ref.errorText,
28
- popoverPlacement = _ref.popoverPlacement,
29
- prefixel = _ref.prefixel,
30
- error = _ref.error,
31
- onDropdownVisibleChange = _ref.onDropdownVisibleChange,
32
- dropdownProps = _ref.dropdownProps,
33
- suffixel = _ref.suffixel,
34
- hideNow = _ref.hideNow,
35
- readOnly = _ref.readOnly,
36
- renderTrigger = _ref.renderTrigger,
37
- inputProps = _ref.inputProps,
38
- _ref$allowClear = _ref.allowClear,
39
- allowClear = _ref$allowClear === void 0 ? true : _ref$allowClear,
40
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
41
-
14
+ disabled = _ref.disabled,
15
+ texts = _ref.texts,
16
+ format = _ref.format,
17
+ valueFormatOptions = _ref.valueFormatOptions,
18
+ value = _ref.value,
19
+ onApply = _ref.onApply,
20
+ showTime = _ref.showTime,
21
+ onValueChange = _ref.onValueChange,
22
+ onClear = _ref.onClear,
23
+ errorText = _ref.errorText,
24
+ popoverPlacement = _ref.popoverPlacement,
25
+ prefixel = _ref.prefixel,
26
+ error = _ref.error,
27
+ onDropdownVisibleChange = _ref.onDropdownVisibleChange,
28
+ dropdownProps = _ref.dropdownProps,
29
+ suffixel = _ref.suffixel,
30
+ hideNow = _ref.hideNow,
31
+ readOnly = _ref.readOnly,
32
+ renderTrigger = _ref.renderTrigger,
33
+ inputProps = _ref.inputProps,
34
+ _ref$allowClear = _ref.allowClear,
35
+ allowClear = _ref$allowClear === void 0 ? true : _ref$allowClear,
36
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
42
37
  var _useState = useState(autoFocus || false),
43
- dropVisible = _useState[0],
44
- setDropVisible = _useState[1];
45
-
38
+ dropVisible = _useState[0],
39
+ setDropVisible = _useState[1];
46
40
  var _useState2 = useState(value),
47
- selectedDate = _useState2[0],
48
- setSelectedDate = _useState2[1];
49
-
41
+ selectedDate = _useState2[0],
42
+ setSelectedDate = _useState2[1];
50
43
  var ref = useRef(null);
51
44
  var intl = useIntl();
52
45
  var allTexts = getDefaultTexts(intl, texts);
@@ -111,5 +104,4 @@ var DatePicker = function DatePicker(_ref) {
111
104
  disabled: disabled
112
105
  }, dropdownProps), trigger);
113
106
  };
114
-
115
107
  export default DatePicker;
@@ -1,9 +1,6 @@
1
1
  var _excluded = ["month", "onMonthChange", "onMonthNameClick", "onYearNameClick", "hideLongNext", "hideLongPrev", "hideShortNext", "hideShortPrev", "renderNavbar", "intl", "modifiers"];
2
-
3
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
-
5
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
4
  import React from 'react';
8
5
  import { injectIntl } from 'react-intl';
9
6
  import { useDataFormat } from '@synerise/ds-data-format';
@@ -13,28 +10,24 @@ import { fnsAddMonths, fnsAddYears } from '../../fns';
13
10
  import localeUtils from '../../localeUtils';
14
11
  import { DayPicker } from './DayPicker.styles';
15
12
  import * as S from '../Navbar/Navbar.styles';
16
-
17
13
  var captionElement = function captionElement() {
18
14
  return null;
19
15
  };
20
-
21
16
  var Picker = function Picker(props) {
22
17
  var month = props.month,
23
- onMonthChange = props.onMonthChange,
24
- onMonthNameClick = props.onMonthNameClick,
25
- onYearNameClick = props.onYearNameClick,
26
- hideLongNext = props.hideLongNext,
27
- hideLongPrev = props.hideLongPrev,
28
- hideShortNext = props.hideShortNext,
29
- hideShortPrev = props.hideShortPrev,
30
- renderNavbar = props.renderNavbar,
31
- intl = props.intl,
32
- modifiers = props.modifiers,
33
- rest = _objectWithoutPropertiesLoose(props, _excluded);
34
-
18
+ onMonthChange = props.onMonthChange,
19
+ onMonthNameClick = props.onMonthNameClick,
20
+ onYearNameClick = props.onYearNameClick,
21
+ hideLongNext = props.hideLongNext,
22
+ hideLongPrev = props.hideLongPrev,
23
+ hideShortNext = props.hideShortNext,
24
+ hideShortPrev = props.hideShortPrev,
25
+ renderNavbar = props.renderNavbar,
26
+ intl = props.intl,
27
+ modifiers = props.modifiers,
28
+ rest = _objectWithoutPropertiesLoose(props, _excluded);
35
29
  var _useDataFormat = useDataFormat(),
36
- firstDayOfWeek = _useDataFormat.firstDayOfWeek;
37
-
30
+ firstDayOfWeek = _useDataFormat.firstDayOfWeek;
38
31
  return /*#__PURE__*/React.createElement(React.Fragment, null, renderNavbar ? renderNavbar(props) : /*#__PURE__*/React.createElement(Navbar, {
39
32
  title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.Link, {
40
33
  "data-testid": "datapicker-nav-title-monthpicker-link",
@@ -66,5 +59,4 @@ var Picker = function Picker(props) {
66
59
  modifiers: modifiers
67
60
  }, rest)));
68
61
  };
69
-
70
62
  export default injectIntl(Picker);
@@ -1,11 +1,9 @@
1
1
  import styled from 'styled-components';
2
2
  import DayPickerBase from 'react-day-picker';
3
3
  var DaySelectorPrefix = ".DayPicker-Day";
4
-
5
4
  var daySelector = function daySelector(modifier) {
6
5
  return DaySelectorPrefix + "--" + modifier;
7
6
  };
8
-
9
7
  export var DayBackground = styled.div.withConfig({
10
8
  displayName: "DayPickerstyles__DayBackground",
11
9
  componentId: "oi7l9r-0"
@@ -1,13 +1,8 @@
1
1
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2
-
3
2
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import { range } from 'lodash';
13
8
  import { legacyParse } from '@date-fns/upgrade/v2';
@@ -15,13 +10,11 @@ import GridPicker from '../GridPicker/GridPicker';
15
10
  import Navbar from '../Navbar/Navbar';
16
11
  import { getDecadeRange, getCenturyRange } from '../../utils';
17
12
  import { fnsAddYears, fnsSetYear, fnsGetYear } from '../../fns';
18
-
19
13
  function getInitialState(props) {
20
14
  return {
21
15
  cursor: props.value || new Date()
22
16
  };
23
17
  }
24
-
25
18
  function getCells(cursor) {
26
19
  var startYear = getCenturyRange(cursor)[0];
27
20
  return range(0, 10).map(function (index) {
@@ -32,75 +25,54 @@ function getCells(cursor) {
32
25
  };
33
26
  });
34
27
  }
35
-
36
28
  var DecadePicker = /*#__PURE__*/function (_React$PureComponent) {
37
29
  function DecadePicker() {
38
30
  var _this;
39
-
40
31
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
41
32
  args[_key] = arguments[_key];
42
33
  }
43
-
44
34
  _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
45
-
46
35
  _defineProperty(_this, "state", getInitialState(_this.props));
47
-
48
36
  _defineProperty(_this, "handleLongPrev", function () {
49
37
  var cursor = _this.state.cursor;
50
-
51
38
  _this.setState({
52
39
  cursor: fnsAddYears(cursor, -100)
53
40
  });
54
41
  });
55
-
56
42
  _defineProperty(_this, "handleLongNext", function () {
57
43
  var cursor = _this.state.cursor;
58
-
59
44
  _this.setState({
60
45
  cursor: fnsAddYears(cursor, 100)
61
46
  });
62
47
  });
63
-
64
48
  _defineProperty(_this, "handleCellClick", function (isoDate) {
65
49
  var onChange = _this.props.onChange;
66
-
67
50
  if (isoDate === -1) {
68
51
  _this.handleLongPrev();
69
-
70
52
  return;
71
53
  }
72
-
73
54
  if (isoDate === 1) {
74
55
  _this.handleLongNext();
75
-
76
56
  return;
77
57
  }
78
-
79
58
  onChange && onChange(new Date(isoDate));
80
59
  });
81
-
82
60
  return _this;
83
61
  }
84
-
85
62
  _inheritsLoose(DecadePicker, _React$PureComponent);
86
-
87
63
  var _proto = DecadePicker.prototype;
88
-
89
64
  _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
90
65
  var value = this.props.value;
91
-
92
66
  if ((prevProps == null ? void 0 : prevProps.value) !== value) {
93
67
  this.setState(getInitialState(this.props));
94
68
  }
95
-
96
69
  return null;
97
70
  };
98
-
99
71
  _proto.render = function render() {
100
72
  var cursor = this.state.cursor;
101
73
  var _this$props = this.props,
102
- value = _this$props.value,
103
- onTitleClick = _this$props.onTitleClick;
74
+ value = _this$props.value,
75
+ onTitleClick = _this$props.onTitleClick;
104
76
  var centuryRange = getCenturyRange(cursor);
105
77
  var cells = getCells(cursor);
106
78
  var valueCell = value ? cells.find(function (cell) {
@@ -132,8 +104,6 @@ var DecadePicker = /*#__PURE__*/function (_React$PureComponent) {
132
104
  key: "body"
133
105
  })];
134
106
  };
135
-
136
107
  return DecadePicker;
137
108
  }(React.PureComponent);
138
-
139
109
  export { DecadePicker as default };
@@ -1,9 +1,6 @@
1
1
  var _excluded = ["text", "canApply", "onApply", "intl", "canSwitchMode", "onSwitchMode", "mode", "dateOnly", "message", "texts", "hideNow"];
2
-
3
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
-
5
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
-
7
4
  import React from 'react';
8
5
  import { injectIntl } from 'react-intl';
9
6
  import { v4 as uuid } from 'uuid';
@@ -11,21 +8,19 @@ import Button from '@synerise/ds-button';
11
8
  import Tooltip from '@synerise/ds-tooltip';
12
9
  import Icon, { CalendarM, ClockM } from '@synerise/ds-icon';
13
10
  import * as S from './Footer.styles';
14
-
15
11
  var Footer = function Footer(_ref) {
16
12
  var text = _ref.text,
17
- canApply = _ref.canApply,
18
- onApply = _ref.onApply,
19
- intl = _ref.intl,
20
- canSwitchMode = _ref.canSwitchMode,
21
- onSwitchMode = _ref.onSwitchMode,
22
- mode = _ref.mode,
23
- dateOnly = _ref.dateOnly,
24
- message = _ref.message,
25
- texts = _ref.texts,
26
- hideNow = _ref.hideNow,
27
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
28
-
13
+ canApply = _ref.canApply,
14
+ onApply = _ref.onApply,
15
+ intl = _ref.intl,
16
+ canSwitchMode = _ref.canSwitchMode,
17
+ onSwitchMode = _ref.onSwitchMode,
18
+ mode = _ref.mode,
19
+ dateOnly = _ref.dateOnly,
20
+ message = _ref.message,
21
+ texts = _ref.texts,
22
+ hideNow = _ref.hideNow,
23
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
29
24
  var SwitchModeButton = React.useMemo(function () {
30
25
  return /*#__PURE__*/React.createElement(Button, {
31
26
  type: "ghost",
@@ -58,5 +53,4 @@ var Footer = function Footer(_ref) {
58
53
  }
59
54
  }, texts.apply))));
60
55
  };
61
-
62
56
  export default injectIntl(Footer);
@@ -1,39 +1,29 @@
1
1
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2
-
3
2
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import classNames from 'classnames';
13
8
  import * as S from './GridPicker.styles';
14
-
15
9
  var GridPicker = /*#__PURE__*/function (_React$PureComponent) {
16
10
  function GridPicker() {
17
11
  var _this;
18
-
19
12
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
20
13
  args[_key] = arguments[_key];
21
14
  }
22
-
23
15
  _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
24
-
25
16
  _defineProperty(_this, "handleCellClick", function (cell) {
26
17
  if (cell.disabled) return;
27
18
  var onCellClick = _this.props.onCellClick;
28
19
  onCellClick && onCellClick(cell.key);
29
20
  });
30
-
31
21
  _defineProperty(_this, "renderCell", function (cell) {
32
22
  var selectedKey = _this.props.selectedKey;
33
23
  var key = cell.key,
34
- text = cell.text,
35
- disabled = cell.disabled,
36
- outside = cell.outside;
24
+ text = cell.text,
25
+ disabled = cell.disabled,
26
+ outside = cell.outside;
37
27
  return /*#__PURE__*/React.createElement(S.CellContainer, {
38
28
  className: classNames('cell', {
39
29
  'cell--selected': selectedKey === key,
@@ -49,20 +39,14 @@ var GridPicker = /*#__PURE__*/function (_React$PureComponent) {
49
39
  className: "cell-content"
50
40
  }, text));
51
41
  });
52
-
53
42
  return _this;
54
43
  }
55
-
56
44
  _inheritsLoose(GridPicker, _React$PureComponent);
57
-
58
45
  var _proto = GridPicker.prototype;
59
-
60
46
  _proto.render = function render() {
61
47
  var cells = this.props.cells;
62
48
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.GridContainer, null, cells.map(this.renderCell)));
63
49
  };
64
-
65
50
  return GridPicker;
66
51
  }(React.PureComponent);
67
-
68
52
  export { GridPicker as default };
@@ -1,13 +1,8 @@
1
1
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2
-
3
2
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import { injectIntl } from 'react-intl';
13
8
  import { range } from 'lodash';
@@ -17,14 +12,12 @@ import fnsFormat from '../../format';
17
12
  import YearPicker from '../YearPicker/YearPicker';
18
13
  import GridPicker from '../GridPicker/GridPicker';
19
14
  import Navbar from '../Navbar/Navbar';
20
-
21
15
  function getInitialState(props) {
22
16
  return {
23
17
  cursor: props.value || new Date(),
24
18
  yearMode: false
25
19
  };
26
20
  }
27
-
28
21
  function getCells(cursor, min, max, locale) {
29
22
  var minDate = min ? fnsStartOfMonth(min) : fnsSetMonth(cursor, 0);
30
23
  var maxDate = max ? fnsEndOfMonth(max) : fnsSetMonth(cursor, 12);
@@ -37,70 +30,53 @@ function getCells(cursor, min, max, locale) {
37
30
  };
38
31
  });
39
32
  }
40
-
41
33
  var MonthPicker = /*#__PURE__*/function (_React$PureComponent) {
42
34
  function MonthPicker() {
43
35
  var _this;
44
-
45
36
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
46
37
  args[_key] = arguments[_key];
47
38
  }
48
-
49
39
  _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
50
-
51
40
  _defineProperty(_this, "state", getInitialState(_this.props));
52
-
53
41
  _defineProperty(_this, "handleLongPrev", function () {
54
42
  var cursor = _this.state.cursor;
55
-
56
43
  _this.setState({
57
44
  cursor: fnsAddYears(cursor, -1)
58
45
  });
59
46
  });
60
-
61
47
  _defineProperty(_this, "handleLongNext", function () {
62
48
  var cursor = _this.state.cursor;
63
-
64
49
  _this.setState({
65
50
  cursor: fnsAddYears(cursor, 1)
66
51
  });
67
52
  });
68
-
69
53
  return _this;
70
54
  }
71
-
72
55
  _inheritsLoose(MonthPicker, _React$PureComponent);
73
-
74
56
  var _proto = MonthPicker.prototype;
75
-
76
57
  _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
77
58
  var value = this.props.value;
78
-
79
59
  if ((prevProps == null ? void 0 : prevProps.value) !== value) {
80
60
  this.setState(getInitialState(this.props));
81
61
  }
82
-
83
62
  return null;
84
63
  };
85
-
86
64
  _proto.render = function render() {
87
65
  var _this2 = this;
88
-
89
66
  var _this$state = this.state,
90
- cursor = _this$state.cursor,
91
- yearMode = _this$state.yearMode;
67
+ cursor = _this$state.cursor,
68
+ yearMode = _this$state.yearMode;
92
69
  var _this$props = this.props,
93
- min = _this$props.min,
94
- max = _this$props.max,
95
- value = _this$props.value,
96
- intl = _this$props.intl,
97
- onChange = _this$props.onChange;
70
+ min = _this$props.min,
71
+ max = _this$props.max,
72
+ value = _this$props.value,
73
+ intl = _this$props.intl,
74
+ onChange = _this$props.onChange;
98
75
  var cells = getCells(cursor, min, max, intl == null ? void 0 : intl.locale);
99
76
  var valueCell = value ? cells.find(function (cell) {
100
77
  return fnsIsSameMonth(value, legacyParse(cell.key));
101
78
  }) : null;
102
79
  var selectedKey = valueCell ? valueCell.key : null;
103
-
104
80
  if (yearMode) {
105
81
  return /*#__PURE__*/React.createElement(YearPicker, {
106
82
  value: cursor,
@@ -112,7 +88,6 @@ var MonthPicker = /*#__PURE__*/function (_React$PureComponent) {
112
88
  }
113
89
  });
114
90
  }
115
-
116
91
  return [/*#__PURE__*/React.createElement(Navbar, {
117
92
  onTitleClick: function onTitleClick() {
118
93
  return _this2.setState({
@@ -132,8 +107,6 @@ var MonthPicker = /*#__PURE__*/function (_React$PureComponent) {
132
107
  key: "body"
133
108
  })];
134
109
  };
135
-
136
110
  return MonthPicker;
137
111
  }(React.PureComponent);
138
-
139
112
  export default injectIntl(MonthPicker);
@@ -2,18 +2,17 @@ import React from 'react';
2
2
  import { v4 as uuid } from 'uuid';
3
3
  import Icon, { AngleLeftS, AngleRightS, DoubleAngleLeftS, DoubleAngleRightS } from '@synerise/ds-icon';
4
4
  import * as S from './Navbar.styles';
5
-
6
5
  var Navbar = function Navbar(props) {
7
6
  var title = props.title,
8
- onTitleClick = props.onTitleClick,
9
- hidePrev = props.hidePrev,
10
- hideNext = props.hideNext,
11
- onLongPrev = props.onLongPrev,
12
- onLongNext = props.onLongNext,
13
- onShortPrev = props.onShortPrev,
14
- onShortNext = props.onShortNext,
15
- inactivePrev = props.inactivePrev,
16
- inactiveNext = props.inactiveNext;
7
+ onTitleClick = props.onTitleClick,
8
+ hidePrev = props.hidePrev,
9
+ hideNext = props.hideNext,
10
+ onLongPrev = props.onLongPrev,
11
+ onLongNext = props.onLongNext,
12
+ onShortPrev = props.onShortPrev,
13
+ onShortNext = props.onShortNext,
14
+ inactivePrev = props.inactivePrev,
15
+ inactiveNext = props.inactiveNext;
17
16
  return /*#__PURE__*/React.createElement(S.Container, {
18
17
  className: "ds-date-picker-nav"
19
18
  }, /*#__PURE__*/React.createElement(S.ArrowContainer, null, onLongPrev && !hidePrev ? /*#__PURE__*/React.createElement(S.NavButton, {
@@ -68,5 +67,4 @@ var Navbar = function Navbar(props) {
68
67
  className: "arrow-placeholder long-next"
69
68
  })));
70
69
  };
71
-
72
70
  export default Navbar;
@@ -1,19 +1,11 @@
1
1
  var _excluded = ["autoFocus", "size", "disabled", "readOnly", "value", "format", "valueFormatOptions", "onChange", "showTime", "placeholder", "onClear", "onClick", "clearTooltip", "highlight", "error", "errorText", "prefixel", "suffixel", "allowClear"];
2
-
3
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
-
5
3
  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; }
6
-
7
4
  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) { _defineProperty(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; }
8
-
9
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
-
11
6
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
-
13
7
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
-
15
8
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
-
17
9
  import React, { useCallback, useMemo, useState } from 'react';
18
10
  import Icon, { CalendarM, Close3S } from '@synerise/ds-icon';
19
11
  import Tooltip from '@synerise/ds-tooltip';
@@ -21,47 +13,40 @@ import { getDefaultDataTimeOptions, useDataFormat } from '@synerise/ds-data-form
21
13
  import { legacyParse } from '@date-fns/upgrade/v2';
22
14
  import * as S from './PickerInput.styles';
23
15
  import format from '../../format';
24
-
25
16
  var PickerInput = function PickerInput(_ref) {
26
17
  var autoFocus = _ref.autoFocus,
27
- size = _ref.size,
28
- disabled = _ref.disabled,
29
- readOnly = _ref.readOnly,
30
- value = _ref.value,
31
- dateFormat = _ref.format,
32
- valueFormatOptions = _ref.valueFormatOptions,
33
- onChange = _ref.onChange,
34
- showTime = _ref.showTime,
35
- placeholder = _ref.placeholder,
36
- onClear = _ref.onClear,
37
- onClick = _ref.onClick,
38
- clearTooltip = _ref.clearTooltip,
39
- highlight = _ref.highlight,
40
- error = _ref.error,
41
- errorText = _ref.errorText,
42
- prefixel = _ref.prefixel,
43
- suffixel = _ref.suffixel,
44
- allowClear = _ref.allowClear,
45
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
46
-
18
+ size = _ref.size,
19
+ disabled = _ref.disabled,
20
+ readOnly = _ref.readOnly,
21
+ value = _ref.value,
22
+ dateFormat = _ref.format,
23
+ valueFormatOptions = _ref.valueFormatOptions,
24
+ onChange = _ref.onChange,
25
+ showTime = _ref.showTime,
26
+ placeholder = _ref.placeholder,
27
+ onClear = _ref.onClear,
28
+ onClick = _ref.onClick,
29
+ clearTooltip = _ref.clearTooltip,
30
+ highlight = _ref.highlight,
31
+ error = _ref.error,
32
+ errorText = _ref.errorText,
33
+ prefixel = _ref.prefixel,
34
+ suffixel = _ref.suffixel,
35
+ allowClear = _ref.allowClear,
36
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
47
37
  var _useDataFormat = useDataFormat(),
48
- formatValue = _useDataFormat.formatValue;
49
-
38
+ formatValue = _useDataFormat.formatValue;
50
39
  var _useState = useState(false),
51
- hovered = _useState[0],
52
- setHovered = _useState[1];
53
-
40
+ hovered = _useState[0],
41
+ setHovered = _useState[1];
54
42
  var getText = useCallback(function () {
55
43
  if (!value) return '';
56
-
57
44
  if (dateFormat) {
58
45
  return format(legacyParse(value), dateFormat);
59
46
  }
60
-
61
47
  if (typeof value === 'string') {
62
48
  return format(legacyParse(value), dateFormat || showTime ? 'MMM d, yyyy, HH:mm' : 'MMM d, yyyy');
63
49
  }
64
-
65
50
  return formatValue(value, _objectSpread({}, getDefaultDataTimeOptions(showTime), {}, valueFormatOptions));
66
51
  }, [value, dateFormat, showTime, formatValue, valueFormatOptions]);
67
52
  var handleApply = useCallback(function (date) {
@@ -114,5 +99,4 @@ var PickerInput = function PickerInput(_ref) {
114
99
  errorText: errorText
115
100
  }, rest))), !!suffixel && /*#__PURE__*/React.createElement(S.Suffixel, null, suffixel));
116
101
  };
117
-
118
102
  export default PickerInput;
@@ -12,11 +12,9 @@ export var Suffixel = styled.div.withConfig({
12
12
  })(["border:1px solid ", ";border-radius:0 3px 3px 0;border-left-width:0;"], function (props) {
13
13
  return props.theme.palette['grey-300'];
14
14
  });
15
-
16
15
  var activeStyle = function activeStyle(props) {
17
16
  return css(["box-shadow:inset 0 0 0 1px ", ";border-color:", ";background:", ";"], props.theme.palette['blue-600'], props.theme.palette['blue-600'], props.theme.palette['blue-050']);
18
17
  };
19
-
20
18
  export var Input = styled(DSInput).withConfig({
21
19
  displayName: "PickerInputstyles__Input",
22
20
  componentId: "sc-168pcz5-2"
@@ -1,37 +1,29 @@
1
1
  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; }
2
-
3
2
  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) { _defineProperty(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; }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import { useDataFormat, getDefaultDataTimeOptions } from '@synerise/ds-data-format';
13
8
  import Navbar from '../Navbar/Navbar';
14
9
  import * as S from './TimePicker.styles';
15
-
16
10
  var TimePicker = function TimePicker(_ref) {
17
11
  var _ref$value = _ref.value,
18
- value = _ref$value === void 0 ? new Date() : _ref$value,
19
- _ref$disabledHours = _ref.disabledHours,
20
- disabledHours = _ref$disabledHours === void 0 ? [] : _ref$disabledHours,
21
- _ref$disabledMinutes = _ref.disabledMinutes,
22
- disabledMinutes = _ref$disabledMinutes === void 0 ? [] : _ref$disabledMinutes,
23
- _ref$disabledSeconds = _ref.disabledSeconds,
24
- disabledSeconds = _ref$disabledSeconds === void 0 ? [] : _ref$disabledSeconds,
25
- inactivePrev = _ref.inactivePrev,
26
- inactiveNext = _ref.inactiveNext,
27
- onChange = _ref.onChange,
28
- onShortNext = _ref.onShortNext,
29
- onShortPrev = _ref.onShortPrev;
30
-
12
+ value = _ref$value === void 0 ? new Date() : _ref$value,
13
+ _ref$disabledHours = _ref.disabledHours,
14
+ disabledHours = _ref$disabledHours === void 0 ? [] : _ref$disabledHours,
15
+ _ref$disabledMinutes = _ref.disabledMinutes,
16
+ disabledMinutes = _ref$disabledMinutes === void 0 ? [] : _ref$disabledMinutes,
17
+ _ref$disabledSeconds = _ref.disabledSeconds,
18
+ disabledSeconds = _ref$disabledSeconds === void 0 ? [] : _ref$disabledSeconds,
19
+ inactivePrev = _ref.inactivePrev,
20
+ inactiveNext = _ref.inactiveNext,
21
+ onChange = _ref.onChange,
22
+ onShortNext = _ref.onShortNext,
23
+ onShortPrev = _ref.onShortPrev;
31
24
  var _useDataFormat = useDataFormat(),
32
- is12HoursClock = _useDataFormat.is12HoursClock,
33
- formatValue = _useDataFormat.formatValue;
34
-
25
+ is12HoursClock = _useDataFormat.is12HoursClock,
26
+ formatValue = _useDataFormat.formatValue;
35
27
  var navbarDate = formatValue(value, _objectSpread({}, getDefaultDataTimeOptions(), {
36
28
  targetFormat: 'date',
37
29
  month: 'short'
@@ -56,5 +48,4 @@ var TimePicker = function TimePicker(_ref) {
56
48
  raw: true
57
49
  })));
58
50
  };
59
-
60
51
  export default TimePicker;
@@ -1,13 +1,8 @@
1
1
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2
-
3
2
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import { legacyParse } from '@date-fns/upgrade/v2';
13
8
  import fnsFormat from '../../format';
@@ -16,14 +11,12 @@ import GridPicker from '../GridPicker/GridPicker';
16
11
  import Navbar from '../Navbar/Navbar';
17
12
  import { getDecadeRange } from '../../utils';
18
13
  import { fnsAddYears, fnsSetYear, fnsIsSameYear } from '../../fns';
19
-
20
14
  function getInitialState(props) {
21
15
  return {
22
16
  cursor: props.value || new Date(),
23
17
  decadeMode: false
24
18
  };
25
19
  }
26
-
27
20
  function getCells(cursor) {
28
21
  var startYear = getDecadeRange(cursor)[0];
29
22
  return Array.from(Array(10)).map(function (_, index) {
@@ -34,76 +27,54 @@ function getCells(cursor) {
34
27
  };
35
28
  });
36
29
  }
37
-
38
30
  var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
39
31
  function YearPicker() {
40
32
  var _this;
41
-
42
33
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
43
34
  args[_key] = arguments[_key];
44
35
  }
45
-
46
36
  _this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
47
-
48
37
  _defineProperty(_this, "state", getInitialState(_this.props));
49
-
50
38
  _defineProperty(_this, "handleLongPrev", function () {
51
39
  var cursor = _this.state.cursor;
52
-
53
40
  _this.setState({
54
41
  cursor: fnsAddYears(cursor, -10)
55
42
  });
56
43
  });
57
-
58
44
  _defineProperty(_this, "handleLongNext", function () {
59
45
  var cursor = _this.state.cursor;
60
-
61
46
  _this.setState({
62
47
  cursor: fnsAddYears(cursor, 10)
63
48
  });
64
49
  });
65
-
66
50
  _defineProperty(_this, "handleCellClick", function (isoDate) {
67
51
  var onChange = _this.props.onChange;
68
-
69
52
  if (isoDate === -1) {
70
53
  _this.handleLongPrev();
71
-
72
54
  return;
73
55
  }
74
-
75
56
  if (isoDate === 1) {
76
57
  _this.handleLongNext();
77
-
78
58
  return;
79
59
  }
80
-
81
60
  onChange && onChange(new Date(isoDate));
82
61
  });
83
-
84
62
  return _this;
85
63
  }
86
-
87
64
  _inheritsLoose(YearPicker, _React$PureComponent);
88
-
89
65
  var _proto = YearPicker.prototype;
90
-
91
66
  _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
92
67
  var value = this.props.value;
93
-
94
68
  if (value && (prevProps == null ? void 0 : prevProps.value) !== value) {
95
69
  this.setState(getInitialState(this.props));
96
70
  }
97
-
98
71
  return null;
99
72
  };
100
-
101
73
  _proto.render = function render() {
102
74
  var _this2 = this;
103
-
104
75
  var _this$state = this.state,
105
- cursor = _this$state.cursor,
106
- decadeMode = _this$state.decadeMode;
76
+ cursor = _this$state.cursor,
77
+ decadeMode = _this$state.decadeMode;
107
78
  var value = this.props.value;
108
79
  var decadeRange = getDecadeRange(cursor);
109
80
  var cells = getCells(cursor);
@@ -120,7 +91,6 @@ var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
120
91
  text: decadeRange[1] + 1,
121
92
  outside: true
122
93
  }]);
123
-
124
94
  if (decadeMode) {
125
95
  return /*#__PURE__*/React.createElement(DecadePicker, {
126
96
  value: cursor,
@@ -132,7 +102,6 @@ var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
132
102
  }
133
103
  });
134
104
  }
135
-
136
105
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Navbar, {
137
106
  onTitleClick: function onTitleClick() {
138
107
  return _this2.setState({
@@ -150,8 +119,6 @@ var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
150
119
  key: "body"
151
120
  }));
152
121
  };
153
-
154
122
  return YearPicker;
155
123
  }(React.PureComponent);
156
-
157
124
  export { YearPicker as default };
@@ -1,13 +1,8 @@
1
1
  function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
2
-
3
2
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import { injectIntl } from 'react-intl';
13
8
  import { legacyParse } from '@date-fns/upgrade/v2';
@@ -22,64 +17,55 @@ import { DayBackground, DayText, DayForeground } from '../Elements/DayPicker/Day
22
17
  import { fnsStartOfMonth, fnsSetYear, fnsSetMonth, fnsSetDate, fnsStartOfDay, fnsEndOfDay, fnsAddDays } from '../fns';
23
18
  import { changeDayWithHoursPreserved } from '../utils';
24
19
  import { getDefaultTexts } from '../utils/getDefaultTexts';
25
-
26
20
  var RawDatePicker = /*#__PURE__*/function (_React$Component) {
27
21
  function RawDatePicker(props) {
28
22
  var _this;
23
+ _this = _React$Component.call(this, props) || this;
29
24
 
30
- _this = _React$Component.call(this, props) || this; // eslint-disable-next-line react/state-in-constructor
31
-
25
+ // eslint-disable-next-line react/state-in-constructor
32
26
  _defineProperty(_this, "handleChange", function (value) {
33
27
  var onValueChange = _this.props.onValueChange;
34
28
  var _this$state = _this.state,
35
- mode = _this$state.mode,
36
- valueFromState = _this$state.value;
37
-
29
+ mode = _this$state.mode,
30
+ valueFromState = _this$state.value;
38
31
  if (mode === 'date' && !!valueFromState && !!value) {
39
32
  var dateToBeUpdated = changeDayWithHoursPreserved(valueFromState, value);
40
-
41
33
  _this.setState({
42
34
  value: dateToBeUpdated,
43
35
  changed: true
44
36
  });
45
-
46
37
  onValueChange && onValueChange(dateToBeUpdated);
47
38
  } else {
48
39
  _this.setState({
49
40
  value: value,
50
41
  changed: true
51
42
  });
52
-
53
43
  onValueChange && onValueChange(value);
54
44
  }
55
45
  });
56
-
57
46
  _defineProperty(_this, "handleDayMouseEnter", function (day) {
58
47
  return _this.setState({
59
48
  enteredTo: day
60
49
  });
61
50
  });
62
-
63
51
  _defineProperty(_this, "handleDayMouseLeave", function () {
64
52
  return _this.setState({
65
53
  enteredTo: undefined
66
54
  });
67
55
  });
68
-
69
56
  _defineProperty(_this, "handleDayClick", function (day, modifiers) {
70
57
  var _this$state2 = _this.state,
71
- isChanged = _this$state2.changed,
72
- value = _this$state2.value;
58
+ isChanged = _this$state2.changed,
59
+ value = _this$state2.value;
73
60
  var _this$props = _this.props,
74
- useStartOfDay = _this$props.useStartOfDay,
75
- useEndOfDay = _this$props.useEndOfDay,
76
- showTime = _this$props.showTime;
61
+ useStartOfDay = _this$props.useStartOfDay,
62
+ useEndOfDay = _this$props.useEndOfDay,
63
+ showTime = _this$props.showTime;
77
64
  if (modifiers.disabled) return;
78
65
  var nextDateWithCurrentTime = isChanged && value ? value : new Date();
79
66
  nextDateWithCurrentTime = fnsSetYear(nextDateWithCurrentTime, day.getFullYear());
80
67
  nextDateWithCurrentTime = fnsSetMonth(nextDateWithCurrentTime, day.getMonth());
81
68
  nextDateWithCurrentTime = fnsSetDate(nextDateWithCurrentTime, day.getDate());
82
-
83
69
  if (useStartOfDay) {
84
70
  _this.handleChange(fnsStartOfDay(nextDateWithCurrentTime));
85
71
  } else if (useEndOfDay) {
@@ -87,48 +73,39 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
87
73
  } else {
88
74
  _this.handleChange(nextDateWithCurrentTime);
89
75
  }
90
-
91
76
  !!showTime && _this.handleModeSwitch('time');
92
77
  });
93
-
94
78
  _defineProperty(_this, "handleModeSwitch", function (mode) {
95
79
  return _this.setState({
96
80
  mode: mode
97
81
  });
98
82
  });
99
-
100
83
  _defineProperty(_this, "handleApply", function (date) {
101
84
  var onApply = _this.props.onApply;
102
85
  if (!onApply) return;
103
86
  var value = _this.state.value;
104
-
105
87
  if (date instanceof Date) {
106
88
  onApply(date);
107
-
108
89
  _this.setState({
109
90
  value: date
110
91
  });
111
92
  } else {
112
93
  onApply(value);
113
94
  }
114
-
115
95
  _this.handleModeSwitch('date');
116
96
  });
117
-
118
97
  _defineProperty(_this, "handleMonthChange", function (month, mode) {
119
98
  return _this.setState({
120
99
  month: month,
121
100
  mode: mode
122
101
  });
123
102
  });
124
-
125
103
  _defineProperty(_this, "renderDay", function (day) {
126
104
  var text = day.getDate();
127
105
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DayBackground, null), /*#__PURE__*/React.createElement(DayText, {
128
106
  "data-attr": text
129
107
  }, text), /*#__PURE__*/React.createElement(DayForeground, null));
130
108
  });
131
-
132
109
  _defineProperty(_this, "renderYearPicker", function () {
133
110
  var month = _this.state.month;
134
111
  return /*#__PURE__*/React.createElement(YearPicker, {
@@ -138,7 +115,6 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
138
115
  }
139
116
  });
140
117
  });
141
-
142
118
  _defineProperty(_this, "renderMonthPicker", function () {
143
119
  var month = _this.state.month;
144
120
  return /*#__PURE__*/React.createElement(MonthPicker, {
@@ -148,11 +124,10 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
148
124
  }
149
125
  });
150
126
  });
151
-
152
127
  _defineProperty(_this, "renderDayPicker", function () {
153
128
  var _this$state3 = _this.state,
154
- value = _this$state3.value,
155
- enteredTo = _this$state3.enteredTo;
129
+ value = _this$state3.value,
130
+ enteredTo = _this$state3.enteredTo;
156
131
  var disabledDates = _this.props.disabledDates;
157
132
  var modifiers = {
158
133
  start: value,
@@ -187,22 +162,21 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
187
162
  modifiers: modifiers
188
163
  });
189
164
  });
190
-
191
165
  _defineProperty(_this, "handleDaySwitch", function (day) {
192
- var disabledDates = _this.props.disabledDates; // @ts-ignore
166
+ var disabledDates = _this.props.disabledDates;
193
167
 
168
+ // @ts-ignore
194
169
  _this.handleDayClick(day, {
195
170
  disabled: disabledDates ? disabledDates(day) : false
196
171
  });
197
172
  });
198
-
199
173
  _defineProperty(_this, "renderTimePicker", function () {
200
174
  var value = _this.state.value;
201
175
  var _this$props2 = _this.props,
202
- disabledHours = _this$props2.disabledHours,
203
- disabledMinutes = _this$props2.disabledMinutes,
204
- disabledSeconds = _this$props2.disabledSeconds,
205
- disabledDates = _this$props2.disabledDates;
176
+ disabledHours = _this$props2.disabledHours,
177
+ disabledMinutes = _this$props2.disabledMinutes,
178
+ disabledSeconds = _this$props2.disabledSeconds,
179
+ disabledDates = _this$props2.disabledDates;
206
180
  var prevDay = fnsAddDays(legacyParse(value), -1);
207
181
  var nextDay = fnsAddDays(legacyParse(value), 1);
208
182
  var inactivePrev = disabledDates ? disabledDates(prevDay) : false;
@@ -223,7 +197,6 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
223
197
  }
224
198
  });
225
199
  });
226
-
227
200
  _this.state = {
228
201
  mode: 'date',
229
202
  month: fnsStartOfMonth(props.value || new Date()),
@@ -234,22 +207,17 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
234
207
  };
235
208
  return _this;
236
209
  }
237
-
238
210
  _inheritsLoose(RawDatePicker, _React$Component);
239
-
240
211
  var _proto = RawDatePicker.prototype;
241
-
242
212
  _proto.getTexts = function getTexts() {
243
213
  var _this$props3 = this.props,
244
- texts = _this$props3.texts,
245
- intl = _this$props3.intl;
214
+ texts = _this$props3.texts,
215
+ intl = _this$props3.intl;
246
216
  return getDefaultTexts(intl, texts);
247
217
  };
248
-
249
218
  _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
250
219
  var value = this.props.value;
251
220
  var mode = this.state.mode;
252
-
253
221
  if ((prevProps == null ? void 0 : prevProps.value) !== value) {
254
222
  this.setState({
255
223
  value: value,
@@ -258,46 +226,37 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
258
226
  mode: value === undefined ? 'date' : mode
259
227
  });
260
228
  }
261
-
262
229
  return null;
263
230
  };
264
-
265
231
  _proto.render = function render() {
266
232
  var _this2 = this;
267
-
268
233
  var _this$state4 = this.state,
269
- mode = _this$state4.mode,
270
- changed = _this$state4.changed,
271
- value = _this$state4.value,
272
- texts = _this$state4.texts;
234
+ mode = _this$state4.mode,
235
+ changed = _this$state4.changed,
236
+ value = _this$state4.value,
237
+ texts = _this$state4.texts;
273
238
  var _this$props4 = this.props,
274
- showTime = _this$props4.showTime,
275
- hideNow = _this$props4.hideNow;
239
+ showTime = _this$props4.showTime,
240
+ hideNow = _this$props4.hideNow;
276
241
  var isValid = !!value;
277
242
  var picker;
278
-
279
243
  switch (mode) {
280
244
  case 'time':
281
245
  picker = this.renderTimePicker();
282
246
  break;
283
-
284
247
  case 'date':
285
248
  picker = this.renderDayPicker();
286
249
  break;
287
-
288
250
  case 'month':
289
251
  picker = this.renderMonthPicker();
290
252
  break;
291
-
292
253
  case 'year':
293
254
  picker = this.renderYearPicker();
294
255
  break;
295
-
296
256
  default:
297
257
  picker = null;
298
258
  break;
299
259
  }
300
-
301
260
  return /*#__PURE__*/React.createElement(S.Container, null, picker, /*#__PURE__*/React.createElement(Footer, {
302
261
  canApply: isValid && changed,
303
262
  onApply: this.handleApply,
@@ -311,15 +270,12 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
311
270
  hideNow: hideNow
312
271
  }));
313
272
  };
314
-
315
273
  return RawDatePicker;
316
274
  }(React.Component);
317
-
318
275
  _defineProperty(RawDatePicker, "defaultProps", {
319
276
  showTime: false,
320
277
  disabledHours: [],
321
278
  disabledMinutes: [],
322
279
  disabledSeconds: []
323
280
  });
324
-
325
281
  export default injectIntl(RawDatePicker);
package/dist/format.js CHANGED
@@ -11,11 +11,9 @@ export default function (date, formatStr, locale) {
11
11
  if (locale === void 0) {
12
12
  locale = defaultLocale;
13
13
  }
14
-
15
14
  if (!fnsIsValid(date)) {
16
15
  return '';
17
16
  }
18
-
19
17
  return fnsFormat(date, formatStr, {
20
18
  locale: locales[locale.substring(0, 2)]
21
19
  });
@@ -1,13 +1,8 @@
1
1
  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; }
2
-
3
2
  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) { _defineProperty(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; }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import MomentLocaleUtils from 'react-day-picker/moment';
12
7
  var WEEKDAYS_LONG = {
13
8
  en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
@@ -27,56 +22,44 @@ var FIRST_DAY = {
27
22
  };
28
23
  var DEFAULT_LOCALE = 'en';
29
24
  var DEFAULT_FORMAT = 'MMM DD, YYYY';
30
-
31
25
  var getValidLocale = function getValidLocale(locale) {
32
26
  return Object.keys(MONTHS).includes(locale) ? locale : DEFAULT_LOCALE;
33
- }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
-
27
+ };
35
28
 
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
30
  function formatDay(d, format, locale) {
37
31
  if (format === void 0) {
38
32
  format = DEFAULT_FORMAT;
39
33
  }
40
-
41
34
  if (locale === void 0) {
42
35
  locale = DEFAULT_LOCALE;
43
36
  }
44
-
45
37
  return WEEKDAYS_LONG[getValidLocale(locale)][d.getDay()] + ", " + d.getDate() + " " + MONTHS[getValidLocale(locale)][d.getMonth()] + " " + d.getFullYear();
46
38
  }
47
-
48
39
  function formatMonthTitle(d, locale) {
49
40
  if (locale === void 0) {
50
41
  locale = DEFAULT_LOCALE;
51
42
  }
52
-
53
43
  return MONTHS[getValidLocale(locale)][d.getMonth()] + " " + d.getFullYear();
54
44
  }
55
-
56
45
  function formatWeekdayShort(i, locale) {
57
46
  if (locale === void 0) {
58
47
  locale = DEFAULT_LOCALE;
59
48
  }
60
-
61
49
  return WEEKDAYS_SHORT[getValidLocale(locale)][i];
62
50
  }
63
-
64
51
  function formatWeekdayLong(weekday, locale) {
65
52
  if (locale === void 0) {
66
53
  locale = DEFAULT_LOCALE;
67
54
  }
68
-
69
55
  return WEEKDAYS_SHORT[getValidLocale(locale)][weekday];
70
56
  }
71
-
72
57
  function getFirstDayOfWeek(locale) {
73
58
  if (locale === void 0) {
74
59
  locale = DEFAULT_LOCALE;
75
60
  }
76
-
77
61
  return FIRST_DAY[getValidLocale(locale)];
78
62
  }
79
-
80
63
  var localeUtils = _objectSpread({}, MomentLocaleUtils, {
81
64
  formatDay: formatDay,
82
65
  formatMonthTitle: formatMonthTitle,
@@ -84,5 +67,4 @@ var localeUtils = _objectSpread({}, MomentLocaleUtils, {
84
67
  formatWeekdayLong: formatWeekdayLong,
85
68
  getFirstDayOfWeek: getFirstDayOfWeek
86
69
  });
87
-
88
70
  export default localeUtils;
@@ -1,13 +1,8 @@
1
1
  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; }
2
-
3
2
  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) { _defineProperty(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; }
4
-
5
3
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
4
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
8
-
9
5
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
-
11
6
  import React from 'react';
12
7
  import { FormattedMessage } from 'react-intl';
13
8
  export var getDefaultTexts = function getDefaultTexts(intl, texts) {
package/dist/utils.js CHANGED
@@ -5,7 +5,6 @@ export var range = function range(start, end) {
5
5
  if (end <= start) {
6
6
  return [];
7
7
  }
8
-
9
8
  var size = end - start;
10
9
  return [].concat(Array(size).keys()).map(function (i) {
11
10
  return i + start;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-date-picker",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "DatePicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -35,13 +35,13 @@
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
37
  "@date-fns/upgrade": "^1.0.3",
38
- "@synerise/ds-button": "^0.21.19",
38
+ "@synerise/ds-button": "^0.21.20",
39
39
  "@synerise/ds-data-format": "^0.6.1",
40
- "@synerise/ds-dropdown": "^0.18.24",
41
- "@synerise/ds-icon": "^0.67.0",
42
- "@synerise/ds-input": "^0.24.14",
43
- "@synerise/ds-time-picker": "^0.11.2",
44
- "@synerise/ds-tooltip": "^0.14.49",
40
+ "@synerise/ds-dropdown": "^0.18.25",
41
+ "@synerise/ds-icon": "^0.67.1",
42
+ "@synerise/ds-input": "^0.24.15",
43
+ "@synerise/ds-time-picker": "^0.11.3",
44
+ "@synerise/ds-tooltip": "^0.14.50",
45
45
  "@synerise/ds-utils": "^0.31.2",
46
46
  "classnames": "2.3.2",
47
47
  "date-fns": "2.16.1",
@@ -56,5 +56,5 @@
56
56
  "react-intl": ">=3.12.0 <= 6.8",
57
57
  "styled-components": "5.0.1"
58
58
  },
59
- "gitHead": "05f083c767e2cec3c2f91c9475aee89852a77d6c"
59
+ "gitHead": "4a56ee7ef816c22341ce704154dc7aa65b7d1dcc"
60
60
  }