1 | import { a as __extends } from './tslib.es6-f952ba6f.js';
|
2 | import { U as Utils } from './Utils-38a0872e.js';
|
3 | import { select } from 'd3';
|
4 | import { D as DateTimePicker } from './DateTimePicker-570b44a6.js';
|
5 | import { D as DateTimeButton } from './DateTimeButton-ac146823.js';
|
6 |
|
7 | var DateTimeButtonRange = (function (_super) {
|
8 | __extends(DateTimeButtonRange, _super);
|
9 | function DateTimeButtonRange(renderTarget) {
|
10 | return _super.call(this, renderTarget) || this;
|
11 | }
|
12 | DateTimeButtonRange.prototype.setButtonText = function (fromMillis, toMillis, isRelative, quickTime) {
|
13 | var fromString = this.buttonDateTimeFormat(fromMillis);
|
14 | var tzAbbr = Utils.createTimezoneAbbreviation(this.chartOptions.offset);
|
15 | var toString = this.buttonDateTimeFormat(toMillis) + ' (' + tzAbbr + ')';
|
16 | if (!isRelative) {
|
17 | this.dateTimeButton.text(fromString + " - " + toString);
|
18 | this.dateTimeButton.attr('aria-label', this.getString('a button to launch a time selection dialog current selected time is ') + " " + fromString + " - " + toString);
|
19 | }
|
20 | else {
|
21 | var quickTimeText = this.dateTimePicker.getQuickTimeText(quickTime);
|
22 | var text = quickTimeText !== null ? quickTimeText + " (" + fromString + " - " + toString + ")" : fromString + " - " + this.getString('Latest') + " (" + toString + ")";
|
23 | this.dateTimeButton.text(text);
|
24 | this.dateTimeButton.attr('aria-label', this.getString('a button to launch a time selection dialog current selected time is ') + " " + text);
|
25 | }
|
26 | };
|
27 | DateTimeButtonRange.prototype.onClose = function () {
|
28 | this.dateTimePickerContainer.style("display", "none");
|
29 | this.dateTimeButton.node().focus();
|
30 | };
|
31 | DateTimeButtonRange.prototype.render = function (chartOptions, minMillis, maxMillis, fromMillis, toMillis, onSet, onCancel) {
|
32 | var _this = this;
|
33 | if (chartOptions === void 0) { chartOptions = {}; }
|
34 | if (fromMillis === void 0) { fromMillis = null; }
|
35 | if (toMillis === void 0) { toMillis = null; }
|
36 | if (onSet === void 0) { onSet = null; }
|
37 | if (onCancel === void 0) { onCancel = null; }
|
38 | _super.prototype.render.call(this, chartOptions, minMillis, maxMillis, onSet);
|
39 | select(this.renderTarget).classed('tsi-dateTimeContainerRange', true);
|
40 | this.fromMillis = fromMillis;
|
41 | this.toMillis = toMillis;
|
42 | this.onCancel = onCancel ? onCancel : function () { };
|
43 | if (!this.dateTimePicker) {
|
44 | this.dateTimePicker = new DateTimePicker(this.dateTimePickerContainer.node());
|
45 | }
|
46 | this.setButtonText(fromMillis, toMillis, toMillis === maxMillis, this.toMillis - this.fromMillis);
|
47 | this.dateTimeButton.on("click", function () {
|
48 | if (_this.dateTimePickerContainer.style("display") !== "none") {
|
49 | _this.onClose();
|
50 | }
|
51 | else {
|
52 | _this.chartOptions.dTPIsModal = true;
|
53 | _this.dateTimePickerContainer.style("display", "block");
|
54 | _this.dateTimePicker.render(_this.chartOptions, minMillis, maxMillis, _this.fromMillis, _this.toMillis, function (fromMillis, toMillis, offset, isRelative, currentQuickTime) {
|
55 | _this.chartOptions.offset = offset;
|
56 | _this.fromMillis = fromMillis;
|
57 | _this.toMillis = toMillis;
|
58 | _this.setButtonText(fromMillis, toMillis, isRelative, currentQuickTime);
|
59 | _this.onSet(fromMillis, toMillis, offset);
|
60 | _this.onClose();
|
61 | }, function () {
|
62 | _this.onClose();
|
63 | _this.onCancel();
|
64 | });
|
65 | }
|
66 | });
|
67 | };
|
68 | return DateTimeButtonRange;
|
69 | }(DateTimeButton));
|
70 |
|
71 | export { DateTimeButtonRange as D };
|