tsichart-core 2.0.0 → 2.1.2

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/dist/index.d.ts CHANGED
@@ -310,18 +310,27 @@ declare class Legend extends Component {
310
310
  private svgSelection;
311
311
  private chartComponentData;
312
312
  constructor(drawChart: any, renderTarget: Element, legendWidth: number);
313
+ private getHeightPerSplitBy;
314
+ private addColorKey;
315
+ private addEyeIcon;
316
+ private addSeriesName;
317
+ private addSeriesTypeSelection;
318
+ private handleSplitByClick;
319
+ private handleSplitByMouseOver;
320
+ private handleSplitByMouseOut;
321
+ private isStickied;
313
322
  private labelMouseoutWrapper;
314
323
  private toggleSplitByVisible;
315
324
  triggerSplitByFocus(aggKey: string, splitBy: string): void;
316
- private getHeightPerSplitBy;
317
325
  private createGradient;
318
- private isNonNumeric;
319
326
  private createNonNumericColorKey;
320
327
  private createCategoricalColorKey;
321
328
  private createEventsColorKey;
329
+ private handleShowMoreSplitBys;
322
330
  private renderSplitBys;
323
331
  private toggleSticky;
324
332
  draw(legendState: string, chartComponentData: any, labelMouseover: any, svgSelection: any, options: any, labelMouseoutAction?: any, stickySeriesAction?: any, event?: any): void;
333
+ destroy(): void;
325
334
  }
326
335
 
