@synerise/ds-date-picker 0.6.2 → 0.6.6
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 +32 -0
- package/dist/DatePicker.js +6 -22
- package/dist/Elements/DayPicker/DayPicker.js +1 -3
- package/dist/Elements/DayPicker/DayPicker.styles.js +1 -1
- package/dist/Elements/DecadePicker/DecadePicker.js +57 -90
- package/dist/Elements/Footer/Footer.js +1 -3
- package/dist/Elements/GridPicker/GridPicker.js +14 -35
- package/dist/Elements/MonthPicker/MonthPicker.js +63 -84
- package/dist/Elements/PickerInput/PickerInput.js +3 -18
- package/dist/Elements/PickerInput/PickerInput.styles.js +2 -2
- package/dist/Elements/YearPicker/YearPicker.js +69 -102
- package/dist/RawDatePicker/RawDatePicker.js +114 -136
- package/dist/format.js +5 -2
- package/dist/localeUtils.js +12 -6
- package/dist/utils.js +1 -13
- package/package.json +7 -7
|
@@ -2,20 +2,6 @@ var _excluded = ["autoFocus", "size", "disabled", "value", "format", "onChange",
|
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || 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
4
|
|
|
5
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
-
|
|
7
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
-
|
|
13
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
14
|
-
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
|
|
17
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
-
|
|
19
5
|
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; }
|
|
20
6
|
|
|
21
7
|
import * as React from 'react';
|
|
@@ -43,12 +29,11 @@ var PickerInput = function PickerInput(_ref) {
|
|
|
43
29
|
errorText = _ref.errorText,
|
|
44
30
|
prefixel = _ref.prefixel,
|
|
45
31
|
suffixel = _ref.suffixel,
|
|
46
|
-
rest =
|
|
32
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
47
33
|
|
|
48
34
|
var _React$useState = React.useState(false),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
setHovered = _React$useState2[1];
|
|
35
|
+
hovered = _React$useState[0],
|
|
36
|
+
setHovered = _React$useState[1];
|
|
52
37
|
|
|
53
38
|
var getText = React.useCallback(function () {
|
|
54
39
|
if (!value) return '';
|
|
@@ -29,9 +29,9 @@ export var PickerInputWrapper = styled.div.withConfig({
|
|
|
29
29
|
})(["display:flex;align-items:center;", ",", "{background:", ";display:flex;align-items:center;align-self:stretch;padding:0 12px;}", " ", ""], Prefixel, Suffixel, function (props) {
|
|
30
30
|
return props.theme.palette['grey-050'];
|
|
31
31
|
}, function (props) {
|
|
32
|
-
return props.prefixel && "\n "
|
|
32
|
+
return props.prefixel && "\n " + Input + " input {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n ";
|
|
33
33
|
}, function (props) {
|
|
34
|
-
return props.suffixel && "\n "
|
|
34
|
+
return props.suffixel && "\n " + Input + " input {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n ";
|
|
35
35
|
});
|
|
36
36
|
export var Container = styled.div.withConfig({
|
|
37
37
|
displayName: "PickerInputstyles__Container",
|
|
@@ -1,36 +1,8 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
-
|
|
5
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
10
|
-
|
|
11
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
12
|
-
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
14
|
-
|
|
15
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
-
|
|
17
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
18
|
-
|
|
19
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
20
|
-
|
|
21
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
22
|
-
|
|
23
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
|
-
|
|
25
|
-
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); }; }
|
|
26
|
-
|
|
27
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
28
|
-
|
|
29
1
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
2
|
|
|
31
|
-
function
|
|
3
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
32
4
|
|
|
33
|
-
function
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
34
6
|
|
|
35
7
|
import * as React from 'react';
|
|
36
8
|
import { legacyParse } from '@date-fns/upgrade/v2';
|
|
@@ -60,39 +32,36 @@ function getCells(cursor) {
|
|
|
60
32
|
}
|
|
61
33
|
|
|
62
34
|
var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var _super = _createSuper(YearPicker);
|
|
35
|
+
_inheritsLoose(YearPicker, _React$PureComponent);
|
|
66
36
|
|
|
67
37
|
function YearPicker() {
|
|
68
38
|
var _this;
|
|
69
39
|
|
|
70
|
-
_classCallCheck(this, YearPicker);
|
|
71
|
-
|
|
72
40
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
73
41
|
args[_key] = arguments[_key];
|
|
74
42
|
}
|
|
75
43
|
|
|
76
|
-
_this =
|
|
77
|
-
|
|
44
|
+
_this = _React$PureComponent.call.apply(_React$PureComponent, [this].concat(args)) || this;
|
|
45
|
+
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "state", getInitialState(_this.props));
|
|
78
47
|
|
|
79
|
-
_this
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "handleLongPrev", function () {
|
|
80
49
|
var cursor = _this.state.cursor;
|
|
81
50
|
|
|
82
51
|
_this.setState({
|
|
83
52
|
cursor: fnsAddYears(cursor, -10)
|
|
84
53
|
});
|
|
85
|
-
};
|
|
54
|
+
});
|
|
86
55
|
|
|
87
|
-
_this
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "handleLongNext", function () {
|
|
88
57
|
var cursor = _this.state.cursor;
|
|
89
58
|
|
|
90
59
|
_this.setState({
|
|
91
60
|
cursor: fnsAddYears(cursor, 10)
|
|
92
61
|
});
|
|
93
|
-
};
|
|
62
|
+
});
|
|
94
63
|
|
|
95
|
-
_this
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "handleCellClick", function (isoDate) {
|
|
96
65
|
var onChange = _this.props.onChange;
|
|
97
66
|
|
|
98
67
|
if (isoDate === -1) {
|
|
@@ -108,77 +77,75 @@ var YearPicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
108
77
|
}
|
|
109
78
|
|
|
110
79
|
onChange && onChange(new Date(isoDate));
|
|
111
|
-
};
|
|
80
|
+
});
|
|
112
81
|
|
|
113
82
|
return _this;
|
|
114
83
|
}
|
|
115
84
|
|
|
116
|
-
|
|
117
|
-
key: "getSnapshotBeforeUpdate",
|
|
118
|
-
value: function getSnapshotBeforeUpdate(prevProps) {
|
|
119
|
-
var value = this.props.value;
|
|
85
|
+
var _proto = YearPicker.prototype;
|
|
120
86
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
87
|
+
_proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
|
|
88
|
+
var value = this.props.value;
|
|
124
89
|
|
|
125
|
-
|
|
90
|
+
if (value && (prevProps == null ? void 0 : prevProps.value) !== value) {
|
|
91
|
+
this.setState(getInitialState(this.props));
|
|
126
92
|
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "render",
|
|
129
|
-
value: function render() {
|
|
130
|
-
var _this2 = this;
|
|
131
|
-
|
|
132
|
-
var _this$state = this.state,
|
|
133
|
-
cursor = _this$state.cursor,
|
|
134
|
-
decadeMode = _this$state.decadeMode;
|
|
135
|
-
var value = this.props.value;
|
|
136
|
-
var decadeRange = getDecadeRange(cursor);
|
|
137
|
-
var cells = getCells(cursor);
|
|
138
|
-
var valueCell = value ? cells.find(function (cell) {
|
|
139
|
-
return fnsIsSameYear(value, legacyParse(cell.key));
|
|
140
|
-
}) : null;
|
|
141
|
-
var selectedKey = valueCell ? valueCell.key : null;
|
|
142
|
-
cells = [{
|
|
143
|
-
key: -1,
|
|
144
|
-
text: decadeRange[0] - 1,
|
|
145
|
-
outside: true
|
|
146
|
-
}].concat(_toConsumableArray(cells), [{
|
|
147
|
-
key: 1,
|
|
148
|
-
text: decadeRange[1] + 1,
|
|
149
|
-
outside: true
|
|
150
|
-
}]);
|
|
151
|
-
|
|
152
|
-
if (decadeMode) {
|
|
153
|
-
return /*#__PURE__*/React.createElement(DecadePicker, {
|
|
154
|
-
value: cursor,
|
|
155
|
-
onChange: function onChange(selectedDecade) {
|
|
156
|
-
return _this2.setState({
|
|
157
|
-
cursor: selectedDecade,
|
|
158
|
-
decadeMode: false
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
93
|
|
|
164
|
-
|
|
165
|
-
|
|
94
|
+
return null;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
_proto.render = function render() {
|
|
98
|
+
var _this2 = this;
|
|
99
|
+
|
|
100
|
+
var _this$state = this.state,
|
|
101
|
+
cursor = _this$state.cursor,
|
|
102
|
+
decadeMode = _this$state.decadeMode;
|
|
103
|
+
var value = this.props.value;
|
|
104
|
+
var decadeRange = getDecadeRange(cursor);
|
|
105
|
+
var cells = getCells(cursor);
|
|
106
|
+
var valueCell = value ? cells.find(function (cell) {
|
|
107
|
+
return fnsIsSameYear(value, legacyParse(cell.key));
|
|
108
|
+
}) : null;
|
|
109
|
+
var selectedKey = valueCell ? valueCell.key : null;
|
|
110
|
+
cells = [{
|
|
111
|
+
key: -1,
|
|
112
|
+
text: decadeRange[0] - 1,
|
|
113
|
+
outside: true
|
|
114
|
+
}].concat(cells, [{
|
|
115
|
+
key: 1,
|
|
116
|
+
text: decadeRange[1] + 1,
|
|
117
|
+
outside: true
|
|
118
|
+
}]);
|
|
119
|
+
|
|
120
|
+
if (decadeMode) {
|
|
121
|
+
return /*#__PURE__*/React.createElement(DecadePicker, {
|
|
122
|
+
value: cursor,
|
|
123
|
+
onChange: function onChange(selectedDecade) {
|
|
166
124
|
return _this2.setState({
|
|
167
|
-
|
|
125
|
+
cursor: selectedDecade,
|
|
126
|
+
decadeMode: false
|
|
168
127
|
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
onLongPrev: this.handleLongPrev,
|
|
172
|
-
onLongNext: this.handleLongNext,
|
|
173
|
-
key: "head"
|
|
174
|
-
}), /*#__PURE__*/React.createElement(GridPicker, {
|
|
175
|
-
selectedKey: selectedKey,
|
|
176
|
-
cells: cells,
|
|
177
|
-
onCellClick: this.handleCellClick,
|
|
178
|
-
key: "body"
|
|
179
|
-
}), ",");
|
|
128
|
+
}
|
|
129
|
+
});
|
|
180
130
|
}
|
|
181
|
-
|
|
131
|
+
|
|
132
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Navbar, {
|
|
133
|
+
onTitleClick: function onTitleClick() {
|
|
134
|
+
return _this2.setState({
|
|
135
|
+
decadeMode: true
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
title: decadeRange.join('-'),
|
|
139
|
+
onLongPrev: this.handleLongPrev,
|
|
140
|
+
onLongNext: this.handleLongNext,
|
|
141
|
+
key: "head"
|
|
142
|
+
}), /*#__PURE__*/React.createElement(GridPicker, {
|
|
143
|
+
selectedKey: selectedKey,
|
|
144
|
+
cells: cells,
|
|
145
|
+
onCellClick: this.handleCellClick,
|
|
146
|
+
key: "body"
|
|
147
|
+
}), ",");
|
|
148
|
+
};
|
|
182
149
|
|
|
183
150
|
return YearPicker;
|
|
184
151
|
}(React.PureComponent);
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
10
|
-
|
|
11
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
-
|
|
13
|
-
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
|
-
|
|
15
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
-
|
|
17
1
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
2
|
|
|
19
|
-
function
|
|
3
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
20
4
|
|
|
21
|
-
function
|
|
5
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
6
|
|
|
23
7
|
import * as React from 'react';
|
|
24
8
|
import { FormattedMessage } from 'react-intl';
|
|
@@ -35,18 +19,14 @@ import { fnsStartOfMonth, fnsSetYear, fnsSetMonth, fnsSetDate, fnsStartOfDay, fn
|
|
|
35
19
|
import { changeDayWithHoursPreserved } from '../utils';
|
|
36
20
|
|
|
37
21
|
var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var _super = _createSuper(RawDatePicker);
|
|
22
|
+
_inheritsLoose(RawDatePicker, _React$Component);
|
|
41
23
|
|
|
42
24
|
function RawDatePicker(props) {
|
|
43
25
|
var _this;
|
|
44
26
|
|
|
45
|
-
|
|
27
|
+
_this = _React$Component.call(this, props) || this; // eslint-disable-next-line react/state-in-constructor
|
|
46
28
|
|
|
47
|
-
_this
|
|
48
|
-
|
|
49
|
-
_this.handleChange = function (value) {
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (value) {
|
|
50
30
|
var onValueChange = _this.props.onValueChange;
|
|
51
31
|
var _this$state = _this.state,
|
|
52
32
|
mode = _this$state.mode,
|
|
@@ -69,21 +49,21 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
69
49
|
|
|
70
50
|
onValueChange && onValueChange(value);
|
|
71
51
|
}
|
|
72
|
-
};
|
|
52
|
+
});
|
|
73
53
|
|
|
74
|
-
_this
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "handleDayMouseEnter", function (day) {
|
|
75
55
|
return _this.setState({
|
|
76
56
|
enteredTo: day
|
|
77
57
|
});
|
|
78
|
-
};
|
|
58
|
+
});
|
|
79
59
|
|
|
80
|
-
_this
|
|
60
|
+
_defineProperty(_assertThisInitialized(_this), "handleDayMouseLeave", function () {
|
|
81
61
|
return _this.setState({
|
|
82
62
|
enteredTo: undefined
|
|
83
63
|
});
|
|
84
|
-
};
|
|
64
|
+
});
|
|
85
65
|
|
|
86
|
-
_this
|
|
66
|
+
_defineProperty(_assertThisInitialized(_this), "handleDayClick", function (day, modifiers) {
|
|
87
67
|
var _this$state2 = _this.state,
|
|
88
68
|
isChanged = _this$state2.changed,
|
|
89
69
|
value = _this$state2.value;
|
|
@@ -106,15 +86,15 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
106
86
|
}
|
|
107
87
|
|
|
108
88
|
!!showTime && _this.handleModeSwitch('time');
|
|
109
|
-
};
|
|
89
|
+
});
|
|
110
90
|
|
|
111
|
-
_this
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "handleModeSwitch", function (mode) {
|
|
112
92
|
return _this.setState({
|
|
113
93
|
mode: mode
|
|
114
94
|
});
|
|
115
|
-
};
|
|
95
|
+
});
|
|
116
96
|
|
|
117
|
-
_this
|
|
97
|
+
_defineProperty(_assertThisInitialized(_this), "handleApply", function (date) {
|
|
118
98
|
var onApply = _this.props.onApply;
|
|
119
99
|
if (!onApply) return;
|
|
120
100
|
var value = _this.state.value;
|
|
@@ -130,23 +110,23 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
130
110
|
}
|
|
131
111
|
|
|
132
112
|
_this.handleModeSwitch('date');
|
|
133
|
-
};
|
|
113
|
+
});
|
|
134
114
|
|
|
135
|
-
_this
|
|
115
|
+
_defineProperty(_assertThisInitialized(_this), "handleMonthChange", function (month, mode) {
|
|
136
116
|
return _this.setState({
|
|
137
117
|
month: month,
|
|
138
118
|
mode: mode
|
|
139
119
|
});
|
|
140
|
-
};
|
|
120
|
+
});
|
|
141
121
|
|
|
142
|
-
_this
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "renderDay", function (day) {
|
|
143
123
|
var text = day.getDate();
|
|
144
124
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DayBackground, null), /*#__PURE__*/React.createElement(DayText, {
|
|
145
125
|
"data-attr": text
|
|
146
126
|
}, text), /*#__PURE__*/React.createElement(DayForeground, null));
|
|
147
|
-
};
|
|
127
|
+
});
|
|
148
128
|
|
|
149
|
-
_this
|
|
129
|
+
_defineProperty(_assertThisInitialized(_this), "renderYearPicker", function () {
|
|
150
130
|
var month = _this.state.month;
|
|
151
131
|
return /*#__PURE__*/React.createElement(YearPicker, {
|
|
152
132
|
value: month,
|
|
@@ -154,9 +134,9 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
154
134
|
return changedMonth && _this.handleMonthChange(changedMonth, 'date');
|
|
155
135
|
}
|
|
156
136
|
});
|
|
157
|
-
};
|
|
137
|
+
});
|
|
158
138
|
|
|
159
|
-
_this
|
|
139
|
+
_defineProperty(_assertThisInitialized(_this), "renderMonthPicker", function () {
|
|
160
140
|
var month = _this.state.month;
|
|
161
141
|
return /*#__PURE__*/React.createElement(MonthPicker, {
|
|
162
142
|
value: month,
|
|
@@ -164,9 +144,9 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
164
144
|
return changedMonth && _this.handleMonthChange(changedMonth, 'date');
|
|
165
145
|
}
|
|
166
146
|
});
|
|
167
|
-
};
|
|
147
|
+
});
|
|
168
148
|
|
|
169
|
-
_this
|
|
149
|
+
_defineProperty(_assertThisInitialized(_this), "renderDayPicker", function () {
|
|
170
150
|
var _this$state3 = _this.state,
|
|
171
151
|
value = _this$state3.value,
|
|
172
152
|
enteredTo = _this$state3.enteredTo;
|
|
@@ -203,18 +183,18 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
203
183
|
},
|
|
204
184
|
modifiers: modifiers
|
|
205
185
|
});
|
|
206
|
-
};
|
|
186
|
+
});
|
|
207
187
|
|
|
208
|
-
_this
|
|
188
|
+
_defineProperty(_assertThisInitialized(_this), "handleDaySwitch", function (day) {
|
|
209
189
|
var disabledDates = _this.props.disabledDates; // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
210
190
|
// @ts-ignore
|
|
211
191
|
|
|
212
192
|
_this.handleDayClick(day, {
|
|
213
193
|
disabled: disabledDates ? disabledDates(day) : false
|
|
214
194
|
});
|
|
215
|
-
};
|
|
195
|
+
});
|
|
216
196
|
|
|
217
|
-
_this
|
|
197
|
+
_defineProperty(_assertThisInitialized(_this), "renderTimePicker", function () {
|
|
218
198
|
var value = _this.state.value;
|
|
219
199
|
var _this$props2 = _this.props,
|
|
220
200
|
disabledHours = _this$props2.disabledHours,
|
|
@@ -233,7 +213,7 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
233
213
|
return _this.handleDaySwitch(fnsAddDays(legacyParse(value), -1));
|
|
234
214
|
}
|
|
235
215
|
});
|
|
236
|
-
};
|
|
216
|
+
});
|
|
237
217
|
|
|
238
218
|
_this.state = {
|
|
239
219
|
mode: 'date',
|
|
@@ -246,102 +226,100 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
|
|
|
246
226
|
return _this;
|
|
247
227
|
}
|
|
248
228
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
value
|
|
271
|
-
|
|
272
|
-
var mode = this.state.mode;
|
|
273
|
-
|
|
274
|
-
if ((prevProps === null || prevProps === void 0 ? void 0 : prevProps.value) !== value) {
|
|
275
|
-
this.setState({
|
|
276
|
-
value: value,
|
|
277
|
-
month: fnsStartOfMonth(value || new Date()),
|
|
278
|
-
changed: true,
|
|
279
|
-
mode: value === undefined ? 'date' : mode
|
|
280
|
-
});
|
|
281
|
-
}
|
|
229
|
+
var _proto = RawDatePicker.prototype;
|
|
230
|
+
|
|
231
|
+
_proto.getTexts = function getTexts() {
|
|
232
|
+
var _this$props3 = this.props,
|
|
233
|
+
texts = _this$props3.texts,
|
|
234
|
+
intl = _this$props3.intl;
|
|
235
|
+
var updatedTexts = {
|
|
236
|
+
apply: (texts == null ? void 0 : texts.apply) || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
237
|
+
id: "DS.DATE-PICKER.APPLY"
|
|
238
|
+
}),
|
|
239
|
+
now: (texts == null ? void 0 : texts.now) || /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
240
|
+
id: "DS.DATE-PICKER.NOW"
|
|
241
|
+
}),
|
|
242
|
+
inputPlaceholder: (texts == null ? void 0 : texts.inputPlaceholder) || (intl == null ? void 0 : intl.formatMessage({
|
|
243
|
+
id: 'DS.DATE-PICKER.SELECT-DATE'
|
|
244
|
+
})) || ''
|
|
245
|
+
};
|
|
246
|
+
return updatedTexts;
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
_proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
|
|
250
|
+
var value = this.props.value;
|
|
251
|
+
var mode = this.state.mode;
|
|
282
252
|
|
|
283
|
-
|
|
253
|
+
if ((prevProps == null ? void 0 : prevProps.value) !== value) {
|
|
254
|
+
this.setState({
|
|
255
|
+
value: value,
|
|
256
|
+
month: fnsStartOfMonth(value || new Date()),
|
|
257
|
+
changed: true,
|
|
258
|
+
mode: value === undefined ? 'date' : mode
|
|
259
|
+
});
|
|
284
260
|
}
|
|
285
|
-
}, {
|
|
286
|
-
key: "render",
|
|
287
|
-
value: function render() {
|
|
288
|
-
var _this2 = this;
|
|
289
|
-
|
|
290
|
-
var _this$state4 = this.state,
|
|
291
|
-
mode = _this$state4.mode,
|
|
292
|
-
changed = _this$state4.changed,
|
|
293
|
-
value = _this$state4.value,
|
|
294
|
-
texts = _this$state4.texts;
|
|
295
|
-
var _this$props4 = this.props,
|
|
296
|
-
showTime = _this$props4.showTime,
|
|
297
|
-
hideNow = _this$props4.hideNow;
|
|
298
|
-
var isValid = !!value;
|
|
299
|
-
var picker;
|
|
300
|
-
|
|
301
|
-
switch (mode) {
|
|
302
|
-
case 'time':
|
|
303
|
-
picker = this.renderTimePicker();
|
|
304
|
-
break;
|
|
305
|
-
|
|
306
|
-
case 'date':
|
|
307
|
-
picker = this.renderDayPicker();
|
|
308
|
-
break;
|
|
309
|
-
|
|
310
|
-
case 'month':
|
|
311
|
-
picker = this.renderMonthPicker();
|
|
312
|
-
break;
|
|
313
|
-
|
|
314
|
-
case 'year':
|
|
315
|
-
picker = this.renderYearPicker();
|
|
316
|
-
break;
|
|
317
|
-
|
|
318
|
-
default:
|
|
319
|
-
picker = null;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
261
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
262
|
+
return null;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
_proto.render = function render() {
|
|
266
|
+
var _this2 = this;
|
|
267
|
+
|
|
268
|
+
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;
|
|
273
|
+
var _this$props4 = this.props,
|
|
274
|
+
showTime = _this$props4.showTime,
|
|
275
|
+
hideNow = _this$props4.hideNow;
|
|
276
|
+
var isValid = !!value;
|
|
277
|
+
var picker;
|
|
278
|
+
|
|
279
|
+
switch (mode) {
|
|
280
|
+
case 'time':
|
|
281
|
+
picker = this.renderTimePicker();
|
|
282
|
+
break;
|
|
283
|
+
|
|
284
|
+
case 'date':
|
|
285
|
+
picker = this.renderDayPicker();
|
|
286
|
+
break;
|
|
287
|
+
|
|
288
|
+
case 'month':
|
|
289
|
+
picker = this.renderMonthPicker();
|
|
290
|
+
break;
|
|
291
|
+
|
|
292
|
+
case 'year':
|
|
293
|
+
picker = this.renderYearPicker();
|
|
294
|
+
break;
|
|
295
|
+
|
|
296
|
+
default:
|
|
297
|
+
picker = null;
|
|
298
|
+
break;
|
|
335
299
|
}
|
|
336
|
-
|
|
300
|
+
|
|
301
|
+
return /*#__PURE__*/React.createElement(S.Container, null, picker, /*#__PURE__*/React.createElement(Footer, {
|
|
302
|
+
canApply: isValid && changed,
|
|
303
|
+
onApply: this.handleApply,
|
|
304
|
+
dateOnly: !showTime,
|
|
305
|
+
mode: mode,
|
|
306
|
+
canSwitchMode: isValid,
|
|
307
|
+
onSwitchMode: function onSwitchMode() {
|
|
308
|
+
return _this2.handleModeSwitch(mode === 'time' ? 'date' : 'time');
|
|
309
|
+
},
|
|
310
|
+
texts: texts,
|
|
311
|
+
hideNow: hideNow
|
|
312
|
+
}));
|
|
313
|
+
};
|
|
337
314
|
|
|
338
315
|
return RawDatePicker;
|
|
339
316
|
}(React.Component);
|
|
340
317
|
|
|
341
|
-
RawDatePicker
|
|
318
|
+
_defineProperty(RawDatePicker, "defaultProps", {
|
|
342
319
|
showTime: false,
|
|
343
320
|
disabledHours: [],
|
|
344
321
|
disabledMinutes: [],
|
|
345
322
|
disabledSeconds: []
|
|
346
|
-
};
|
|
323
|
+
});
|
|
324
|
+
|
|
347
325
|
export default RawDatePicker;
|
package/dist/format.js
CHANGED
|
@@ -6,8 +6,11 @@ var locales = {
|
|
|
6
6
|
es: es
|
|
7
7
|
};
|
|
8
8
|
var defaultLocale = 'en';
|
|
9
|
-
export default function (date, formatStr) {
|
|
10
|
-
|
|
9
|
+
export default function (date, formatStr, locale) {
|
|
10
|
+
if (locale === void 0) {
|
|
11
|
+
locale = defaultLocale;
|
|
12
|
+
}
|
|
13
|
+
|
|
11
14
|
return fnsFormat(date, formatStr, {
|
|
12
15
|
locale: locales[locale.substring(0, 2)]
|
|
13
16
|
});
|