1 | import { a as __extends } from './tslib.es6-863e3717.js';
|
2 | import { U as Utils } from './Utils-5f9f1f09.js';
|
3 | import { select } from 'd3';
|
4 | import { D as DateTimeButton } from './DateTimeButton-b021f323.js';
|
5 | import { S as SingleDateTimePicker } from './SingleDateTimePicker-634d46bc.js';
|
6 |
|
7 | var DateTimeButtonSingle = (function (_super) {
|
8 | __extends(DateTimeButtonSingle, _super);
|
9 | function DateTimeButtonSingle(renderTarget) {
|
10 | var _this = _super.call(this, renderTarget) || this;
|
11 | _this.sDTPOnSet = function (millis) {
|
12 | if (millis === void 0) { millis = null; }
|
13 | if (millis !== null) {
|
14 | _this.dateTimeButton.text(_this.buttonDateTimeFormat(millis));
|
15 | _this.selectedMillis = millis;
|
16 | _this.onSet(millis);
|
17 | }
|
18 | _this.closeSDTP();
|
19 | };
|
20 | return _this;
|
21 | }
|
22 | DateTimeButtonSingle.prototype.closeSDTP = function () {
|
23 | this.dateTimePickerContainer.style("display", "none");
|
24 | this.dateTimeButton.node().focus();
|
25 | };
|
26 | DateTimeButtonSingle.prototype.render = function (chartOptions, minMillis, maxMillis, selectedMillis, onSet) {
|
27 | var _this = this;
|
28 | if (chartOptions === void 0) { chartOptions = {}; }
|
29 | if (selectedMillis === void 0) { selectedMillis = null; }
|
30 | if (onSet === void 0) { onSet = null; }
|
31 | _super.prototype.render.call(this, chartOptions, minMillis, maxMillis, onSet);
|
32 | this.selectedMillis = selectedMillis;
|
33 | select(this.renderTarget).classed('tsi-dateTimeContainerSingle', true);
|
34 | this.dateTimeButton.text(this.buttonDateTimeFormat(selectedMillis));
|
35 | if (!this.dateTimePicker) {
|
36 | this.dateTimePicker = new SingleDateTimePicker(this.dateTimePickerContainer.node());
|
37 | }
|
38 | var targetElement = select(this.renderTarget);
|
39 | var dateTimeTextChildren = (targetElement.select(".tsi-dateTimePickerContainer")).selectAll("*");
|
40 | select("html").on("click." + Utils.guid(), function () {
|
41 | var pickerContainerChildren = _this.dateTimePickerContainer.selectAll("*");
|
42 | var outside = dateTimeTextChildren.filter(Utils.equalToEventTarget).empty()
|
43 | && targetElement.selectAll(".tsi-dateTimePickerContainer").filter(Utils.equalToEventTarget).empty()
|
44 | && targetElement.selectAll(".tsi-dateTimeButton").filter(Utils.equalToEventTarget).empty()
|
45 | && targetElement.selectAll(".tsi-saveButton").filter(Utils.equalToEventTarget).empty();
|
46 | var inClickTarget = pickerContainerChildren.filter(Utils.equalToEventTarget).empty();
|
47 | if (outside && inClickTarget && (_this.dateTimePickerContainer.style('display') !== 'none')) {
|
48 | _this.closeSDTP();
|
49 | }
|
50 | });
|
51 | this.dateTimeButton.on("click", function () {
|
52 | _this.chartOptions.dTPIsModal = true;
|
53 | _this.dateTimePickerContainer.style("display", "block");
|
54 | _this.dateTimePicker.render(_this.chartOptions, _this.minMillis, _this.maxMillis, _this.selectedMillis, _this.sDTPOnSet);
|
55 | });
|
56 | };
|
57 | return DateTimeButtonSingle;
|
58 | }(DateTimeButton));
|
59 |
|
60 | export { DateTimeButtonSingle as D };
|