327
336
  declare class ChartComponent extends Component {
@@ -1097,29 +1106,52 @@ declare class ModelAutocomplete extends Component {
1097
1106
  chartOptions: any;
1098
1107
  ap: any;
1099
1108
  constructor(renderTarget: Element);
1100
- render(environmentFqdn: string, getToken: any, chartOptions: any): void;
1109
+ render(chartOptions: any): void;
1101
1110
  }
1102
1111
 
1103
1112
  declare class HierarchyNavigation extends Component {
1104
1113
  private searchFunction;
1105
1114
  private hierarchyElem;
1106
1115
  private path;
1116
+ private debounceTimer;
1117
+ private debounceDelay;
1118
+ private requestCounter;
1119
+ private latestRequestId;
1107
1120
  selectedIds: Array<string>;
1108
1121
  searchEnabled: boolean;
1122
+ autocompleteEnabled: boolean;
1109
1123
  private searchWrapperElem;
1110
1124
  private hierarchyNavWrapper;
1125
+ private isSearchMode;
1126
+ private pathsToAutoExpand;
1111
1127
  ap: any;
1112
1128
  constructor(renderTarget: Element);
1113
- render(searchF: Function, hierarchyNavOptions: any, preselectedIds: Array<string>): Promise<void>;
1129
+ render(searchF: (payload: any) => Promise<any>, hierarchyNavOptions: any, preselectedIds: Array<string>): Promise<void>;
1114
1130
  private createHierarchyNavWrapper;
1115
1131
  private createResultsWrapper;
1116
1132
  private createHierarchyElem;
1133
+ private onKeyDown;
1134
+ private getVisibleItemElems;
1135
+ private focusItem;
1136
+ private focusNext;
1137
+ private focusPrev;
1138
+ private handleArrowRight;
1139
+ private handleArrowLeft;
1117
1140
  private requestPayload;
1118
1141
  private renderTree;
1119
1142
  private renderSearchBox;
1120
1143
  private pathSearchAndRenderResult;
1121
1144
  private renderSearchResult;
1122
1145
  private filterTree;
1146
+ private fetchAutocompleteSuggestions;
1147
+ private performDeepSearch;
1148
+ private renderSearchResults;
1149
+ private exitSearchMode;
1150
+ private navigateToPath;
1151
+ private computePathsToAutoExpand;
1152
+ private shouldAutoExpand;
1153
+ private autoExpandNode;
1154
+ private highlightMatch;
1123
1155
  private fillDataRecursively;
1124
1156
  private createHierarchyItemElem;
1125
1157
  private getAriaLabel;
@@ -1129,6 +1161,1203 @@ declare class HierarchyNavigation extends Component {
1129
1161
  private instanceNodeString;
1130
1162
  }
1131
1163
 
1164
+ /*!
1165
+ * Pikaday
1166
+ *
1167
+ * Copyright © 2014 David Bushell | BSD & MIT license | https://github.com/dbushell/Pikaday
1168
+ */
1169
+ (function (root, factory) {
1170
+
1171
+ var moment;
1172
+ if (typeof exports === 'object') {
1173
+ // CommonJS module
1174
+ // Load moment.js as an optional dependency
1175
+ try { moment = require('moment'); } catch (e) { moment = (typeof window !== 'undefined' && window.moment) || undefined; }
1176
+ module.exports = factory(moment);
1177
+ } else if (typeof define === 'function' && define.amd) {
1178
+ // AMD. Register as an anonymous module.
1179
+ define(function (req) {
1180
+ // Load moment.js as an optional dependency
1181
+ var id = 'moment';
1182
+ try { moment = req(id); } catch (e) { moment = (typeof window !== 'undefined' && window.moment) || undefined; }
1183
+ return factory(moment);
1184
+ });
1185
+ } else {
1186
+ // Browser global - safely access moment from multiple sources
1187
+ moment = (typeof window !== 'undefined' && window.moment) ||
1188
+ (typeof root !== 'undefined' && root && root.moment) ||
1189
+ (typeof global !== 'undefined' && global.moment);
1190
+
1191
+ // Safely assign Pikaday to root if it exists, otherwise use window
1192
+ if (typeof root !== 'undefined' && root) {
1193
+ root.Pikaday = factory(moment);
1194
+ } else if (typeof window !== 'undefined') {
1195
+ window.Pikaday = factory(moment);
1196
+ }
1197
+ }
1198
+ }(typeof self !== 'undefined' ? self :
1199
+ typeof window !== 'undefined' ? window :
1200
+ typeof global !== 'undefined' ? global :
1201
+ undefined, function (moment) {
1202
+
1203
+ /**
1204
+ * feature detection and helper functions
1205
+ */
1206
+ var hasMoment = typeof moment === 'function' || (moment && typeof moment.version === 'string'),
1207
+
1208
+ hasEventListeners = !!window.addEventListener,
1209
+
1210
+ document = window.document,
1211
+
1212
+ sto = window.setTimeout,
1213
+
1214
+ addEvent = function (el, e, callback, capture) {
1215
+ if (hasEventListeners) {
1216
+ el.addEventListener(e, callback, !!capture);
1217
+ } else {
1218
+ el.attachEvent('on' + e, callback);
1219
+ }
1220
+ },
1221
+
1222
+ removeEvent = function (el, e, callback, capture) {
1223
+ if (hasEventListeners) {
1224
+ el.removeEventListener(e, callback, !!capture);
1225
+ } else {
1226
+ el.detachEvent('on' + e, callback);
1227
+ }
1228
+ },
1229
+
1230
+ trim = function (str) {
1231
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
1232
+ },
1233
+
1234
+ hasClass = function (el, cn) {
1235
+ return (' ' + el.className + ' ').indexOf(' ' + cn + ' ') !== -1;
1236
+ },
1237
+
1238
+ addClass = function (el, cn) {
1239
+ if (!hasClass(el, cn)) {
1240
+ el.className = (el.className === '') ? cn : el.className + ' ' + cn;
1241
+ }
1242
+ },
1243
+
1244
+ removeClass = function (el, cn) {
1245
+ el.className = trim((' ' + el.className + ' ').replace(' ' + cn + ' ', ' '));
1246
+ },
1247
+
1248
+ isArray = function (obj) {
1249
+ return (/Array/).test(Object.prototype.toString.call(obj));
1250
+ },
1251
+
1252
+ isDate = function (obj) {
1253
+ return (/Date/).test(Object.prototype.toString.call(obj)) && !isNaN(obj.getTime());
1254
+ },
1255
+
1256
+ isWeekend = function (date) {
1257
+ var day = date.getDay();
1258
+ return day === 0 || day === 6;
1259
+ },
1260
+
1261
+ isLeapYear = function (year) {
1262
+ // solution by Matti Virkkunen: http://stackoverflow.com/a/4881951
1263
+ return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
1264
+ },
1265
+
1266
+ getDaysInMonth = function (year, month) {
1267
+ return [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
1268
+ },
1269
+
1270
+ setToStartOfDay = function (date) {
1271
+ if (isDate(date)) date.setHours(0, 0, 0, 0);
1272
+ },
1273
+
1274
+ compareDates = function (a, b) {
1275
+ // weak date comparison (use setToStartOfDay(date) to ensure correct result)
1276
+ return a.getTime() === b.getTime();
1277
+ },
1278
+
1279
+ extend = function (to, from, overwrite) {
1280
+ var prop, hasProp;
1281
+ for (prop in from) {
1282
+ hasProp = to[prop] !== undefined;
1283
+ if (hasProp && typeof from[prop] === 'object' && from[prop] !== null && from[prop].nodeName === undefined) {
1284
+ if (isDate(from[prop])) {
1285
+ if (overwrite) {
1286
+ to[prop] = new Date(from[prop].getTime());
1287
+ }
1288
+ }
1289
+ else if (isArray(from[prop])) {
1290
+ if (overwrite) {
1291
+ to[prop] = from[prop].slice(0);
1292
+ }
1293
+ } else {
1294
+ to[prop] = extend({}, from[prop], overwrite);
1295
+ }
1296
+ } else if (overwrite || !hasProp) {
1297
+ to[prop] = from[prop];
1298
+ }
1299
+ }
1300
+ return to;
1301
+ },
1302
+
1303
+ fireEvent = function (el, eventName, data) {
1304
+ var ev;
1305
+
1306
+ if (document.createEvent) {
1307
+ ev = document.createEvent('HTMLEvents');
1308
+ ev.initEvent(eventName, true, false);
1309
+ ev = extend(ev, data);
1310
+ el.dispatchEvent(ev);
1311
+ } else if (document.createEventObject) {
1312
+ ev = document.createEventObject();
1313
+ ev = extend(ev, data);
1314
+ el.fireEvent('on' + eventName, ev);
1315
+ }
1316
+ },
1317
+
1318
+ adjustCalendar = function (calendar) {
1319
+ if (calendar.month < 0) {
1320
+ calendar.year -= Math.ceil(Math.abs(calendar.month) / 12);
1321
+ calendar.month += 12;
1322
+ }
1323
+ if (calendar.month > 11) {
1324
+ calendar.year += Math.floor(Math.abs(calendar.month) / 12);
1325
+ calendar.month -= 12;
1326
+ }
1327
+ return calendar;
1328
+ },
1329
+
1330
+ /**
1331
+ * defaults and localisation
1332
+ */
1333
+ defaults = {
1334
+
1335
+ // bind the picker to a form field
1336
+ field: null,
1337
+
1338
+ // automatically show/hide the picker on `field` focus (default `true` if `field` is set)
1339
+ bound: undefined,
1340
+
1341
+ // position of the datepicker, relative to the field (default to bottom & left)
1342
+ // ('bottom' & 'left' keywords are not used, 'top' & 'right' are modifier on the bottom/left position)
1343
+ position: 'bottom left',
1344
+
1345
+ // automatically fit in the viewport even if it means repositioning from the position option
1346
+ reposition: true,
1347
+
1348
+ // the default output format for `.toString()` and `field` value
1349
+ format: 'YYYY-MM-DD',
1350
+
1351
+ // the toString function which gets passed a current date object and format
1352
+ // and returns a string
1353
+ toString: null,
1354
+
1355
+ // used to create date object from current input string
1356
+ parse: null,
1357
+
1358
+ // the initial date to view when first opened
1359
+ defaultDate: null,
1360
+
1361
+ // make the `defaultDate` the initial selected value
1362
+ setDefaultDate: false,
1363
+
1364
+ // first day of week (0: Sunday, 1: Monday etc)
1365
+ firstDay: 0,
1366
+
1367
+ // the default flag for moment's strict date parsing
1368
+ formatStrict: false,
1369
+
1370
+ // the minimum/earliest date that can be selected
1371
+ minDate: null,
1372
+ // the maximum/latest date that can be selected
1373
+ maxDate: null,
1374
+
1375
+ // number of years either side, or array of upper/lower range
1376
+ yearRange: 10,
1377
+
1378
+ // show week numbers at head of row
1379
+ showWeekNumber: false,
1380
+
1381
+ // Week picker mode
1382
+ pickWholeWeek: false,
1383
+
1384
+ // used internally (don't config outside)
1385
+ minYear: 0,
1386
+ maxYear: 9999,
1387
+ minMonth: undefined,
1388
+ maxMonth: undefined,
1389
+
1390
+ startRange: null,
1391
+ endRange: null,
1392
+
1393
+ isRTL: false,
1394
+
1395
+ // Additional text to append to the year in the calendar title
1396
+ yearSuffix: '',
1397
+
1398
+ // Render the month after year in the calendar title
1399
+ showMonthAfterYear: false,
1400
+
1401
+ // Render days of the calendar grid that fall in the next or previous month
1402
+ showDaysInNextAndPreviousMonths: false,
1403
+
1404
+ // Allows user to select days that fall in the next or previous month
1405
+ enableSelectionDaysInNextAndPreviousMonths: false,
1406
+
1407
+ // how many months are visible
1408
+ numberOfMonths: 1,
1409
+
1410
+ // when numberOfMonths is used, this will help you to choose where the main calendar will be (default `left`, can be set to `right`)
1411
+ // only used for the first display or when a selected date is not visible
1412
+ mainCalendar: 'left',
1413
+
1414
+ // Specify a DOM element to render the calendar in
1415
+ container: undefined,
1416
+
1417
+ // Blur field when date is selected
1418
+ blurFieldOnSelect: true,
1419
+
1420
+ // internationalization
1421
+ i18n: {
1422
+ previousMonth: 'Previous Month',
1423
+ nextMonth: 'Next Month',
1424
+ months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
1425
+ weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
1426
+ weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
1427
+ },
1428
+
1429
+ // Theme Classname
1430
+ theme: null,
1431
+
1432
+ // events array
1433
+ events: [],
1434
+
1435
+ // callback function
1436
+ onSelect: null,
1437
+ onOpen: null,
1438
+ onClose: null,
1439
+ onDraw: null,
1440
+
1441
+ // Enable keyboard input
1442
+ keyboardInput: true
1443
+ },
1444
+
1445
+
1446
+ /**
1447
+ * templating functions to abstract HTML rendering
1448
+ */
1449
+ renderDayName = function (opts, day, abbr) {
1450
+ day += opts.firstDay;
1451
+ while (day >= 7) {
1452
+ day -= 7;
1453
+ }
1454
+ return abbr ? opts.i18n.weekdaysShort[day] : opts.i18n.weekdays[day];
1455
+ },
1456
+
1457
+ renderDay = function (opts) {
1458
+ var arr = [];
1459
+ var ariaSelected = 'false';
1460
+ if (opts.isEmpty) {
1461
+ if (opts.showDaysInNextAndPreviousMonths) {
1462
+ arr.push('is-outside-current-month');
1463
+
1464
+ if (!opts.enableSelectionDaysInNextAndPreviousMonths) {
1465
+ arr.push('is-selection-disabled');
1466
+ }
1467
+
1468
+ } else {
1469
+ return '<td class="is-empty"></td>';
1470
+ }
1471
+ }
1472
+ if (opts.isDisabled) {
1473
+ arr.push('is-disabled');
1474
+ }
1475
+ if (opts.isToday) {
1476
+ arr.push('is-today');
1477
+ }
1478
+ if (opts.isSelected) {
1479
+ arr.push('is-selected');
1480
+ ariaSelected = 'true';
1481
+ }
1482
+ if (opts.hasEvent) {
1483
+ arr.push('has-event');
1484
+ }
1485
+ if (opts.isInRange) {
1486
+ arr.push('is-inrange');
1487
+ }
1488
+ if (opts.isStartRange) {
1489
+ arr.push('is-startrange');
1490
+ }
1491
+ if (opts.isEndRange) {
1492
+ arr.push('is-endrange');
1493
+ }
1494
+ return '<td data-day="' + opts.day + '" class="' + arr.join(' ') + '" aria-selected="' + ariaSelected + '">' +
1495
+ '<button tabIndex="-1" class="pika-button pika-day" type="button" ' +
1496
+ 'data-pika-year="' + opts.year + '" data-pika-month="' + opts.month + '" data-pika-day="' + opts.day + '">' +
1497
+ opts.day +
1498
+ '</button>' +
1499
+ '</td>';
1500
+ },
1501
+
1502
+ renderWeek = function (d, m, y) {
1503
+ // Lifted from http://javascript.about.com/library/blweekyear.htm, lightly modified.
1504
+ var onejan = new Date(y, 0, 1),
1505
+ weekNum = Math.ceil((((new Date(y, m, d) - onejan) / 86400000) + onejan.getDay() + 1) / 7);
1506
+ return '<td class="pika-week">' + weekNum + '</td>';
1507
+ },
1508
+
1509
+ renderRow = function (days, isRTL, pickWholeWeek, isRowSelected) {
1510
+ return '<tr class="pika-row' + (pickWholeWeek ? ' pick-whole-week' : '') + (isRowSelected ? ' is-selected' : '') + '">' + (isRTL ? days.reverse() : days).join('') + '</tr>';
1511
+ },
1512
+
1513
+ renderBody = function (rows) {
1514
+ return '<tbody>' + rows.join('') + '</tbody>';
1515
+ },
1516
+
1517
+ renderHead = function (opts) {
1518
+ var i, arr = [];
1519
+ if (opts.showWeekNumber) {
1520
+ arr.push('<th></th>');
1521
+ }
1522
+ for (i = 0; i < 7; i++) {
1523
+ arr.push('<th scope="col"><abbr title="' + renderDayName(opts, i) + '">' + renderDayName(opts, i, true) + '</abbr></th>');
1524
+ }
1525
+ return '<thead><tr>' + (opts.isRTL ? arr.reverse() : arr).join('') + '</tr></thead>';
1526
+ },
1527
+
1528
+ renderTitle = function (instance, c, year, month, refYear, randId) {
1529
+ var i, j, arr,
1530
+ opts = instance._o,
1531
+ isMinYear = year === opts.minYear,
1532
+ isMaxYear = year === opts.maxYear,
1533
+ html = '<div id="' + randId + '" class="pika-title">',
1534
+ monthHtml,
1535
+ yearHtml,
1536
+ prev = true,
1537
+ next = true;
1538
+
1539
+ for (arr = [], i = 0; i < 12; i++) {
1540
+ arr.push('<option value="' + (year === refYear ? i - c : 12 + i - c) + '"' +
1541
+ (i === month ? ' selected="selected"' : '') +
1542
+ ((isMinYear && i < opts.minMonth) || (isMaxYear && i > opts.maxMonth) ? 'disabled="disabled"' : '') + '>' +
1543
+ opts.i18n.months[i] + '</option>');
1544
+ }
1545
+
1546
+ monthHtml = '<div class="pika-label">' + opts.i18n.months[month] + '<select aria-label="select month" class="pika-select pika-select-month" tabindex="-1">' + arr.join('') + '</select></div>';
1547
+
1548
+ if (isArray(opts.yearRange)) {
1549
+ i = opts.yearRange[0];
1550
+ j = opts.yearRange[1] + 1;
1551
+ } else {
1552
+ i = year - opts.yearRange;
1553
+ j = 1 + year + opts.yearRange;
1554
+ }
1555
+
1556
+ for (arr = []; i < j && i <= opts.maxYear; i++) {
1557
+ if (i >= opts.minYear) {
1558
+ arr.push('<option value="' + i + '"' + (i === year ? ' selected="selected"' : '') + '>' + (i) + '</option>');
1559
+ }
1560
+ }
1561
+ yearHtml = '<div class="pika-label">' + year + opts.yearSuffix + '<select aria-label="select year" class="pika-select pika-select-year" tabindex="-1">' + arr.join('') + '</select></div>';
1562
+
1563
+ if (opts.showMonthAfterYear) {
1564
+ html += yearHtml + monthHtml;
1565
+ } else {
1566
+ html += monthHtml + yearHtml;
1567
+ }
1568
+
1569
+ if (isMinYear && (month === 0 || opts.minMonth >= month)) {
1570
+ prev = false;
1571
+ }
1572
+
1573
+ if (isMaxYear && (month === 11 || opts.maxMonth <= month)) {
1574
+ next = false;
1575
+ }
1576
+
1577
+ if (c === 0) {
1578
+ html += '<button tabIndex="-1" class="pika-prev' + (prev ? '' : ' is-disabled') + '" type="button">' + opts.i18n.previousMonth + '</button>';
1579
+ }
1580
+ if (c === (instance._o.numberOfMonths - 1)) {
1581
+ html += '<button tabIndex="-1" class="pika-next' + (next ? '' : ' is-disabled') + '" type="button">' + opts.i18n.nextMonth + '</button>';
1582
+ }
1583
+
1584
+ return html += '</div>';
1585
+ },
1586
+
1587
+ renderTable = function (opts, data, randId) {
1588
+ return '<table cellpadding="0" cellspacing="0" class="pika-table" role="grid" aria-labelledby="' + randId + '">' + renderHead(opts) + renderBody(data) + '</table>';
1589
+ },
1590
+
1591
+
1592
+ /**
1593
+ * Pikaday constructor
1594
+ */
1595
+ Pikaday = function (options) {
1596
+ var self = this,
1597
+ opts = self.config(options);
1598
+
1599
+ self._onMouseDown = function (e) {
1600
+ if (!self._v) {
1601
+ return;
1602
+ }
1603
+ e = e || window.event;
1604
+ var target = e.target || e.srcElement;
1605
+ if (!target) {
1606
+ return;
1607
+ }
1608
+
1609
+ if (!hasClass(target, 'is-disabled')) {
1610
+ if (hasClass(target, 'pika-button') && !hasClass(target, 'is-empty') && !hasClass(target.parentNode, 'is-disabled')) {
1611
+ self.setDate(new Date(target.getAttribute('data-pika-year'), target.getAttribute('data-pika-month'), target.getAttribute('data-pika-day')));
1612
+ if (opts.bound) {
1613
+ sto(function () {
1614
+ self.hide();
1615
+ if (opts.blurFieldOnSelect && opts.field) {
1616
+ opts.field.blur();
1617
+ }
1618
+ }, 100);
1619
+ }
1620
+ }
1621
+ else if (hasClass(target, 'pika-prev')) {
1622
+ self.prevMonth();
1623
+ }
1624
+ else if (hasClass(target, 'pika-next')) {
1625
+ self.nextMonth();
1626
+ }
1627
+ }
1628
+ if (!hasClass(target, 'pika-select')) {
1629
+ // if this is touch event prevent mouse events emulation
1630
+ if (e.preventDefault) {
1631
+ e.preventDefault();
1632
+ } else {
1633
+ e.returnValue = false;
1634
+ return false;
1635
+ }
1636
+ } else {
1637
+ self._c = true;
1638
+ }
1639
+ };
1640
+
1641
+ self._onChange = function (e) {
1642
+ e = e || window.event;
1643
+ var target = e.target || e.srcElement;
1644
+ if (!target) {
1645
+ return;
1646
+ }
1647
+ if (hasClass(target, 'pika-select-month')) {
1648
+ self.gotoMonth(target.value);
1649
+ }
1650
+ else if (hasClass(target, 'pika-select-year')) {
1651
+ self.gotoYear(target.value);
1652
+ }
1653
+ };
1654
+
1655
+ self._onKeyChange = function (e) {
1656
+ e = e || window.event;
1657
+ // ignore if event comes from input box
1658
+ if (self.isVisible() && e.target && e.target.type !== 'text') {
1659
+
1660
+ switch (e.keyCode) {
1661
+ case 13:
1662
+ case 27:
1663
+ if (opts.field) {
1664
+ opts.field.blur();
1665
+ }
1666
+ break;
1667
+ case 37:
1668
+ e.preventDefault();
1669
+ self.adjustDate('subtract', 1);
1670
+ break;
1671
+ case 38:
1672
+ self.adjustDate('subtract', 7);
1673
+ break;
1674
+ case 39:
1675
+ self.adjustDate('add', 1);
1676
+ break;
1677
+ case 40:
1678
+ self.adjustDate('add', 7);
1679
+ break;
1680
+ }
1681
+ }
1682
+ };
1683
+
1684
+ self._onInputChange = function (e) {
1685
+ var date;
1686
+
1687
+ if (e.firedBy === self) {
1688
+ return;
1689
+ }
1690
+ if (opts.parse) {
1691
+ date = opts.parse(opts.field.value, opts.format);
1692
+ } else if (hasMoment) {
1693
+ date = moment(opts.field.value, opts.format, opts.formatStrict);
1694
+ date = (date && date.isValid()) ? date.toDate() : null;
1695
+ }
1696
+ else {
1697
+ date = new Date(Date.parse(opts.field.value));
1698
+ }
1699
+ // if (isDate(date)) {
1700
+ // self.setDate(date);
1701
+ // }
1702
+ // if (!self._v) {
1703
+ // self.show();
1704
+ // }
1705
+ };
1706
+
1707
+ self._onInputFocus = function () {
1708
+ self.show();
1709
+ };
1710
+
1711
+ self._onInputClick = function () {
1712
+ self.show();
1713
+ };
1714
+
1715
+ self._onInputBlur = function () {
1716
+ // IE allows pika div to gain focus; catch blur the input field
1717
+ var pEl = document.activeElement;
1718
+ do {
1719
+ if (hasClass(pEl, 'pika-single')) {
1720
+ return;
1721
+ }
1722
+ }
1723
+ while ((pEl = pEl.parentNode));
1724
+
1725
+ if (!self._c) {
1726
+ self._b = sto(function () {
1727
+ self.hide();
1728
+ }, 50);
1729
+ }
1730
+ self._c = false;
1731
+ };
1732
+
1733
+ self._onClick = function (e) {
1734
+ e = e || window.event;
1735
+ var target = e.target || e.srcElement,
1736
+ pEl = target;
1737
+ if (!target) {
1738
+ return;
1739
+ }
1740
+ if (!hasEventListeners && hasClass(target, 'pika-select')) {
1741
+ if (!target.onchange) {
1742
+ target.setAttribute('onchange', 'return;');
1743
+ addEvent(target, 'change', self._onChange);
1744
+ }
1745
+ }
1746
+ do {
1747
+ if (hasClass(pEl, 'pika-single') || pEl === opts.trigger) {
1748
+ return;
1749
+ }
1750
+ }
1751
+ while ((pEl = pEl.parentNode));
1752
+ if (self._v && target !== opts.trigger && pEl !== opts.trigger) {
1753
+ self.hide();
1754
+ }
1755
+ };
1756
+
1757
+ self.el = document.createElement('div');
1758
+ self.el.className = 'pika-single' + (opts.isRTL ? ' is-rtl' : '') + (opts.theme ? ' ' + opts.theme : '');
1759
+
1760
+ addEvent(self.el, 'mousedown', self._onMouseDown, true);
1761
+ addEvent(self.el, 'touchend', self._onMouseDown, true);
1762
+ addEvent(self.el, 'change', self._onChange);
1763
+
1764
+ if (opts.keyboardInput) {
1765
+ addEvent(document, 'keydown', self._onKeyChange);
1766
+ }
1767
+
1768
+ if (opts.field) {
1769
+ if (opts.container) {
1770
+ opts.container.appendChild(self.el);
1771
+ } else if (opts.bound) {
1772
+ document.body.appendChild(self.el);
1773
+ } else {
1774
+ opts.field.parentNode.insertBefore(self.el, opts.field.nextSibling);
1775
+ }
1776
+ addEvent(opts.field, 'change', self._onInputChange);
1777
+
1778
+ if (!opts.defaultDate) {
1779
+ if (hasMoment && opts.field.value) {
1780
+ opts.defaultDate = moment(opts.field.value, opts.format).toDate();
1781
+ } else {
1782
+ opts.defaultDate = new Date(Date.parse(opts.field.value));
1783
+ }
1784
+ opts.setDefaultDate = true;
1785
+ }
1786
+ }
1787
+
1788
+ var defDate = opts.defaultDate;
1789
+
1790
+ if (isDate(defDate)) {
1791
+ if (opts.setDefaultDate) {
1792
+ self.setDate(defDate, true);
1793
+ } else {
1794
+ self.gotoDate(defDate);
1795
+ }
1796
+ } else {
1797
+ self.gotoDate(new Date());
1798
+ }
1799
+
1800
+ if (opts.bound) {
1801
+ this.hide();
1802
+ self.el.className += ' is-bound';
1803
+ addEvent(opts.trigger, 'click', self._onInputClick);
1804
+ addEvent(opts.trigger, 'focus', self._onInputFocus);
1805
+ addEvent(opts.trigger, 'blur', self._onInputBlur);
1806
+ } else {
1807
+ this.show();
1808
+ }
1809
+ };
1810
+
1811
+
1812
+ /**
1813
+ * public Pikaday API
1814
+ */
1815
+ Pikaday.prototype = {
1816
+
1817
+
1818
+ /**
1819
+ * configure functionality
1820
+ */
1821
+ config: function (options) {
1822
+ if (!this._o) {
1823
+ this._o = extend({}, defaults, true);
1824
+ }
1825
+
1826
+ var opts = extend(this._o, options, true);
1827
+
1828
+ opts.isRTL = !!opts.isRTL;
1829
+
1830
+ opts.field = (opts.field && opts.field.nodeName) ? opts.field : null;
1831
+
1832
+ opts.theme = (typeof opts.theme) === 'string' && opts.theme ? opts.theme : null;
1833
+
1834
+ opts.bound = !!(opts.bound !== undefined ? opts.field && opts.bound : opts.field);
1835
+
1836
+ opts.trigger = (opts.trigger && opts.trigger.nodeName) ? opts.trigger : opts.field;
1837
+
1838
+ opts.disableWeekends = !!opts.disableWeekends;
1839
+
1840
+ opts.disableDayFn = (typeof opts.disableDayFn) === 'function' ? opts.disableDayFn : null;
1841
+
1842
+ var nom = parseInt(opts.numberOfMonths, 10) || 1;
1843
+ opts.numberOfMonths = nom > 4 ? 4 : nom;
1844
+
1845
+ if (!isDate(opts.minDate)) {
1846
+ opts.minDate = false;
1847
+ }
1848
+ if (!isDate(opts.maxDate)) {
1849
+ opts.maxDate = false;
1850
+ }
1851
+ if ((opts.minDate && opts.maxDate) && opts.maxDate < opts.minDate) {
1852
+ opts.maxDate = opts.minDate = false;
1853
+ }
1854
+ if (opts.minDate) {
1855
+ this.setMinDate(opts.minDate);
1856
+ }
1857
+ if (opts.maxDate) {
1858
+ this.setMaxDate(opts.maxDate);
1859
+ }
1860
+
1861
+ if (isArray(opts.yearRange)) {
1862
+ var fallback = new Date().getFullYear() - 10;
1863
+ opts.yearRange[0] = parseInt(opts.yearRange[0], 10) || fallback;
1864
+ opts.yearRange[1] = parseInt(opts.yearRange[1], 10) || fallback;
1865
+ } else {
1866
+ opts.yearRange = Math.abs(parseInt(opts.yearRange, 10)) || defaults.yearRange;
1867
+ if (opts.yearRange > 100) {
1868
+ opts.yearRange = 100;
1869
+ }
1870
+ }
1871
+
1872
+ return opts;
1873
+ },
1874
+
1875
+ /**
1876
+ * return a formatted string of the current selection (using Moment.js if available)
1877
+ */
1878
+ toString: function (format) {
1879
+ format = format || this._o.format;
1880
+ if (!isDate(this._d)) {
1881
+ return '';
1882
+ }
1883
+ if (this._o.toString) {
1884
+ return this._o.toString(this._d, format);
1885
+ }
1886
+ if (hasMoment) {
1887
+ return moment(this._d).format(format);
1888
+ }
1889
+ return this._d.toDateString();
1890
+ },
1891
+
1892
+ /**
1893
+ * return a Moment.js object of the current selection (if available)
1894
+ */
1895
+ getMoment: function () {
1896
+ return hasMoment ? moment(this._d) : null;
1897
+ },
1898
+
1899
+ /**
1900
+ * set the current selection from a Moment.js object (if available)
1901
+ */
1902
+ setMoment: function (date, preventOnSelect) {
1903
+ if (hasMoment && moment.isMoment(date)) {
1904
+ this.setDate(date.toDate(), preventOnSelect);
1905
+ }
1906
+ },
1907
+
1908
+ /**
1909
+ * return a Date object of the current selection
1910
+ */
1911
+ getDate: function () {
1912
+ return isDate(this._d) ? new Date(this._d.getTime()) : null;
1913
+ },
1914
+
1915
+ /**
1916
+ * set the current selection
1917
+ */
1918
+ setDate: function (date, preventOnSelect) {
1919
+ if (!date) {
1920
+ this._d = null;
1921
+
1922
+ if (this._o.field) {
1923
+ this._o.field.value = '';
1924
+ fireEvent(this._o.field, 'change', { firedBy: this });
1925
+ }
1926
+
1927
+ return this.draw();
1928
+ }
1929
+ if (typeof date === 'string') {
1930
+ date = new Date(Date.parse(date));
1931
+ }
1932
+ if (!isDate(date)) {
1933
+ return;
1934
+ }
1935
+
1936
+ var min = this._o.minDate,
1937
+ max = this._o.maxDate;
1938
+
1939
+ if (isDate(min) && date < min) {
1940
+ date = min;
1941
+ } else if (isDate(max) && date > max) {
1942
+ date = max;
1943
+ }
1944
+
1945
+ this._d = new Date(date.getTime());
1946
+ setToStartOfDay(this._d);
1947
+ this.gotoDate(this._d);
1948
+
1949
+ if (this._o.field) {
1950
+ this._o.field.value = this.toString();
1951
+ fireEvent(this._o.field, 'change', { firedBy: this });
1952
+ }
1953
+ if (!preventOnSelect && typeof this._o.onSelect === 'function') {
1954
+ this._o.onSelect.call(this, this.getDate());
1955
+ }
1956
+ },
1957
+
1958
+ /**
1959
+ * change view to a specific date
1960
+ */
1961
+ gotoDate: function (date) {
1962
+ var newCalendar = true;
1963
+
1964
+ if (!isDate(date)) {
1965
+ return;
1966
+ }
1967
+
1968
+ if (this.calendars) {
1969
+ var firstVisibleDate = new Date(this.calendars[0].year, this.calendars[0].month, 1),
1970
+ lastVisibleDate = new Date(this.calendars[this.calendars.length - 1].year, this.calendars[this.calendars.length - 1].month, 1),
1971
+ visibleDate = date.getTime();
1972
+ // get the end of the month
1973
+ lastVisibleDate.setMonth(lastVisibleDate.getMonth() + 1);
1974
+ lastVisibleDate.setDate(lastVisibleDate.getDate() - 1);
1975
+ newCalendar = (visibleDate < firstVisibleDate.getTime() || lastVisibleDate.getTime() < visibleDate);
1976
+ }
1977
+
1978
+ if (newCalendar) {
1979
+ this.calendars = [{
1980
+ month: date.getMonth(),
1981
+ year: date.getFullYear()
1982
+ }];
1983
+ if (this._o.mainCalendar === 'right') {
1984
+ this.calendars[0].month += 1 - this._o.numberOfMonths;
1985
+ }
1986
+ }
1987
+
1988
+ this.adjustCalendars();
1989
+ },
1990
+
1991
+ adjustDate: function (sign, days) {
1992
+
1993
+ var day = this.getDate() || new Date();
1994
+ var difference = parseInt(days) * 24 * 60 * 60 * 1000;
1995
+
1996
+ var newDay;
1997
+
1998
+ if (sign === 'add') {
1999
+ newDay = new Date(day.valueOf() + difference);
2000
+ } else if (sign === 'subtract') {
2001
+ newDay = new Date(day.valueOf() - difference);
2002
+ }
2003
+
2004
+ this.setDate(newDay);
2005
+ },
2006
+
2007
+ adjustCalendars: function () {
2008
+ this.calendars[0] = adjustCalendar(this.calendars[0]);
2009
+ for (var c = 1; c < this._o.numberOfMonths; c++) {
2010
+ this.calendars[c] = adjustCalendar({
2011
+ month: this.calendars[0].month + c,
2012
+ year: this.calendars[0].year
2013
+ });
2014
+ }
2015
+ this.draw();
2016
+ },
2017
+
2018
+ gotoToday: function () {
2019
+ this.gotoDate(new Date());
2020
+ },
2021
+
2022
+ /**
2023
+ * change view to a specific month (zero-index, e.g. 0: January)
2024
+ */
2025
+ gotoMonth: function (month) {
2026
+ if (!isNaN(month)) {
2027
+ this.calendars[0].month = parseInt(month, 10);
2028
+ this.adjustCalendars();
2029
+ }
2030
+ },
2031
+
2032
+ nextMonth: function () {
2033
+ this.calendars[0].month++;
2034
+ this.adjustCalendars();
2035
+ },
2036
+
2037
+ prevMonth: function () {
2038
+ this.calendars[0].month--;
2039
+ this.adjustCalendars();
2040
+ },
2041
+
2042
+ /**
2043
+ * change view to a specific full year (e.g. "2012")
2044
+ */
2045
+ gotoYear: function (year) {
2046
+ if (!isNaN(year)) {
2047
+ this.calendars[0].year = parseInt(year, 10);
2048
+ this.adjustCalendars();
2049
+ }
2050
+ },
2051
+
2052
+ /**
2053
+ * change the minDate
2054
+ */
2055
+ setMinDate: function (value) {
2056
+ if (value instanceof Date) {
2057
+ setToStartOfDay(value);
2058
+ this._o.minDate = value;
2059
+ this._o.minYear = value.getFullYear();
2060
+ this._o.minMonth = value.getMonth();
2061
+ } else {
2062
+ this._o.minDate = defaults.minDate;
2063
+ this._o.minYear = defaults.minYear;
2064
+ this._o.minMonth = defaults.minMonth;
2065
+ this._o.startRange = defaults.startRange;
2066
+ }
2067
+
2068
+ this.draw();
2069
+ },
2070
+
2071
+ /**
2072
+ * change the maxDate
2073
+ */
2074
+ setMaxDate: function (value) {
2075
+ if (value instanceof Date) {
2076
+ setToStartOfDay(value);
2077
+ this._o.maxDate = value;
2078
+ this._o.maxYear = value.getFullYear();
2079
+ this._o.maxMonth = value.getMonth();
2080
+ } else {
2081
+ this._o.maxDate = defaults.maxDate;
2082
+ this._o.maxYear = defaults.maxYear;
2083
+ this._o.maxMonth = defaults.maxMonth;
2084
+ this._o.endRange = defaults.endRange;
2085
+ }
2086
+
2087
+ this.draw();
2088
+ },
2089
+
2090
+ setStartRange: function (value) {
2091
+ this._o.startRange = value;
2092
+ },
2093
+
2094
+ setEndRange: function (value) {
2095
+ this._o.endRange = value;
2096
+ },
2097
+
2098
+ /**
2099
+ * refresh the HTML
2100
+ */
2101
+ draw: function (force) {
2102
+ if (!this._v && !force) {
2103
+ return;
2104
+ }
2105
+ var opts = this._o,
2106
+ minYear = opts.minYear,
2107
+ maxYear = opts.maxYear,
2108
+ minMonth = opts.minMonth,
2109
+ maxMonth = opts.maxMonth,
2110
+ html = '',
2111
+ randId;
2112
+
2113
+ if (this._y <= minYear) {
2114
+ this._y = minYear;
2115
+ if (!isNaN(minMonth) && this._m < minMonth) {
2116
+ this._m = minMonth;
2117
+ }
2118
+ }
2119
+ if (this._y >= maxYear) {
2120
+ this._y = maxYear;
2121
+ if (!isNaN(maxMonth) && this._m > maxMonth) {
2122
+ this._m = maxMonth;
2123
+ }
2124
+ }
2125
+
2126
+ for (var c = 0; c < opts.numberOfMonths; c++) {
2127
+ randId = 'pika-title-' + Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 2);
2128
+ html += '<div class="pika-lendar">' + renderTitle(this, c, this.calendars[c].year, this.calendars[c].month, this.calendars[0].year, randId) + this.render(this.calendars[c].year, this.calendars[c].month, randId) + '</div>';
2129
+ }
2130
+
2131
+ this.el.innerHTML = html;
2132
+
2133
+ if (opts.bound) {
2134
+ if (opts.field.type !== 'hidden') {
2135
+ sto(function () {
2136
+ opts.trigger.focus();
2137
+ }, 1);
2138
+ }
2139
+ }
2140
+
2141
+ if (typeof this._o.onDraw === 'function') {
2142
+ this._o.onDraw(this);
2143
+ }
2144
+
2145
+ if (opts.bound) {
2146
+ // let the screen reader user know to use arrow keys
2147
+ opts.field.setAttribute('aria-label', 'Use the arrow keys to pick a date');
2148
+ }
2149
+ },
2150
+
2151
+ adjustPosition: function () {
2152
+ var field, pEl, width, height, viewportWidth, viewportHeight, scrollTop, left, top, clientRect;
2153
+
2154
+ if (this._o.container) return;
2155
+
2156
+ this.el.style.position = 'absolute';
2157
+
2158
+ field = this._o.trigger;
2159
+ pEl = field;
2160
+ width = this.el.offsetWidth;
2161
+ height = this.el.offsetHeight;
2162
+ viewportWidth = window.innerWidth || document.documentElement.clientWidth;
2163
+ viewportHeight = window.innerHeight || document.documentElement.clientHeight;
2164
+ scrollTop = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
2165
+
2166
+ if (typeof field.getBoundingClientRect === 'function') {
2167
+ clientRect = field.getBoundingClientRect();
2168
+ left = clientRect.left + window.pageXOffset;
2169
+ top = clientRect.bottom + window.pageYOffset;
2170
+ } else {
2171
+ left = pEl.offsetLeft;
2172
+ top = pEl.offsetTop + pEl.offsetHeight;
2173
+ while ((pEl = pEl.offsetParent)) {
2174
+ left += pEl.offsetLeft;
2175
+ top += pEl.offsetTop;
2176
+ }
2177
+ }
2178
+
2179
+ // default position is bottom & left
2180
+ if ((this._o.reposition && left + width > viewportWidth) ||
2181
+ (
2182
+ this._o.position.indexOf('right') > -1 &&
2183
+ left - width + field.offsetWidth > 0
2184
+ )
2185
+ ) {
2186
+ left = left - width + field.offsetWidth;
2187
+ }
2188
+ if ((this._o.reposition && top + height > viewportHeight + scrollTop) ||
2189
+ (
2190
+ this._o.position.indexOf('top') > -1 &&
2191
+ top - height - field.offsetHeight > 0
2192
+ )
2193
+ ) {
2194
+ top = top - height - field.offsetHeight;
2195
+ }
2196
+
2197
+ this.el.style.left = left + 'px';
2198
+ this.el.style.top = top + 'px';
2199
+ },
2200
+
2201
+ /**
2202
+ * render HTML for a particular month
2203
+ */
2204
+ render: function (year, month, randId) {
2205
+ var opts = this._o,
2206
+ now = new Date(),
2207
+ days = getDaysInMonth(year, month),
2208
+ before = new Date(year, month, 1).getDay(),
2209
+ data = [],
2210
+ row = [];
2211
+ setToStartOfDay(now);
2212
+ if (opts.firstDay > 0) {
2213
+ before -= opts.firstDay;
2214
+ if (before < 0) {
2215
+ before += 7;
2216
+ }
2217
+ }
2218
+ var previousMonth = month === 0 ? 11 : month - 1,
2219
+ nextMonth = month === 11 ? 0 : month + 1,
2220
+ yearOfPreviousMonth = month === 0 ? year - 1 : year,
2221
+ yearOfNextMonth = month === 11 ? year + 1 : year,
2222
+ daysInPreviousMonth = getDaysInMonth(yearOfPreviousMonth, previousMonth);
2223
+ var cells = days + before,
2224
+ after = cells;
2225
+ while (after > 7) {
2226
+ after -= 7;
2227
+ }
2228
+ cells += 7 - after;
2229
+ var isWeekSelected = false;
2230
+ for (var i = 0, r = 0; i < cells; i++) {
2231
+ var day = new Date(year, month, 1 + (i - before)),
2232
+ isSelected = isDate(this._d) ? compareDates(day, this._d) : false,
2233
+ isToday = compareDates(day, now),
2234
+ hasEvent = opts.events.indexOf(day.toDateString()) !== -1 ? true : false,
2235
+ isEmpty = i < before || i >= (days + before),
2236
+ dayNumber = 1 + (i - before),
2237
+ monthNumber = month,
2238
+ yearNumber = year,
2239
+ isStartRange = opts.startRange && compareDates(opts.startRange, day),
2240
+ isEndRange = opts.endRange && compareDates(opts.endRange, day),
2241
+ isInRange = opts.startRange && opts.endRange && opts.startRange < day && day < opts.endRange,
2242
+ isDisabled = (opts.minDate && day < opts.minDate) ||
2243
+ (opts.maxDate && day > opts.maxDate) ||
2244
+ (opts.disableWeekends && isWeekend(day)) ||
2245
+ (opts.disableDayFn && opts.disableDayFn(day));
2246
+
2247
+ if (isEmpty) {
2248
+ if (i < before) {
2249
+ dayNumber = daysInPreviousMonth + dayNumber;
2250
+ monthNumber = previousMonth;
2251
+ yearNumber = yearOfPreviousMonth;
2252
+ } else {
2253
+ dayNumber = dayNumber - days;
2254
+ monthNumber = nextMonth;
2255
+ yearNumber = yearOfNextMonth;
2256
+ }
2257
+ }
2258
+
2259
+ var dayConfig = {
2260
+ day: dayNumber,
2261
+ month: monthNumber,
2262
+ year: yearNumber,
2263
+ hasEvent: hasEvent,
2264
+ isSelected: isSelected,
2265
+ isToday: isToday,
2266
+ isDisabled: isDisabled,
2267
+ isEmpty: isEmpty,
2268
+ isStartRange: isStartRange,
2269
+ isEndRange: isEndRange,
2270
+ isInRange: isInRange,
2271
+ showDaysInNextAndPreviousMonths: opts.showDaysInNextAndPreviousMonths,
2272
+ enableSelectionDaysInNextAndPreviousMonths: opts.enableSelectionDaysInNextAndPreviousMonths
2273
+ };
2274
+
2275
+ if (opts.pickWholeWeek && isSelected) {
2276
+ isWeekSelected = true;
2277
+ }
2278
+
2279
+ row.push(renderDay(dayConfig));
2280
+
2281
+ if (++r === 7) {
2282
+ if (opts.showWeekNumber) {
2283
+ row.unshift(renderWeek(i - before, month, year));
2284
+ }
2285
+ data.push(renderRow(row, opts.isRTL, opts.pickWholeWeek, isWeekSelected));
2286
+ row = [];
2287
+ r = 0;
2288
+ isWeekSelected = false;
2289
+ }
2290
+ }
2291
+ return renderTable(opts, data, randId);
2292
+ },
2293
+
2294
+ isVisible: function () {
2295
+ return this._v;
2296
+ },
2297
+
2298
+ show: function () {
2299
+ if (!this.isVisible()) {
2300
+ this._v = true;
2301
+ this.draw();
2302
+ removeClass(this.el, 'is-hidden');
2303
+ if (this._o.bound) {
2304
+ addEvent(document, 'click', this._onClick);
2305
+ this.adjustPosition();
2306
+ }
2307
+ if (typeof this._o.onOpen === 'function') {
2308
+ this._o.onOpen.call(this);
2309
+ }
2310
+ }
2311
+ },
2312
+
2313
+ hide: function () {
2314
+ var v = this._v;
2315
+ if (v !== false) {
2316
+ if (this._o.bound) {
2317
+ removeEvent(document, 'click', this._onClick);
2318
+ }
2319
+ this.el.style.position = 'static'; // reset
2320
+ this.el.style.left = 'auto';
2321
+ this.el.style.top = 'auto';
2322
+ addClass(this.el, 'is-hidden');
2323
+ this._v = false;
2324
+ if (v !== undefined && typeof this._o.onClose === 'function') {
2325
+ this._o.onClose.call(this);
2326
+ }
2327
+ }
2328
+ },
2329
+
2330
+ /**
2331
+ * GAME OVER
2332
+ */
2333
+ destroy: function () {
2334
+ var opts = this._o;
2335
+
2336
+ this.hide();
2337
+ removeEvent(this.el, 'mousedown', this._onMouseDown, true);
2338
+ removeEvent(this.el, 'touchend', this._onMouseDown, true);
2339
+ removeEvent(this.el, 'change', this._onChange);
2340
+ if (opts.keyboardInput) {
2341
+ removeEvent(document, 'keydown', this._onKeyChange);
2342
+ }
2343
+ if (opts.field) {
2344
+ removeEvent(opts.field, 'change', this._onInputChange);
2345
+ if (opts.bound) {
2346
+ removeEvent(opts.trigger, 'click', this._onInputClick);
2347
+ removeEvent(opts.trigger, 'focus', this._onInputFocus);
2348
+ removeEvent(opts.trigger, 'blur', this._onInputBlur);
2349
+ }
2350
+ }
2351
+ if (this.el.parentNode) {
2352
+ this.el.parentNode.removeChild(this.el);
2353
+ }
2354
+ }
2355
+
2356
+ };
2357
+
2358
+ return Pikaday;
2359
+ }));
2360
+
1132
2361
  declare class SingleDateTimePicker extends ChartComponent {
1133
2362
  private calendar;
1134
2363
  private calendarPicker;
@@ -1177,12 +2406,16 @@ declare class DateTimeButton extends ChartComponent {
1177
2406
  constructor(renderTarget: Element);
1178
2407
  protected buttonDateTimeFormat(millis: any): string;
1179
2408
  render(chartOptions: any, minMillis: any, maxMillis: any, onSet?: any): void;
2409
+ private getTimezoneFromOffset;
1180
2410
  }
1181
2411
 
1182
2412
  declare class DateTimeButtonSingle extends DateTimeButton {
1183
2413
  private selectedMillis;
2414
+ private clickOutsideHandler;
1184
2415
  constructor(renderTarget: Element);
1185
2416
  private closeSDTP;
2417
+ private removeClickOutsideHandler;
2418
+ private setupClickOutsideHandler;
1186
2419
  private sDTPOnSet;
1187
2420
  render(chartOptions: any, minMillis: number, maxMillis: number, selectedMillis?: number, onSet?: any): void;
1188
2421
  }
@@ -1191,9 +2424,12 @@ declare class DateTimeButtonRange extends DateTimeButton {
1191
2424
  private onCancel;
1192
2425
  private fromMillis;
1193
2426
  private toMillis;
2427
+ private clickOutsideHandler;
1194
2428
  constructor(renderTarget: Element);
1195
2429
  private setButtonText;
1196
2430
  private onClose;
2431
+ private removeClickOutsideHandler;
2432
+ private setupClickOutsideHandler;
1197
2433
  render(chartOptions: any, minMillis: number, maxMillis: number, fromMillis?: number, toMillis?: number, onSet?: any, onCancel?: any): void;
1198
2434
  }
1199
2435
 
@@ -1201,7 +2437,15 @@ interface IPlaybackSettings {
1201
2437
  intervalMillis: number;
1202
2438
  stepSizeMillis: number;
1203
2439
  }
2440
+ interface IPlaybackOptions {
2441
+ theme?: string;
2442
+ offset?: string;
2443
+ is24HourTime?: boolean;
2444
+ dateLocale?: string;
2445
+ xAxisHidden?: boolean;
2446
+ }
1204
2447
  declare class PlaybackControls extends Component {
2448
+ private static readonly CONSTANTS;
1205
2449
  private playbackInterval;
1206
2450
  private playButton;
1207
2451
  private handleElement;
@@ -1217,14 +2461,19 @@ declare class PlaybackControls extends Component {
1217
2461
  private playbackSettings;
1218
2462
  private end;
1219
2463
  private wasPlayingWhenDragStarted;
2464
+ private rafId;
1220
2465
  readonly handleRadius: number;
1221
2466
  readonly minimumPlaybackInterval: number;
1222
2467
  constructor(renderTarget: Element, initialTimeStamp?: Date);
1223
2468
  get currentTimeStamp(): Date;
1224
- render(start: Date, end: Date, onSelectTimeStamp: (d: Date) => {}, options: any, playbackSettings: IPlaybackSettings): void;
2469
+ render(start: Date, end: Date, onSelectTimeStamp: (timestamp: Date) => void, options: IPlaybackOptions, playbackSettings: IPlaybackSettings): void;
1225
2470
  play(): void;
1226
2471
  pause(): void;
1227
2472
  next(): void;
2473
+ /**
2474
+ * Cleanup resources to prevent memory leaks
2475
+ */
2476
+ destroy(): void;
1228
2477
  private clamp;
1229
2478
  private onDrag;
1230
2479
  private onDragEnd;