Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
// timeZoneOffset is in minutes
function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
if (stripZeroTime === void 0) { stripZeroTime = false; }
var s = marker.toISOString();
s = s.replace('.000', '');
if (stripZeroTime) {
s = s.replace('T00:00:00Z', '');
}
if (s.length > 10) { // time part wasn't stripped, can add timezone info
if (timeZoneOffset == null) {
s = s.replace('Z', '');
}
else if (timeZoneOffset !== 0) {
s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
}
// otherwise, its UTC-0 and we want to keep the Z
}
return s;
}
// formats the date, but with no time part
// TODO: somehow merge with buildIsoString and stripZeroTime
// TODO: rename. omit "string"
function formatDayString(marker) {
return marker.toISOString().replace(/T.*$/, '');
}
// TODO: use Date::toISOString and use everything after the T?
function formatIsoTimeString(marker) {
return padStart(marker.getUTCHours(), 2) + ':' +
padStart(marker.getUTCMinutes(), 2) + ':' +
padStart(marker.getUTCSeconds(), 2);
}
function formatTimeZoneOffset(minutes, doIso) {
if (doIso === void 0) { doIso = false; }
var sign = minutes < 0 ? '-' : '+';
var abs = Math.abs(minutes);
var hours = Math.floor(abs / 60);
var mins = Math.round(abs % 60);
if (doIso) {
return sign + padStart(hours, 2) + ":" + padStart(mins, 2);
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
return "GMT" + sign + hours + (mins ? ":" + padStart(mins, 2) : '');
}
// TODO: new util arrayify?
function removeExact(array, exactVal) {
var removeCnt = 0;
var i = 0;
while (i < array.length) {
if (array[i] === exactVal) {
array.splice(i, 1);
removeCnt += 1;
}
else {
i += 1;
}
}
return removeCnt;
}
function isArraysEqual(a0, a1, equalityFunc) {
if (a0 === a1) {
return true;
}
var len = a0.length;
var i;
if (len !== a1.length) { // not array? or not same length?
return false;
}
for (i = 0; i < len; i += 1) {
if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
return false;
}
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
}
function memoize(workerFunc, resEquality, teardownFunc) {
var currentArgs;
var currentRes;
return function () {
var newArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
newArgs[_i] = arguments[_i];
}
if (!currentArgs) {
currentRes = workerFunc.apply(this, newArgs);
}
else if (!isArraysEqual(currentArgs, newArgs)) {
if (teardownFunc) {
teardownFunc(currentRes);
}
var res = workerFunc.apply(this, newArgs);
if (!resEquality || !resEquality(res, currentRes)) {
currentRes = res;
}
}
currentArgs = newArgs;
return currentRes;
};
}
function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
var currentArg;
var currentRes;
return function (newArg) {
if (!currentArg) {
currentRes = workerFunc.call(_this, newArg);
}
else if (!isPropsEqual(currentArg, newArg)) {
if (teardownFunc) {
teardownFunc(currentRes);
}
var res = workerFunc.call(_this, newArg);
if (!resEquality || !resEquality(res, currentRes)) {
currentRes = res;
}
}
currentArg = newArg;
return currentRes;
};
}
function memoizeArraylike(// used at all?
workerFunc, resEquality, teardownFunc) {
var currentArgSets = [];
var currentResults = [];
return function (newArgSets) {
var currentLen = currentArgSets.length;
var newLen = newArgSets.length;
var i = 0;
if (!newArgSets[i]) { // one of the old sets no longer exists
if (teardownFunc) {
teardownFunc(currentResults[i]);
}
}
else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
if (teardownFunc) {
teardownFunc(currentResults[i]);
}
var res = workerFunc.apply(_this, newArgSets[i]);
if (!resEquality || !resEquality(res, currentResults[i])) {
currentResults[i] = res;
}
}
}
for (; i < newLen; i += 1) {
currentResults[i] = workerFunc.apply(_this, newArgSets[i]);
}
currentArgSets = newArgSets;
currentResults.splice(newLen); // remove excess
return currentResults;
};
}
function memoizeHashlike(// used?
workerFunc, resEquality, teardownFunc) {
var _this = this;
var currentArgHash = {};
var currentResHash = {};
return function (newArgHash) {
var newResHash = {};
for (var key in newArgHash) {
if (!currentResHash[key]) {
newResHash[key] = workerFunc.apply(_this, newArgHash[key]);
}
else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
if (teardownFunc) {
teardownFunc(currentResHash[key]);
}
var res = workerFunc.apply(_this, newArgHash[key]);
newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
? currentResHash[key]
: res;
}
else {
newResHash[key] = currentResHash[key];
}
}
currentArgHash = newArgHash;
currentResHash = newResHash;
return newResHash;
};
}
var EXTENDED_SETTINGS_AND_SEVERITIES = {
week: 3,
separator: 0,
omitZeroMinute: 0,
meridiem: 0,
};
var STANDARD_DATE_PROP_SEVERITIES = {
timeZoneName: 7,
era: 6,
year: 5,
month: 4,
day: 2,
weekday: 2,
hour: 1,
minute: 1,
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
};
var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
var COMMA_RE = /,/g; // we need re for globalness
var MULTI_SPACE_RE = /\s+/g;
var LTR_RE = /\u200e/g; // control character
var UTC_RE = /UTC|GMT/;
var NativeFormatter = /** @class */ (function () {
function NativeFormatter(formatSettings) {
var standardDateProps = {};
var extendedSettings = {};
var severity = 0;
for (var name_1 in formatSettings) {
if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
extendedSettings[name_1] = formatSettings[name_1];
severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
}
else {
standardDateProps[name_1] = formatSettings[name_1];
if (name_1 in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
}
}
}
this.standardDateProps = standardDateProps;
this.extendedSettings = extendedSettings;
this.severity = severity;
this.buildFormattingFunc = memoize(buildFormattingFunc);
}
NativeFormatter.prototype.format = function (date, context) {
return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
};
NativeFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
if (!diffSeverity) {
return this.format(start, context);
}
var biggestUnitForPartial = diffSeverity;
if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
(standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
(standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
(standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
}
var full0 = this.format(start, context);
var full1 = this.format(end, context);
if (full0 === full1) {
return full0;
}
var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
var partial0 = partialFormattingFunc(start);
var partial1 = partialFormattingFunc(end);
var insertion = findCommonInsertion(full0, partial0, full1, partial1);
var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
if (insertion) {
return insertion.before + partial0 + separator + partial1 + insertion.after;
}
return full0 + separator + full1;
};
NativeFormatter.prototype.getLargestUnit = function () {
switch (this.severity) {
case 7:
case 6:
case 5:
return 'year';
case 4:
return 'month';
case 3:
return 'week';
case 2:
return 'day';
default:
return 'time'; // really?
}
};
return NativeFormatter;
}());
function buildFormattingFunc(standardDateProps, extendedSettings, context) {
var standardDatePropCnt = Object.keys(standardDateProps).length;
if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
return function (date) { return (formatTimeZoneOffset(date.timeZoneOffset)); };
}
if (standardDatePropCnt === 0 && extendedSettings.week) {
return function (date) { return (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.locale, extendedSettings.week)); };
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
}
return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
}
function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
standardDateProps = __assign({}, standardDateProps); // copy
extendedSettings = __assign({}, extendedSettings); // copy
sanitizeSettings(standardDateProps, extendedSettings);
standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
var zeroFormat; // needed?
if (extendedSettings.omitZeroMinute) {
var zeroProps = __assign({}, standardDateProps);
delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
}
return function (date) {
var marker = date.marker;
var format;
if (zeroFormat && !marker.getUTCMinutes()) {
format = zeroFormat;
}
else {
format = normalFormat;
}
var s = format.format(marker);
return postProcess(s, date, standardDateProps, extendedSettings, context);
};
}
function sanitizeSettings(standardDateProps, extendedSettings) {
// deal with a browser inconsistency where formatting the timezone
// requires that the hour/minute be present.
if (standardDateProps.timeZoneName) {
if (!standardDateProps.hour) {
standardDateProps.hour = '2-digit';
}
if (!standardDateProps.minute) {
standardDateProps.minute = '2-digit';
}
}
// only support short timezone names
if (standardDateProps.timeZoneName === 'long') {
standardDateProps.timeZoneName = 'short';
}
// if requesting to display seconds, MUST display minutes
if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
delete extendedSettings.omitZeroMinute;
}
}
function postProcess(s, date, standardDateProps, extendedSettings, context) {
s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
if (standardDateProps.timeZoneName === 'short') {
s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
'UTC' : // important to normalize for IE, which does "GMT"
formatTimeZoneOffset(date.timeZoneOffset));
}
if (extendedSettings.omitCommas) {
s = s.replace(COMMA_RE, '').trim();
}
if (extendedSettings.omitZeroMinute) {
s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
}
// ^ do anything that might create adjacent spaces before this point,
// because MERIDIEM_RE likes to eat up loading spaces
if (extendedSettings.meridiem === false) {
s = s.replace(MERIDIEM_RE, '').trim();
}
else if (extendedSettings.meridiem === 'narrow') { // a/p
s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase(); });
}
else if (extendedSettings.meridiem === 'short') { // am/pm
s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase() + "m"; });
}
else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
s = s.replace(MERIDIEM_RE, function (m0) { return m0.toLocaleLowerCase(); });
}
s = s.replace(MULTI_SPACE_RE, ' ');
s = s.trim();
return s;
}
function injectTzoStr(s, tzoStr) {
var replaced = false;
s = s.replace(UTC_RE, function () {
replaced = true;
return tzoStr;
});
// IE11 doesn't include UTC/GMT in the original string, so append to end
if (!replaced) {
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
}
return s;
}
function formatWeekNumber(num, weekText, locale, display) {
var parts = [];
if (display === 'narrow') {
parts.push(weekText);
}
else if (display === 'short') {
parts.push(weekText, ' ');
}
// otherwise, considered 'numeric'
parts.push(locale.simpleNumberFormat.format(num));
if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
parts.reverse();
}
return parts.join('');
}
// Range Formatting Utils
// 0 = exactly the same
// 1 = different by time
// and bigger
function computeMarkerDiffSeverity(d0, d1, ca) {
if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
return 5;
}
if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
return 4;
}
if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
return 2;
}
if (timeAsMs(d0) !== timeAsMs(d1)) {
return 1;
}
return 0;
}
function computePartialFormattingOptions(options, biggestUnit) {
var partialOptions = {};
for (var name_2 in options) {
if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
partialOptions[name_2] = options[name_2];
}
}
return partialOptions;
}
function findCommonInsertion(full0, partial0, full1, partial1) {
var i0 = 0;
while (i0 < full0.length) {
var found0 = full0.indexOf(partial0, i0);
if (found0 === -1) {
break;
}
var before0 = full0.substr(0, found0);
i0 = found0 + partial0.length;
var after0 = full0.substr(i0);
var i1 = 0;
while (i1 < full1.length) {
var found1 = full1.indexOf(partial1, i1);
if (found1 === -1) {
break;
}
var before1 = full1.substr(0, found1);
i1 = found1 + partial1.length;
var after1 = full1.substr(i1);
if (before0 === before1 && after0 === after1) {
return {
before: before0,
};
}
}
}
return null;
}
function expandZonedMarker(dateInfo, calendarSystem) {
var a = calendarSystem.markerToArray(dateInfo.marker);
return {
marker: dateInfo.marker,
timeZoneOffset: dateInfo.timeZoneOffset,
array: a,
year: a[0],
month: a[1],
day: a[2],
hour: a[3],
minute: a[4],
second: a[5],
};
}
function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
var startInfo = expandZonedMarker(start, context.calendarSystem);
var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
return {
date: startInfo,
start: startInfo,
end: endInfo,
timeZone: context.timeZone,
localeCodes: context.locale.codes,
defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
};
}
/*
TODO: fix the terminology of "formatter" vs "formatting func"
*/
/*
At the time of instantiation, this object does not know which cmd-formatting system it will use.
It receives this at the time of formatting, as a setting.
*/
var CmdFormatter = /** @class */ (function () {
function CmdFormatter(cmdStr) {
this.cmdStr = cmdStr;
}
CmdFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
};
CmdFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
};
return CmdFormatter;
}());
var FuncFormatter = /** @class */ (function () {
function FuncFormatter(func) {
this.func = func;
}
FuncFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
};
FuncFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
};
return FuncFormatter;
}());
function createFormatter(input) {
if (typeof input === 'object' && input) { // non-null object
return new NativeFormatter(input);
}
return new CmdFormatter(input);
}
return new FuncFormatter(input);
}
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
}
// base options
// ------------
var BASE_OPTION_REFINERS = {
navLinkDayClick: identity,
navLinkWeekClick: identity,
duration: createDuration,
bootstrapFontAwesome: identity,
buttonIcons: identity,
customButtons: identity,
defaultAllDayEventDuration: createDuration,
defaultTimedEventDuration: createDuration,
nextDayThreshold: createDuration,
scrollTime: createDuration,
slotMinTime: createDuration,
slotMaxTime: createDuration,
dayPopoverFormat: createFormatter,
slotDuration: createDuration,
snapDuration: createDuration,
headerToolbar: identity,
footerToolbar: identity,
defaultRangeSeparator: String,
titleRangeSeparator: String,
forceEventDuration: Boolean,
dayHeaders: Boolean,
dayHeaderFormat: createFormatter,
dayHeaderClassNames: identity,
dayHeaderContent: identity,
dayHeaderDidMount: identity,
dayHeaderWillUnmount: identity,
dayCellClassNames: identity,
dayCellContent: identity,
dayCellDidMount: identity,
dayCellWillUnmount: identity,
initialView: String,
aspectRatio: Number,
weekends: Boolean,
weekNumberCalculation: identity,
weekNumbers: Boolean,
weekNumberClassNames: identity,
weekNumberContent: identity,
weekNumberDidMount: identity,
weekNumberWillUnmount: identity,
editable: Boolean,
viewClassNames: identity,
viewDidMount: identity,
viewWillUnmount: identity,
nowIndicator: Boolean,
nowIndicatorClassNames: identity,
nowIndicatorContent: identity,
nowIndicatorDidMount: identity,
nowIndicatorWillUnmount: identity,
showNonCurrentDates: Boolean,
lazyFetching: Boolean,
startParam: String,
endParam: String,
timeZoneParam: String,
timeZone: String,
locales: identity,
locale: identity,
themeSystem: String,
dragRevertDuration: Number,
dragScroll: Boolean,
allDayMaintainDuration: Boolean,
unselectAuto: Boolean,
dropAccept: identity,
eventOrder: parseFieldSpecs,
handleWindowResize: Boolean,
windowResizeDelay: Number,
longPressDelay: Number,
eventDragMinDistance: Number,
expandRows: Boolean,
height: identity,
contentHeight: identity,
direction: String,
weekNumberFormat: createFormatter,
eventResizableFromStart: Boolean,
displayEventTime: Boolean,
displayEventEnd: Boolean,
weekText: String,
progressiveEventRendering: Boolean,
businessHours: identity,
initialDate: identity,
now: identity,
eventDataTransform: identity,
stickyHeaderDates: identity,
stickyFooterScrollbar: identity,
viewHeight: identity,
defaultAllDay: Boolean,
eventSourceFailure: identity,
eventSourceSuccess: identity,
eventDisplay: String,
eventStartEditable: Boolean,
eventDurationEditable: Boolean,
eventOverlap: identity,
eventConstraint: identity,
eventAllow: identity,
eventBackgroundColor: String,
eventBorderColor: String,
eventTextColor: String,
eventColor: String,
eventClassNames: identity,
eventContent: identity,
eventDidMount: identity,
eventWillUnmount: identity,
selectConstraint: identity,
selectOverlap: identity,
selectAllow: identity,
droppable: Boolean,
unselectCancel: String,
slotLabelFormat: identity,
slotLaneClassNames: identity,
slotLaneContent: identity,
slotLaneDidMount: identity,
slotLaneWillUnmount: identity,
slotLabelClassNames: identity,
slotLabelContent: identity,
slotLabelDidMount: identity,
slotLabelWillUnmount: identity,
dayMaxEvents: identity,
dayMaxEventRows: identity,
dayMinWidth: Number,
slotLabelInterval: createDuration,
allDayText: String,
allDayClassNames: identity,
allDayContent: identity,
allDayDidMount: identity,
allDayWillUnmount: identity,
slotMinWidth: Number,
navLinks: Boolean,
eventTimeFormat: createFormatter,
rerenderDelay: Number,
moreLinkText: identity,
selectMinDistance: Number,
selectable: Boolean,
selectLongPressDelay: Number,
eventLongPressDelay: Number,
selectMirror: Boolean,
eventMinHeight: Number,
slotEventOverlap: Boolean,
plugins: identity,
firstDay: Number,
dayCount: Number,
dateAlignment: String,
dateIncrement: createDuration,
hiddenDays: identity,
monthMode: Boolean,
fixedWeekCount: Boolean,
validRange: identity,
visibleRange: identity,
titleFormat: identity,
// only used by list-view, but languages define the value, so we need it in base options
};
// do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
// raw values.
var BASE_OPTION_DEFAULTS = {
eventDisplay: 'auto',
defaultRangeSeparator: ' - ',
titleRangeSeparator: ' \u2013 ',
defaultTimedEventDuration: '01:00:00',
defaultAllDayEventDuration: { day: 1 },
forceEventDuration: false,
nextDayThreshold: '00:00:00',
dayHeaders: true,
initialView: '',
aspectRatio: 1.35,
headerToolbar: {
start: 'title',
center: '',
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
},
weekends: true,
weekNumbers: false,
weekNumberCalculation: 'local',
editable: false,
nowIndicator: false,
scrollTime: '06:00:00',
slotMinTime: '00:00:00',
slotMaxTime: '24:00:00',
showNonCurrentDates: true,
lazyFetching: true,
startParam: 'start',
endParam: 'end',
timeZoneParam: 'timeZone',
timeZone: 'local',
locales: [],
locale: '',
themeSystem: 'standard',
dragRevertDuration: 500,
dragScroll: true,
allDayMaintainDuration: false,
unselectAuto: true,
dropAccept: '*',
eventOrder: 'start,-duration,allDay,title',
dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
handleWindowResize: true,
windowResizeDelay: 100,
longPressDelay: 1000,
eventDragMinDistance: 5,
expandRows: false,
navLinks: false,
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
};
// calendar listeners
// ------------------
var CALENDAR_LISTENER_REFINERS = {
datesSet: identity,
eventsSet: identity,
eventAdd: identity,
eventChange: identity,
eventRemove: identity,
windowResize: identity,
eventClick: identity,
eventMouseEnter: identity,
eventMouseLeave: identity,
select: identity,
unselect: identity,
loading: identity,
// internal
_unmount: identity,
_beforeprint: identity,
_afterprint: identity,
_noEventDrop: identity,
_noEventResize: identity,
_resize: identity,
};
// calendar-specific options
// -------------------------
var CALENDAR_OPTION_REFINERS = {
buttonText: identity,
views: identity,
plugins: identity,
initialEvents: identity,
events: identity,
};
var COMPLEX_OPTION_COMPARATORS = {
headerToolbar: isBoolComplexEqual,
footerToolbar: isBoolComplexEqual,
buttonText: isBoolComplexEqual,
};
function isBoolComplexEqual(a, b) {
if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
return isPropsEqual(a, b);
}
}
// view-specific options
// ---------------------
var VIEW_OPTION_REFINERS = {
type: String,
component: identity,
buttonText: String,
buttonTextKey: String,
dateProfileGeneratorClass: identity,
usesMinMaxTime: Boolean,
classNames: identity,
content: identity,
didMount: identity,
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
};
// util funcs
// ----------------------------------------------------------------------------------------------------
function mergeRawOptions(optionSets) {
return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
}
function refineProps(input, refiners) {
var refined = {};
var extra = {};
for (var propName in refiners) {
if (propName in input) {
refined[propName] = refiners[propName](input[propName]);
}
}
for (var propName in input) {
if (!(propName in refiners)) {
extra[propName] = input[propName];
}
}
return { refined: refined, extra: extra };
}
function identity(raw) {
return raw;
}
function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
var eventStore = createEmptyEventStore();
var eventRefiners = buildEventRefiners(context);
for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
var rawEvent = rawEvents_1[_i];
var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
if (tuple) {
eventTupleToStore(tuple, eventStore);
}
}
return eventStore;
}
function eventTupleToStore(tuple, eventStore) {
if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
eventStore.defs[tuple.def.defId] = tuple.def;
if (tuple.instance) {
eventStore.instances[tuple.instance.instanceId] = tuple.instance;
}
return eventStore;
}
// retrieves events that have the same groupId as the instance specified by `instanceId`
// or they are the same as the instance.
// why might instanceId not be in the store? an event from another calendar?
function getRelevantEvents(eventStore, instanceId) {
var instance = eventStore.instances[instanceId];
if (instance) {
var def_1 = eventStore.defs[instance.defId];
// get events/instances with same group
var newStore = filterEventStoreDefs(eventStore, function (lookDef) { return isEventDefsGrouped(def_1, lookDef); });
// add the original
// TODO: wish we could use eventTupleToStore or something like it
newStore.defs[def_1.defId] = def_1;
newStore.instances[instance.instanceId] = instance;
return newStore;
}
return createEmptyEventStore();
}
function isEventDefsGrouped(def0, def1) {
return Boolean(def0.groupId && def0.groupId === def1.groupId);
}
function createEmptyEventStore() {
return { defs: {}, instances: {} };
}
function mergeEventStores(store0, store1) {
return {
defs: __assign(__assign({}, store0.defs), store1.defs),
instances: __assign(__assign({}, store0.instances), store1.instances),
};
}
function filterEventStoreDefs(eventStore, filterFunc) {
var defs = filterHash(eventStore.defs, filterFunc);
var instances = filterHash(eventStore.instances, function (instance) { return (defs[instance.defId] // still exists?
); });
return { defs: defs, instances: instances };
}
function excludeSubEventStore(master, sub) {
var defs = master.defs, instances = master.instances;
var filteredDefs = {};
var filteredInstances = {};
for (var defId in defs) {
if (!sub.defs[defId]) { // not explicitly excluded
filteredDefs[defId] = defs[defId];
}
}
for (var instanceId in instances) {
if (!sub.instances[instanceId] && // not explicitly excluded
filteredDefs[instances[instanceId].defId] // def wasn't filtered away
) {
filteredInstances[instanceId] = instances[instanceId];
}
}
return {
defs: filteredDefs,
};
}
function normalizeConstraint(input, context) {
if (Array.isArray(input)) {
return parseEvents(input, null, context, true); // allowOpenRange=true
}
if (typeof input === 'object' && input) { // non-null object
return parseEvents([input], null, context, true); // allowOpenRange=true
}
return String(input);
}
}
function parseClassNames(raw) {
if (Array.isArray(raw)) {
return raw;
}
return raw.split(/\s+/);
}
}
// TODO: better called "EventSettings" or "EventConfig"
// TODO: move this file into structs
// TODO: separate constraint/overlap/allow, because selection uses only that, not other props
var EVENT_UI_REFINERS = {
display: String,
editable: Boolean,
startEditable: Boolean,
durationEditable: Boolean,
constraint: identity,
overlap: identity,
allow: identity,
className: parseClassNames,
classNames: parseClassNames,
color: String,
backgroundColor: String,
borderColor: String,
textColor: String,
};
var EMPTY_EVENT_UI = {
display: null,
startEditable: null,
durationEditable: null,
constraints: [],
overlap: null,
allows: [],
backgroundColor: '',
borderColor: '',
textColor: '',
classNames: [],
};
function createEventUi(refined, context) {
var constraint = normalizeConstraint(refined.constraint, context);
return {
display: refined.display || null,
startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
constraints: constraint != null ? [constraint] : [],
overlap: refined.overlap != null ? refined.overlap : null,
allows: refined.allow != null ? [refined.allow] : [],
backgroundColor: refined.backgroundColor || refined.color || '',
borderColor: refined.borderColor || refined.color || '',
textColor: refined.textColor || '',
classNames: (refined.className || []).concat(refined.classNames || []),
};
}
// TODO: prevent against problems with <2 args!
function combineEventUis(uis) {
return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
}
function combineTwoEventUis(item0, item1) {
return {
display: item1.display != null ? item1.display : item0.display,
startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
constraints: item0.constraints.concat(item1.constraints),
overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
allows: item0.allows.concat(item1.allows),
backgroundColor: item1.backgroundColor || item0.backgroundColor,
borderColor: item1.borderColor || item0.borderColor,
textColor: item1.textColor || item0.textColor,
classNames: item0.classNames.concat(item1.classNames),
};
}
var EVENT_NON_DATE_REFINERS = {
id: String,
groupId: String,
title: String,
};
var EVENT_DATE_REFINERS = {
start: identity,
end: identity,
date: identity,
};
var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
if (refiners === void 0) { refiners = buildEventRefiners(context); }
var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
if (recurringRes) {
var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context);
def.recurringDef = {
typeId: recurringRes.typeId,
typeData: recurringRes.typeData,