Newer
Older
removeResizeHandler: function (handler) {
emitter.off('_resize', handler);
},
createScrollResponder: function (execFunc) {
return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime));
},
registerInteractiveComponent: registerInteractiveComponent,
unregisterInteractiveComponent: unregisterInteractiveComponent,
var PureComponent = /** @class */ (function (_super) {
__extends(PureComponent, _super);
function PureComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
PureComponent.prototype.shouldComponentUpdate = function (nextProps, nextState) {
if (this.debug) {
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
}
return !compareObjs(this.props, nextProps, this.propEquality) ||
!compareObjs(this.state, nextState, this.stateEquality);
};
PureComponent.addPropsEquality = addPropsEquality;
PureComponent.addStateEquality = addStateEquality;
PureComponent.contextType = ViewContextType;
return PureComponent;
}(Component));
PureComponent.prototype.propEquality = {};
PureComponent.prototype.stateEquality = {};
var BaseComponent = /** @class */ (function (_super) {
__extends(BaseComponent, _super);
function BaseComponent() {
return _super !== null && _super.apply(this, arguments) || this;
}
BaseComponent.contextType = ViewContextType;
return BaseComponent;
}(PureComponent));
function addPropsEquality(propEquality) {
var hash = Object.create(this.prototype.propEquality);
__assign(hash, propEquality);
this.prototype.propEquality = hash;
}
function addStateEquality(stateEquality) {
var hash = Object.create(this.prototype.stateEquality);
__assign(hash, stateEquality);
this.prototype.stateEquality = hash;
}
// use other one
function setRef(ref, current) {
if (typeof ref === 'function') {
ref(current);
}
else if (ref) {
// see https://github.com/facebook/react/issues/13029
ref.current = current;
}
}
function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
switch (action.type) {
case 'RECEIVE_EVENTS': // raw
return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
case 'ADD_EVENTS': // already parsed, but not expanded
return addEvent(eventStore, action.eventStore, // new ones
dateProfile ? dateProfile.activeRange : null, context);
case 'RESET_EVENTS':
return action.eventStore;
case 'MERGE_EVENTS': // already parsed and expanded
return mergeEventStores(eventStore, action.eventStore);
case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
case 'NEXT':
case 'CHANGE_DATE':
case 'CHANGE_VIEW_TYPE':
if (dateProfile) {
return expandRecurring(eventStore, dateProfile.activeRange, context);
}
case 'REMOVE_EVENTS':
return excludeSubEventStore(eventStore, action.eventStore);
case 'REMOVE_EVENT_SOURCE':
return excludeEventsBySourceId(eventStore, action.sourceId);
case 'REMOVE_ALL_EVENT_SOURCES':
return filterEventStoreDefs(eventStore, function (eventDef) { return (!eventDef.sourceId // only keep events with no source id
); });
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
case 'REMOVE_ALL_EVENTS':
return createEmptyEventStore();
default:
return eventStore;
}
}
function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
if (eventSource && // not already removed
fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
) {
var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
if (fetchRange) {
subset = expandRecurring(subset, fetchRange, context);
}
return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
}
return eventStore;
}
function transformRawEvents(rawEvents, eventSource, context) {
var calEachTransform = context.options.eventDataTransform;
var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
if (sourceEachTransform) {
rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
}
if (calEachTransform) {
rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
}
return rawEvents;
}
function transformEachRawEvent(rawEvents, func) {
var refinedEvents;
if (!func) {
refinedEvents = rawEvents;
}
else {
refinedEvents = [];
for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
var rawEvent = rawEvents_1[_i];
var refinedEvent = func(rawEvent);
if (refinedEvent) {
refinedEvents.push(refinedEvent);
}
else if (refinedEvent == null) {
refinedEvents.push(rawEvent);
} // if a different falsy value, do nothing
}
}
return refinedEvents;
}
function addEvent(eventStore, subset, expandRange, context) {
if (expandRange) {
subset = expandRecurring(subset, expandRange, context);
}
return mergeEventStores(eventStore, subset);
}
function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
var defs = eventStore.defs;
var instances = mapHash(eventStore.instances, function (instance) {
var def = defs[instance.defId];
if (def.allDay || def.recurringDef) {
return instance; // isn't dependent on timezone
}
return __assign(__assign({}, instance), { range: {
start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
}, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
});
return { defs: defs, instances: instances };
}
function excludeEventsBySourceId(eventStore, sourceId) {
return filterEventStoreDefs(eventStore, function (eventDef) { return eventDef.sourceId !== sourceId; });
}
// QUESTION: why not just return instances? do a general object-property-exclusion util
function excludeInstances(eventStore, removals) {
return {
defs: eventStore.defs,
instances: filterHash(eventStore.instances, function (instance) { return !removals[instance.instanceId]; }),
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
};
}
// high-level segmenting-aware tester functions
// ------------------------------------------------------------------------------------------------------------------------
function isInteractionValid(interaction, context) {
return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
}
function isDateSelectionValid(dateSelection, context) {
return isNewPropsValid({ dateSelection: dateSelection }, context);
}
function isNewPropsValid(newProps, context) {
var calendarState = context.getCurrentData();
var props = __assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
}
function isPropsValid(state, context, dateSpanMeta, filterConfig) {
if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
return false;
}
if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
return false;
}
return true;
}
// Moving Event Validation
// ------------------------------------------------------------------------------------------------------------------------
function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
var currentState = context.getCurrentData();
var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
var subjectEventStore = interaction.mutatedEvents;
var subjectDefs = subjectEventStore.defs;
var subjectInstances = subjectEventStore.instances;
var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
state.eventUiBases :
if (filterConfig) {
subjectConfigs = mapHash(subjectConfigs, filterConfig);
}
// exclude the subject events. TODO: exclude defs too?
var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
var otherDefs = otherEventStore.defs;
var otherInstances = otherEventStore.instances;
var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
for (var subjectInstanceId in subjectInstances) {
var subjectInstance = subjectInstances[subjectInstanceId];
var subjectRange = subjectInstance.range;
var subjectConfig = subjectConfigs[subjectInstance.defId];
var subjectDef = subjectDefs[subjectInstance.defId];
// constraint
if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
return false;
}
// overlap
var eventOverlap = context.options.eventOverlap;
var eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
for (var otherInstanceId in otherInstances) {
var otherInstance = otherInstances[otherInstanceId];
// intersect! evaluate
if (rangesIntersect(subjectRange, otherInstance.range)) {
var otherOverlap = otherConfigs[otherInstance.defId].overlap;
// consider the other event's overlap. only do this if the subject event is a "real" event
if (otherOverlap === false && interaction.isEvent) {
return false;
}
if (subjectConfig.overlap === false) {
return false;
}
if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), // still event
new EventApi(context, subjectDef, subjectInstance))) {
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
return false;
}
}
}
// allow (a function)
var calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
var subjectAllow = _a[_i];
var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
var origDef = calendarEventStore.defs[subjectDef.defId];
var origInstance = calendarEventStore.instances[subjectInstanceId];
var eventApi = void 0;
if (origDef) { // was previously in the calendar
eventApi = new EventApi(context, origDef, origInstance);
}
else { // was an external event
eventApi = new EventApi(context, subjectDef); // no instance, because had no dates
}
if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
return false;
}
}
}
return true;
}
// Date Selection Validation
// ------------------------------------------------------------------------------------------------------------------------
function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
var relevantEventStore = state.eventStore;
var relevantDefs = relevantEventStore.defs;
var relevantInstances = relevantEventStore.instances;
var selection = state.dateSelection;
var selectionRange = selection.range;
var selectionConfig = context.getCurrentData().selectionConfig;
if (filterConfig) {
selectionConfig = filterConfig(selectionConfig);
}
// constraint
if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
return false;
}
// overlap
var selectOverlap = context.options.selectOverlap;
var selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
for (var relevantInstanceId in relevantInstances) {
var relevantInstance = relevantInstances[relevantInstanceId];
// intersect! evaluate
if (rangesIntersect(selectionRange, relevantInstance.range)) {
if (selectionConfig.overlap === false) {
return false;
}
if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
return false;
}
}
}
// allow (a function)
for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
var selectionAllow = _a[_i];
var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
return false;
}
}
return true;
}
// Constraint Utils
// ------------------------------------------------------------------------------------------------------------------------
function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
var constraint = constraints_1[_i];
if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
return false;
}
}
return true;
}
function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
otherEventStore, // for if constraint is an even group ID
businessHoursUnexpanded, // for if constraint is 'businessHours'
if (constraint === 'businessHours') {
return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
}
if (typeof constraint === 'string') { // an group ID
return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) { return eventDef.groupId === constraint; }));
if (typeof constraint === 'object' && constraint) { // non-null object
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
}
return []; // if it's false
}
// TODO: move to event-store file?
function eventStoreToRanges(eventStore) {
var instances = eventStore.instances;
var ranges = [];
for (var instanceId in instances) {
ranges.push(instances[instanceId].range);
}
return ranges;
}
// TODO: move to geom file?
function anyRangesContainRange(outerRanges, innerRange) {
for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
var outerRange = outerRanges_1[_i];
if (rangeContainsRange(outerRange, innerRange)) {
return true;
}
}
return false;
}
/*
an INTERACTABLE date component
PURPOSES:
- hook up to fg, fill, and mirror renderers
- interface for dragging and hits
*/
var DateComponent = /** @class */ (function (_super) {
__extends(DateComponent, _super);
function DateComponent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.uid = guid();
return _this;
}
// Hit System
// -----------------------------------------------------------------------------------------------------------------
DateComponent.prototype.prepareHits = function () {
};
DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
return null; // this should be abstract
};
// Validation
// -----------------------------------------------------------------------------------------------------------------
DateComponent.prototype.isInteractionValid = function (interaction) {
var dateProfile = this.props.dateProfile; // HACK
var instances = interaction.mutatedEvents.instances;
if (dateProfile) { // HACK for MorePopover
for (var instanceId in instances) {
if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
return false;
}
}
}
return isInteractionValid(interaction, this.context);
};
DateComponent.prototype.isDateSelectionValid = function (selection) {
var dateProfile = this.props.dateProfile; // HACK
if (dateProfile && // HACK for MorePopover
!rangeContainsRange(dateProfile.validRange, selection.range)) {
return false;
}
return isDateSelectionValid(selection, this.context);
};
// Pointer Interaction Utils
// -----------------------------------------------------------------------------------------------------------------
DateComponent.prototype.isValidSegDownEl = function (el) {
return !this.props.eventDrag && // HACK
!this.props.eventResize && // HACK
!elementClosest(el, '.fc-event-mirror');
};
DateComponent.prototype.isValidDateDownEl = function (el) {
return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
!elementClosest(el, '.fc-daygrid-more-link') && // a "more.." link
!elementClosest(el, 'a[data-navlink]') && // a clickable nav link
!elementClosest(el, '.fc-popover'); // hack
};
return DateComponent;
}(BaseComponent));
// TODO: easier way to add new hooks? need to update a million things
function createPlugin(input) {
return {
id: guid(),
deps: input.deps || [],
reducers: input.reducers || [],
isLoadingFuncs: input.isLoadingFuncs || [],
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
contextInit: [].concat(input.contextInit || []),
eventRefiners: input.eventRefiners || {},
eventDefMemberAdders: input.eventDefMemberAdders || [],
eventSourceRefiners: input.eventSourceRefiners || {},
isDraggableTransformers: input.isDraggableTransformers || [],
eventDragMutationMassagers: input.eventDragMutationMassagers || [],
eventDefMutationAppliers: input.eventDefMutationAppliers || [],
dateSelectionTransformers: input.dateSelectionTransformers || [],
datePointTransforms: input.datePointTransforms || [],
dateSpanTransforms: input.dateSpanTransforms || [],
views: input.views || {},
viewPropsTransformers: input.viewPropsTransformers || [],
isPropsValid: input.isPropsValid || null,
externalDefTransforms: input.externalDefTransforms || [],
eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
viewContainerAppends: input.viewContainerAppends || [],
eventDropTransformers: input.eventDropTransformers || [],
componentInteractions: input.componentInteractions || [],
calendarInteractions: input.calendarInteractions || [],
themeClasses: input.themeClasses || {},
eventSourceDefs: input.eventSourceDefs || [],
cmdFormatter: input.cmdFormatter,
recurringTypes: input.recurringTypes || [],
namedTimeZonedImpl: input.namedTimeZonedImpl,
initialView: input.initialView || '',
elementDraggingImpl: input.elementDraggingImpl,
optionChangeHandlers: input.optionChangeHandlers || {},
scrollGridImpl: input.scrollGridImpl || null,
contentTypeHandlers: input.contentTypeHandlers || {},
listenerRefiners: input.listenerRefiners || {},
optionRefiners: input.optionRefiners || {},
propSetHandlers: input.propSetHandlers || {},
};
}
function buildPluginHooks(pluginDefs, globalDefs) {
var isAdded = {};
var hooks = {
reducers: [],
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
contextInit: [],
eventRefiners: {},
eventDefMemberAdders: [],
eventSourceRefiners: {},
isDraggableTransformers: [],
eventDragMutationMassagers: [],
eventDefMutationAppliers: [],
dateSelectionTransformers: [],
datePointTransforms: [],
dateSpanTransforms: [],
views: {},
viewPropsTransformers: [],
isPropsValid: null,
externalDefTransforms: [],
eventResizeJoinTransforms: [],
viewContainerAppends: [],
eventDropTransformers: [],
componentInteractions: [],
calendarInteractions: [],
themeClasses: {},
eventSourceDefs: [],
cmdFormatter: null,
recurringTypes: [],
namedTimeZonedImpl: null,
initialView: '',
elementDraggingImpl: null,
optionChangeHandlers: {},
scrollGridImpl: null,
contentTypeHandlers: {},
listenerRefiners: {},
optionRefiners: {},
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
};
function addDefs(defs) {
for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
var def = defs_1[_i];
if (!isAdded[def.id]) {
isAdded[def.id] = true;
addDefs(def.deps);
hooks = combineHooks(hooks, def);
}
}
}
if (pluginDefs) {
addDefs(pluginDefs);
}
addDefs(globalDefs);
return hooks;
}
function buildBuildPluginHooks() {
var currentOverrideDefs = [];
var currentGlobalDefs = [];
var currentHooks;
return function (overrideDefs, globalDefs) {
if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
currentHooks = buildPluginHooks(overrideDefs, globalDefs);
}
currentOverrideDefs = overrideDefs;
currentGlobalDefs = globalDefs;
return currentHooks;
};
}
function combineHooks(hooks0, hooks1) {
return {
reducers: hooks0.reducers.concat(hooks1.reducers),
isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
contextInit: hooks0.contextInit.concat(hooks1.contextInit),
eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
views: __assign(__assign({}, hooks0.views), hooks1.views),
viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
initialView: hooks0.initialView || hooks1.initialView,
elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
};
}
var StandardTheme = /** @class */ (function (_super) {
__extends(StandardTheme, _super);
function StandardTheme() {
return _super !== null && _super.apply(this, arguments) || this;
}
return StandardTheme;
}(Theme));
StandardTheme.prototype.classes = {
root: 'fc-theme-standard',
tableCellShaded: 'fc-cell-shaded',
buttonGroup: 'fc-button-group',
button: 'fc-button fc-button-primary',
};
StandardTheme.prototype.baseIconClass = 'fc-icon';
StandardTheme.prototype.iconClasses = {
close: 'fc-icon-x',
prev: 'fc-icon-chevron-left',
next: 'fc-icon-chevron-right',
prevYear: 'fc-icon-chevrons-left',
};
StandardTheme.prototype.rtlIconClasses = {
prev: 'fc-icon-chevron-right',
next: 'fc-icon-chevron-left',
prevYear: 'fc-icon-chevrons-right',
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
};
StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
function compileViewDefs(defaultConfigs, overrideConfigs) {
var hash = {};
var viewType;
for (viewType in defaultConfigs) {
ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
}
for (viewType in overrideConfigs) {
ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
}
return hash;
}
function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
if (hash[viewType]) {
return hash[viewType];
}
var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
if (viewDef) {
hash[viewType] = viewDef;
}
return viewDef;
}
function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
var defaultConfig = defaultConfigs[viewType];
var overrideConfig = overrideConfigs[viewType];
var queryProp = function (name) { return ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null)); };
var theComponent = queryProp('component');
var superType = queryProp('superType');
var superDef = null;
if (superType) {
if (superType === viewType) {
throw new Error('Can\'t have a custom view type that references itself');
}
superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
}
if (!theComponent && superDef) {
theComponent = superDef.component;
}
if (!theComponent) {
return null; // don't throw a warning, might be settings for a single-unit view
}
return {
type: viewType,
component: theComponent,
defaults: __assign(__assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
overrides: __assign(__assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
// NOTE: in JSX, you should always use this class with <HookProps> arg. otherwise, will default to any???
var RenderHook = /** @class */ (function (_super) {
__extends(RenderHook, _super);
function RenderHook() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.rootElRef = createRef();
_this.handleRootEl = function (el) {
setRef(_this.rootElRef, el);
if (_this.props.elRef) {
setRef(_this.props.elRef, el);
}
};
return _this;
}
RenderHook.prototype.render = function () {
var _this = this;
var props = this.props;
var hookProps = props.hookProps;
return (createElement(MountHook, { hookProps: hookProps, didMount: props.didMount, willUnmount: props.willUnmount, elRef: this.handleRootEl }, function (rootElRef) { return (createElement(ContentHook, { hookProps: hookProps, content: props.content, defaultContent: props.defaultContent, backupElRef: _this.rootElRef }, function (innerElRef, innerContent) { return props.children(rootElRef, normalizeClassNames(props.classNames, hookProps), innerElRef, innerContent); })); }));
};
return RenderHook;
}(BaseComponent));
// TODO: rename to be about function, not default. use in above type
// for forcing rerender of components that use the ContentHook
var CustomContentRenderContext = createContext$1(0);
function ContentHook(props) {
return (createElement(CustomContentRenderContext.Consumer, null, function (renderId) { return (createElement(ContentHookInner, __assign({ renderId: renderId }, props))); }));
}
var ContentHookInner = /** @class */ (function (_super) {
__extends(ContentHookInner, _super);
function ContentHookInner() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.innerElRef = createRef();
return _this;
}
ContentHookInner.prototype.render = function () {
return this.props.children(this.innerElRef, this.renderInnerContent());
ContentHookInner.prototype.componentDidMount = function () {
this.updateCustomContent();
};
ContentHookInner.prototype.componentDidUpdate = function () {
this.updateCustomContent();
};
ContentHookInner.prototype.componentWillUnmount = function () {
if (this.customContentInfo && this.customContentInfo.destroy) {
this.customContentInfo.destroy();
}
};
ContentHookInner.prototype.renderInnerContent = function () {
var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
var _a = this, props = _a.props, customContentInfo = _a.customContentInfo;
var rawVal = props.content;
var innerContent = normalizeContent(rawVal, props.hookProps);
var innerContentVDom = null;
if (innerContent === undefined) { // use the default
innerContent = normalizeContent(props.defaultContent, props.hookProps);
}
if (innerContent !== undefined) { // we allow custom content handlers to return nothing
if (customContentInfo) {
customContentInfo.contentVal = innerContent[customContentInfo.contentKey];
}
else if (typeof innerContent === 'object') {
// look for a prop that would indicate a custom content handler is needed
for (var contentKey in contentTypeHandlers) {
if (innerContent[contentKey] !== undefined) {
var stuff = contentTypeHandlers[contentKey]();
customContentInfo = this.customContentInfo = __assign({ contentKey: contentKey, contentVal: innerContent[contentKey] }, stuff);
break;
}
}
}
if (customContentInfo) {
innerContentVDom = []; // signal that something was specified
}
else {
innerContentVDom = innerContent; // assume a [p]react vdom node. use it
}
}
return innerContentVDom;
};
ContentHookInner.prototype.updateCustomContent = function () {
if (this.customContentInfo) {
this.customContentInfo.render(this.innerElRef.current || this.props.backupElRef.current, // the element to render into
this.customContentInfo.contentVal);
}
};
}(BaseComponent));
var MountHook = /** @class */ (function (_super) {
__extends(MountHook, _super);
function MountHook() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.handleRootEl = function (rootEl) {
_this.rootEl = rootEl;
if (_this.props.elRef) {
setRef(_this.props.elRef, rootEl);
}
};
return _this;
}
MountHook.prototype.render = function () {
return this.props.children(this.handleRootEl);
};
MountHook.prototype.componentDidMount = function () {
var callback = this.props.didMount;
if (callback) {
callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
}
};
MountHook.prototype.componentWillUnmount = function () {
var callback = this.props.willUnmount;
if (callback) {
callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
}
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
};
return MountHook;
}(BaseComponent));
function buildClassNameNormalizer() {
var currentGenerator;
var currentHookProps;
var currentClassNames = [];
return function (generator, hookProps) {
if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
currentGenerator = generator;
currentHookProps = hookProps;
currentClassNames = normalizeClassNames(generator, hookProps);
}
return currentClassNames;
};
}
function normalizeClassNames(classNames, hookProps) {
if (typeof classNames === 'function') {
classNames = classNames(hookProps);
}
return parseClassNames(classNames);
}
function normalizeContent(input, hookProps) {
if (typeof input === 'function') {
return input(hookProps, createElement); // give the function the vdom-creation func
}
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
}
var ViewRoot = /** @class */ (function (_super) {
__extends(ViewRoot, _super);
function ViewRoot() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.normalizeClassNames = buildClassNameNormalizer();
return _this;
}
ViewRoot.prototype.render = function () {
var _a = this, props = _a.props, context = _a.context;
var options = context.options;
var hookProps = { view: context.viewApi };
var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
return (createElement(MountHook, { hookProps: hookProps, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, ["fc-" + props.viewSpec.type + "-view", 'fc-view'].concat(customClassNames)); }));
};
return ViewRoot;
}(BaseComponent));
function parseViewConfigs(inputs) {
return mapHash(inputs, parseViewConfig);
}
function parseViewConfig(input) {
var rawOptions = typeof input === 'function' ?
{ component: input } :
input;
var component = rawOptions.component;
if (rawOptions.content) {
component = createViewHookComponent(rawOptions);
// TODO: remove content/classNames/didMount/etc from options?
}
return {
superType: rawOptions.type,
component: component,
};
}
function createViewHookComponent(options) {
return function (viewProps) { return (createElement(ViewContextType.Consumer, null, function (context) { return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (viewElRef, viewClassNames) {
var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
return (createElement(RenderHook, { hookProps: hookProps, classNames: options.classNames, content: options.content, didMount: options.didMount, willUnmount: options.willUnmount, elRef: viewElRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("div", { className: viewClassNames.concat(customClassNames).join(' '), ref: rootElRef }, innerContent)); }));
})); })); };
}
function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
var defaultConfigs = parseViewConfigs(defaultInputs);
var overrideConfigs = parseViewConfigs(optionOverrides.views);
var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
return mapHash(viewDefs, function (viewDef) { return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults); });
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
}
function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
var durationInput = viewDef.overrides.duration ||
viewDef.defaults.duration ||
dynamicOptionOverrides.duration ||
optionOverrides.duration;
var duration = null;
var durationUnit = '';
var singleUnit = '';
var singleUnitOverrides = {};
if (durationInput) {
duration = createDurationCached(durationInput);
if (duration) { // valid?
var denom = greatestDurationDenominator(duration);
durationUnit = denom.unit;
if (denom.value === 1) {
singleUnit = durationUnit;
singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
}
}
}
var queryButtonText = function (optionsSubset) {
var buttonTextMap = optionsSubset.buttonText || {};
var buttonTextKey = viewDef.defaults.buttonTextKey;
if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
return buttonTextMap[buttonTextKey];
}
if (buttonTextMap[viewDef.type] != null) {
return buttonTextMap[viewDef.type];
}
if (buttonTextMap[singleUnit] != null) {
return buttonTextMap[singleUnit];
}
};
return {
type: viewDef.type,
component: viewDef.component,
duration: duration,
durationUnit: durationUnit,
singleUnit: singleUnit,
optionDefaults: viewDef.defaults,
optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
viewDef.overrides.buttonText,
buttonTextDefault: queryButtonText(localeDefaults) ||
viewDef.defaults.buttonText ||
queryButtonText(BASE_OPTION_DEFAULTS) ||
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
};
}
// hack to get memoization working
var durationInputMap = {};
function createDurationCached(durationInput) {
var json = JSON.stringify(durationInput);
var res = durationInputMap[json];
if (res === undefined) {
res = createDuration(durationInput);
durationInputMap[json] = res;
}
return res;
}
var DateProfileGenerator = /** @class */ (function () {
function DateProfileGenerator(props) {
this.props = props;
this.nowDate = getNow(props.nowInput, props.dateEnv);
this.initHiddenDays();
}
/* Date Range Computation
------------------------------------------------------------------------------------------------------------------*/
// Builds a structure with info about what the dates/ranges will be for the "prev" view.
DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate, forceToValid) {
var dateEnv = this.props.dateEnv;
var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
currentDateProfile.dateIncrement);
return this.build(prevDate, -1, forceToValid);
};
// Builds a structure with info about what the dates/ranges will be for the "next" view.
DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate, forceToValid) {
var dateEnv = this.props.dateEnv;
var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
currentDateProfile.dateIncrement);
return this.build(nextDate, 1, forceToValid);
};
// Builds a structure holding dates/ranges for rendering around the given date.
// Optional direction param indicates whether the date is being incremented/decremented
// from its previous value. decremented = -1, incremented = 1 (default).
DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
if (forceToValid === void 0) { forceToValid = true; }
var props = this.props;
var validRange;
var currentInfo;
var isRangeAllDay;
var renderRange;
var activeRange;
var isValid;
validRange = this.buildValidRange();
validRange = this.trimHiddenDays(validRange);
if (forceToValid) {
currentDate = constrainMarkerToRange(currentDate, validRange);
}
currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
renderRange = this.trimHiddenDays(renderRange);
activeRange = renderRange;
if (!props.showNonCurrentDates) {
activeRange = intersectRanges(activeRange, currentInfo.range);
}
activeRange = this.adjustActiveRange(activeRange);
activeRange = intersectRanges(activeRange, validRange); // might return null
// it's invalid if the originally requested date is not contained,
// or if the range is completely outside of the valid range.
isValid = rangesIntersect(currentInfo.range, validRange);
return {
// constraint for where prev/next operations can go and where events can be dragged/resized to.
// an object with optional start and end properties.
validRange: validRange,
// range the view is formally responsible for.
// for example, a month view might have 1st-31st, excluding padded dates
currentRange: currentInfo.range,
// name of largest unit being displayed, like "month" or "week"
currentRangeUnit: currentInfo.unit,
isRangeAllDay: isRangeAllDay,
// dates that display events and accept drag-n-drop
// will be `null` if no dates accept events
activeRange: activeRange,
// date range with a rendered skeleton
// includes not-active days that need some sort of DOM
renderRange: renderRange,
// Duration object that denotes the first visible time of any given day
slotMinTime: props.slotMinTime,
// Duration object that denotes the exclusive visible end time of any given day
slotMaxTime: props.slotMaxTime,
isValid: isValid,
// how far the current date will move for a prev/next operation
dateIncrement: this.buildDateIncrement(currentInfo.duration),
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
};
};
// Builds an object with optional start/end properties.
// Indicates the minimum/maximum dates to display.
// not responsible for trimming hidden days.
DateProfileGenerator.prototype.buildValidRange = function () {
var input = this.props.validRangeInput;
var simpleInput = typeof input === 'function'
? input.call(this.props.calendarApi, this.nowDate)
: input;
return this.refineRange(simpleInput) ||
{ start: null, end: null }; // completely open-ended
};
// Builds a structure with info about the "current" range, the range that is
// highlighted as being the current month for example.
// See build() for a description of `direction`.
// Guaranteed to have `range` and `unit` properties. `duration` is optional.
DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
var props = this.props;
var duration = null;
var unit = null;
var range = null;
var dayCount;
if (props.duration) {
duration = props.duration;
unit = props.durationUnit;
range = this.buildRangeFromDuration(date, direction, duration, unit);
}
else if ((dayCount = this.props.dayCount)) {
unit = 'day';
range = this.buildRangeFromDayCount(date, direction, dayCount);
}
else if ((range = this.buildCustomVisibleRange(date))) {
unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
}