1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.DateTimePicker = void 0;
|
19 | var tslib_1 = require("tslib");
|
20 | var classnames_1 = tslib_1.__importDefault(require("classnames"));
|
21 | var React = tslib_1.__importStar(require("react"));
|
22 | var core_1 = require("@blueprintjs/core");
|
23 | var Classes = tslib_1.__importStar(require("./common/classes"));
|
24 | var DateUtils = tslib_1.__importStar(require("./common/dateUtils"));
|
25 | var datePicker_1 = require("./datePicker");
|
26 | var timePicker_1 = require("./timePicker");
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | var DateTimePicker = (function (_super) {
|
34 | tslib_1.__extends(DateTimePicker, _super);
|
35 | function DateTimePicker(props, context) {
|
36 | var _this = _super.call(this, props, context) || this;
|
37 | _this.handleDateChange = function (dateValue, isUserChange) {
|
38 | var _a, _b;
|
39 | if (_this.props.value === undefined) {
|
40 | _this.setState({ dateValue: dateValue });
|
41 | }
|
42 | var value = DateUtils.getDateTime(dateValue, _this.state.timeValue);
|
43 | (_b = (_a = _this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, isUserChange);
|
44 | };
|
45 | _this.handleTimeChange = function (timeValue) {
|
46 | var _a, _b;
|
47 | if (_this.props.value === undefined) {
|
48 | _this.setState({ timeValue: timeValue });
|
49 | }
|
50 | var value = DateUtils.getDateTime(_this.state.dateValue, timeValue);
|
51 | (_b = (_a = _this.props).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, value, true);
|
52 | };
|
53 | var initialValue = _this.props.value !== undefined ? _this.props.value : _this.props.defaultValue;
|
54 | _this.state = {
|
55 | dateValue: initialValue,
|
56 | timeValue: initialValue,
|
57 | };
|
58 | return _this;
|
59 | }
|
60 | DateTimePicker.prototype.render = function () {
|
61 | var value = DateUtils.getDateTime(this.state.dateValue, this.state.timeValue);
|
62 | return (React.createElement("div", { className: (0, classnames_1.default)(Classes.DATETIMEPICKER, this.props.className) },
|
63 | React.createElement(datePicker_1.DatePicker, tslib_1.__assign({}, this.props.datePickerProps, { canClearSelection: this.props.canClearSelection, onChange: this.handleDateChange, value: value })),
|
64 | React.createElement(timePicker_1.TimePicker, tslib_1.__assign({}, this.props.timePickerProps, { onChange: this.handleTimeChange, value: this.state.timeValue }))));
|
65 | };
|
66 | DateTimePicker.prototype.componentDidUpdate = function (prevProps) {
|
67 | if (this.props.value === prevProps.value) {
|
68 | return;
|
69 | }
|
70 | else if (this.props.value != null) {
|
71 | this.setState({
|
72 | dateValue: this.props.value,
|
73 | timeValue: this.props.value,
|
74 | });
|
75 | }
|
76 | else {
|
77 |
|
78 | this.setState({ dateValue: null });
|
79 | }
|
80 | };
|
81 | DateTimePicker.defaultProps = {
|
82 | canClearSelection: true,
|
83 | defaultValue: new Date(),
|
84 | };
|
85 | DateTimePicker.displayName = "".concat(core_1.DISPLAYNAME_PREFIX, ".DateTimePicker");
|
86 | return DateTimePicker;
|
87 | }(core_1.AbstractPureComponent2));
|
88 | exports.DateTimePicker = DateTimePicker;
|
89 |
|
\ | No newline at end of file |