tsichart-core 1.0.0
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/LICENSE +22 -0
- package/README.MD +189 -0
- package/dist/AggregateExpression.d.ts +13 -0
- package/dist/AggregateExpression.js +70 -0
- package/dist/AvailabilityChart-i_efwXCX.js +488 -0
- package/dist/AvailabilityChart.d.ts +59 -0
- package/dist/AvailabilityChart.js +26 -0
- package/dist/ChartComponent-DTcc6aED.d.ts +80 -0
- package/dist/ChartComponent-DnKLTxWe.js +302 -0
- package/dist/ChartComponentData-D5wuQmmZ.d.ts +47 -0
- package/dist/ChartDataOptions-DBS28b1-.d.ts +38 -0
- package/dist/ChartDataOptions-DRd8NHra.js +49 -0
- package/dist/ChartVisualizationComponent-CG7e5xlc.js +23 -0
- package/dist/ChartVisualizationComponent-DBjiqR1n.d.ts +8 -0
- package/dist/ColorPicker-CH__K8xm.js +120 -0
- package/dist/ColorPicker.d.ts +28 -0
- package/dist/ColorPicker.js +6 -0
- package/dist/Component-CofgyEw0.js +401 -0
- package/dist/Component-Rp30sSAW.d.ts +226 -0
- package/dist/ContextMenu-DABSkTA2.js +197 -0
- package/dist/DateTimeButton-CMcCxc8x.d.ts +16 -0
- package/dist/DateTimeButton-Ca1487GR.js +38 -0
- package/dist/DateTimeButtonRange-DpgfhHQt.js +71 -0
- package/dist/DateTimeButtonRange.d.ts +19 -0
- package/dist/DateTimeButtonRange.js +15 -0
- package/dist/DateTimeButtonSingle-C6cTx5VO.js +48 -0
- package/dist/DateTimeButtonSingle.d.ts +17 -0
- package/dist/DateTimeButtonSingle.js +14 -0
- package/dist/DateTimePicker-BH6qiVfQ.js +532 -0
- package/dist/DateTimePicker.d.ts +69 -0
- package/dist/DateTimePicker.js +13 -0
- package/dist/EllipsisMenu-30FNqoIv.js +116 -0
- package/dist/EllipsisMenu.d.ts +20 -0
- package/dist/EllipsisMenu.js +6 -0
- package/dist/Enums-ChUuTtHV.d.ts +12 -0
- package/dist/EventsTable-a0XLbsMF.js +553 -0
- package/dist/EventsTable.d.ts +34 -0
- package/dist/EventsTable.js +10 -0
- package/dist/GeoProcessGraphic-AVAzyF7k.js +145 -0
- package/dist/GeoProcessGraphic.d.ts +34 -0
- package/dist/GeoProcessGraphic.js +7 -0
- package/dist/Grid-DfFAkeeV.js +874 -0
- package/dist/Grid.d.ts +43 -0
- package/dist/Grid.js +6 -0
- package/dist/GroupedBarChart-BspwM8r2.js +579 -0
- package/dist/GroupedBarChart.d.ts +22 -0
- package/dist/GroupedBarChart.js +17 -0
- package/dist/GroupedBarChartData-BRCyDxbA.js +121 -0
- package/dist/GroupedBarChartData-C0YQydrP.d.ts +20 -0
- package/dist/Heatmap-D8ET8Ue8.js +524 -0
- package/dist/Heatmap.d.ts +31 -0
- package/dist/Heatmap.js +14 -0
- package/dist/Hierarchy-QkWLHkxo.js +260 -0
- package/dist/Hierarchy.d.ts +39 -0
- package/dist/Hierarchy.js +6 -0
- package/dist/HierarchyNavigation-CR6YUilh.js +336 -0
- package/dist/HierarchyNavigation.d.ts +34 -0
- package/dist/HierarchyNavigation.js +6 -0
- package/dist/HistoryPlayback-BmA-54lT.d.ts +68 -0
- package/dist/HistoryPlayback-SjeQbAPq.js +175 -0
- package/dist/Interfaces-BKRQ685G.d.ts +6 -0
- package/dist/Legend-DlSXQXHF.js +497 -0
- package/dist/LineChart-CExEyjZa.js +3181 -0
- package/dist/LineChart.d.ts +163 -0
- package/dist/LineChart.js +18 -0
- package/dist/ModelAutocomplete-TRD16egq.js +100 -0
- package/dist/ModelAutocomplete.d.ts +12 -0
- package/dist/ModelAutocomplete.js +7 -0
- package/dist/ModelSearch-WEa7Ud20.js +189 -0
- package/dist/ModelSearch.d.ts +23 -0
- package/dist/ModelSearch.js +9 -0
- package/dist/PieChart-B1ZXk13Q.js +258 -0
- package/dist/PieChart.d.ts +26 -0
- package/dist/PieChart.js +17 -0
- package/dist/PlaybackControls-Dwt6dif9.js +195 -0
- package/dist/PlaybackControls.d.ts +39 -0
- package/dist/PlaybackControls.js +13 -0
- package/dist/ProcessGraphic-CixT-zZl.js +154 -0
- package/dist/ProcessGraphic.d.ts +31 -0
- package/dist/ProcessGraphic.js +7 -0
- package/dist/README.MD +189 -0
- package/dist/ScatterPlot-DrPoHNDJ.js +924 -0
- package/dist/ScatterPlot.d.ts +115 -0
- package/dist/ScatterPlot.js +17 -0
- package/dist/SingleDateTimePicker-7anflEq8.js +213 -0
- package/dist/SingleDateTimePicker.d.ts +45 -0
- package/dist/SingleDateTimePicker.js +12 -0
- package/dist/Slider-BtSdC4fj.js +186 -0
- package/dist/Slider.d.ts +31 -0
- package/dist/Slider.js +6 -0
- package/dist/TemporalXAxisComponent-CyiM5EH0.d.ts +23 -0
- package/dist/TemporalXAxisComponent-DkyVvASs.js +129 -0
- package/dist/TimezonePicker-ClfP1lBL.js +58 -0
- package/dist/TimezonePicker.d.ts +16 -0
- package/dist/TimezonePicker.js +10 -0
- package/dist/Tooltip-Fa-0Xekn.js +104 -0
- package/dist/TsqExpression.d.ts +36 -0
- package/dist/TsqExpression.js +89 -0
- package/dist/UXClient-DydSPZwM.js +230 -0
- package/dist/UXClient.d.ts +74 -0
- package/dist/UXClient.js +47 -0
- package/dist/Utils-BsPLzJBC.d.ts +104 -0
- package/dist/Utils-C_j8IgZh.js +1138 -0
- package/dist/Utils.d.ts +7 -0
- package/dist/Utils.js +7 -0
- package/dist/_tslib-5_9pMg1F.js +96 -0
- package/dist/package.json +106 -0
- package/dist/pikaday-DMSzaLH6.js +1252 -0
- package/dist/tsiclient.cjs.js +3 -0
- package/dist/tsiclient.cjs.js.LICENSE.txt +19 -0
- package/dist/tsiclient.cjs.js.map +1 -0
- package/dist/tsiclient.css +17323 -0
- package/dist/tsiclient.d.ts +46 -0
- package/dist/tsiclient.esm.js +3 -0
- package/dist/tsiclient.esm.js.LICENSE.txt +19 -0
- package/dist/tsiclient.esm.js.map +1 -0
- package/dist/tsiclient.js +58 -0
- package/dist/tsiclient.min.css +6 -0
- package/dist/tsiclient.min.css.map +1 -0
- package/dist/tsiclient.umd.js +3 -0
- package/dist/tsiclient.umd.js.LICENSE.txt +19 -0
- package/dist/tsiclient.umd.js.map +1 -0
- package/dist/tsiclient.umd.min.js +3 -0
- package/dist/tsiclient.umd.min.js.LICENSE.txt +19 -0
- package/dist/tsiclient.umd.min.js.map +1 -0
- package/package.json +106 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import { _ as __extends } from './_tslib-5_9pMg1F.js';
|
|
2
|
+
import * as d3 from 'd3';
|
|
3
|
+
import { P as Pikaday } from './pikaday-DMSzaLH6.js';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { C as ChartComponent } from './ChartComponent-DnKLTxWe.js';
|
|
6
|
+
import { T as TimezonePicker } from './TimezonePicker-ClfP1lBL.js';
|
|
7
|
+
import { U as Utils } from './Utils-C_j8IgZh.js';
|
|
8
|
+
|
|
9
|
+
var DateTimePicker = /** @class */ (function (_super) {
|
|
10
|
+
__extends(DateTimePicker, _super);
|
|
11
|
+
function DateTimePicker(renderTarget) {
|
|
12
|
+
var _this = _super.call(this, renderTarget) || this;
|
|
13
|
+
_this.isValid = true;
|
|
14
|
+
_this.isSettingStartTime = true;
|
|
15
|
+
_this.quickTimeArray = [
|
|
16
|
+
["Last 15 mins", 15 * 60 * 1000],
|
|
17
|
+
["Last 30 mins", 30 * 60 * 1000],
|
|
18
|
+
["Last Hour", 60 * 60 * 1000],
|
|
19
|
+
["Last 2 Hours", 2 * 60 * 60 * 1000],
|
|
20
|
+
["Last 4 Hours", 4 * 60 * 60 * 1000],
|
|
21
|
+
["Last 12 Hours", 12 * 60 * 60 * 1000],
|
|
22
|
+
["Last 24 Hours", 24 * 60 * 60 * 1000],
|
|
23
|
+
["Last 7 Days", 7 * 24 * 60 * 60 * 1000],
|
|
24
|
+
["Last 30 Days", 30 * 24 * 60 * 60 * 1000],
|
|
25
|
+
["Last 90 Days", 90 * 24 * 60 * 60 * 1000]
|
|
26
|
+
];
|
|
27
|
+
_this.onSaveOrCancel = function () {
|
|
28
|
+
_this.isSettingStartTime = true;
|
|
29
|
+
};
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
// returns -1 if not currently a quicktime
|
|
33
|
+
DateTimePicker.prototype.getCurrentQuickTime = function () {
|
|
34
|
+
var _this = this;
|
|
35
|
+
var matchingQuickTime = this.quickTimeArray.filter(function (quickTimeTuple) {
|
|
36
|
+
return (_this.toMillis - _this.fromMillis === quickTimeTuple[1]);
|
|
37
|
+
});
|
|
38
|
+
if (matchingQuickTime.length !== 1 || this.toMillis !== this.maxMillis) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
return matchingQuickTime[0][1];
|
|
42
|
+
};
|
|
43
|
+
DateTimePicker.prototype.getQuickTimeText = function (quickTimeMillis) {
|
|
44
|
+
var filteredQuickTime = this.quickTimeArray.filter(function (quickTimeTuple) {
|
|
45
|
+
return (quickTimeMillis === quickTimeTuple[1]);
|
|
46
|
+
});
|
|
47
|
+
if (filteredQuickTime.length !== 1) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return filteredQuickTime[0][0];
|
|
51
|
+
};
|
|
52
|
+
DateTimePicker.prototype.convertToCalendarDate = function (millis) {
|
|
53
|
+
return this.roundDay(Utils.adjustDateFromTimezoneOffset(Utils.offsetFromUTC(new Date(millis), this.chartOptions.offset)));
|
|
54
|
+
};
|
|
55
|
+
DateTimePicker.prototype.setNewOffset = function (oldOffset) {
|
|
56
|
+
var _this = this;
|
|
57
|
+
var valuesToUpdate = ['fromMillis', 'toMillis'];
|
|
58
|
+
valuesToUpdate.forEach(function (currValue) {
|
|
59
|
+
var oldOffsetMinutes = Utils.getMinutesToUTC(oldOffset, _this[currValue]);
|
|
60
|
+
var utcMillis = _this[currValue] - (oldOffsetMinutes * 60 * 1000);
|
|
61
|
+
_this[currValue] = utcMillis - Utils.getOffsetMinutes(_this.chartOptions.offset, utcMillis) * 60 * 1000;
|
|
62
|
+
});
|
|
63
|
+
this.setFromMillis(this.fromMillis);
|
|
64
|
+
this.setToMillis(this.toMillis);
|
|
65
|
+
this.updateDisplayedFromDateTime();
|
|
66
|
+
this.updateDisplayedToDateTime();
|
|
67
|
+
this.startRange = new Date(this.fromMillis);
|
|
68
|
+
this.endRange = new Date(this.toMillis);
|
|
69
|
+
this.calendarPicker.config({ minDate: this.convertToCalendarDate(this.minMillis) });
|
|
70
|
+
this.calendarPicker.config({ maxDate: this.convertToCalendarDate(this.maxMillis) });
|
|
71
|
+
this.calendarPicker.draw();
|
|
72
|
+
var rangeErrorCheck = this.rangeIsValid(this.fromMillis, this.toMillis);
|
|
73
|
+
this.setIsSaveable(rangeErrorCheck.isSaveable);
|
|
74
|
+
this.displayRangeErrors(rangeErrorCheck.errors);
|
|
75
|
+
};
|
|
76
|
+
DateTimePicker.prototype.render = function (chartOptions, minMillis, maxMillis, fromMillis, toMillis, onSet, onCancel) {
|
|
77
|
+
var _this = this;
|
|
78
|
+
if (chartOptions === void 0) { chartOptions = {}; }
|
|
79
|
+
if (fromMillis === void 0) { fromMillis = null; }
|
|
80
|
+
if (toMillis === void 0) { toMillis = null; }
|
|
81
|
+
if (onSet === void 0) { onSet = null; }
|
|
82
|
+
if (onCancel === void 0) { onCancel = null; }
|
|
83
|
+
this.isSettingStartTime = true;
|
|
84
|
+
this.minMillis = minMillis;
|
|
85
|
+
this.maxMillis = maxMillis;
|
|
86
|
+
if (chartOptions.offset && (typeof chartOptions.offset === "string")) {
|
|
87
|
+
this.offsetName = chartOptions.offset;
|
|
88
|
+
}
|
|
89
|
+
if (toMillis == null) {
|
|
90
|
+
toMillis = this.maxMillis;
|
|
91
|
+
}
|
|
92
|
+
if (fromMillis == null) {
|
|
93
|
+
fromMillis = Math.max(toMillis - (24 * 60 * 60 * 1000), minMillis);
|
|
94
|
+
}
|
|
95
|
+
this.chartOptions.setOptions(chartOptions);
|
|
96
|
+
moment.locale(this.chartOptions.dateLocale);
|
|
97
|
+
this.fromMillis = fromMillis;
|
|
98
|
+
this.toMillis = toMillis;
|
|
99
|
+
this.onSet = onSet;
|
|
100
|
+
this.onCancel = onCancel;
|
|
101
|
+
this.targetElement = d3.select(this.renderTarget)
|
|
102
|
+
.classed("tsi-dateTimePicker", true);
|
|
103
|
+
this.targetElement.html('');
|
|
104
|
+
_super.prototype.themify.call(this, this.targetElement, this.chartOptions.theme);
|
|
105
|
+
var group = this.targetElement.append('div')
|
|
106
|
+
.classed('tsi-dateTimeGroup', true)
|
|
107
|
+
.on('keydown', function (event) {
|
|
108
|
+
if (event.keyCode <= 40 && event.keyCode >= 37) { //arrow key
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
}
|
|
111
|
+
if (event.keyCode === 27 && _this.chartOptions.dTPIsModal) { //escape
|
|
112
|
+
_this.onCancel();
|
|
113
|
+
_this.onSaveOrCancel();
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
this.quickTimesPanel = group.append('div')
|
|
117
|
+
.classed('tsi-quickTimesPanel', true);
|
|
118
|
+
this.buildQuickTimesPanel();
|
|
119
|
+
this.dateTimeSelectionPanel = group.append('div')
|
|
120
|
+
.classed('tsi-dateTimeSelectionPanel', true);
|
|
121
|
+
this.timeControls = this.dateTimeSelectionPanel.append("div").classed("tsi-timeControlsContainer", true);
|
|
122
|
+
this.calendar = this.dateTimeSelectionPanel.append("div").classed("tsi-calendarPicker", true);
|
|
123
|
+
this.createTimezonePicker();
|
|
124
|
+
var saveButtonContainer = this.dateTimeSelectionPanel.append("div").classed("tsi-saveButtonContainer", true);
|
|
125
|
+
var self = this;
|
|
126
|
+
saveButtonContainer.append("button").classed("tsi-saveButton", true).text(this.getString("Save"))
|
|
127
|
+
.on("click", function () {
|
|
128
|
+
self.onSet(self.fromMillis, self.toMillis, self.chartOptions.offset, self.maxMillis === self.toMillis, self.getCurrentQuickTime());
|
|
129
|
+
self.onSaveOrCancel();
|
|
130
|
+
});
|
|
131
|
+
saveButtonContainer.append('button')
|
|
132
|
+
.attr('class', 'tsi-cancelButton')
|
|
133
|
+
.text(this.getString('Cancel'))
|
|
134
|
+
.on('click', function () {
|
|
135
|
+
_this.onCancel();
|
|
136
|
+
_this.onSaveOrCancel();
|
|
137
|
+
})
|
|
138
|
+
.on('keydown', function (event) {
|
|
139
|
+
if (event.keyCode === 9 && !event.shiftKey && _this.chartOptions.dTPIsModal) { // tab
|
|
140
|
+
_this.quickTimesPanel.selectAll('.tsi-quickTime')
|
|
141
|
+
.filter(function (d, i) { return i === 0; })
|
|
142
|
+
.node()
|
|
143
|
+
.focus();
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
//originally set toMillis to last possible time
|
|
148
|
+
this.toMillis = this.maxMillis;
|
|
149
|
+
this.setFromMillis(fromMillis);
|
|
150
|
+
this.setToMillis(toMillis);
|
|
151
|
+
this.targetElement.append("div").classed("tsi-errorMessageContainer", true);
|
|
152
|
+
this.createTimePicker();
|
|
153
|
+
this.createCalendar();
|
|
154
|
+
this.calendarPicker.draw();
|
|
155
|
+
this.updateDisplayedFromDateTime();
|
|
156
|
+
this.updateDisplayedToDateTime();
|
|
157
|
+
this.startRange = new Date(this.fromMillis);
|
|
158
|
+
this.endRange = new Date(this.toMillis);
|
|
159
|
+
this.calendarPicker.draw();
|
|
160
|
+
return;
|
|
161
|
+
};
|
|
162
|
+
DateTimePicker.prototype.updateDisplayedDateTimes = function () {
|
|
163
|
+
var _this = this;
|
|
164
|
+
['from', 'to'].forEach(function (fromOrTo) {
|
|
165
|
+
var selectedDate = new Date(_this[fromOrTo + 'Millis']);
|
|
166
|
+
_this.calendarPicker.setDate(_this.roundDay(Utils.offsetFromUTC(selectedDate)));
|
|
167
|
+
_this[fromOrTo + 'Input'].node().value = _this.createTimeString(Utils.offsetFromUTC(selectedDate));
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
DateTimePicker.prototype.setFromQuickTimes = function (relativeMillis) {
|
|
171
|
+
this.isSettingStartTime = true;
|
|
172
|
+
this.setToMillis(this.maxMillis);
|
|
173
|
+
this.setFromMillis(this.maxMillis - relativeMillis);
|
|
174
|
+
this.updateDisplayedFromDateTime();
|
|
175
|
+
this.updateDisplayedToDateTime();
|
|
176
|
+
this.calendarPicker.draw();
|
|
177
|
+
};
|
|
178
|
+
DateTimePicker.prototype.buildQuickTimesPanel = function () {
|
|
179
|
+
var _this = this;
|
|
180
|
+
var quickTimes = this.quickTimesPanel.selectAll('.tsi-quickTime')
|
|
181
|
+
.data(this.quickTimeArray);
|
|
182
|
+
var enteredQuickTimes = quickTimes.enter()
|
|
183
|
+
.append('button')
|
|
184
|
+
.attr('class', 'tsi-quickTime')
|
|
185
|
+
.on('click', function (event, d) {
|
|
186
|
+
_this.setFromQuickTimes(d[1]);
|
|
187
|
+
})
|
|
188
|
+
.text(function (d) { return d[0]; })
|
|
189
|
+
.attr('aria-label', function (d) { return "".concat(_this.getString('select quick time of'), " ").concat(d[0]); });
|
|
190
|
+
// wrap around tab order if dTP in modal form
|
|
191
|
+
var firstQuickTime = enteredQuickTimes.filter(function (d, i) {
|
|
192
|
+
return (i === 0);
|
|
193
|
+
})
|
|
194
|
+
.on('keydown', function (event) {
|
|
195
|
+
if (event.keyCode === 9 && event.shiftKey && _this.chartOptions.dTPIsModal) { // shift tab
|
|
196
|
+
_this.dateTimeSelectionPanel.select(".tsi-saveButtonContainer").select(".tsi-cancelButton").node().focus();
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
if (this.chartOptions.dTPIsModal) {
|
|
201
|
+
firstQuickTime.node().focus();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
DateTimePicker.prototype.createTimeString = function (currDate) {
|
|
205
|
+
return this.getTimeFormat()(currDate);
|
|
206
|
+
};
|
|
207
|
+
DateTimePicker.prototype.getTimeFormat = function () {
|
|
208
|
+
return Utils.timeFormat(true, true, this.chartOptions.offset, true, 0, null, this.chartOptions.dateLocale);
|
|
209
|
+
};
|
|
210
|
+
DateTimePicker.prototype.updateFromAndTo = function (fromMillis, toMillis) {
|
|
211
|
+
this.setFromMillis(fromMillis);
|
|
212
|
+
this.setToMillis(toMillis);
|
|
213
|
+
this.updateDisplayedFromDateTime();
|
|
214
|
+
this.updateDisplayedToDateTime();
|
|
215
|
+
this.startRange = new Date(this.fromMillis);
|
|
216
|
+
this.endRange = new Date(this.toMillis);
|
|
217
|
+
this.calendarPicker.draw();
|
|
218
|
+
};
|
|
219
|
+
DateTimePicker.prototype.createTimezonePicker = function () {
|
|
220
|
+
var _this = this;
|
|
221
|
+
var offset = this.chartOptions.offset;
|
|
222
|
+
if (this.chartOptions.includeTimezones && (typeof offset == "string" || offset == 0)) {
|
|
223
|
+
var timezoneContainer = this.dateTimeSelectionPanel.append("div").attr("class", "tsi-timezoneContainer");
|
|
224
|
+
var timezoneSelectionLabelID = Utils.guid();
|
|
225
|
+
var timezoneSelectionID = timezoneSelectionLabelID + 'Tz';
|
|
226
|
+
timezoneContainer.append("label")
|
|
227
|
+
.classed("tsi-timeLabel", true)
|
|
228
|
+
.attr('aria-label', this.getString('timezone selection'))
|
|
229
|
+
.attr('id', timezoneSelectionLabelID)
|
|
230
|
+
.attr('for', timezoneSelectionID)
|
|
231
|
+
.text(this.getString('timezone'));
|
|
232
|
+
var timezonePickerContainer = timezoneContainer.append("div").classed("tsi-timezonePickerContainer", true);
|
|
233
|
+
var timezonePicker = new TimezonePicker(timezonePickerContainer.node());
|
|
234
|
+
timezonePicker.render(function (newOffset) {
|
|
235
|
+
var matchingQuickTime = _this.getCurrentQuickTime();
|
|
236
|
+
var oldOffset = _this.chartOptions.offset;
|
|
237
|
+
_this.chartOptions.offset = newOffset;
|
|
238
|
+
_this.setNewOffset(oldOffset);
|
|
239
|
+
if (matchingQuickTime !== -1) {
|
|
240
|
+
_this.setFromQuickTimes(matchingQuickTime);
|
|
241
|
+
}
|
|
242
|
+
}, (typeof offset == "string" ? offset : "UTC"));
|
|
243
|
+
d3.select(timezonePicker.renderTarget).select('select')
|
|
244
|
+
.attr('aria-labelledBy', timezoneSelectionLabelID)
|
|
245
|
+
.attr('id', timezoneSelectionID);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
//zero out everything but year, month and day
|
|
249
|
+
DateTimePicker.prototype.roundDay = function (d) {
|
|
250
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
251
|
+
};
|
|
252
|
+
DateTimePicker.prototype.setTimeRange = function (d, isFromSelect) {
|
|
253
|
+
if (this.isSettingStartTime) {
|
|
254
|
+
this.calendarPicker.setStartRange(d);
|
|
255
|
+
this.calendarPicker.setEndRange(null);
|
|
256
|
+
this.startRange = d;
|
|
257
|
+
this.anchorDate = d;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
if (d.valueOf() > this.anchorDate.valueOf()) {
|
|
261
|
+
if (isFromSelect) {
|
|
262
|
+
this.setFromDate(this.anchorDate);
|
|
263
|
+
this.setToDate(d);
|
|
264
|
+
}
|
|
265
|
+
this.calendarPicker.setEndRange(d);
|
|
266
|
+
this.calendarPicker.setStartRange(this.anchorDate);
|
|
267
|
+
this.startRange = this.anchorDate;
|
|
268
|
+
this.endRange = d;
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
if (isFromSelect) {
|
|
272
|
+
this.setFromDate(d);
|
|
273
|
+
this.setToDate(this.anchorDate);
|
|
274
|
+
}
|
|
275
|
+
this.calendarPicker.setStartRange(d);
|
|
276
|
+
this.calendarPicker.setEndRange(this.anchorDate);
|
|
277
|
+
this.endRange = this.anchorDate;
|
|
278
|
+
this.startRange = d;
|
|
279
|
+
}
|
|
280
|
+
this.setTimeInputBox(this.fromMillis, true);
|
|
281
|
+
this.setTimeInputBox(this.toMillis, false);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
DateTimePicker.prototype.createCalendar = function () {
|
|
285
|
+
var _this = this;
|
|
286
|
+
var i18nOptions = {
|
|
287
|
+
previousMonth: this.getString('Previous Month'),
|
|
288
|
+
nextMonth: this.getString('Next Month'),
|
|
289
|
+
months: moment.localeData().months(),
|
|
290
|
+
weekdays: moment.localeData().weekdays(),
|
|
291
|
+
weekdaysShort: moment.localeData().weekdaysMin()
|
|
292
|
+
};
|
|
293
|
+
//@ts-ignore
|
|
294
|
+
this.calendarPicker = new Pikaday({
|
|
295
|
+
bound: false,
|
|
296
|
+
container: this.calendar.node(),
|
|
297
|
+
field: this.calendar.node(),
|
|
298
|
+
i18n: i18nOptions,
|
|
299
|
+
numberOfMonths: 2,
|
|
300
|
+
onSelect: function (d) {
|
|
301
|
+
_this.setTimeRange(d, true);
|
|
302
|
+
_this.isSettingStartTime = !_this.isSettingStartTime;
|
|
303
|
+
_this.calendarPicker.draw();
|
|
304
|
+
},
|
|
305
|
+
onDraw: function (d) {
|
|
306
|
+
if (_this.isSettingStartTime)
|
|
307
|
+
return;
|
|
308
|
+
var self = _this;
|
|
309
|
+
_this.calendar.select(".pika-single").selectAll(".pika-day")
|
|
310
|
+
.on("mouseover", function () {
|
|
311
|
+
var date = new Date(Number(d3.select(this).attr("data-pika-year")), Number(d3.select(this).attr("data-pika-month")), Number(d3.select(this).attr("data-pika-day")));
|
|
312
|
+
if (!self.isSettingStartTime) {
|
|
313
|
+
if (date.valueOf() < self.anchorDate.valueOf() && self.startRange.valueOf() != date.valueOf()) {
|
|
314
|
+
self.setTimeRange(date, false);
|
|
315
|
+
self.calendarPicker.draw();
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
if (date.valueOf() >= self.anchorDate.valueOf() && (self.endRange == undefined || self.endRange.valueOf() != date.valueOf())) {
|
|
319
|
+
self.setTimeRange(date, false);
|
|
320
|
+
self.calendarPicker.draw();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
},
|
|
326
|
+
minDate: this.convertToCalendarDate(this.minMillis),
|
|
327
|
+
maxDate: this.convertToCalendarDate(this.maxMillis),
|
|
328
|
+
defaultDate: Utils.adjustDateFromTimezoneOffset(new Date(this.fromMillis))
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
DateTimePicker.prototype.setSelectedQuickTimes = function () {
|
|
332
|
+
var _this = this;
|
|
333
|
+
var isSelected = function (d) {
|
|
334
|
+
return (_this.toMillis === _this.maxMillis && (_this.toMillis - _this.fromMillis === d[1]));
|
|
335
|
+
};
|
|
336
|
+
this.quickTimesPanel.selectAll('.tsi-quickTime')
|
|
337
|
+
.classed('tsi-isSelected', isSelected)
|
|
338
|
+
.attr('aria-pressed', isSelected);
|
|
339
|
+
};
|
|
340
|
+
DateTimePicker.prototype.setFromDate = function (calendarDate) {
|
|
341
|
+
var convertedFrom = new Date(Utils.offsetFromUTC(new Date(this.fromMillis), this.chartOptions.offset));
|
|
342
|
+
convertedFrom.setUTCFullYear(calendarDate.getFullYear());
|
|
343
|
+
convertedFrom.setUTCMonth(calendarDate.getMonth());
|
|
344
|
+
convertedFrom.setUTCDate(calendarDate.getDate());
|
|
345
|
+
this.setFromMillis(Utils.offsetToUTC(convertedFrom, this.chartOptions.offset).valueOf());
|
|
346
|
+
};
|
|
347
|
+
DateTimePicker.prototype.setToDate = function (calendarDate) {
|
|
348
|
+
var convertedTo = new Date(Utils.offsetFromUTC(new Date(this.toMillis), this.chartOptions.offset));
|
|
349
|
+
convertedTo.setUTCFullYear(calendarDate.getFullYear());
|
|
350
|
+
convertedTo.setUTCMonth(calendarDate.getMonth());
|
|
351
|
+
convertedTo.setUTCDate(calendarDate.getDate());
|
|
352
|
+
this.setToMillis(Utils.offsetToUTC(convertedTo, this.chartOptions.offset).valueOf());
|
|
353
|
+
};
|
|
354
|
+
DateTimePicker.prototype.setIsSaveable = function (isSaveable) {
|
|
355
|
+
// For now, lets allow users to save the time even in the presence of errors
|
|
356
|
+
this.dateTimeSelectionPanel.select(".tsi-saveButtonContainer").select(".tsi-saveButton")
|
|
357
|
+
.attr("disabled", isSaveable ? null : true)
|
|
358
|
+
.classed("tsi-buttonDisabled", !isSaveable);
|
|
359
|
+
this.isValid = isSaveable;
|
|
360
|
+
};
|
|
361
|
+
//line up the seconds and millis with the second and millis of the max date
|
|
362
|
+
DateTimePicker.prototype.adjustSecondsAndMillis = function (rawMillis) {
|
|
363
|
+
var currDate = new Date(rawMillis);
|
|
364
|
+
var maxDate = new Date(this.maxMillis);
|
|
365
|
+
currDate.setUTCSeconds(maxDate.getUTCSeconds());
|
|
366
|
+
currDate.setUTCMilliseconds(maxDate.getUTCMilliseconds());
|
|
367
|
+
return currDate.valueOf();
|
|
368
|
+
};
|
|
369
|
+
DateTimePicker.prototype.setFromMillis = function (millis) {
|
|
370
|
+
var rangeErrorCheck = this.rangeIsValid(millis, this.toMillis);
|
|
371
|
+
this.fromMillis = millis;
|
|
372
|
+
this.setIsSaveable(rangeErrorCheck.isSaveable);
|
|
373
|
+
this.displayRangeErrors(rangeErrorCheck.errors);
|
|
374
|
+
this.setSelectedQuickTimes();
|
|
375
|
+
};
|
|
376
|
+
DateTimePicker.prototype.setToMillis = function (millis) {
|
|
377
|
+
var rangeErrorCheck = this.rangeIsValid(this.fromMillis, millis);
|
|
378
|
+
this.toMillis = millis;
|
|
379
|
+
this.setIsSaveable(rangeErrorCheck.isSaveable);
|
|
380
|
+
this.displayRangeErrors(rangeErrorCheck.errors);
|
|
381
|
+
this.setSelectedQuickTimes();
|
|
382
|
+
};
|
|
383
|
+
DateTimePicker.prototype.displayRangeErrors = function (rangeErrors) {
|
|
384
|
+
this.targetElement.select(".tsi-errorMessageContainer").selectAll(".tsi-errorMessage").remove();
|
|
385
|
+
if (rangeErrors.length != 0) {
|
|
386
|
+
this.targetElement.select(".tsi-errorMessageContainer").selectAll(".tsi-errorMessages")
|
|
387
|
+
.data(rangeErrors)
|
|
388
|
+
.enter()
|
|
389
|
+
.append("div")
|
|
390
|
+
.classed("tsi-errorMessage", true)
|
|
391
|
+
.attr('role', 'alert')
|
|
392
|
+
.attr('aria-live', 'assertive')
|
|
393
|
+
.text(function (d) { return d; });
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
DateTimePicker.prototype.rangeIsValid = function (prospectiveFromMillis, prospectiveToMillis) {
|
|
397
|
+
var accumulatedErrors = [];
|
|
398
|
+
var isSaveable = true;
|
|
399
|
+
var bothTimesValid = !isNaN(prospectiveFromMillis) && !isNaN(prospectiveToMillis);
|
|
400
|
+
if (isNaN(prospectiveFromMillis)) {
|
|
401
|
+
accumulatedErrors.push("*Invalid Start date/time");
|
|
402
|
+
isSaveable = false;
|
|
403
|
+
}
|
|
404
|
+
if (isNaN(prospectiveToMillis)) {
|
|
405
|
+
accumulatedErrors.push("*Invalid end date/time");
|
|
406
|
+
isSaveable = false;
|
|
407
|
+
}
|
|
408
|
+
if (bothTimesValid) {
|
|
409
|
+
if (prospectiveFromMillis > prospectiveToMillis) {
|
|
410
|
+
accumulatedErrors.push("*Start time must be before end time");
|
|
411
|
+
isSaveable = false;
|
|
412
|
+
}
|
|
413
|
+
if (prospectiveFromMillis < this.minMillis) {
|
|
414
|
+
accumulatedErrors.push("*Start time is before first possible time (" + this.getTimeFormat()(this.minMillis) + ")");
|
|
415
|
+
}
|
|
416
|
+
if (prospectiveFromMillis > this.maxMillis) {
|
|
417
|
+
accumulatedErrors.push("*Start time is after last possible time (" + this.getTimeFormat()(this.maxMillis) + ")");
|
|
418
|
+
}
|
|
419
|
+
if (prospectiveToMillis > this.maxMillis) {
|
|
420
|
+
accumulatedErrors.push("*End time is after last possible time (" + this.getTimeFormat()(this.maxMillis) + ")");
|
|
421
|
+
}
|
|
422
|
+
if (prospectiveToMillis < this.minMillis) {
|
|
423
|
+
accumulatedErrors.push("*End time is before first possible time (" + this.getTimeFormat()(this.minMillis) + ")");
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
rangeIsValid: (accumulatedErrors.length == 0),
|
|
428
|
+
errors: accumulatedErrors,
|
|
429
|
+
isSaveable: isSaveable
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
DateTimePicker.prototype.updateDisplayedFromDateTime = function (fromInput) {
|
|
433
|
+
if (fromInput === void 0) { fromInput = false; }
|
|
434
|
+
this.calendarPicker.setStartRange(this.convertToCalendarDate(this.fromMillis));
|
|
435
|
+
if (!fromInput)
|
|
436
|
+
this.setTimeInputBox(new Date(this.fromMillis), true);
|
|
437
|
+
};
|
|
438
|
+
DateTimePicker.prototype.updateDisplayedToDateTime = function (fromInput) {
|
|
439
|
+
if (fromInput === void 0) { fromInput = false; }
|
|
440
|
+
this.calendarPicker.setEndRange(this.convertToCalendarDate(this.toMillis));
|
|
441
|
+
if (!fromInput)
|
|
442
|
+
this.setTimeInputBox(new Date(this.toMillis), false);
|
|
443
|
+
};
|
|
444
|
+
DateTimePicker.prototype.offsetUTC = function (date) {
|
|
445
|
+
var dateCopy = new Date(date.valueOf());
|
|
446
|
+
dateCopy.setTime(dateCopy.getTime() - dateCopy.getTimezoneOffset() * 60 * 1000);
|
|
447
|
+
return dateCopy;
|
|
448
|
+
};
|
|
449
|
+
DateTimePicker.prototype.offsetFromUTC = function (date) {
|
|
450
|
+
var dateCopy = new Date(date.valueOf());
|
|
451
|
+
dateCopy.setTime(dateCopy.getTime() + dateCopy.getTimezoneOffset() * 60 * 1000);
|
|
452
|
+
return dateCopy;
|
|
453
|
+
};
|
|
454
|
+
DateTimePicker.prototype.checkDateTimeValidity = function () {
|
|
455
|
+
var parsedFrom = Utils.parseUserInputDateTime(this.fromInput.node().value, this.chartOptions.offset);
|
|
456
|
+
var parsedTo = Utils.parseUserInputDateTime(this.toInput.node().value, this.chartOptions.offset);
|
|
457
|
+
var rangeErrorCheck = this.rangeIsValid(parsedFrom, parsedTo);
|
|
458
|
+
this.setIsSaveable(rangeErrorCheck.isSaveable);
|
|
459
|
+
this.displayRangeErrors(rangeErrorCheck.errors);
|
|
460
|
+
};
|
|
461
|
+
DateTimePicker.prototype.setTimeInputBox = function (utcDate, isFrom) {
|
|
462
|
+
if (isFrom) {
|
|
463
|
+
this.fromInput.node().value = this.createTimeString(utcDate);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
466
|
+
this.toInput.node().value = this.createTimeString(utcDate);
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
DateTimePicker.prototype.createTimePicker = function () {
|
|
470
|
+
var _this = this;
|
|
471
|
+
var timeInputContainer = this.timeControls.append("div").attr("class", "tsi-timeInputContainer");
|
|
472
|
+
var createTimePicker = function (startOrEnd) {
|
|
473
|
+
var fromOrToContainer = timeInputContainer.append("div").classed("tsi-" + startOrEnd + "Container", true);
|
|
474
|
+
var inputLabelID = Utils.guid();
|
|
475
|
+
var inputID = inputLabelID + 'Input';
|
|
476
|
+
var timeLabel = fromOrToContainer.append("label")
|
|
477
|
+
.classed("tsi-timeLabel", true)
|
|
478
|
+
.attr('id', inputLabelID)
|
|
479
|
+
.attr('for', inputID)
|
|
480
|
+
.attr('aria-label', "".concat(startOrEnd === 'start' ? _this.getString('Start time input') : _this.getString('End time input')))
|
|
481
|
+
.text(_this.getString(startOrEnd));
|
|
482
|
+
timeLabel.append("span")
|
|
483
|
+
.classed("tsi-timeRequired", true)
|
|
484
|
+
.text(_this.getString('*'));
|
|
485
|
+
var inputName = startOrEnd === 'start' ? 'fromInput' : 'toInput';
|
|
486
|
+
_this[inputName] = fromOrToContainer.append('input')
|
|
487
|
+
.attr('class', 'tsi-dateTimeInput', true)
|
|
488
|
+
.attr('aria-labelledby', inputLabelID)
|
|
489
|
+
.attr('required', true)
|
|
490
|
+
.attr('id', inputID)
|
|
491
|
+
.on('input', function () {
|
|
492
|
+
_this.checkDateTimeValidity();
|
|
493
|
+
_this.isSettingStartTime = true;
|
|
494
|
+
if (_this.isValid) {
|
|
495
|
+
if (startOrEnd === 'start') {
|
|
496
|
+
var parsedFrom = Utils.parseUserInputDateTime(_this.fromInput.node().value, _this.chartOptions.offset);
|
|
497
|
+
_this.setFromMillis(parsedFrom);
|
|
498
|
+
_this.updateDisplayedFromDateTime(true);
|
|
499
|
+
_this.calendarPicker.draw();
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
var parsedTo = Utils.parseUserInputDateTime(_this.toInput.node().value, _this.chartOptions.offset);
|
|
503
|
+
_this.setToMillis(parsedTo);
|
|
504
|
+
_this.updateDisplayedToDateTime(true);
|
|
505
|
+
_this.calendarPicker.draw();
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
if (startOrEnd == 'end') {
|
|
510
|
+
fromOrToContainer.append("button")
|
|
511
|
+
.attr("class", "tsi-snapToEndRangeButton")
|
|
512
|
+
.text(_this.getString("Latest"))
|
|
513
|
+
.attr('aria-label', _this.getString('snap end time to latest'))
|
|
514
|
+
.on("click", function () {
|
|
515
|
+
if (!_this.isSettingStartTime) {
|
|
516
|
+
_this.setFromDate(_this.startRange);
|
|
517
|
+
}
|
|
518
|
+
_this.setToMillis(_this.maxMillis);
|
|
519
|
+
_this.updateDisplayedFromDateTime();
|
|
520
|
+
_this.updateDisplayedToDateTime();
|
|
521
|
+
_this.isSettingStartTime = true;
|
|
522
|
+
_this.calendarPicker.draw();
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
createTimePicker("start");
|
|
527
|
+
createTimePicker("end");
|
|
528
|
+
};
|
|
529
|
+
return DateTimePicker;
|
|
530
|
+
}(ChartComponent));
|
|
531
|
+
|
|
532
|
+
export { DateTimePicker as D };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { C as ChartComponent } from './ChartComponent-DTcc6aED.js';
|
|
2
|
+
import './Enums-ChUuTtHV.js';
|
|
3
|
+
import './Component-Rp30sSAW.js';
|
|
4
|
+
import './Interfaces-BKRQ685G.js';
|
|
5
|
+
import './ChartComponentData-D5wuQmmZ.js';
|
|
6
|
+
import './EllipsisMenu.js';
|
|
7
|
+
|
|
8
|
+
declare class DateTimePicker extends ChartComponent {
|
|
9
|
+
private calendar;
|
|
10
|
+
private calendarPicker;
|
|
11
|
+
private timeControls;
|
|
12
|
+
private minMillis;
|
|
13
|
+
private maxMillis;
|
|
14
|
+
private fromMillis;
|
|
15
|
+
private toMillis;
|
|
16
|
+
private fromMinutes;
|
|
17
|
+
private fromHours;
|
|
18
|
+
private toMinutes;
|
|
19
|
+
private toHours;
|
|
20
|
+
private onSet;
|
|
21
|
+
private onCancel;
|
|
22
|
+
private isValid;
|
|
23
|
+
private targetElement;
|
|
24
|
+
private dateTimeSelectionPanel;
|
|
25
|
+
private quickTimesPanel;
|
|
26
|
+
private isSettingStartTime;
|
|
27
|
+
private startRange;
|
|
28
|
+
private endRange;
|
|
29
|
+
private anchorDate;
|
|
30
|
+
private offsetName;
|
|
31
|
+
private fromInput;
|
|
32
|
+
private toInput;
|
|
33
|
+
private quickTimeArray;
|
|
34
|
+
constructor(renderTarget: Element);
|
|
35
|
+
private getCurrentQuickTime;
|
|
36
|
+
getQuickTimeText(quickTimeMillis: any): any;
|
|
37
|
+
private convertToCalendarDate;
|
|
38
|
+
private setNewOffset;
|
|
39
|
+
private onSaveOrCancel;
|
|
40
|
+
render(chartOptions: any, minMillis: number, maxMillis: number, fromMillis?: number, toMillis?: number, onSet?: any, onCancel?: any): void;
|
|
41
|
+
private updateDisplayedDateTimes;
|
|
42
|
+
private setFromQuickTimes;
|
|
43
|
+
private buildQuickTimesPanel;
|
|
44
|
+
private createTimeString;
|
|
45
|
+
private getTimeFormat;
|
|
46
|
+
updateFromAndTo(fromMillis: any, toMillis: any): void;
|
|
47
|
+
private createTimezonePicker;
|
|
48
|
+
private roundDay;
|
|
49
|
+
private setTimeRange;
|
|
50
|
+
private createCalendar;
|
|
51
|
+
private setSelectedQuickTimes;
|
|
52
|
+
private setFromDate;
|
|
53
|
+
private setToDate;
|
|
54
|
+
private setIsSaveable;
|
|
55
|
+
private adjustSecondsAndMillis;
|
|
56
|
+
private setFromMillis;
|
|
57
|
+
private setToMillis;
|
|
58
|
+
private displayRangeErrors;
|
|
59
|
+
private rangeIsValid;
|
|
60
|
+
private updateDisplayedFromDateTime;
|
|
61
|
+
private updateDisplayedToDateTime;
|
|
62
|
+
private offsetUTC;
|
|
63
|
+
private offsetFromUTC;
|
|
64
|
+
private checkDateTimeValidity;
|
|
65
|
+
private setTimeInputBox;
|
|
66
|
+
private createTimePicker;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { DateTimePicker as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { D as default } from './DateTimePicker-BH6qiVfQ.js';
|
|
2
|
+
import './_tslib-5_9pMg1F.js';
|
|
3
|
+
import 'd3';
|
|
4
|
+
import './pikaday-DMSzaLH6.js';
|
|
5
|
+
import 'moment';
|
|
6
|
+
import './ChartComponent-DnKLTxWe.js';
|
|
7
|
+
import './Utils-C_j8IgZh.js';
|
|
8
|
+
import 'moment-timezone';
|
|
9
|
+
import './Component-CofgyEw0.js';
|
|
10
|
+
import './Grid-DfFAkeeV.js';
|
|
11
|
+
import 'split.js';
|
|
12
|
+
import './EllipsisMenu-30FNqoIv.js';
|
|
13
|
+
import './TimezonePicker-ClfP1lBL.js';
|