fullcalendar.js 365 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745
  1. /*!
  2. FullCalendar Core Package v4.4.2
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2019 Adam Shaw
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  8. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  9. (global = global || self, factory(global.FullCalendar = {}));
  10. }(this, function (exports) { 'use strict';
  11. // Creating
  12. // ----------------------------------------------------------------------------------------------------------------
  13. var elementPropHash = {
  14. className: true,
  15. colSpan: true,
  16. rowSpan: true
  17. };
  18. var containerTagHash = {
  19. '<tr': 'tbody',
  20. '<td': 'tr'
  21. };
  22. function createElement(tagName, attrs, content) {
  23. var el = document.createElement(tagName);
  24. if (attrs) {
  25. for (var attrName in attrs) {
  26. if (attrName === 'style') {
  27. applyStyle(el, attrs[attrName]);
  28. }
  29. else if (elementPropHash[attrName]) {
  30. el[attrName] = attrs[attrName];
  31. }
  32. else {
  33. el.setAttribute(attrName, attrs[attrName]);
  34. }
  35. }
  36. }
  37. if (typeof content === 'string') {
  38. el.innerHTML = content; // shortcut. no need to process HTML in any way
  39. }
  40. else if (content != null) {
  41. appendToElement(el, content);
  42. }
  43. return el;
  44. }
  45. function htmlToElement(html) {
  46. html = html.trim();
  47. var container = document.createElement(computeContainerTag(html));
  48. container.innerHTML = html;
  49. return container.firstChild;
  50. }
  51. function htmlToElements(html) {
  52. return Array.prototype.slice.call(htmlToNodeList(html));
  53. }
  54. function htmlToNodeList(html) {
  55. html = html.trim();
  56. var container = document.createElement(computeContainerTag(html));
  57. container.innerHTML = html;
  58. return container.childNodes;
  59. }
  60. // assumes html already trimmed and tag names are lowercase
  61. function computeContainerTag(html) {
  62. return containerTagHash[html.substr(0, 3) // faster than using regex
  63. ] || 'div';
  64. }
  65. function appendToElement(el, content) {
  66. var childNodes = normalizeContent(content);
  67. for (var i = 0; i < childNodes.length; i++) {
  68. el.appendChild(childNodes[i]);
  69. }
  70. }
  71. function prependToElement(parent, content) {
  72. var newEls = normalizeContent(content);
  73. var afterEl = parent.firstChild || null; // if no firstChild, will append to end, but that's okay, b/c there were no children
  74. for (var i = 0; i < newEls.length; i++) {
  75. parent.insertBefore(newEls[i], afterEl);
  76. }
  77. }
  78. function insertAfterElement(refEl, content) {
  79. var newEls = normalizeContent(content);
  80. var afterEl = refEl.nextSibling || null;
  81. for (var i = 0; i < newEls.length; i++) {
  82. refEl.parentNode.insertBefore(newEls[i], afterEl);
  83. }
  84. }
  85. function normalizeContent(content) {
  86. var els;
  87. if (typeof content === 'string') {
  88. els = htmlToElements(content);
  89. }
  90. else if (content instanceof Node) {
  91. els = [content];
  92. }
  93. else { // Node[] or NodeList
  94. els = Array.prototype.slice.call(content);
  95. }
  96. return els;
  97. }
  98. function removeElement(el) {
  99. if (el.parentNode) {
  100. el.parentNode.removeChild(el);
  101. }
  102. }
  103. // Querying
  104. // ----------------------------------------------------------------------------------------------------------------
  105. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  106. var matchesMethod = Element.prototype.matches ||
  107. Element.prototype.matchesSelector ||
  108. Element.prototype.msMatchesSelector;
  109. var closestMethod = Element.prototype.closest || function (selector) {
  110. // polyfill
  111. var el = this;
  112. if (!document.documentElement.contains(el)) {
  113. return null;
  114. }
  115. do {
  116. if (elementMatches(el, selector)) {
  117. return el;
  118. }
  119. el = el.parentElement || el.parentNode;
  120. } while (el !== null && el.nodeType === 1);
  121. return null;
  122. };
  123. function elementClosest(el, selector) {
  124. return closestMethod.call(el, selector);
  125. }
  126. function elementMatches(el, selector) {
  127. return matchesMethod.call(el, selector);
  128. }
  129. // accepts multiple subject els
  130. // returns a real array. good for methods like forEach
  131. function findElements(container, selector) {
  132. var containers = container instanceof HTMLElement ? [container] : container;
  133. var allMatches = [];
  134. for (var i = 0; i < containers.length; i++) {
  135. var matches = containers[i].querySelectorAll(selector);
  136. for (var j = 0; j < matches.length; j++) {
  137. allMatches.push(matches[j]);
  138. }
  139. }
  140. return allMatches;
  141. }
  142. // accepts multiple subject els
  143. // only queries direct child elements
  144. function findChildren(parent, selector) {
  145. var parents = parent instanceof HTMLElement ? [parent] : parent;
  146. var allMatches = [];
  147. for (var i = 0; i < parents.length; i++) {
  148. var childNodes = parents[i].children; // only ever elements
  149. for (var j = 0; j < childNodes.length; j++) {
  150. var childNode = childNodes[j];
  151. if (!selector || elementMatches(childNode, selector)) {
  152. allMatches.push(childNode);
  153. }
  154. }
  155. }
  156. return allMatches;
  157. }
  158. // Attributes
  159. // ----------------------------------------------------------------------------------------------------------------
  160. function forceClassName(el, className, bool) {
  161. if (bool) {
  162. el.classList.add(className);
  163. }
  164. else {
  165. el.classList.remove(className);
  166. }
  167. }
  168. // Style
  169. // ----------------------------------------------------------------------------------------------------------------
  170. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  171. function applyStyle(el, props) {
  172. for (var propName in props) {
  173. applyStyleProp(el, propName, props[propName]);
  174. }
  175. }
  176. function applyStyleProp(el, name, val) {
  177. if (val == null) {
  178. el.style[name] = '';
  179. }
  180. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  181. el.style[name] = val + 'px';
  182. }
  183. else {
  184. el.style[name] = val;
  185. }
  186. }
  187. function pointInsideRect(point, rect) {
  188. return point.left >= rect.left &&
  189. point.left < rect.right &&
  190. point.top >= rect.top &&
  191. point.top < rect.bottom;
  192. }
  193. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  194. function intersectRects(rect1, rect2) {
  195. var res = {
  196. left: Math.max(rect1.left, rect2.left),
  197. right: Math.min(rect1.right, rect2.right),
  198. top: Math.max(rect1.top, rect2.top),
  199. bottom: Math.min(rect1.bottom, rect2.bottom)
  200. };
  201. if (res.left < res.right && res.top < res.bottom) {
  202. return res;
  203. }
  204. return false;
  205. }
  206. function translateRect(rect, deltaX, deltaY) {
  207. return {
  208. left: rect.left + deltaX,
  209. right: rect.right + deltaX,
  210. top: rect.top + deltaY,
  211. bottom: rect.bottom + deltaY
  212. };
  213. }
  214. // Returns a new point that will have been moved to reside within the given rectangle
  215. function constrainPoint(point, rect) {
  216. return {
  217. left: Math.min(Math.max(point.left, rect.left), rect.right),
  218. top: Math.min(Math.max(point.top, rect.top), rect.bottom)
  219. };
  220. }
  221. // Returns a point that is the center of the given rectangle
  222. function getRectCenter(rect) {
  223. return {
  224. left: (rect.left + rect.right) / 2,
  225. top: (rect.top + rect.bottom) / 2
  226. };
  227. }
  228. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  229. function diffPoints(point1, point2) {
  230. return {
  231. left: point1.left - point2.left,
  232. top: point1.top - point2.top
  233. };
  234. }
  235. // Logic for determining if, when the element is right-to-left, the scrollbar appears on the left side
  236. var isRtlScrollbarOnLeft = null;
  237. function getIsRtlScrollbarOnLeft() {
  238. if (isRtlScrollbarOnLeft === null) {
  239. isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  240. }
  241. return isRtlScrollbarOnLeft;
  242. }
  243. function computeIsRtlScrollbarOnLeft() {
  244. var outerEl = createElement('div', {
  245. style: {
  246. position: 'absolute',
  247. top: -1000,
  248. left: 0,
  249. border: 0,
  250. padding: 0,
  251. overflow: 'scroll',
  252. direction: 'rtl'
  253. }
  254. }, '<div></div>');
  255. document.body.appendChild(outerEl);
  256. var innerEl = outerEl.firstChild;
  257. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  258. removeElement(outerEl);
  259. return res;
  260. }
  261. // The scrollbar width computations in computeEdges are sometimes flawed when it comes to
  262. // retina displays, rounding, and IE11. Massage them into a usable value.
  263. function sanitizeScrollbarWidth(width) {
  264. width = Math.max(0, width); // no negatives
  265. width = Math.round(width);
  266. return width;
  267. }
  268. function computeEdges(el, getPadding) {
  269. if (getPadding === void 0) { getPadding = false; }
  270. var computedStyle = window.getComputedStyle(el);
  271. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  272. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  273. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  274. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  275. // must use offset(Width|Height) because compatible with client(Width|Height)
  276. var scrollbarLeftRight = sanitizeScrollbarWidth(el.offsetWidth - el.clientWidth - borderLeft - borderRight);
  277. var scrollbarBottom = sanitizeScrollbarWidth(el.offsetHeight - el.clientHeight - borderTop - borderBottom);
  278. var res = {
  279. borderLeft: borderLeft,
  280. borderRight: borderRight,
  281. borderTop: borderTop,
  282. borderBottom: borderBottom,
  283. scrollbarBottom: scrollbarBottom,
  284. scrollbarLeft: 0,
  285. scrollbarRight: 0
  286. };
  287. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  288. res.scrollbarLeft = scrollbarLeftRight;
  289. }
  290. else {
  291. res.scrollbarRight = scrollbarLeftRight;
  292. }
  293. if (getPadding) {
  294. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  295. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  296. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  297. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  298. }
  299. return res;
  300. }
  301. function computeInnerRect(el, goWithinPadding) {
  302. if (goWithinPadding === void 0) { goWithinPadding = false; }
  303. var outerRect = computeRect(el);
  304. var edges = computeEdges(el, goWithinPadding);
  305. var res = {
  306. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  307. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  308. top: outerRect.top + edges.borderTop,
  309. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom
  310. };
  311. if (goWithinPadding) {
  312. res.left += edges.paddingLeft;
  313. res.right -= edges.paddingRight;
  314. res.top += edges.paddingTop;
  315. res.bottom -= edges.paddingBottom;
  316. }
  317. return res;
  318. }
  319. function computeRect(el) {
  320. var rect = el.getBoundingClientRect();
  321. return {
  322. left: rect.left + window.pageXOffset,
  323. top: rect.top + window.pageYOffset,
  324. right: rect.right + window.pageXOffset,
  325. bottom: rect.bottom + window.pageYOffset
  326. };
  327. }
  328. function computeViewportRect() {
  329. return {
  330. left: window.pageXOffset,
  331. right: window.pageXOffset + document.documentElement.clientWidth,
  332. top: window.pageYOffset,
  333. bottom: window.pageYOffset + document.documentElement.clientHeight
  334. };
  335. }
  336. function computeHeightAndMargins(el) {
  337. return el.getBoundingClientRect().height + computeVMargins(el);
  338. }
  339. function computeVMargins(el) {
  340. var computed = window.getComputedStyle(el);
  341. return parseInt(computed.marginTop, 10) +
  342. parseInt(computed.marginBottom, 10);
  343. }
  344. // does not return window
  345. function getClippingParents(el) {
  346. var parents = [];
  347. while (el instanceof HTMLElement) { // will stop when gets to document or null
  348. var computedStyle = window.getComputedStyle(el);
  349. if (computedStyle.position === 'fixed') {
  350. break;
  351. }
  352. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  353. parents.push(el);
  354. }
  355. el = el.parentNode;
  356. }
  357. return parents;
  358. }
  359. function computeClippingRect(el) {
  360. return getClippingParents(el)
  361. .map(function (el) {
  362. return computeInnerRect(el);
  363. })
  364. .concat(computeViewportRect())
  365. .reduce(function (rect0, rect1) {
  366. return intersectRects(rect0, rect1) || rect1; // should always intersect
  367. });
  368. }
  369. // Stops a mouse/touch event from doing it's native browser action
  370. function preventDefault(ev) {
  371. ev.preventDefault();
  372. }
  373. // Event Delegation
  374. // ----------------------------------------------------------------------------------------------------------------
  375. function listenBySelector(container, eventType, selector, handler) {
  376. function realHandler(ev) {
  377. var matchedChild = elementClosest(ev.target, selector);
  378. if (matchedChild) {
  379. handler.call(matchedChild, ev, matchedChild);
  380. }
  381. }
  382. container.addEventListener(eventType, realHandler);
  383. return function () {
  384. container.removeEventListener(eventType, realHandler);
  385. };
  386. }
  387. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  388. var currentMatchedChild;
  389. return listenBySelector(container, 'mouseover', selector, function (ev, matchedChild) {
  390. if (matchedChild !== currentMatchedChild) {
  391. currentMatchedChild = matchedChild;
  392. onMouseEnter(ev, matchedChild);
  393. var realOnMouseLeave_1 = function (ev) {
  394. currentMatchedChild = null;
  395. onMouseLeave(ev, matchedChild);
  396. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  397. };
  398. // listen to the next mouseleave, and then unattach
  399. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  400. }
  401. });
  402. }
  403. // Animation
  404. // ----------------------------------------------------------------------------------------------------------------
  405. var transitionEventNames = [
  406. 'webkitTransitionEnd',
  407. 'otransitionend',
  408. 'oTransitionEnd',
  409. 'msTransitionEnd',
  410. 'transitionend'
  411. ];
  412. // triggered only when the next single subsequent transition finishes
  413. function whenTransitionDone(el, callback) {
  414. var realCallback = function (ev) {
  415. callback(ev);
  416. transitionEventNames.forEach(function (eventName) {
  417. el.removeEventListener(eventName, realCallback);
  418. });
  419. };
  420. transitionEventNames.forEach(function (eventName) {
  421. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  422. });
  423. }
  424. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  425. // Adding
  426. function addWeeks(m, n) {
  427. var a = dateToUtcArray(m);
  428. a[2] += n * 7;
  429. return arrayToUtcDate(a);
  430. }
  431. function addDays(m, n) {
  432. var a = dateToUtcArray(m);
  433. a[2] += n;
  434. return arrayToUtcDate(a);
  435. }
  436. function addMs(m, n) {
  437. var a = dateToUtcArray(m);
  438. a[6] += n;
  439. return arrayToUtcDate(a);
  440. }
  441. // Diffing (all return floats)
  442. function diffWeeks(m0, m1) {
  443. return diffDays(m0, m1) / 7;
  444. }
  445. function diffDays(m0, m1) {
  446. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  447. }
  448. function diffHours(m0, m1) {
  449. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  450. }
  451. function diffMinutes(m0, m1) {
  452. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  453. }
  454. function diffSeconds(m0, m1) {
  455. return (m1.valueOf() - m0.valueOf()) / 1000;
  456. }
  457. function diffDayAndTime(m0, m1) {
  458. var m0day = startOfDay(m0);
  459. var m1day = startOfDay(m1);
  460. return {
  461. years: 0,
  462. months: 0,
  463. days: Math.round(diffDays(m0day, m1day)),
  464. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf())
  465. };
  466. }
  467. // Diffing Whole Units
  468. function diffWholeWeeks(m0, m1) {
  469. var d = diffWholeDays(m0, m1);
  470. if (d !== null && d % 7 === 0) {
  471. return d / 7;
  472. }
  473. return null;
  474. }
  475. function diffWholeDays(m0, m1) {
  476. if (timeAsMs(m0) === timeAsMs(m1)) {
  477. return Math.round(diffDays(m0, m1));
  478. }
  479. return null;
  480. }
  481. // Start-Of
  482. function startOfDay(m) {
  483. return arrayToUtcDate([
  484. m.getUTCFullYear(),
  485. m.getUTCMonth(),
  486. m.getUTCDate()
  487. ]);
  488. }
  489. function startOfHour(m) {
  490. return arrayToUtcDate([
  491. m.getUTCFullYear(),
  492. m.getUTCMonth(),
  493. m.getUTCDate(),
  494. m.getUTCHours()
  495. ]);
  496. }
  497. function startOfMinute(m) {
  498. return arrayToUtcDate([
  499. m.getUTCFullYear(),
  500. m.getUTCMonth(),
  501. m.getUTCDate(),
  502. m.getUTCHours(),
  503. m.getUTCMinutes()
  504. ]);
  505. }
  506. function startOfSecond(m) {
  507. return arrayToUtcDate([
  508. m.getUTCFullYear(),
  509. m.getUTCMonth(),
  510. m.getUTCDate(),
  511. m.getUTCHours(),
  512. m.getUTCMinutes(),
  513. m.getUTCSeconds()
  514. ]);
  515. }
  516. // Week Computation
  517. function weekOfYear(marker, dow, doy) {
  518. var y = marker.getUTCFullYear();
  519. var w = weekOfGivenYear(marker, y, dow, doy);
  520. if (w < 1) {
  521. return weekOfGivenYear(marker, y - 1, dow, doy);
  522. }
  523. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  524. if (nextW >= 1) {
  525. return Math.min(w, nextW);
  526. }
  527. return w;
  528. }
  529. function weekOfGivenYear(marker, year, dow, doy) {
  530. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  531. var dayStart = startOfDay(marker);
  532. var days = Math.round(diffDays(firstWeekStart, dayStart));
  533. return Math.floor(days / 7) + 1; // zero-indexed
  534. }
  535. // start-of-first-week - start-of-year
  536. function firstWeekOffset(year, dow, doy) {
  537. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  538. var fwd = 7 + dow - doy;
  539. // first-week day local weekday -- which local weekday is fwd
  540. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  541. return -fwdlw + fwd - 1;
  542. }
  543. // Array Conversion
  544. function dateToLocalArray(date) {
  545. return [
  546. date.getFullYear(),
  547. date.getMonth(),
  548. date.getDate(),
  549. date.getHours(),
  550. date.getMinutes(),
  551. date.getSeconds(),
  552. date.getMilliseconds()
  553. ];
  554. }
  555. function arrayToLocalDate(a) {
  556. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  557. a[3] || 0, a[4] || 0, a[5] || 0);
  558. }
  559. function dateToUtcArray(date) {
  560. return [
  561. date.getUTCFullYear(),
  562. date.getUTCMonth(),
  563. date.getUTCDate(),
  564. date.getUTCHours(),
  565. date.getUTCMinutes(),
  566. date.getUTCSeconds(),
  567. date.getUTCMilliseconds()
  568. ];
  569. }
  570. function arrayToUtcDate(a) {
  571. // according to web standards (and Safari), a month index is required.
  572. // massage if only given a year.
  573. if (a.length === 1) {
  574. a = a.concat([0]);
  575. }
  576. return new Date(Date.UTC.apply(Date, a));
  577. }
  578. // Other Utils
  579. function isValidDate(m) {
  580. return !isNaN(m.valueOf());
  581. }
  582. function timeAsMs(m) {
  583. return m.getUTCHours() * 1000 * 60 * 60 +
  584. m.getUTCMinutes() * 1000 * 60 +
  585. m.getUTCSeconds() * 1000 +
  586. m.getUTCMilliseconds();
  587. }
  588. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  589. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  590. // Parsing and Creation
  591. function createDuration(input, unit) {
  592. var _a;
  593. if (typeof input === 'string') {
  594. return parseString(input);
  595. }
  596. else if (typeof input === 'object' && input) { // non-null object
  597. return normalizeObject(input);
  598. }
  599. else if (typeof input === 'number') {
  600. return normalizeObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  601. }
  602. else {
  603. return null;
  604. }
  605. }
  606. function parseString(s) {
  607. var m = PARSE_RE.exec(s);
  608. if (m) {
  609. var sign = m[1] ? -1 : 1;
  610. return {
  611. years: 0,
  612. months: 0,
  613. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  614. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  615. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  616. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  617. (m[6] ? parseInt(m[6], 10) : 0) // ms
  618. )
  619. };
  620. }
  621. return null;
  622. }
  623. function normalizeObject(obj) {
  624. return {
  625. years: obj.years || obj.year || 0,
  626. months: obj.months || obj.month || 0,
  627. days: (obj.days || obj.day || 0) +
  628. getWeeksFromInput(obj) * 7,
  629. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  630. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  631. (obj.seconds || obj.second || 0) * 1000 + // seconds
  632. (obj.milliseconds || obj.millisecond || obj.ms || 0) // ms
  633. };
  634. }
  635. function getWeeksFromInput(obj) {
  636. return obj.weeks || obj.week || 0;
  637. }
  638. // Equality
  639. function durationsEqual(d0, d1) {
  640. return d0.years === d1.years &&
  641. d0.months === d1.months &&
  642. d0.days === d1.days &&
  643. d0.milliseconds === d1.milliseconds;
  644. }
  645. function isSingleDay(dur) {
  646. return dur.years === 0 && dur.months === 0 && dur.days === 1 && dur.milliseconds === 0;
  647. }
  648. // Simple Math
  649. function addDurations(d0, d1) {
  650. return {
  651. years: d0.years + d1.years,
  652. months: d0.months + d1.months,
  653. days: d0.days + d1.days,
  654. milliseconds: d0.milliseconds + d1.milliseconds
  655. };
  656. }
  657. function subtractDurations(d1, d0) {
  658. return {
  659. years: d1.years - d0.years,
  660. months: d1.months - d0.months,
  661. days: d1.days - d0.days,
  662. milliseconds: d1.milliseconds - d0.milliseconds
  663. };
  664. }
  665. function multiplyDuration(d, n) {
  666. return {
  667. years: d.years * n,
  668. months: d.months * n,
  669. days: d.days * n,
  670. milliseconds: d.milliseconds * n
  671. };
  672. }
  673. // Conversions
  674. // "Rough" because they are based on average-case Gregorian months/years
  675. function asRoughYears(dur) {
  676. return asRoughDays(dur) / 365;
  677. }
  678. function asRoughMonths(dur) {
  679. return asRoughDays(dur) / 30;
  680. }
  681. function asRoughDays(dur) {
  682. return asRoughMs(dur) / 864e5;
  683. }
  684. function asRoughMinutes(dur) {
  685. return asRoughMs(dur) / (1000 * 60);
  686. }
  687. function asRoughSeconds(dur) {
  688. return asRoughMs(dur) / 1000;
  689. }
  690. function asRoughMs(dur) {
  691. return dur.years * (365 * 864e5) +
  692. dur.months * (30 * 864e5) +
  693. dur.days * 864e5 +
  694. dur.milliseconds;
  695. }
  696. // Advanced Math
  697. function wholeDivideDurations(numerator, denominator) {
  698. var res = null;
  699. for (var i = 0; i < INTERNAL_UNITS.length; i++) {
  700. var unit = INTERNAL_UNITS[i];
  701. if (denominator[unit]) {
  702. var localRes = numerator[unit] / denominator[unit];
  703. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  704. return null;
  705. }
  706. res = localRes;
  707. }
  708. else if (numerator[unit]) {
  709. // needs to divide by something but can't!
  710. return null;
  711. }
  712. }
  713. return res;
  714. }
  715. function greatestDurationDenominator(dur, dontReturnWeeks) {
  716. var ms = dur.milliseconds;
  717. if (ms) {
  718. if (ms % 1000 !== 0) {
  719. return { unit: 'millisecond', value: ms };
  720. }
  721. if (ms % (1000 * 60) !== 0) {
  722. return { unit: 'second', value: ms / 1000 };
  723. }
  724. if (ms % (1000 * 60 * 60) !== 0) {
  725. return { unit: 'minute', value: ms / (1000 * 60) };
  726. }
  727. if (ms) {
  728. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  729. }
  730. }
  731. if (dur.days) {
  732. if (!dontReturnWeeks && dur.days % 7 === 0) {
  733. return { unit: 'week', value: dur.days / 7 };
  734. }
  735. return { unit: 'day', value: dur.days };
  736. }
  737. if (dur.months) {
  738. return { unit: 'month', value: dur.months };
  739. }
  740. if (dur.years) {
  741. return { unit: 'year', value: dur.years };
  742. }
  743. return { unit: 'millisecond', value: 0 };
  744. }
  745. /* FullCalendar-specific DOM Utilities
  746. ----------------------------------------------------------------------------------------------------------------------*/
  747. // Given the scrollbar widths of some other container, create borders/margins on rowEls in order to match the left
  748. // and right space that was offset by the scrollbars. A 1-pixel border first, then margin beyond that.
  749. function compensateScroll(rowEl, scrollbarWidths) {
  750. if (scrollbarWidths.left) {
  751. applyStyle(rowEl, {
  752. borderLeftWidth: 1,
  753. marginLeft: scrollbarWidths.left - 1
  754. });
  755. }
  756. if (scrollbarWidths.right) {
  757. applyStyle(rowEl, {
  758. borderRightWidth: 1,
  759. marginRight: scrollbarWidths.right - 1
  760. });
  761. }
  762. }
  763. // Undoes compensateScroll and restores all borders/margins
  764. function uncompensateScroll(rowEl) {
  765. applyStyle(rowEl, {
  766. marginLeft: '',
  767. marginRight: '',
  768. borderLeftWidth: '',
  769. borderRightWidth: ''
  770. });
  771. }
  772. // Make the mouse cursor express that an event is not allowed in the current area
  773. function disableCursor() {
  774. document.body.classList.add('fc-not-allowed');
  775. }
  776. // Returns the mouse cursor to its original look
  777. function enableCursor() {
  778. document.body.classList.remove('fc-not-allowed');
  779. }
  780. // Given a total available height to fill, have `els` (essentially child rows) expand to accomodate.
  781. // By default, all elements that are shorter than the recommended height are expanded uniformly, not considering
  782. // any other els that are already too tall. if `shouldRedistribute` is on, it considers these tall rows and
  783. // reduces the available height.
  784. function distributeHeight(els, availableHeight, shouldRedistribute) {
  785. // *FLOORING NOTE*: we floor in certain places because zoom can give inaccurate floating-point dimensions,
  786. // and it is better to be shorter than taller, to avoid creating unnecessary scrollbars.
  787. var minOffset1 = Math.floor(availableHeight / els.length); // for non-last element
  788. var minOffset2 = Math.floor(availableHeight - minOffset1 * (els.length - 1)); // for last element *FLOORING NOTE*
  789. var flexEls = []; // elements that are allowed to expand. array of DOM nodes
  790. var flexOffsets = []; // amount of vertical space it takes up
  791. var flexHeights = []; // actual css height
  792. var usedHeight = 0;
  793. undistributeHeight(els); // give all elements their natural height
  794. // find elements that are below the recommended height (expandable).
  795. // important to query for heights in a single first pass (to avoid reflow oscillation).
  796. els.forEach(function (el, i) {
  797. var minOffset = i === els.length - 1 ? minOffset2 : minOffset1;
  798. var naturalHeight = el.getBoundingClientRect().height;
  799. var naturalOffset = naturalHeight + computeVMargins(el);
  800. if (naturalOffset < minOffset) {
  801. flexEls.push(el);
  802. flexOffsets.push(naturalOffset);
  803. flexHeights.push(naturalHeight);
  804. }
  805. else {
  806. // this element stretches past recommended height (non-expandable). mark the space as occupied.
  807. usedHeight += naturalOffset;
  808. }
  809. });
  810. // readjust the recommended height to only consider the height available to non-maxed-out rows.
  811. if (shouldRedistribute) {
  812. availableHeight -= usedHeight;
  813. minOffset1 = Math.floor(availableHeight / flexEls.length);
  814. minOffset2 = Math.floor(availableHeight - minOffset1 * (flexEls.length - 1)); // *FLOORING NOTE*
  815. }
  816. // assign heights to all expandable elements
  817. flexEls.forEach(function (el, i) {
  818. var minOffset = i === flexEls.length - 1 ? minOffset2 : minOffset1;
  819. var naturalOffset = flexOffsets[i];
  820. var naturalHeight = flexHeights[i];
  821. var newHeight = minOffset - (naturalOffset - naturalHeight); // subtract the margin/padding
  822. if (naturalOffset < minOffset) { // we check this again because redistribution might have changed things
  823. el.style.height = newHeight + 'px';
  824. }
  825. });
  826. }
  827. // Undoes distrubuteHeight, restoring all els to their natural height
  828. function undistributeHeight(els) {
  829. els.forEach(function (el) {
  830. el.style.height = '';
  831. });
  832. }
  833. // Given `els`, a set of <td> cells, find the cell with the largest natural width and set the widths of all the
  834. // cells to be that width.
  835. // PREREQUISITE: if you want a cell to take up width, it needs to have a single inner element w/ display:inline
  836. function matchCellWidths(els) {
  837. var maxInnerWidth = 0;
  838. els.forEach(function (el) {
  839. var innerEl = el.firstChild; // hopefully an element
  840. if (innerEl instanceof HTMLElement) {
  841. var innerWidth_1 = innerEl.getBoundingClientRect().width;
  842. if (innerWidth_1 > maxInnerWidth) {
  843. maxInnerWidth = innerWidth_1;
  844. }
  845. }
  846. });
  847. maxInnerWidth++; // sometimes not accurate of width the text needs to stay on one line. insurance
  848. els.forEach(function (el) {
  849. el.style.width = maxInnerWidth + 'px';
  850. });
  851. return maxInnerWidth;
  852. }
  853. // Given one element that resides inside another,
  854. // Subtracts the height of the inner element from the outer element.
  855. function subtractInnerElHeight(outerEl, innerEl) {
  856. // effin' IE8/9/10/11 sometimes returns 0 for dimensions. this weird hack was the only thing that worked
  857. var reflowStyleProps = {
  858. position: 'relative',
  859. left: -1 // ensure reflow in case the el was already relative. negative is less likely to cause new scroll
  860. };
  861. applyStyle(outerEl, reflowStyleProps);
  862. applyStyle(innerEl, reflowStyleProps);
  863. var diff = // grab the dimensions
  864. outerEl.getBoundingClientRect().height -
  865. innerEl.getBoundingClientRect().height;
  866. // undo hack
  867. var resetStyleProps = { position: '', left: '' };
  868. applyStyle(outerEl, resetStyleProps);
  869. applyStyle(innerEl, resetStyleProps);
  870. return diff;
  871. }
  872. /* Selection
  873. ----------------------------------------------------------------------------------------------------------------------*/
  874. function preventSelection(el) {
  875. el.classList.add('fc-unselectable');
  876. el.addEventListener('selectstart', preventDefault);
  877. }
  878. function allowSelection(el) {
  879. el.classList.remove('fc-unselectable');
  880. el.removeEventListener('selectstart', preventDefault);
  881. }
  882. /* Context Menu
  883. ----------------------------------------------------------------------------------------------------------------------*/
  884. function preventContextMenu(el) {
  885. el.addEventListener('contextmenu', preventDefault);
  886. }
  887. function allowContextMenu(el) {
  888. el.removeEventListener('contextmenu', preventDefault);
  889. }
  890. /* Object Ordering by Field
  891. ----------------------------------------------------------------------------------------------------------------------*/
  892. function parseFieldSpecs(input) {
  893. var specs = [];
  894. var tokens = [];
  895. var i;
  896. var token;
  897. if (typeof input === 'string') {
  898. tokens = input.split(/\s*,\s*/);
  899. }
  900. else if (typeof input === 'function') {
  901. tokens = [input];
  902. }
  903. else if (Array.isArray(input)) {
  904. tokens = input;
  905. }
  906. for (i = 0; i < tokens.length; i++) {
  907. token = tokens[i];
  908. if (typeof token === 'string') {
  909. specs.push(token.charAt(0) === '-' ?
  910. { field: token.substring(1), order: -1 } :
  911. { field: token, order: 1 });
  912. }
  913. else if (typeof token === 'function') {
  914. specs.push({ func: token });
  915. }
  916. }
  917. return specs;
  918. }
  919. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  920. var i;
  921. var cmp;
  922. for (i = 0; i < fieldSpecs.length; i++) {
  923. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  924. if (cmp) {
  925. return cmp;
  926. }
  927. }
  928. return 0;
  929. }
  930. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  931. if (fieldSpec.func) {
  932. return fieldSpec.func(obj0, obj1);
  933. }
  934. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  935. * (fieldSpec.order || 1);
  936. }
  937. function flexibleCompare(a, b) {
  938. if (!a && !b) {
  939. return 0;
  940. }
  941. if (b == null) {
  942. return -1;
  943. }
  944. if (a == null) {
  945. return 1;
  946. }
  947. if (typeof a === 'string' || typeof b === 'string') {
  948. return String(a).localeCompare(String(b));
  949. }
  950. return a - b;
  951. }
  952. /* String Utilities
  953. ----------------------------------------------------------------------------------------------------------------------*/
  954. function capitaliseFirstLetter(str) {
  955. return str.charAt(0).toUpperCase() + str.slice(1);
  956. }
  957. function padStart(val, len) {
  958. var s = String(val);
  959. return '000'.substr(0, len - s.length) + s;
  960. }
  961. /* Number Utilities
  962. ----------------------------------------------------------------------------------------------------------------------*/
  963. function compareNumbers(a, b) {
  964. return a - b;
  965. }
  966. function isInt(n) {
  967. return n % 1 === 0;
  968. }
  969. /* Weird Utilities
  970. ----------------------------------------------------------------------------------------------------------------------*/
  971. function applyAll(functions, thisObj, args) {
  972. if (typeof functions === 'function') { // supplied a single function
  973. functions = [functions];
  974. }
  975. if (functions) {
  976. var i = void 0;
  977. var ret = void 0;
  978. for (i = 0; i < functions.length; i++) {
  979. ret = functions[i].apply(thisObj, args) || ret;
  980. }
  981. return ret;
  982. }
  983. }
  984. function firstDefined() {
  985. var args = [];
  986. for (var _i = 0; _i < arguments.length; _i++) {
  987. args[_i] = arguments[_i];
  988. }
  989. for (var i = 0; i < args.length; i++) {
  990. if (args[i] !== undefined) {
  991. return args[i];
  992. }
  993. }
  994. }
  995. // Returns a function, that, as long as it continues to be invoked, will not
  996. // be triggered. The function will be called after it stops being called for
  997. // N milliseconds. If `immediate` is passed, trigger the function on the
  998. // leading edge, instead of the trailing.
  999. // https://github.com/jashkenas/underscore/blob/1.6.0/underscore.js#L714
  1000. function debounce(func, wait) {
  1001. var timeout;
  1002. var args;
  1003. var context;
  1004. var timestamp;
  1005. var result;
  1006. var later = function () {
  1007. var last = new Date().valueOf() - timestamp;
  1008. if (last < wait) {
  1009. timeout = setTimeout(later, wait - last);
  1010. }
  1011. else {
  1012. timeout = null;
  1013. result = func.apply(context, args);
  1014. context = args = null;
  1015. }
  1016. };
  1017. return function () {
  1018. context = this;
  1019. args = arguments;
  1020. timestamp = new Date().valueOf();
  1021. if (!timeout) {
  1022. timeout = setTimeout(later, wait);
  1023. }
  1024. return result;
  1025. };
  1026. }
  1027. // Number and Boolean are only types that defaults or not computed for
  1028. // TODO: write more comments
  1029. function refineProps(rawProps, processors, defaults, leftoverProps) {
  1030. if (defaults === void 0) { defaults = {}; }
  1031. var refined = {};
  1032. for (var key in processors) {
  1033. var processor = processors[key];
  1034. if (rawProps[key] !== undefined) {
  1035. // found
  1036. if (processor === Function) {
  1037. refined[key] = typeof rawProps[key] === 'function' ? rawProps[key] : null;
  1038. }
  1039. else if (processor) { // a refining function?
  1040. refined[key] = processor(rawProps[key]);
  1041. }
  1042. else {
  1043. refined[key] = rawProps[key];
  1044. }
  1045. }
  1046. else if (defaults[key] !== undefined) {
  1047. // there's an explicit default
  1048. refined[key] = defaults[key];
  1049. }
  1050. else {
  1051. // must compute a default
  1052. if (processor === String) {
  1053. refined[key] = ''; // empty string is default for String
  1054. }
  1055. else if (!processor || processor === Number || processor === Boolean || processor === Function) {
  1056. refined[key] = null; // assign null for other non-custom processor funcs
  1057. }
  1058. else {
  1059. refined[key] = processor(null); // run the custom processor func
  1060. }
  1061. }
  1062. }
  1063. if (leftoverProps) {
  1064. for (var key in rawProps) {
  1065. if (processors[key] === undefined) {
  1066. leftoverProps[key] = rawProps[key];
  1067. }
  1068. }
  1069. }
  1070. return refined;
  1071. }
  1072. /* Date stuff that doesn't belong in datelib core
  1073. ----------------------------------------------------------------------------------------------------------------------*/
  1074. // given a timed range, computes an all-day range that has the same exact duration,
  1075. // but whose start time is aligned with the start of the day.
  1076. function computeAlignedDayRange(timedRange) {
  1077. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  1078. var start = startOfDay(timedRange.start);
  1079. var end = addDays(start, dayCnt);
  1080. return { start: start, end: end };
  1081. }
  1082. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  1083. // TODO: give nextDayThreshold a default arg
  1084. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  1085. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  1086. var startDay = null;
  1087. var endDay = null;
  1088. if (timedRange.end) {
  1089. endDay = startOfDay(timedRange.end);
  1090. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  1091. // If the end time is actually inclusively part of the next day and is equal to or
  1092. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  1093. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  1094. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  1095. endDay = addDays(endDay, 1);
  1096. }
  1097. }
  1098. if (timedRange.start) {
  1099. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  1100. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  1101. if (endDay && endDay <= startDay) {
  1102. endDay = addDays(startDay, 1);
  1103. }
  1104. }
  1105. return { start: startDay, end: endDay };
  1106. }
  1107. // spans from one day into another?
  1108. function isMultiDayRange(range) {
  1109. var visibleRange = computeVisibleDayRange(range);
  1110. return diffDays(visibleRange.start, visibleRange.end) > 1;
  1111. }
  1112. function diffDates(date0, date1, dateEnv, largeUnit) {
  1113. if (largeUnit === 'year') {
  1114. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  1115. }
  1116. else if (largeUnit === 'month') {
  1117. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  1118. }
  1119. else {
  1120. return diffDayAndTime(date0, date1); // returns a duration
  1121. }
  1122. }
  1123. /*! *****************************************************************************
  1124. Copyright (c) Microsoft Corporation.
  1125. Permission to use, copy, modify, and/or distribute this software for any
  1126. purpose with or without fee is hereby granted.
  1127. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  1128. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  1129. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  1130. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  1131. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  1132. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  1133. PERFORMANCE OF THIS SOFTWARE.
  1134. ***************************************************************************** */
  1135. /* global Reflect, Promise */
  1136. var extendStatics = function(d, b) {
  1137. extendStatics = Object.setPrototypeOf ||
  1138. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1139. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1140. return extendStatics(d, b);
  1141. };
  1142. function __extends(d, b) {
  1143. extendStatics(d, b);
  1144. function __() { this.constructor = d; }
  1145. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1146. }
  1147. var __assign = function() {
  1148. __assign = Object.assign || function __assign(t) {
  1149. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1150. s = arguments[i];
  1151. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1152. }
  1153. return t;
  1154. };
  1155. return __assign.apply(this, arguments);
  1156. };
  1157. function parseRecurring(eventInput, allDayDefault, dateEnv, recurringTypes, leftovers) {
  1158. for (var i = 0; i < recurringTypes.length; i++) {
  1159. var localLeftovers = {};
  1160. var parsed = recurringTypes[i].parse(eventInput, localLeftovers, dateEnv);
  1161. if (parsed) {
  1162. var allDay = localLeftovers.allDay;
  1163. delete localLeftovers.allDay; // remove from leftovers
  1164. if (allDay == null) {
  1165. allDay = allDayDefault;
  1166. if (allDay == null) {
  1167. allDay = parsed.allDayGuess;
  1168. if (allDay == null) {
  1169. allDay = false;
  1170. }
  1171. }
  1172. }
  1173. __assign(leftovers, localLeftovers);
  1174. return {
  1175. allDay: allDay,
  1176. duration: parsed.duration,
  1177. typeData: parsed.typeData,
  1178. typeId: i
  1179. };
  1180. }
  1181. }
  1182. return null;
  1183. }
  1184. /*
  1185. Event MUST have a recurringDef
  1186. */
  1187. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  1188. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  1189. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  1190. start: dateEnv.subtract(framingRange.start, duration),
  1191. end: framingRange.end
  1192. }, dateEnv);
  1193. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  1194. if (eventDef.allDay) {
  1195. markers = markers.map(startOfDay);
  1196. }
  1197. return markers;
  1198. }
  1199. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1200. // Merges an array of objects into a single object.
  1201. // The second argument allows for an array of property names who's object values will be merged together.
  1202. function mergeProps(propObjs, complexProps) {
  1203. var dest = {};
  1204. var i;
  1205. var name;
  1206. var complexObjs;
  1207. var j;
  1208. var val;
  1209. var props;
  1210. if (complexProps) {
  1211. for (i = 0; i < complexProps.length; i++) {
  1212. name = complexProps[i];
  1213. complexObjs = [];
  1214. // collect the trailing object values, stopping when a non-object is discovered
  1215. for (j = propObjs.length - 1; j >= 0; j--) {
  1216. val = propObjs[j][name];
  1217. if (typeof val === 'object' && val) { // non-null object
  1218. complexObjs.unshift(val);
  1219. }
  1220. else if (val !== undefined) {
  1221. dest[name] = val; // if there were no objects, this value will be used
  1222. break;
  1223. }
  1224. }
  1225. // if the trailing values were objects, use the merged value
  1226. if (complexObjs.length) {
  1227. dest[name] = mergeProps(complexObjs);
  1228. }
  1229. }
  1230. }
  1231. // copy values into the destination, going from last to first
  1232. for (i = propObjs.length - 1; i >= 0; i--) {
  1233. props = propObjs[i];
  1234. for (name in props) {
  1235. if (!(name in dest)) { // if already assigned by previous props or complex props, don't reassign
  1236. dest[name] = props[name];
  1237. }
  1238. }
  1239. }
  1240. return dest;
  1241. }
  1242. function filterHash(hash, func) {
  1243. var filtered = {};
  1244. for (var key in hash) {
  1245. if (func(hash[key], key)) {
  1246. filtered[key] = hash[key];
  1247. }
  1248. }
  1249. return filtered;
  1250. }
  1251. function mapHash(hash, func) {
  1252. var newHash = {};
  1253. for (var key in hash) {
  1254. newHash[key] = func(hash[key], key);
  1255. }
  1256. return newHash;
  1257. }
  1258. function arrayToHash(a) {
  1259. var hash = {};
  1260. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  1261. var item = a_1[_i];
  1262. hash[item] = true;
  1263. }
  1264. return hash;
  1265. }
  1266. function hashValuesToArray(obj) {
  1267. var a = [];
  1268. for (var key in obj) {
  1269. a.push(obj[key]);
  1270. }
  1271. return a;
  1272. }
  1273. function isPropsEqual(obj0, obj1) {
  1274. for (var key in obj0) {
  1275. if (hasOwnProperty.call(obj0, key)) {
  1276. if (!(key in obj1)) {
  1277. return false;
  1278. }
  1279. }
  1280. }
  1281. for (var key in obj1) {
  1282. if (hasOwnProperty.call(obj1, key)) {
  1283. if (obj0[key] !== obj1[key]) {
  1284. return false;
  1285. }
  1286. }
  1287. }
  1288. return true;
  1289. }
  1290. function parseEvents(rawEvents, sourceId, calendar, allowOpenRange) {
  1291. var eventStore = createEmptyEventStore();
  1292. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1293. var rawEvent = rawEvents_1[_i];
  1294. var tuple = parseEvent(rawEvent, sourceId, calendar, allowOpenRange);
  1295. if (tuple) {
  1296. eventTupleToStore(tuple, eventStore);
  1297. }
  1298. }
  1299. return eventStore;
  1300. }
  1301. function eventTupleToStore(tuple, eventStore) {
  1302. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1303. eventStore.defs[tuple.def.defId] = tuple.def;
  1304. if (tuple.instance) {
  1305. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1306. }
  1307. return eventStore;
  1308. }
  1309. function expandRecurring(eventStore, framingRange, calendar) {
  1310. var dateEnv = calendar.dateEnv;
  1311. var defs = eventStore.defs, instances = eventStore.instances;
  1312. // remove existing recurring instances
  1313. instances = filterHash(instances, function (instance) {
  1314. return !defs[instance.defId].recurringDef;
  1315. });
  1316. for (var defId in defs) {
  1317. var def = defs[defId];
  1318. if (def.recurringDef) {
  1319. var duration = def.recurringDef.duration;
  1320. if (!duration) {
  1321. duration = def.allDay ?
  1322. calendar.defaultAllDayEventDuration :
  1323. calendar.defaultTimedEventDuration;
  1324. }
  1325. var starts = expandRecurringRanges(def, duration, framingRange, calendar.dateEnv, calendar.pluginSystem.hooks.recurringTypes);
  1326. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  1327. var start = starts_1[_i];
  1328. var instance = createEventInstance(defId, {
  1329. start: start,
  1330. end: dateEnv.add(start, duration)
  1331. });
  1332. instances[instance.instanceId] = instance;
  1333. }
  1334. }
  1335. }
  1336. return { defs: defs, instances: instances };
  1337. }
  1338. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1339. // or they are the same as the instance.
  1340. // why might instanceId not be in the store? an event from another calendar?
  1341. function getRelevantEvents(eventStore, instanceId) {
  1342. var instance = eventStore.instances[instanceId];
  1343. if (instance) {
  1344. var def_1 = eventStore.defs[instance.defId];
  1345. // get events/instances with same group
  1346. var newStore = filterEventStoreDefs(eventStore, function (lookDef) {
  1347. return isEventDefsGrouped(def_1, lookDef);
  1348. });
  1349. // add the original
  1350. // TODO: wish we could use eventTupleToStore or something like it
  1351. newStore.defs[def_1.defId] = def_1;
  1352. newStore.instances[instance.instanceId] = instance;
  1353. return newStore;
  1354. }
  1355. return createEmptyEventStore();
  1356. }
  1357. function isEventDefsGrouped(def0, def1) {
  1358. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1359. }
  1360. function transformRawEvents(rawEvents, eventSource, calendar) {
  1361. var calEachTransform = calendar.opt('eventDataTransform');
  1362. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  1363. if (sourceEachTransform) {
  1364. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  1365. }
  1366. if (calEachTransform) {
  1367. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  1368. }
  1369. return rawEvents;
  1370. }
  1371. function transformEachRawEvent(rawEvents, func) {
  1372. var refinedEvents;
  1373. if (!func) {
  1374. refinedEvents = rawEvents;
  1375. }
  1376. else {
  1377. refinedEvents = [];
  1378. for (var _i = 0, rawEvents_2 = rawEvents; _i < rawEvents_2.length; _i++) {
  1379. var rawEvent = rawEvents_2[_i];
  1380. var refinedEvent = func(rawEvent);
  1381. if (refinedEvent) {
  1382. refinedEvents.push(refinedEvent);
  1383. }
  1384. else if (refinedEvent == null) {
  1385. refinedEvents.push(rawEvent);
  1386. } // if a different falsy value, do nothing
  1387. }
  1388. }
  1389. return refinedEvents;
  1390. }
  1391. function createEmptyEventStore() {
  1392. return { defs: {}, instances: {} };
  1393. }
  1394. function mergeEventStores(store0, store1) {
  1395. return {
  1396. defs: __assign({}, store0.defs, store1.defs),
  1397. instances: __assign({}, store0.instances, store1.instances)
  1398. };
  1399. }
  1400. function filterEventStoreDefs(eventStore, filterFunc) {
  1401. var defs = filterHash(eventStore.defs, filterFunc);
  1402. var instances = filterHash(eventStore.instances, function (instance) {
  1403. return defs[instance.defId]; // still exists?
  1404. });
  1405. return { defs: defs, instances: instances };
  1406. }
  1407. function parseRange(input, dateEnv) {
  1408. var start = null;
  1409. var end = null;
  1410. if (input.start) {
  1411. start = dateEnv.createMarker(input.start);
  1412. }
  1413. if (input.end) {
  1414. end = dateEnv.createMarker(input.end);
  1415. }
  1416. if (!start && !end) {
  1417. return null;
  1418. }
  1419. if (start && end && end < start) {
  1420. return null;
  1421. }
  1422. return { start: start, end: end };
  1423. }
  1424. // SIDE-EFFECT: will mutate ranges.
  1425. // Will return a new array result.
  1426. function invertRanges(ranges, constraintRange) {
  1427. var invertedRanges = [];
  1428. var start = constraintRange.start; // the end of the previous range. the start of the new range
  1429. var i;
  1430. var dateRange;
  1431. // ranges need to be in order. required for our date-walking algorithm
  1432. ranges.sort(compareRanges);
  1433. for (i = 0; i < ranges.length; i++) {
  1434. dateRange = ranges[i];
  1435. // add the span of time before the event (if there is any)
  1436. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  1437. invertedRanges.push({ start: start, end: dateRange.start });
  1438. }
  1439. if (dateRange.end > start) {
  1440. start = dateRange.end;
  1441. }
  1442. }
  1443. // add the span of time after the last event (if there is any)
  1444. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  1445. invertedRanges.push({ start: start, end: constraintRange.end });
  1446. }
  1447. return invertedRanges;
  1448. }
  1449. function compareRanges(range0, range1) {
  1450. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  1451. }
  1452. function intersectRanges(range0, range1) {
  1453. var start = range0.start;
  1454. var end = range0.end;
  1455. var newRange = null;
  1456. if (range1.start !== null) {
  1457. if (start === null) {
  1458. start = range1.start;
  1459. }
  1460. else {
  1461. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  1462. }
  1463. }
  1464. if (range1.end != null) {
  1465. if (end === null) {
  1466. end = range1.end;
  1467. }
  1468. else {
  1469. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  1470. }
  1471. }
  1472. if (start === null || end === null || start < end) {
  1473. newRange = { start: start, end: end };
  1474. }
  1475. return newRange;
  1476. }
  1477. function rangesEqual(range0, range1) {
  1478. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  1479. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  1480. }
  1481. function rangesIntersect(range0, range1) {
  1482. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  1483. (range0.start === null || range1.end === null || range0.start < range1.end);
  1484. }
  1485. function rangeContainsRange(outerRange, innerRange) {
  1486. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  1487. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  1488. }
  1489. function rangeContainsMarker(range, date) {
  1490. return (range.start === null || date >= range.start) &&
  1491. (range.end === null || date < range.end);
  1492. }
  1493. // If the given date is not within the given range, move it inside.
  1494. // (If it's past the end, make it one millisecond before the end).
  1495. function constrainMarkerToRange(date, range) {
  1496. if (range.start != null && date < range.start) {
  1497. return range.start;
  1498. }
  1499. if (range.end != null && date >= range.end) {
  1500. return new Date(range.end.valueOf() - 1);
  1501. }
  1502. return date;
  1503. }
  1504. function removeExact(array, exactVal) {
  1505. var removeCnt = 0;
  1506. var i = 0;
  1507. while (i < array.length) {
  1508. if (array[i] === exactVal) {
  1509. array.splice(i, 1);
  1510. removeCnt++;
  1511. }
  1512. else {
  1513. i++;
  1514. }
  1515. }
  1516. return removeCnt;
  1517. }
  1518. function isArraysEqual(a0, a1) {
  1519. var len = a0.length;
  1520. var i;
  1521. if (len !== a1.length) { // not array? or not same length?
  1522. return false;
  1523. }
  1524. for (i = 0; i < len; i++) {
  1525. if (a0[i] !== a1[i]) {
  1526. return false;
  1527. }
  1528. }
  1529. return true;
  1530. }
  1531. function memoize(workerFunc) {
  1532. var args;
  1533. var res;
  1534. return function () {
  1535. if (!args || !isArraysEqual(args, arguments)) {
  1536. args = arguments;
  1537. res = workerFunc.apply(this, arguments);
  1538. }
  1539. return res;
  1540. };
  1541. }
  1542. /*
  1543. always executes the workerFunc, but if the result is equal to the previous result,
  1544. return the previous result instead.
  1545. */
  1546. function memoizeOutput(workerFunc, equalityFunc) {
  1547. var cachedRes = null;
  1548. return function () {
  1549. var newRes = workerFunc.apply(this, arguments);
  1550. if (cachedRes === null || !(cachedRes === newRes || equalityFunc(cachedRes, newRes))) {
  1551. cachedRes = newRes;
  1552. }
  1553. return cachedRes;
  1554. };
  1555. }
  1556. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1557. week: 3,
  1558. separator: 0,
  1559. omitZeroMinute: 0,
  1560. meridiem: 0,
  1561. omitCommas: 0
  1562. };
  1563. var STANDARD_DATE_PROP_SEVERITIES = {
  1564. timeZoneName: 7,
  1565. era: 6,
  1566. year: 5,
  1567. month: 4,
  1568. day: 2,
  1569. weekday: 2,
  1570. hour: 1,
  1571. minute: 1,
  1572. second: 1
  1573. };
  1574. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1575. var COMMA_RE = /,/g; // we need re for globalness
  1576. var MULTI_SPACE_RE = /\s+/g;
  1577. var LTR_RE = /\u200e/g; // control character
  1578. var UTC_RE = /UTC|GMT/;
  1579. var NativeFormatter = /** @class */ (function () {
  1580. function NativeFormatter(formatSettings) {
  1581. var standardDateProps = {};
  1582. var extendedSettings = {};
  1583. var severity = 0;
  1584. for (var name_1 in formatSettings) {
  1585. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1586. extendedSettings[name_1] = formatSettings[name_1];
  1587. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1588. }
  1589. else {
  1590. standardDateProps[name_1] = formatSettings[name_1];
  1591. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) {
  1592. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1593. }
  1594. }
  1595. }
  1596. this.standardDateProps = standardDateProps;
  1597. this.extendedSettings = extendedSettings;
  1598. this.severity = severity;
  1599. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1600. }
  1601. NativeFormatter.prototype.format = function (date, context) {
  1602. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1603. };
  1604. NativeFormatter.prototype.formatRange = function (start, end, context) {
  1605. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1606. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1607. if (!diffSeverity) {
  1608. return this.format(start, context);
  1609. }
  1610. var biggestUnitForPartial = diffSeverity;
  1611. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1612. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1613. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1614. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1615. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1616. }
  1617. var full0 = this.format(start, context);
  1618. var full1 = this.format(end, context);
  1619. if (full0 === full1) {
  1620. return full0;
  1621. }
  1622. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1623. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1624. var partial0 = partialFormattingFunc(start);
  1625. var partial1 = partialFormattingFunc(end);
  1626. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1627. var separator = extendedSettings.separator || '';
  1628. if (insertion) {
  1629. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1630. }
  1631. return full0 + separator + full1;
  1632. };
  1633. NativeFormatter.prototype.getLargestUnit = function () {
  1634. switch (this.severity) {
  1635. case 7:
  1636. case 6:
  1637. case 5:
  1638. return 'year';
  1639. case 4:
  1640. return 'month';
  1641. case 3:
  1642. return 'week';
  1643. default:
  1644. return 'day';
  1645. }
  1646. };
  1647. return NativeFormatter;
  1648. }());
  1649. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1650. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1651. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1652. return function (date) {
  1653. return formatTimeZoneOffset(date.timeZoneOffset);
  1654. };
  1655. }
  1656. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1657. return function (date) {
  1658. return formatWeekNumber(context.computeWeekNumber(date.marker), context.weekLabel, context.locale, extendedSettings.week);
  1659. };
  1660. }
  1661. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1662. }
  1663. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1664. standardDateProps = __assign({}, standardDateProps); // copy
  1665. extendedSettings = __assign({}, extendedSettings); // copy
  1666. sanitizeSettings(standardDateProps, extendedSettings);
  1667. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1668. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1669. var zeroFormat; // needed?
  1670. if (extendedSettings.omitZeroMinute) {
  1671. var zeroProps = __assign({}, standardDateProps);
  1672. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1673. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1674. }
  1675. return function (date) {
  1676. var marker = date.marker;
  1677. var format;
  1678. if (zeroFormat && !marker.getUTCMinutes()) {
  1679. format = zeroFormat;
  1680. }
  1681. else {
  1682. format = normalFormat;
  1683. }
  1684. var s = format.format(marker);
  1685. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1686. };
  1687. }
  1688. function sanitizeSettings(standardDateProps, extendedSettings) {
  1689. // deal with a browser inconsistency where formatting the timezone
  1690. // requires that the hour/minute be present.
  1691. if (standardDateProps.timeZoneName) {
  1692. if (!standardDateProps.hour) {
  1693. standardDateProps.hour = '2-digit';
  1694. }
  1695. if (!standardDateProps.minute) {
  1696. standardDateProps.minute = '2-digit';
  1697. }
  1698. }
  1699. // only support short timezone names
  1700. if (standardDateProps.timeZoneName === 'long') {
  1701. standardDateProps.timeZoneName = 'short';
  1702. }
  1703. // if requesting to display seconds, MUST display minutes
  1704. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1705. delete extendedSettings.omitZeroMinute;
  1706. }
  1707. }
  1708. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1709. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1710. if (standardDateProps.timeZoneName === 'short') {
  1711. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1712. 'UTC' : // important to normalize for IE, which does "GMT"
  1713. formatTimeZoneOffset(date.timeZoneOffset));
  1714. }
  1715. if (extendedSettings.omitCommas) {
  1716. s = s.replace(COMMA_RE, '').trim();
  1717. }
  1718. if (extendedSettings.omitZeroMinute) {
  1719. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1720. }
  1721. // ^ do anything that might create adjacent spaces before this point,
  1722. // because MERIDIEM_RE likes to eat up loading spaces
  1723. if (extendedSettings.meridiem === false) {
  1724. s = s.replace(MERIDIEM_RE, '').trim();
  1725. }
  1726. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1727. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1728. return m1.toLocaleLowerCase();
  1729. });
  1730. }
  1731. else if (extendedSettings.meridiem === 'short') { // am/pm
  1732. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1733. return m1.toLocaleLowerCase() + 'm';
  1734. });
  1735. }
  1736. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1737. s = s.replace(MERIDIEM_RE, function (m0) {
  1738. return m0.toLocaleLowerCase();
  1739. });
  1740. }
  1741. s = s.replace(MULTI_SPACE_RE, ' ');
  1742. s = s.trim();
  1743. return s;
  1744. }
  1745. function injectTzoStr(s, tzoStr) {
  1746. var replaced = false;
  1747. s = s.replace(UTC_RE, function () {
  1748. replaced = true;
  1749. return tzoStr;
  1750. });
  1751. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1752. if (!replaced) {
  1753. s += ' ' + tzoStr;
  1754. }
  1755. return s;
  1756. }
  1757. function formatWeekNumber(num, weekLabel, locale, display) {
  1758. var parts = [];
  1759. if (display === 'narrow') {
  1760. parts.push(weekLabel);
  1761. }
  1762. else if (display === 'short') {
  1763. parts.push(weekLabel, ' ');
  1764. }
  1765. // otherwise, considered 'numeric'
  1766. parts.push(locale.simpleNumberFormat.format(num));
  1767. if (locale.options.isRtl) { // TODO: use control characters instead?
  1768. parts.reverse();
  1769. }
  1770. return parts.join('');
  1771. }
  1772. // Range Formatting Utils
  1773. // 0 = exactly the same
  1774. // 1 = different by time
  1775. // and bigger
  1776. function computeMarkerDiffSeverity(d0, d1, ca) {
  1777. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1778. return 5;
  1779. }
  1780. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1781. return 4;
  1782. }
  1783. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1784. return 2;
  1785. }
  1786. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1787. return 1;
  1788. }
  1789. return 0;
  1790. }
  1791. function computePartialFormattingOptions(options, biggestUnit) {
  1792. var partialOptions = {};
  1793. for (var name_2 in options) {
  1794. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1795. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1796. partialOptions[name_2] = options[name_2];
  1797. }
  1798. }
  1799. return partialOptions;
  1800. }
  1801. function findCommonInsertion(full0, partial0, full1, partial1) {
  1802. var i0 = 0;
  1803. while (i0 < full0.length) {
  1804. var found0 = full0.indexOf(partial0, i0);
  1805. if (found0 === -1) {
  1806. break;
  1807. }
  1808. var before0 = full0.substr(0, found0);
  1809. i0 = found0 + partial0.length;
  1810. var after0 = full0.substr(i0);
  1811. var i1 = 0;
  1812. while (i1 < full1.length) {
  1813. var found1 = full1.indexOf(partial1, i1);
  1814. if (found1 === -1) {
  1815. break;
  1816. }
  1817. var before1 = full1.substr(0, found1);
  1818. i1 = found1 + partial1.length;
  1819. var after1 = full1.substr(i1);
  1820. if (before0 === before1 && after0 === after1) {
  1821. return {
  1822. before: before0,
  1823. after: after0
  1824. };
  1825. }
  1826. }
  1827. }
  1828. return null;
  1829. }
  1830. /*
  1831. TODO: fix the terminology of "formatter" vs "formatting func"
  1832. */
  1833. /*
  1834. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1835. It receives this at the time of formatting, as a setting.
  1836. */
  1837. var CmdFormatter = /** @class */ (function () {
  1838. function CmdFormatter(cmdStr, separator) {
  1839. this.cmdStr = cmdStr;
  1840. this.separator = separator;
  1841. }
  1842. CmdFormatter.prototype.format = function (date, context) {
  1843. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, this.separator));
  1844. };
  1845. CmdFormatter.prototype.formatRange = function (start, end, context) {
  1846. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, this.separator));
  1847. };
  1848. return CmdFormatter;
  1849. }());
  1850. var FuncFormatter = /** @class */ (function () {
  1851. function FuncFormatter(func) {
  1852. this.func = func;
  1853. }
  1854. FuncFormatter.prototype.format = function (date, context) {
  1855. return this.func(createVerboseFormattingArg(date, null, context));
  1856. };
  1857. FuncFormatter.prototype.formatRange = function (start, end, context) {
  1858. return this.func(createVerboseFormattingArg(start, end, context));
  1859. };
  1860. return FuncFormatter;
  1861. }());
  1862. // Formatter Object Creation
  1863. function createFormatter(input, defaultSeparator) {
  1864. if (typeof input === 'object' && input) { // non-null object
  1865. if (typeof defaultSeparator === 'string') {
  1866. input = __assign({ separator: defaultSeparator }, input);
  1867. }
  1868. return new NativeFormatter(input);
  1869. }
  1870. else if (typeof input === 'string') {
  1871. return new CmdFormatter(input, defaultSeparator);
  1872. }
  1873. else if (typeof input === 'function') {
  1874. return new FuncFormatter(input);
  1875. }
  1876. }
  1877. // String Utils
  1878. // timeZoneOffset is in minutes
  1879. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  1880. if (stripZeroTime === void 0) { stripZeroTime = false; }
  1881. var s = marker.toISOString();
  1882. s = s.replace('.000', '');
  1883. if (stripZeroTime) {
  1884. s = s.replace('T00:00:00Z', '');
  1885. }
  1886. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  1887. if (timeZoneOffset == null) {
  1888. s = s.replace('Z', '');
  1889. }
  1890. else if (timeZoneOffset !== 0) {
  1891. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  1892. }
  1893. // otherwise, its UTC-0 and we want to keep the Z
  1894. }
  1895. return s;
  1896. }
  1897. function formatIsoTimeString(marker) {
  1898. return padStart(marker.getUTCHours(), 2) + ':' +
  1899. padStart(marker.getUTCMinutes(), 2) + ':' +
  1900. padStart(marker.getUTCSeconds(), 2);
  1901. }
  1902. function formatTimeZoneOffset(minutes, doIso) {
  1903. if (doIso === void 0) { doIso = false; }
  1904. var sign = minutes < 0 ? '-' : '+';
  1905. var abs = Math.abs(minutes);
  1906. var hours = Math.floor(abs / 60);
  1907. var mins = Math.round(abs % 60);
  1908. if (doIso) {
  1909. return sign + padStart(hours, 2) + ':' + padStart(mins, 2);
  1910. }
  1911. else {
  1912. return 'GMT' + sign + hours + (mins ? ':' + padStart(mins, 2) : '');
  1913. }
  1914. }
  1915. // Arg Utils
  1916. function createVerboseFormattingArg(start, end, context, separator) {
  1917. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1918. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1919. return {
  1920. date: startInfo,
  1921. start: startInfo,
  1922. end: endInfo,
  1923. timeZone: context.timeZone,
  1924. localeCodes: context.locale.codes,
  1925. separator: separator
  1926. };
  1927. }
  1928. function expandZonedMarker(dateInfo, calendarSystem) {
  1929. var a = calendarSystem.markerToArray(dateInfo.marker);
  1930. return {
  1931. marker: dateInfo.marker,
  1932. timeZoneOffset: dateInfo.timeZoneOffset,
  1933. array: a,
  1934. year: a[0],
  1935. month: a[1],
  1936. day: a[2],
  1937. hour: a[3],
  1938. minute: a[4],
  1939. second: a[5],
  1940. millisecond: a[6]
  1941. };
  1942. }
  1943. var EventSourceApi = /** @class */ (function () {
  1944. function EventSourceApi(calendar, internalEventSource) {
  1945. this.calendar = calendar;
  1946. this.internalEventSource = internalEventSource;
  1947. }
  1948. EventSourceApi.prototype.remove = function () {
  1949. this.calendar.dispatch({
  1950. type: 'REMOVE_EVENT_SOURCE',
  1951. sourceId: this.internalEventSource.sourceId
  1952. });
  1953. };
  1954. EventSourceApi.prototype.refetch = function () {
  1955. this.calendar.dispatch({
  1956. type: 'FETCH_EVENT_SOURCES',
  1957. sourceIds: [this.internalEventSource.sourceId]
  1958. });
  1959. };
  1960. Object.defineProperty(EventSourceApi.prototype, "id", {
  1961. get: function () {
  1962. return this.internalEventSource.publicId;
  1963. },
  1964. enumerable: true,
  1965. configurable: true
  1966. });
  1967. Object.defineProperty(EventSourceApi.prototype, "url", {
  1968. // only relevant to json-feed event sources
  1969. get: function () {
  1970. return this.internalEventSource.meta.url;
  1971. },
  1972. enumerable: true,
  1973. configurable: true
  1974. });
  1975. return EventSourceApi;
  1976. }());
  1977. var EventApi = /** @class */ (function () {
  1978. function EventApi(calendar, def, instance) {
  1979. this._calendar = calendar;
  1980. this._def = def;
  1981. this._instance = instance || null;
  1982. }
  1983. /*
  1984. TODO: make event struct more responsible for this
  1985. */
  1986. EventApi.prototype.setProp = function (name, val) {
  1987. var _a, _b;
  1988. if (name in DATE_PROPS) ;
  1989. else if (name in NON_DATE_PROPS) {
  1990. if (typeof NON_DATE_PROPS[name] === 'function') {
  1991. val = NON_DATE_PROPS[name](val);
  1992. }
  1993. this.mutate({
  1994. standardProps: (_a = {}, _a[name] = val, _a)
  1995. });
  1996. }
  1997. else if (name in UNSCOPED_EVENT_UI_PROPS) {
  1998. var ui = void 0;
  1999. if (typeof UNSCOPED_EVENT_UI_PROPS[name] === 'function') {
  2000. val = UNSCOPED_EVENT_UI_PROPS[name](val);
  2001. }
  2002. if (name === 'color') {
  2003. ui = { backgroundColor: val, borderColor: val };
  2004. }
  2005. else if (name === 'editable') {
  2006. ui = { startEditable: val, durationEditable: val };
  2007. }
  2008. else {
  2009. ui = (_b = {}, _b[name] = val, _b);
  2010. }
  2011. this.mutate({
  2012. standardProps: { ui: ui }
  2013. });
  2014. }
  2015. };
  2016. EventApi.prototype.setExtendedProp = function (name, val) {
  2017. var _a;
  2018. this.mutate({
  2019. extendedProps: (_a = {}, _a[name] = val, _a)
  2020. });
  2021. };
  2022. EventApi.prototype.setStart = function (startInput, options) {
  2023. if (options === void 0) { options = {}; }
  2024. var dateEnv = this._calendar.dateEnv;
  2025. var start = dateEnv.createMarker(startInput);
  2026. if (start && this._instance) { // TODO: warning if parsed bad
  2027. var instanceRange = this._instance.range;
  2028. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  2029. if (options.maintainDuration) {
  2030. this.mutate({ datesDelta: startDelta });
  2031. }
  2032. else {
  2033. this.mutate({ startDelta: startDelta });
  2034. }
  2035. }
  2036. };
  2037. EventApi.prototype.setEnd = function (endInput, options) {
  2038. if (options === void 0) { options = {}; }
  2039. var dateEnv = this._calendar.dateEnv;
  2040. var end;
  2041. if (endInput != null) {
  2042. end = dateEnv.createMarker(endInput);
  2043. if (!end) {
  2044. return; // TODO: warning if parsed bad
  2045. }
  2046. }
  2047. if (this._instance) {
  2048. if (end) {
  2049. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  2050. this.mutate({ endDelta: endDelta });
  2051. }
  2052. else {
  2053. this.mutate({ standardProps: { hasEnd: false } });
  2054. }
  2055. }
  2056. };
  2057. EventApi.prototype.setDates = function (startInput, endInput, options) {
  2058. if (options === void 0) { options = {}; }
  2059. var dateEnv = this._calendar.dateEnv;
  2060. var standardProps = { allDay: options.allDay };
  2061. var start = dateEnv.createMarker(startInput);
  2062. var end;
  2063. if (!start) {
  2064. return; // TODO: warning if parsed bad
  2065. }
  2066. if (endInput != null) {
  2067. end = dateEnv.createMarker(endInput);
  2068. if (!end) { // TODO: warning if parsed bad
  2069. return;
  2070. }
  2071. }
  2072. if (this._instance) {
  2073. var instanceRange = this._instance.range;
  2074. // when computing the diff for an event being converted to all-day,
  2075. // compute diff off of the all-day values the way event-mutation does.
  2076. if (options.allDay === true) {
  2077. instanceRange = computeAlignedDayRange(instanceRange);
  2078. }
  2079. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  2080. if (end) {
  2081. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  2082. if (durationsEqual(startDelta, endDelta)) {
  2083. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  2084. }
  2085. else {
  2086. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  2087. }
  2088. }
  2089. else { // means "clear the end"
  2090. standardProps.hasEnd = false;
  2091. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  2092. }
  2093. }
  2094. };
  2095. EventApi.prototype.moveStart = function (deltaInput) {
  2096. var delta = createDuration(deltaInput);
  2097. if (delta) { // TODO: warning if parsed bad
  2098. this.mutate({ startDelta: delta });
  2099. }
  2100. };
  2101. EventApi.prototype.moveEnd = function (deltaInput) {
  2102. var delta = createDuration(deltaInput);
  2103. if (delta) { // TODO: warning if parsed bad
  2104. this.mutate({ endDelta: delta });
  2105. }
  2106. };
  2107. EventApi.prototype.moveDates = function (deltaInput) {
  2108. var delta = createDuration(deltaInput);
  2109. if (delta) { // TODO: warning if parsed bad
  2110. this.mutate({ datesDelta: delta });
  2111. }
  2112. };
  2113. EventApi.prototype.setAllDay = function (allDay, options) {
  2114. if (options === void 0) { options = {}; }
  2115. var standardProps = { allDay: allDay };
  2116. var maintainDuration = options.maintainDuration;
  2117. if (maintainDuration == null) {
  2118. maintainDuration = this._calendar.opt('allDayMaintainDuration');
  2119. }
  2120. if (this._def.allDay !== allDay) {
  2121. standardProps.hasEnd = maintainDuration;
  2122. }
  2123. this.mutate({ standardProps: standardProps });
  2124. };
  2125. EventApi.prototype.formatRange = function (formatInput) {
  2126. var dateEnv = this._calendar.dateEnv;
  2127. var instance = this._instance;
  2128. var formatter = createFormatter(formatInput, this._calendar.opt('defaultRangeSeparator'));
  2129. if (this._def.hasEnd) {
  2130. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  2131. forcedStartTzo: instance.forcedStartTzo,
  2132. forcedEndTzo: instance.forcedEndTzo
  2133. });
  2134. }
  2135. else {
  2136. return dateEnv.format(instance.range.start, formatter, {
  2137. forcedTzo: instance.forcedStartTzo
  2138. });
  2139. }
  2140. };
  2141. EventApi.prototype.mutate = function (mutation) {
  2142. var def = this._def;
  2143. var instance = this._instance;
  2144. if (instance) {
  2145. this._calendar.dispatch({
  2146. type: 'MUTATE_EVENTS',
  2147. instanceId: instance.instanceId,
  2148. mutation: mutation,
  2149. fromApi: true
  2150. });
  2151. var eventStore = this._calendar.state.eventStore;
  2152. this._def = eventStore.defs[def.defId];
  2153. this._instance = eventStore.instances[instance.instanceId];
  2154. }
  2155. };
  2156. EventApi.prototype.remove = function () {
  2157. this._calendar.dispatch({
  2158. type: 'REMOVE_EVENT_DEF',
  2159. defId: this._def.defId
  2160. });
  2161. };
  2162. Object.defineProperty(EventApi.prototype, "source", {
  2163. get: function () {
  2164. var sourceId = this._def.sourceId;
  2165. if (sourceId) {
  2166. return new EventSourceApi(this._calendar, this._calendar.state.eventSources[sourceId]);
  2167. }
  2168. return null;
  2169. },
  2170. enumerable: true,
  2171. configurable: true
  2172. });
  2173. Object.defineProperty(EventApi.prototype, "start", {
  2174. get: function () {
  2175. return this._instance ?
  2176. this._calendar.dateEnv.toDate(this._instance.range.start) :
  2177. null;
  2178. },
  2179. enumerable: true,
  2180. configurable: true
  2181. });
  2182. Object.defineProperty(EventApi.prototype, "end", {
  2183. get: function () {
  2184. return (this._instance && this._def.hasEnd) ?
  2185. this._calendar.dateEnv.toDate(this._instance.range.end) :
  2186. null;
  2187. },
  2188. enumerable: true,
  2189. configurable: true
  2190. });
  2191. Object.defineProperty(EventApi.prototype, "id", {
  2192. // computable props that all access the def
  2193. // TODO: find a TypeScript-compatible way to do this at scale
  2194. get: function () { return this._def.publicId; },
  2195. enumerable: true,
  2196. configurable: true
  2197. });
  2198. Object.defineProperty(EventApi.prototype, "groupId", {
  2199. get: function () { return this._def.groupId; },
  2200. enumerable: true,
  2201. configurable: true
  2202. });
  2203. Object.defineProperty(EventApi.prototype, "allDay", {
  2204. get: function () { return this._def.allDay; },
  2205. enumerable: true,
  2206. configurable: true
  2207. });
  2208. Object.defineProperty(EventApi.prototype, "title", {
  2209. get: function () { return this._def.title; },
  2210. enumerable: true,
  2211. configurable: true
  2212. });
  2213. Object.defineProperty(EventApi.prototype, "url", {
  2214. get: function () { return this._def.url; },
  2215. enumerable: true,
  2216. configurable: true
  2217. });
  2218. Object.defineProperty(EventApi.prototype, "rendering", {
  2219. get: function () { return this._def.rendering; },
  2220. enumerable: true,
  2221. configurable: true
  2222. });
  2223. Object.defineProperty(EventApi.prototype, "startEditable", {
  2224. get: function () { return this._def.ui.startEditable; },
  2225. enumerable: true,
  2226. configurable: true
  2227. });
  2228. Object.defineProperty(EventApi.prototype, "durationEditable", {
  2229. get: function () { return this._def.ui.durationEditable; },
  2230. enumerable: true,
  2231. configurable: true
  2232. });
  2233. Object.defineProperty(EventApi.prototype, "constraint", {
  2234. get: function () { return this._def.ui.constraints[0] || null; },
  2235. enumerable: true,
  2236. configurable: true
  2237. });
  2238. Object.defineProperty(EventApi.prototype, "overlap", {
  2239. get: function () { return this._def.ui.overlap; },
  2240. enumerable: true,
  2241. configurable: true
  2242. });
  2243. Object.defineProperty(EventApi.prototype, "allow", {
  2244. get: function () { return this._def.ui.allows[0] || null; },
  2245. enumerable: true,
  2246. configurable: true
  2247. });
  2248. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  2249. get: function () { return this._def.ui.backgroundColor; },
  2250. enumerable: true,
  2251. configurable: true
  2252. });
  2253. Object.defineProperty(EventApi.prototype, "borderColor", {
  2254. get: function () { return this._def.ui.borderColor; },
  2255. enumerable: true,
  2256. configurable: true
  2257. });
  2258. Object.defineProperty(EventApi.prototype, "textColor", {
  2259. get: function () { return this._def.ui.textColor; },
  2260. enumerable: true,
  2261. configurable: true
  2262. });
  2263. Object.defineProperty(EventApi.prototype, "classNames", {
  2264. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  2265. get: function () { return this._def.ui.classNames; },
  2266. enumerable: true,
  2267. configurable: true
  2268. });
  2269. Object.defineProperty(EventApi.prototype, "extendedProps", {
  2270. get: function () { return this._def.extendedProps; },
  2271. enumerable: true,
  2272. configurable: true
  2273. });
  2274. return EventApi;
  2275. }());
  2276. /*
  2277. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2278. */
  2279. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2280. var inverseBgByGroupId = {};
  2281. var inverseBgByDefId = {};
  2282. var defByGroupId = {};
  2283. var bgRanges = [];
  2284. var fgRanges = [];
  2285. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2286. for (var defId in eventStore.defs) {
  2287. var def = eventStore.defs[defId];
  2288. if (def.rendering === 'inverse-background') {
  2289. if (def.groupId) {
  2290. inverseBgByGroupId[def.groupId] = [];
  2291. if (!defByGroupId[def.groupId]) {
  2292. defByGroupId[def.groupId] = def;
  2293. }
  2294. }
  2295. else {
  2296. inverseBgByDefId[defId] = [];
  2297. }
  2298. }
  2299. }
  2300. for (var instanceId in eventStore.instances) {
  2301. var instance = eventStore.instances[instanceId];
  2302. var def = eventStore.defs[instance.defId];
  2303. var ui = eventUis[def.defId];
  2304. var origRange = instance.range;
  2305. var normalRange = (!def.allDay && nextDayThreshold) ?
  2306. computeVisibleDayRange(origRange, nextDayThreshold) :
  2307. origRange;
  2308. var slicedRange = intersectRanges(normalRange, framingRange);
  2309. if (slicedRange) {
  2310. if (def.rendering === 'inverse-background') {
  2311. if (def.groupId) {
  2312. inverseBgByGroupId[def.groupId].push(slicedRange);
  2313. }
  2314. else {
  2315. inverseBgByDefId[instance.defId].push(slicedRange);
  2316. }
  2317. }
  2318. else {
  2319. (def.rendering === 'background' ? bgRanges : fgRanges).push({
  2320. def: def,
  2321. ui: ui,
  2322. instance: instance,
  2323. range: slicedRange,
  2324. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2325. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf()
  2326. });
  2327. }
  2328. }
  2329. }
  2330. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2331. var ranges = inverseBgByGroupId[groupId];
  2332. var invertedRanges = invertRanges(ranges, framingRange);
  2333. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2334. var invertedRange = invertedRanges_1[_i];
  2335. var def = defByGroupId[groupId];
  2336. var ui = eventUis[def.defId];
  2337. bgRanges.push({
  2338. def: def,
  2339. ui: ui,
  2340. instance: null,
  2341. range: invertedRange,
  2342. isStart: false,
  2343. isEnd: false
  2344. });
  2345. }
  2346. }
  2347. for (var defId in inverseBgByDefId) {
  2348. var ranges = inverseBgByDefId[defId];
  2349. var invertedRanges = invertRanges(ranges, framingRange);
  2350. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2351. var invertedRange = invertedRanges_2[_a];
  2352. bgRanges.push({
  2353. def: eventStore.defs[defId],
  2354. ui: eventUis[defId],
  2355. instance: null,
  2356. range: invertedRange,
  2357. isStart: false,
  2358. isEnd: false
  2359. });
  2360. }
  2361. }
  2362. return { bg: bgRanges, fg: fgRanges };
  2363. }
  2364. function hasBgRendering(def) {
  2365. return def.rendering === 'background' || def.rendering === 'inverse-background';
  2366. }
  2367. function filterSegsViaEls(context, segs, isMirror) {
  2368. var calendar = context.calendar, view = context.view;
  2369. if (calendar.hasPublicHandlers('eventRender')) {
  2370. segs = segs.filter(function (seg) {
  2371. var custom = calendar.publiclyTrigger('eventRender', [
  2372. {
  2373. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  2374. isMirror: isMirror,
  2375. isStart: seg.isStart,
  2376. isEnd: seg.isEnd,
  2377. // TODO: include seg.range once all components consistently generate it
  2378. el: seg.el,
  2379. view: view
  2380. }
  2381. ]);
  2382. if (custom === false) { // means don't render at all
  2383. return false;
  2384. }
  2385. else if (custom && custom !== true) {
  2386. seg.el = custom;
  2387. }
  2388. return true;
  2389. });
  2390. }
  2391. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  2392. var seg = segs_1[_i];
  2393. setElSeg(seg.el, seg);
  2394. }
  2395. return segs;
  2396. }
  2397. function setElSeg(el, seg) {
  2398. el.fcSeg = seg;
  2399. }
  2400. function getElSeg(el) {
  2401. return el.fcSeg || null;
  2402. }
  2403. // event ui computation
  2404. function compileEventUis(eventDefs, eventUiBases) {
  2405. return mapHash(eventDefs, function (eventDef) {
  2406. return compileEventUi(eventDef, eventUiBases);
  2407. });
  2408. }
  2409. function compileEventUi(eventDef, eventUiBases) {
  2410. var uis = [];
  2411. if (eventUiBases['']) {
  2412. uis.push(eventUiBases['']);
  2413. }
  2414. if (eventUiBases[eventDef.defId]) {
  2415. uis.push(eventUiBases[eventDef.defId]);
  2416. }
  2417. uis.push(eventDef.ui);
  2418. return combineEventUis(uis);
  2419. }
  2420. // triggers
  2421. function triggerRenderedSegs(context, segs, isMirrors) {
  2422. var calendar = context.calendar, view = context.view;
  2423. if (calendar.hasPublicHandlers('eventPositioned')) {
  2424. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  2425. var seg = segs_2[_i];
  2426. calendar.publiclyTriggerAfterSizing('eventPositioned', [
  2427. {
  2428. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  2429. isMirror: isMirrors,
  2430. isStart: seg.isStart,
  2431. isEnd: seg.isEnd,
  2432. el: seg.el,
  2433. view: view
  2434. }
  2435. ]);
  2436. }
  2437. }
  2438. if (!calendar.state.eventSourceLoadingLevel) { // avoid initial empty state while pending
  2439. calendar.afterSizingTriggers._eventsPositioned = [null]; // fire once
  2440. }
  2441. }
  2442. function triggerWillRemoveSegs(context, segs, isMirrors) {
  2443. var calendar = context.calendar, view = context.view;
  2444. for (var _i = 0, segs_3 = segs; _i < segs_3.length; _i++) {
  2445. var seg = segs_3[_i];
  2446. calendar.trigger('eventElRemove', seg.el);
  2447. }
  2448. if (calendar.hasPublicHandlers('eventDestroy')) {
  2449. for (var _a = 0, segs_4 = segs; _a < segs_4.length; _a++) {
  2450. var seg = segs_4[_a];
  2451. calendar.publiclyTrigger('eventDestroy', [
  2452. {
  2453. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  2454. isMirror: isMirrors,
  2455. el: seg.el,
  2456. view: view
  2457. }
  2458. ]);
  2459. }
  2460. }
  2461. }
  2462. // is-interactable
  2463. function computeEventDraggable(context, eventDef, eventUi) {
  2464. var calendar = context.calendar, view = context.view;
  2465. var transformers = calendar.pluginSystem.hooks.isDraggableTransformers;
  2466. var val = eventUi.startEditable;
  2467. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  2468. var transformer = transformers_1[_i];
  2469. val = transformer(val, eventDef, eventUi, view);
  2470. }
  2471. return val;
  2472. }
  2473. function computeEventStartResizable(context, eventDef, eventUi) {
  2474. return eventUi.durationEditable && context.options.eventResizableFromStart;
  2475. }
  2476. function computeEventEndResizable(context, eventDef, eventUi) {
  2477. return eventUi.durationEditable;
  2478. }
  2479. // applies the mutation to ALL defs/instances within the event store
  2480. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, calendar) {
  2481. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2482. var dest = createEmptyEventStore();
  2483. for (var defId in eventStore.defs) {
  2484. var def = eventStore.defs[defId];
  2485. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, calendar.pluginSystem.hooks.eventDefMutationAppliers, calendar);
  2486. }
  2487. for (var instanceId in eventStore.instances) {
  2488. var instance = eventStore.instances[instanceId];
  2489. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2490. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, calendar);
  2491. }
  2492. return dest;
  2493. }
  2494. function applyMutationToEventDef(eventDef, eventConfig, mutation, appliers, calendar) {
  2495. var standardProps = mutation.standardProps || {};
  2496. // if hasEnd has not been specified, guess a good value based on deltas.
  2497. // if duration will change, there's no way the default duration will persist,
  2498. // and thus, we need to mark the event as having a real end
  2499. if (standardProps.hasEnd == null &&
  2500. eventConfig.durationEditable &&
  2501. (mutation.startDelta || mutation.endDelta)) {
  2502. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2503. }
  2504. var copy = __assign({}, eventDef, standardProps, { ui: __assign({}, eventDef.ui, standardProps.ui) });
  2505. if (mutation.extendedProps) {
  2506. copy.extendedProps = __assign({}, copy.extendedProps, mutation.extendedProps);
  2507. }
  2508. for (var _i = 0, appliers_1 = appliers; _i < appliers_1.length; _i++) {
  2509. var applier = appliers_1[_i];
  2510. applier(copy, mutation, calendar);
  2511. }
  2512. if (!copy.hasEnd && calendar.opt('forceEventDuration')) {
  2513. copy.hasEnd = true;
  2514. }
  2515. return copy;
  2516. }
  2517. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2518. eventConfig, mutation, calendar) {
  2519. var dateEnv = calendar.dateEnv;
  2520. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2521. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2522. var copy = __assign({}, eventInstance);
  2523. if (forceAllDay) {
  2524. copy.range = computeAlignedDayRange(copy.range);
  2525. }
  2526. if (mutation.datesDelta && eventConfig.startEditable) {
  2527. copy.range = {
  2528. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2529. end: dateEnv.add(copy.range.end, mutation.datesDelta)
  2530. };
  2531. }
  2532. if (mutation.startDelta && eventConfig.durationEditable) {
  2533. copy.range = {
  2534. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2535. end: copy.range.end
  2536. };
  2537. }
  2538. if (mutation.endDelta && eventConfig.durationEditable) {
  2539. copy.range = {
  2540. start: copy.range.start,
  2541. end: dateEnv.add(copy.range.end, mutation.endDelta)
  2542. };
  2543. }
  2544. if (clearEnd) {
  2545. copy.range = {
  2546. start: copy.range.start,
  2547. end: calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start)
  2548. };
  2549. }
  2550. // in case event was all-day but the supplied deltas were not
  2551. // better util for this?
  2552. if (eventDef.allDay) {
  2553. copy.range = {
  2554. start: startOfDay(copy.range.start),
  2555. end: startOfDay(copy.range.end)
  2556. };
  2557. }
  2558. // handle invalid durations
  2559. if (copy.range.end < copy.range.start) {
  2560. copy.range.end = calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start);
  2561. }
  2562. return copy;
  2563. }
  2564. function reduceEventStore (eventStore, action, eventSources, dateProfile, calendar) {
  2565. switch (action.type) {
  2566. case 'RECEIVE_EVENTS': // raw
  2567. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, calendar);
  2568. case 'ADD_EVENTS': // already parsed, but not expanded
  2569. return addEvent(eventStore, action.eventStore, // new ones
  2570. dateProfile ? dateProfile.activeRange : null, calendar);
  2571. case 'MERGE_EVENTS': // already parsed and expanded
  2572. return mergeEventStores(eventStore, action.eventStore);
  2573. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  2574. case 'NEXT':
  2575. case 'SET_DATE':
  2576. case 'SET_VIEW_TYPE':
  2577. if (dateProfile) {
  2578. return expandRecurring(eventStore, dateProfile.activeRange, calendar);
  2579. }
  2580. else {
  2581. return eventStore;
  2582. }
  2583. case 'CHANGE_TIMEZONE':
  2584. return rezoneDates(eventStore, action.oldDateEnv, calendar.dateEnv);
  2585. case 'MUTATE_EVENTS':
  2586. return applyMutationToRelated(eventStore, action.instanceId, action.mutation, action.fromApi, calendar);
  2587. case 'REMOVE_EVENT_INSTANCES':
  2588. return excludeInstances(eventStore, action.instances);
  2589. case 'REMOVE_EVENT_DEF':
  2590. return filterEventStoreDefs(eventStore, function (eventDef) {
  2591. return eventDef.defId !== action.defId;
  2592. });
  2593. case 'REMOVE_EVENT_SOURCE':
  2594. return excludeEventsBySourceId(eventStore, action.sourceId);
  2595. case 'REMOVE_ALL_EVENT_SOURCES':
  2596. return filterEventStoreDefs(eventStore, function (eventDef) {
  2597. return !eventDef.sourceId; // only keep events with no source id
  2598. });
  2599. case 'REMOVE_ALL_EVENTS':
  2600. return createEmptyEventStore();
  2601. case 'RESET_EVENTS':
  2602. return {
  2603. defs: eventStore.defs,
  2604. instances: eventStore.instances
  2605. };
  2606. default:
  2607. return eventStore;
  2608. }
  2609. }
  2610. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, calendar) {
  2611. if (eventSource && // not already removed
  2612. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  2613. ) {
  2614. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, calendar), eventSource.sourceId, calendar);
  2615. if (fetchRange) {
  2616. subset = expandRecurring(subset, fetchRange, calendar);
  2617. }
  2618. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  2619. }
  2620. return eventStore;
  2621. }
  2622. function addEvent(eventStore, subset, expandRange, calendar) {
  2623. if (expandRange) {
  2624. subset = expandRecurring(subset, expandRange, calendar);
  2625. }
  2626. return mergeEventStores(eventStore, subset);
  2627. }
  2628. function rezoneDates(eventStore, oldDateEnv, newDateEnv) {
  2629. var defs = eventStore.defs;
  2630. var instances = mapHash(eventStore.instances, function (instance) {
  2631. var def = defs[instance.defId];
  2632. if (def.allDay || def.recurringDef) {
  2633. return instance; // isn't dependent on timezone
  2634. }
  2635. else {
  2636. return __assign({}, instance, { range: {
  2637. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  2638. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo))
  2639. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  2640. }
  2641. });
  2642. return { defs: defs, instances: instances };
  2643. }
  2644. function applyMutationToRelated(eventStore, instanceId, mutation, fromApi, calendar) {
  2645. var relevant = getRelevantEvents(eventStore, instanceId);
  2646. var eventConfigBase = fromApi ?
  2647. { '': {
  2648. startEditable: true,
  2649. durationEditable: true,
  2650. constraints: [],
  2651. overlap: null,
  2652. allows: [],
  2653. backgroundColor: '',
  2654. borderColor: '',
  2655. textColor: '',
  2656. classNames: []
  2657. } } :
  2658. calendar.eventUiBases;
  2659. relevant = applyMutationToEventStore(relevant, eventConfigBase, mutation, calendar);
  2660. return mergeEventStores(eventStore, relevant);
  2661. }
  2662. function excludeEventsBySourceId(eventStore, sourceId) {
  2663. return filterEventStoreDefs(eventStore, function (eventDef) {
  2664. return eventDef.sourceId !== sourceId;
  2665. });
  2666. }
  2667. // QUESTION: why not just return instances? do a general object-property-exclusion util
  2668. function excludeInstances(eventStore, removals) {
  2669. return {
  2670. defs: eventStore.defs,
  2671. instances: filterHash(eventStore.instances, function (instance) {
  2672. return !removals[instance.instanceId];
  2673. })
  2674. };
  2675. }
  2676. // high-level segmenting-aware tester functions
  2677. // ------------------------------------------------------------------------------------------------------------------------
  2678. function isInteractionValid(interaction, calendar) {
  2679. return isNewPropsValid({ eventDrag: interaction }, calendar); // HACK: the eventDrag props is used for ALL interactions
  2680. }
  2681. function isDateSelectionValid(dateSelection, calendar) {
  2682. return isNewPropsValid({ dateSelection: dateSelection }, calendar);
  2683. }
  2684. function isNewPropsValid(newProps, calendar) {
  2685. var view = calendar.view;
  2686. var props = __assign({ businessHours: view ? view.props.businessHours : createEmptyEventStore(), dateSelection: '', eventStore: calendar.state.eventStore, eventUiBases: calendar.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  2687. return (calendar.pluginSystem.hooks.isPropsValid || isPropsValid)(props, calendar);
  2688. }
  2689. function isPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2690. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  2691. if (state.eventDrag && !isInteractionPropsValid(state, calendar, dateSpanMeta, filterConfig)) {
  2692. return false;
  2693. }
  2694. if (state.dateSelection && !isDateSelectionPropsValid(state, calendar, dateSpanMeta, filterConfig)) {
  2695. return false;
  2696. }
  2697. return true;
  2698. }
  2699. // Moving Event Validation
  2700. // ------------------------------------------------------------------------------------------------------------------------
  2701. function isInteractionPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2702. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  2703. var subjectEventStore = interaction.mutatedEvents;
  2704. var subjectDefs = subjectEventStore.defs;
  2705. var subjectInstances = subjectEventStore.instances;
  2706. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  2707. state.eventUiBases :
  2708. { '': calendar.selectionConfig } // if not a real event, validate as a selection
  2709. );
  2710. if (filterConfig) {
  2711. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  2712. }
  2713. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances); // exclude the subject events. TODO: exclude defs too?
  2714. var otherDefs = otherEventStore.defs;
  2715. var otherInstances = otherEventStore.instances;
  2716. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  2717. for (var subjectInstanceId in subjectInstances) {
  2718. var subjectInstance = subjectInstances[subjectInstanceId];
  2719. var subjectRange = subjectInstance.range;
  2720. var subjectConfig = subjectConfigs[subjectInstance.defId];
  2721. var subjectDef = subjectDefs[subjectInstance.defId];
  2722. // constraint
  2723. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, calendar)) {
  2724. return false;
  2725. }
  2726. // overlap
  2727. var overlapFunc = calendar.opt('eventOverlap');
  2728. if (typeof overlapFunc !== 'function') {
  2729. overlapFunc = null;
  2730. }
  2731. for (var otherInstanceId in otherInstances) {
  2732. var otherInstance = otherInstances[otherInstanceId];
  2733. // intersect! evaluate
  2734. if (rangesIntersect(subjectRange, otherInstance.range)) {
  2735. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  2736. // consider the other event's overlap. only do this if the subject event is a "real" event
  2737. if (otherOverlap === false && interaction.isEvent) {
  2738. return false;
  2739. }
  2740. if (subjectConfig.overlap === false) {
  2741. return false;
  2742. }
  2743. if (overlapFunc && !overlapFunc(new EventApi(calendar, otherDefs[otherInstance.defId], otherInstance), // still event
  2744. new EventApi(calendar, subjectDef, subjectInstance) // moving event
  2745. )) {
  2746. return false;
  2747. }
  2748. }
  2749. }
  2750. // allow (a function)
  2751. var calendarEventStore = calendar.state.eventStore; // need global-to-calendar, not local to component (splittable)state
  2752. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  2753. var subjectAllow = _a[_i];
  2754. var subjectDateSpan = __assign({}, dateSpanMeta, { range: subjectInstance.range, allDay: subjectDef.allDay });
  2755. var origDef = calendarEventStore.defs[subjectDef.defId];
  2756. var origInstance = calendarEventStore.instances[subjectInstanceId];
  2757. var eventApi = void 0;
  2758. if (origDef) { // was previously in the calendar
  2759. eventApi = new EventApi(calendar, origDef, origInstance);
  2760. }
  2761. else { // was an external event
  2762. eventApi = new EventApi(calendar, subjectDef); // no instance, because had no dates
  2763. }
  2764. if (!subjectAllow(calendar.buildDateSpanApi(subjectDateSpan), eventApi)) {
  2765. return false;
  2766. }
  2767. }
  2768. }
  2769. return true;
  2770. }
  2771. // Date Selection Validation
  2772. // ------------------------------------------------------------------------------------------------------------------------
  2773. function isDateSelectionPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2774. var relevantEventStore = state.eventStore;
  2775. var relevantDefs = relevantEventStore.defs;
  2776. var relevantInstances = relevantEventStore.instances;
  2777. var selection = state.dateSelection;
  2778. var selectionRange = selection.range;
  2779. var selectionConfig = calendar.selectionConfig;
  2780. if (filterConfig) {
  2781. selectionConfig = filterConfig(selectionConfig);
  2782. }
  2783. // constraint
  2784. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, calendar)) {
  2785. return false;
  2786. }
  2787. // overlap
  2788. var overlapFunc = calendar.opt('selectOverlap');
  2789. if (typeof overlapFunc !== 'function') {
  2790. overlapFunc = null;
  2791. }
  2792. for (var relevantInstanceId in relevantInstances) {
  2793. var relevantInstance = relevantInstances[relevantInstanceId];
  2794. // intersect! evaluate
  2795. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  2796. if (selectionConfig.overlap === false) {
  2797. return false;
  2798. }
  2799. if (overlapFunc && !overlapFunc(new EventApi(calendar, relevantDefs[relevantInstance.defId], relevantInstance))) {
  2800. return false;
  2801. }
  2802. }
  2803. }
  2804. // allow (a function)
  2805. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  2806. var selectionAllow = _a[_i];
  2807. var fullDateSpan = __assign({}, dateSpanMeta, selection);
  2808. if (!selectionAllow(calendar.buildDateSpanApi(fullDateSpan), null)) {
  2809. return false;
  2810. }
  2811. }
  2812. return true;
  2813. }
  2814. // Constraint Utils
  2815. // ------------------------------------------------------------------------------------------------------------------------
  2816. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, calendar) {
  2817. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  2818. var constraint = constraints_1[_i];
  2819. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, calendar), subjectRange)) {
  2820. return false;
  2821. }
  2822. }
  2823. return true;
  2824. }
  2825. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  2826. otherEventStore, // for if constraint is an even group ID
  2827. businessHoursUnexpanded, // for if constraint is 'businessHours'
  2828. calendar // for expanding businesshours
  2829. ) {
  2830. if (constraint === 'businessHours') {
  2831. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, calendar));
  2832. }
  2833. else if (typeof constraint === 'string') { // an group ID
  2834. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) {
  2835. return eventDef.groupId === constraint;
  2836. }));
  2837. }
  2838. else if (typeof constraint === 'object' && constraint) { // non-null object
  2839. return eventStoreToRanges(expandRecurring(constraint, subjectRange, calendar));
  2840. }
  2841. return []; // if it's false
  2842. }
  2843. // TODO: move to event-store file?
  2844. function eventStoreToRanges(eventStore) {
  2845. var instances = eventStore.instances;
  2846. var ranges = [];
  2847. for (var instanceId in instances) {
  2848. ranges.push(instances[instanceId].range);
  2849. }
  2850. return ranges;
  2851. }
  2852. // TODO: move to geom file?
  2853. function anyRangesContainRange(outerRanges, innerRange) {
  2854. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  2855. var outerRange = outerRanges_1[_i];
  2856. if (rangeContainsRange(outerRange, innerRange)) {
  2857. return true;
  2858. }
  2859. }
  2860. return false;
  2861. }
  2862. // Parsing
  2863. // ------------------------------------------------------------------------------------------------------------------------
  2864. function normalizeConstraint(input, calendar) {
  2865. if (Array.isArray(input)) {
  2866. return parseEvents(input, '', calendar, true); // allowOpenRange=true
  2867. }
  2868. else if (typeof input === 'object' && input) { // non-null object
  2869. return parseEvents([input], '', calendar, true); // allowOpenRange=true
  2870. }
  2871. else if (input != null) {
  2872. return String(input);
  2873. }
  2874. else {
  2875. return null;
  2876. }
  2877. }
  2878. function htmlEscape(s) {
  2879. return (s + '').replace(/&/g, '&amp;')
  2880. .replace(/</g, '&lt;')
  2881. .replace(/>/g, '&gt;')
  2882. .replace(/'/g, '&#039;')
  2883. .replace(/"/g, '&quot;')
  2884. .replace(/\n/g, '<br />');
  2885. }
  2886. // Given a hash of CSS properties, returns a string of CSS.
  2887. // Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values.
  2888. function cssToStr(cssProps) {
  2889. var statements = [];
  2890. for (var name_1 in cssProps) {
  2891. var val = cssProps[name_1];
  2892. if (val != null && val !== '') {
  2893. statements.push(name_1 + ':' + val);
  2894. }
  2895. }
  2896. return statements.join(';');
  2897. }
  2898. // Given an object hash of HTML attribute names to values,
  2899. // generates a string that can be injected between < > in HTML
  2900. function attrsToStr(attrs) {
  2901. var parts = [];
  2902. for (var name_2 in attrs) {
  2903. var val = attrs[name_2];
  2904. if (val != null) {
  2905. parts.push(name_2 + '="' + htmlEscape(val) + '"');
  2906. }
  2907. }
  2908. return parts.join(' ');
  2909. }
  2910. function parseClassName(raw) {
  2911. if (Array.isArray(raw)) {
  2912. return raw;
  2913. }
  2914. else if (typeof raw === 'string') {
  2915. return raw.split(/\s+/);
  2916. }
  2917. else {
  2918. return [];
  2919. }
  2920. }
  2921. var UNSCOPED_EVENT_UI_PROPS = {
  2922. editable: Boolean,
  2923. startEditable: Boolean,
  2924. durationEditable: Boolean,
  2925. constraint: null,
  2926. overlap: null,
  2927. allow: null,
  2928. className: parseClassName,
  2929. classNames: parseClassName,
  2930. color: String,
  2931. backgroundColor: String,
  2932. borderColor: String,
  2933. textColor: String
  2934. };
  2935. function processUnscopedUiProps(rawProps, calendar, leftovers) {
  2936. var props = refineProps(rawProps, UNSCOPED_EVENT_UI_PROPS, {}, leftovers);
  2937. var constraint = normalizeConstraint(props.constraint, calendar);
  2938. return {
  2939. startEditable: props.startEditable != null ? props.startEditable : props.editable,
  2940. durationEditable: props.durationEditable != null ? props.durationEditable : props.editable,
  2941. constraints: constraint != null ? [constraint] : [],
  2942. overlap: props.overlap,
  2943. allows: props.allow != null ? [props.allow] : [],
  2944. backgroundColor: props.backgroundColor || props.color,
  2945. borderColor: props.borderColor || props.color,
  2946. textColor: props.textColor,
  2947. classNames: props.classNames.concat(props.className)
  2948. };
  2949. }
  2950. function processScopedUiProps(prefix, rawScoped, calendar, leftovers) {
  2951. var rawUnscoped = {};
  2952. var wasFound = {};
  2953. for (var key in UNSCOPED_EVENT_UI_PROPS) {
  2954. var scopedKey = prefix + capitaliseFirstLetter(key);
  2955. rawUnscoped[key] = rawScoped[scopedKey];
  2956. wasFound[scopedKey] = true;
  2957. }
  2958. if (prefix === 'event') {
  2959. rawUnscoped.editable = rawScoped.editable; // special case. there is no 'eventEditable', just 'editable'
  2960. }
  2961. if (leftovers) {
  2962. for (var key in rawScoped) {
  2963. if (!wasFound[key]) {
  2964. leftovers[key] = rawScoped[key];
  2965. }
  2966. }
  2967. }
  2968. return processUnscopedUiProps(rawUnscoped, calendar);
  2969. }
  2970. var EMPTY_EVENT_UI = {
  2971. startEditable: null,
  2972. durationEditable: null,
  2973. constraints: [],
  2974. overlap: null,
  2975. allows: [],
  2976. backgroundColor: '',
  2977. borderColor: '',
  2978. textColor: '',
  2979. classNames: []
  2980. };
  2981. // prevent against problems with <2 args!
  2982. function combineEventUis(uis) {
  2983. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  2984. }
  2985. function combineTwoEventUis(item0, item1) {
  2986. return {
  2987. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  2988. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  2989. constraints: item0.constraints.concat(item1.constraints),
  2990. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  2991. allows: item0.allows.concat(item1.allows),
  2992. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  2993. borderColor: item1.borderColor || item0.borderColor,
  2994. textColor: item1.textColor || item0.textColor,
  2995. classNames: item0.classNames.concat(item1.classNames)
  2996. };
  2997. }
  2998. var NON_DATE_PROPS = {
  2999. id: String,
  3000. groupId: String,
  3001. title: String,
  3002. url: String,
  3003. rendering: String,
  3004. extendedProps: null
  3005. };
  3006. var DATE_PROPS = {
  3007. start: null,
  3008. date: null,
  3009. end: null,
  3010. allDay: null
  3011. };
  3012. var uid = 0;
  3013. function parseEvent(raw, sourceId, calendar, allowOpenRange) {
  3014. var allDayDefault = computeIsAllDayDefault(sourceId, calendar);
  3015. var leftovers0 = {};
  3016. var recurringRes = parseRecurring(raw, // raw, but with single-event stuff stripped out
  3017. allDayDefault, calendar.dateEnv, calendar.pluginSystem.hooks.recurringTypes, leftovers0 // will populate with non-recurring props
  3018. );
  3019. if (recurringRes) {
  3020. var def = parseEventDef(leftovers0, sourceId, recurringRes.allDay, Boolean(recurringRes.duration), calendar);
  3021. def.recurringDef = {
  3022. typeId: recurringRes.typeId,
  3023. typeData: recurringRes.typeData,
  3024. duration: recurringRes.duration
  3025. };
  3026. return { def: def, instance: null };
  3027. }
  3028. else {
  3029. var leftovers1 = {};
  3030. var singleRes = parseSingle(raw, allDayDefault, calendar, leftovers1, allowOpenRange);
  3031. if (singleRes) {
  3032. var def = parseEventDef(leftovers1, sourceId, singleRes.allDay, singleRes.hasEnd, calendar);
  3033. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  3034. return { def: def, instance: instance };
  3035. }
  3036. }
  3037. return null;
  3038. }
  3039. /*
  3040. Will NOT populate extendedProps with the leftover properties.
  3041. Will NOT populate date-related props.
  3042. The EventNonDateInput has been normalized (id => publicId, etc).
  3043. */
  3044. function parseEventDef(raw, sourceId, allDay, hasEnd, calendar) {
  3045. var leftovers = {};
  3046. var def = pluckNonDateProps(raw, calendar, leftovers);
  3047. def.defId = String(uid++);
  3048. def.sourceId = sourceId;
  3049. def.allDay = allDay;
  3050. def.hasEnd = hasEnd;
  3051. for (var _i = 0, _a = calendar.pluginSystem.hooks.eventDefParsers; _i < _a.length; _i++) {
  3052. var eventDefParser = _a[_i];
  3053. var newLeftovers = {};
  3054. eventDefParser(def, leftovers, newLeftovers);
  3055. leftovers = newLeftovers;
  3056. }
  3057. def.extendedProps = __assign(leftovers, def.extendedProps || {});
  3058. // help out EventApi from having user modify props
  3059. Object.freeze(def.ui.classNames);
  3060. Object.freeze(def.extendedProps);
  3061. return def;
  3062. }
  3063. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  3064. return {
  3065. instanceId: String(uid++),
  3066. defId: defId,
  3067. range: range,
  3068. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  3069. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
  3070. };
  3071. }
  3072. function parseSingle(raw, allDayDefault, calendar, leftovers, allowOpenRange) {
  3073. var props = pluckDateProps(raw, leftovers);
  3074. var allDay = props.allDay;
  3075. var startMeta;
  3076. var startMarker = null;
  3077. var hasEnd = false;
  3078. var endMeta;
  3079. var endMarker = null;
  3080. startMeta = calendar.dateEnv.createMarkerMeta(props.start);
  3081. if (startMeta) {
  3082. startMarker = startMeta.marker;
  3083. }
  3084. else if (!allowOpenRange) {
  3085. return null;
  3086. }
  3087. if (props.end != null) {
  3088. endMeta = calendar.dateEnv.createMarkerMeta(props.end);
  3089. }
  3090. if (allDay == null) {
  3091. if (allDayDefault != null) {
  3092. allDay = allDayDefault;
  3093. }
  3094. else {
  3095. // fall back to the date props LAST
  3096. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  3097. (!endMeta || endMeta.isTimeUnspecified);
  3098. }
  3099. }
  3100. if (allDay && startMarker) {
  3101. startMarker = startOfDay(startMarker);
  3102. }
  3103. if (endMeta) {
  3104. endMarker = endMeta.marker;
  3105. if (allDay) {
  3106. endMarker = startOfDay(endMarker);
  3107. }
  3108. if (startMarker && endMarker <= startMarker) {
  3109. endMarker = null;
  3110. }
  3111. }
  3112. if (endMarker) {
  3113. hasEnd = true;
  3114. }
  3115. else if (!allowOpenRange) {
  3116. hasEnd = calendar.opt('forceEventDuration') || false;
  3117. endMarker = calendar.dateEnv.add(startMarker, allDay ?
  3118. calendar.defaultAllDayEventDuration :
  3119. calendar.defaultTimedEventDuration);
  3120. }
  3121. return {
  3122. allDay: allDay,
  3123. hasEnd: hasEnd,
  3124. range: { start: startMarker, end: endMarker },
  3125. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  3126. forcedEndTzo: endMeta ? endMeta.forcedTzo : null
  3127. };
  3128. }
  3129. function pluckDateProps(raw, leftovers) {
  3130. var props = refineProps(raw, DATE_PROPS, {}, leftovers);
  3131. props.start = (props.start !== null) ? props.start : props.date;
  3132. delete props.date;
  3133. return props;
  3134. }
  3135. function pluckNonDateProps(raw, calendar, leftovers) {
  3136. var preLeftovers = {};
  3137. var props = refineProps(raw, NON_DATE_PROPS, {}, preLeftovers);
  3138. var ui = processUnscopedUiProps(preLeftovers, calendar, leftovers);
  3139. props.publicId = props.id;
  3140. delete props.id;
  3141. props.ui = ui;
  3142. return props;
  3143. }
  3144. function computeIsAllDayDefault(sourceId, calendar) {
  3145. var res = null;
  3146. if (sourceId) {
  3147. var source = calendar.state.eventSources[sourceId];
  3148. res = source.allDayDefault;
  3149. }
  3150. if (res == null) {
  3151. res = calendar.opt('allDayDefault');
  3152. }
  3153. return res;
  3154. }
  3155. var DEF_DEFAULTS = {
  3156. startTime: '09:00',
  3157. endTime: '17:00',
  3158. daysOfWeek: [1, 2, 3, 4, 5],
  3159. rendering: 'inverse-background',
  3160. classNames: 'fc-nonbusiness',
  3161. groupId: '_businessHours' // so multiple defs get grouped
  3162. };
  3163. /*
  3164. TODO: pass around as EventDefHash!!!
  3165. */
  3166. function parseBusinessHours(input, calendar) {
  3167. return parseEvents(refineInputs(input), '', calendar);
  3168. }
  3169. function refineInputs(input) {
  3170. var rawDefs;
  3171. if (input === true) {
  3172. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  3173. }
  3174. else if (Array.isArray(input)) {
  3175. // if specifying an array, every sub-definition NEEDS a day-of-week
  3176. rawDefs = input.filter(function (rawDef) {
  3177. return rawDef.daysOfWeek;
  3178. });
  3179. }
  3180. else if (typeof input === 'object' && input) { // non-null object
  3181. rawDefs = [input];
  3182. }
  3183. else { // is probably false
  3184. rawDefs = [];
  3185. }
  3186. rawDefs = rawDefs.map(function (rawDef) {
  3187. return __assign({}, DEF_DEFAULTS, rawDef);
  3188. });
  3189. return rawDefs;
  3190. }
  3191. function memoizeRendering(renderFunc, unrenderFunc, dependencies) {
  3192. if (dependencies === void 0) { dependencies = []; }
  3193. var dependents = [];
  3194. var thisContext;
  3195. var prevArgs;
  3196. function unrender() {
  3197. if (prevArgs) {
  3198. for (var _i = 0, dependents_1 = dependents; _i < dependents_1.length; _i++) {
  3199. var dependent = dependents_1[_i];
  3200. dependent.unrender();
  3201. }
  3202. if (unrenderFunc) {
  3203. unrenderFunc.apply(thisContext, prevArgs);
  3204. }
  3205. prevArgs = null;
  3206. }
  3207. }
  3208. function res() {
  3209. if (!prevArgs || !isArraysEqual(prevArgs, arguments)) {
  3210. unrender();
  3211. thisContext = this;
  3212. prevArgs = arguments;
  3213. renderFunc.apply(this, arguments);
  3214. }
  3215. }
  3216. res.dependents = dependents;
  3217. res.unrender = unrender;
  3218. for (var _i = 0, dependencies_1 = dependencies; _i < dependencies_1.length; _i++) {
  3219. var dependency = dependencies_1[_i];
  3220. dependency.dependents.push(res);
  3221. }
  3222. return res;
  3223. }
  3224. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  3225. var Splitter = /** @class */ (function () {
  3226. function Splitter() {
  3227. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  3228. this.splitDateSelection = memoize(this._splitDateSpan);
  3229. this.splitEventStore = memoize(this._splitEventStore);
  3230. this.splitIndividualUi = memoize(this._splitIndividualUi);
  3231. this.splitEventDrag = memoize(this._splitInteraction);
  3232. this.splitEventResize = memoize(this._splitInteraction);
  3233. this.eventUiBuilders = {}; // TODO: typescript protection
  3234. }
  3235. Splitter.prototype.splitProps = function (props) {
  3236. var _this = this;
  3237. var keyInfos = this.getKeyInfo(props);
  3238. var defKeys = this.getKeysForEventDefs(props.eventStore);
  3239. var dateSelections = this.splitDateSelection(props.dateSelection);
  3240. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  3241. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  3242. var eventDrags = this.splitEventDrag(props.eventDrag);
  3243. var eventResizes = this.splitEventResize(props.eventResize);
  3244. var splitProps = {};
  3245. this.eventUiBuilders = mapHash(keyInfos, function (info, key) {
  3246. return _this.eventUiBuilders[key] || memoize(buildEventUiForKey);
  3247. });
  3248. for (var key in keyInfos) {
  3249. var keyInfo = keyInfos[key];
  3250. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  3251. var buildEventUi = this.eventUiBuilders[key];
  3252. splitProps[key] = {
  3253. businessHours: keyInfo.businessHours || props.businessHours,
  3254. dateSelection: dateSelections[key] || null,
  3255. eventStore: eventStore,
  3256. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  3257. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  3258. eventDrag: eventDrags[key] || null,
  3259. eventResize: eventResizes[key] || null
  3260. };
  3261. }
  3262. return splitProps;
  3263. };
  3264. Splitter.prototype._splitDateSpan = function (dateSpan) {
  3265. var dateSpans = {};
  3266. if (dateSpan) {
  3267. var keys = this.getKeysForDateSpan(dateSpan);
  3268. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  3269. var key = keys_1[_i];
  3270. dateSpans[key] = dateSpan;
  3271. }
  3272. }
  3273. return dateSpans;
  3274. };
  3275. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  3276. var _this = this;
  3277. return mapHash(eventStore.defs, function (eventDef) {
  3278. return _this.getKeysForEventDef(eventDef);
  3279. });
  3280. };
  3281. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  3282. var defs = eventStore.defs, instances = eventStore.instances;
  3283. var splitStores = {};
  3284. for (var defId in defs) {
  3285. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  3286. var key = _a[_i];
  3287. if (!splitStores[key]) {
  3288. splitStores[key] = createEmptyEventStore();
  3289. }
  3290. splitStores[key].defs[defId] = defs[defId];
  3291. }
  3292. }
  3293. for (var instanceId in instances) {
  3294. var instance = instances[instanceId];
  3295. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  3296. var key = _c[_b];
  3297. if (splitStores[key]) { // must have already been created
  3298. splitStores[key].instances[instanceId] = instance;
  3299. }
  3300. }
  3301. }
  3302. return splitStores;
  3303. };
  3304. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  3305. var splitHashes = {};
  3306. for (var defId in eventUiBases) {
  3307. if (defId) { // not the '' key
  3308. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  3309. var key = _a[_i];
  3310. if (!splitHashes[key]) {
  3311. splitHashes[key] = {};
  3312. }
  3313. splitHashes[key][defId] = eventUiBases[defId];
  3314. }
  3315. }
  3316. }
  3317. return splitHashes;
  3318. };
  3319. Splitter.prototype._splitInteraction = function (interaction) {
  3320. var splitStates = {};
  3321. if (interaction) {
  3322. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents) // can't use cached. might be events from other calendar
  3323. );
  3324. // can't rely on defKeys because event data is mutated
  3325. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  3326. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  3327. var populate = function (key) {
  3328. if (!splitStates[key]) {
  3329. splitStates[key] = {
  3330. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  3331. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  3332. isEvent: interaction.isEvent,
  3333. origSeg: interaction.origSeg
  3334. };
  3335. }
  3336. };
  3337. for (var key in affectedStores_1) {
  3338. populate(key);
  3339. }
  3340. for (var key in mutatedStores_1) {
  3341. populate(key);
  3342. }
  3343. }
  3344. return splitStates;
  3345. };
  3346. return Splitter;
  3347. }());
  3348. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  3349. var baseParts = [];
  3350. if (allUi) {
  3351. baseParts.push(allUi);
  3352. }
  3353. if (eventUiForKey) {
  3354. baseParts.push(eventUiForKey);
  3355. }
  3356. var stuff = {
  3357. '': combineEventUis(baseParts)
  3358. };
  3359. if (individualUi) {
  3360. __assign(stuff, individualUi);
  3361. }
  3362. return stuff;
  3363. }
  3364. // Generates HTML for an anchor to another view into the calendar.
  3365. // Will either generate an <a> tag or a non-clickable <span> tag, depending on enabled settings.
  3366. // `gotoOptions` can either be a DateMarker, or an object with the form:
  3367. // { date, type, forceOff }
  3368. // `type` is a view-type like "day" or "week". default value is "day".
  3369. // `attrs` and `innerHtml` are use to generate the rest of the HTML tag.
  3370. function buildGotoAnchorHtml(allOptions, dateEnv, gotoOptions, attrs, innerHtml) {
  3371. var date;
  3372. var type;
  3373. var forceOff;
  3374. var finalOptions;
  3375. if (gotoOptions instanceof Date) {
  3376. date = gotoOptions; // a single date-like input
  3377. }
  3378. else {
  3379. date = gotoOptions.date;
  3380. type = gotoOptions.type;
  3381. forceOff = gotoOptions.forceOff;
  3382. }
  3383. finalOptions = {
  3384. date: dateEnv.formatIso(date, { omitTime: true }),
  3385. type: type || 'day'
  3386. };
  3387. if (typeof attrs === 'string') {
  3388. innerHtml = attrs;
  3389. attrs = null;
  3390. }
  3391. attrs = attrs ? ' ' + attrsToStr(attrs) : ''; // will have a leading space
  3392. innerHtml = innerHtml || '';
  3393. if (!forceOff && allOptions.navLinks) {
  3394. return '<a' + attrs +
  3395. ' data-goto="' + htmlEscape(JSON.stringify(finalOptions)) + '">' +
  3396. innerHtml +
  3397. '</a>';
  3398. }
  3399. else {
  3400. return '<span' + attrs + '>' +
  3401. innerHtml +
  3402. '</span>';
  3403. }
  3404. }
  3405. function getAllDayHtml(allOptions) {
  3406. return allOptions.allDayHtml || htmlEscape(allOptions.allDayText);
  3407. }
  3408. // Computes HTML classNames for a single-day element
  3409. function getDayClasses(date, dateProfile, context, noThemeHighlight) {
  3410. var calendar = context.calendar, options = context.options, theme = context.theme, dateEnv = context.dateEnv;
  3411. var classes = [];
  3412. var todayStart;
  3413. var todayEnd;
  3414. if (!rangeContainsMarker(dateProfile.activeRange, date)) {
  3415. classes.push('fc-disabled-day');
  3416. }
  3417. else {
  3418. classes.push('fc-' + DAY_IDS[date.getUTCDay()]);
  3419. if (options.monthMode &&
  3420. dateEnv.getMonth(date) !== dateEnv.getMonth(dateProfile.currentRange.start)) {
  3421. classes.push('fc-other-month');
  3422. }
  3423. todayStart = startOfDay(calendar.getNow());
  3424. todayEnd = addDays(todayStart, 1);
  3425. if (date < todayStart) {
  3426. classes.push('fc-past');
  3427. }
  3428. else if (date >= todayEnd) {
  3429. classes.push('fc-future');
  3430. }
  3431. else {
  3432. classes.push('fc-today');
  3433. if (noThemeHighlight !== true) {
  3434. classes.push(theme.getClass('today'));
  3435. }
  3436. }
  3437. }
  3438. return classes;
  3439. }
  3440. // given a function that resolves a result asynchronously.
  3441. // the function can either call passed-in success and failure callbacks,
  3442. // or it can return a promise.
  3443. // if you need to pass additional params to func, bind them first.
  3444. function unpromisify(func, success, failure) {
  3445. // guard against success/failure callbacks being called more than once
  3446. // and guard against a promise AND callback being used together.
  3447. var isResolved = false;
  3448. var wrappedSuccess = function () {
  3449. if (!isResolved) {
  3450. isResolved = true;
  3451. success.apply(this, arguments);
  3452. }
  3453. };
  3454. var wrappedFailure = function () {
  3455. if (!isResolved) {
  3456. isResolved = true;
  3457. if (failure) {
  3458. failure.apply(this, arguments);
  3459. }
  3460. }
  3461. };
  3462. var res = func(wrappedSuccess, wrappedFailure);
  3463. if (res && typeof res.then === 'function') {
  3464. res.then(wrappedSuccess, wrappedFailure);
  3465. }
  3466. }
  3467. var Mixin = /** @class */ (function () {
  3468. function Mixin() {
  3469. }
  3470. // mix into a CLASS
  3471. Mixin.mixInto = function (destClass) {
  3472. this.mixIntoObj(destClass.prototype);
  3473. };
  3474. // mix into ANY object
  3475. Mixin.mixIntoObj = function (destObj) {
  3476. var _this = this;
  3477. Object.getOwnPropertyNames(this.prototype).forEach(function (name) {
  3478. if (!destObj[name]) { // if destination doesn't already define it
  3479. destObj[name] = _this.prototype[name];
  3480. }
  3481. });
  3482. };
  3483. /*
  3484. will override existing methods
  3485. TODO: remove! not used anymore
  3486. */
  3487. Mixin.mixOver = function (destClass) {
  3488. var _this = this;
  3489. Object.getOwnPropertyNames(this.prototype).forEach(function (name) {
  3490. destClass.prototype[name] = _this.prototype[name];
  3491. });
  3492. };
  3493. return Mixin;
  3494. }());
  3495. /*
  3496. USAGE:
  3497. import { default as EmitterMixin, EmitterInterface } from './EmitterMixin'
  3498. in class:
  3499. on: EmitterInterface['on']
  3500. one: EmitterInterface['one']
  3501. off: EmitterInterface['off']
  3502. trigger: EmitterInterface['trigger']
  3503. triggerWith: EmitterInterface['triggerWith']
  3504. hasHandlers: EmitterInterface['hasHandlers']
  3505. after class:
  3506. EmitterMixin.mixInto(TheClass)
  3507. */
  3508. var EmitterMixin = /** @class */ (function (_super) {
  3509. __extends(EmitterMixin, _super);
  3510. function EmitterMixin() {
  3511. return _super !== null && _super.apply(this, arguments) || this;
  3512. }
  3513. EmitterMixin.prototype.on = function (type, handler) {
  3514. addToHash(this._handlers || (this._handlers = {}), type, handler);
  3515. return this; // for chaining
  3516. };
  3517. // todo: add comments
  3518. EmitterMixin.prototype.one = function (type, handler) {
  3519. addToHash(this._oneHandlers || (this._oneHandlers = {}), type, handler);
  3520. return this; // for chaining
  3521. };
  3522. EmitterMixin.prototype.off = function (type, handler) {
  3523. if (this._handlers) {
  3524. removeFromHash(this._handlers, type, handler);
  3525. }
  3526. if (this._oneHandlers) {
  3527. removeFromHash(this._oneHandlers, type, handler);
  3528. }
  3529. return this; // for chaining
  3530. };
  3531. EmitterMixin.prototype.trigger = function (type) {
  3532. var args = [];
  3533. for (var _i = 1; _i < arguments.length; _i++) {
  3534. args[_i - 1] = arguments[_i];
  3535. }
  3536. this.triggerWith(type, this, args);
  3537. return this; // for chaining
  3538. };
  3539. EmitterMixin.prototype.triggerWith = function (type, context, args) {
  3540. if (this._handlers) {
  3541. applyAll(this._handlers[type], context, args);
  3542. }
  3543. if (this._oneHandlers) {
  3544. applyAll(this._oneHandlers[type], context, args);
  3545. delete this._oneHandlers[type]; // will never fire again
  3546. }
  3547. return this; // for chaining
  3548. };
  3549. EmitterMixin.prototype.hasHandlers = function (type) {
  3550. return (this._handlers && this._handlers[type] && this._handlers[type].length) ||
  3551. (this._oneHandlers && this._oneHandlers[type] && this._oneHandlers[type].length);
  3552. };
  3553. return EmitterMixin;
  3554. }(Mixin));
  3555. function addToHash(hash, type, handler) {
  3556. (hash[type] || (hash[type] = []))
  3557. .push(handler);
  3558. }
  3559. function removeFromHash(hash, type, handler) {
  3560. if (handler) {
  3561. if (hash[type]) {
  3562. hash[type] = hash[type].filter(function (func) {
  3563. return func !== handler;
  3564. });
  3565. }
  3566. }
  3567. else {
  3568. delete hash[type]; // remove all handler funcs for this type
  3569. }
  3570. }
  3571. /*
  3572. Records offset information for a set of elements, relative to an origin element.
  3573. Can record the left/right OR the top/bottom OR both.
  3574. Provides methods for querying the cache by position.
  3575. */
  3576. var PositionCache = /** @class */ (function () {
  3577. function PositionCache(originEl, els, isHorizontal, isVertical) {
  3578. this.originEl = originEl;
  3579. this.els = els;
  3580. this.isHorizontal = isHorizontal;
  3581. this.isVertical = isVertical;
  3582. }
  3583. // Queries the els for coordinates and stores them.
  3584. // Call this method before using and of the get* methods below.
  3585. PositionCache.prototype.build = function () {
  3586. var originEl = this.originEl;
  3587. var originClientRect = this.originClientRect =
  3588. originEl.getBoundingClientRect(); // relative to viewport top-left
  3589. if (this.isHorizontal) {
  3590. this.buildElHorizontals(originClientRect.left);
  3591. }
  3592. if (this.isVertical) {
  3593. this.buildElVerticals(originClientRect.top);
  3594. }
  3595. };
  3596. // Populates the left/right internal coordinate arrays
  3597. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  3598. var lefts = [];
  3599. var rights = [];
  3600. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  3601. var el = _a[_i];
  3602. var rect = el.getBoundingClientRect();
  3603. lefts.push(rect.left - originClientLeft);
  3604. rights.push(rect.right - originClientLeft);
  3605. }
  3606. this.lefts = lefts;
  3607. this.rights = rights;
  3608. };
  3609. // Populates the top/bottom internal coordinate arrays
  3610. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  3611. var tops = [];
  3612. var bottoms = [];
  3613. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  3614. var el = _a[_i];
  3615. var rect = el.getBoundingClientRect();
  3616. tops.push(rect.top - originClientTop);
  3617. bottoms.push(rect.bottom - originClientTop);
  3618. }
  3619. this.tops = tops;
  3620. this.bottoms = bottoms;
  3621. };
  3622. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  3623. // If no intersection is made, returns undefined.
  3624. PositionCache.prototype.leftToIndex = function (leftPosition) {
  3625. var lefts = this.lefts;
  3626. var rights = this.rights;
  3627. var len = lefts.length;
  3628. var i;
  3629. for (i = 0; i < len; i++) {
  3630. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  3631. return i;
  3632. }
  3633. }
  3634. };
  3635. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  3636. // If no intersection is made, returns undefined.
  3637. PositionCache.prototype.topToIndex = function (topPosition) {
  3638. var tops = this.tops;
  3639. var bottoms = this.bottoms;
  3640. var len = tops.length;
  3641. var i;
  3642. for (i = 0; i < len; i++) {
  3643. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  3644. return i;
  3645. }
  3646. }
  3647. };
  3648. // Gets the width of the element at the given index
  3649. PositionCache.prototype.getWidth = function (leftIndex) {
  3650. return this.rights[leftIndex] - this.lefts[leftIndex];
  3651. };
  3652. // Gets the height of the element at the given index
  3653. PositionCache.prototype.getHeight = function (topIndex) {
  3654. return this.bottoms[topIndex] - this.tops[topIndex];
  3655. };
  3656. return PositionCache;
  3657. }());
  3658. /*
  3659. An object for getting/setting scroll-related information for an element.
  3660. Internally, this is done very differently for window versus DOM element,
  3661. so this object serves as a common interface.
  3662. */
  3663. var ScrollController = /** @class */ (function () {
  3664. function ScrollController() {
  3665. }
  3666. ScrollController.prototype.getMaxScrollTop = function () {
  3667. return this.getScrollHeight() - this.getClientHeight();
  3668. };
  3669. ScrollController.prototype.getMaxScrollLeft = function () {
  3670. return this.getScrollWidth() - this.getClientWidth();
  3671. };
  3672. ScrollController.prototype.canScrollVertically = function () {
  3673. return this.getMaxScrollTop() > 0;
  3674. };
  3675. ScrollController.prototype.canScrollHorizontally = function () {
  3676. return this.getMaxScrollLeft() > 0;
  3677. };
  3678. ScrollController.prototype.canScrollUp = function () {
  3679. return this.getScrollTop() > 0;
  3680. };
  3681. ScrollController.prototype.canScrollDown = function () {
  3682. return this.getScrollTop() < this.getMaxScrollTop();
  3683. };
  3684. ScrollController.prototype.canScrollLeft = function () {
  3685. return this.getScrollLeft() > 0;
  3686. };
  3687. ScrollController.prototype.canScrollRight = function () {
  3688. return this.getScrollLeft() < this.getMaxScrollLeft();
  3689. };
  3690. return ScrollController;
  3691. }());
  3692. var ElementScrollController = /** @class */ (function (_super) {
  3693. __extends(ElementScrollController, _super);
  3694. function ElementScrollController(el) {
  3695. var _this = _super.call(this) || this;
  3696. _this.el = el;
  3697. return _this;
  3698. }
  3699. ElementScrollController.prototype.getScrollTop = function () {
  3700. return this.el.scrollTop;
  3701. };
  3702. ElementScrollController.prototype.getScrollLeft = function () {
  3703. return this.el.scrollLeft;
  3704. };
  3705. ElementScrollController.prototype.setScrollTop = function (top) {
  3706. this.el.scrollTop = top;
  3707. };
  3708. ElementScrollController.prototype.setScrollLeft = function (left) {
  3709. this.el.scrollLeft = left;
  3710. };
  3711. ElementScrollController.prototype.getScrollWidth = function () {
  3712. return this.el.scrollWidth;
  3713. };
  3714. ElementScrollController.prototype.getScrollHeight = function () {
  3715. return this.el.scrollHeight;
  3716. };
  3717. ElementScrollController.prototype.getClientHeight = function () {
  3718. return this.el.clientHeight;
  3719. };
  3720. ElementScrollController.prototype.getClientWidth = function () {
  3721. return this.el.clientWidth;
  3722. };
  3723. return ElementScrollController;
  3724. }(ScrollController));
  3725. var WindowScrollController = /** @class */ (function (_super) {
  3726. __extends(WindowScrollController, _super);
  3727. function WindowScrollController() {
  3728. return _super !== null && _super.apply(this, arguments) || this;
  3729. }
  3730. WindowScrollController.prototype.getScrollTop = function () {
  3731. return window.pageYOffset;
  3732. };
  3733. WindowScrollController.prototype.getScrollLeft = function () {
  3734. return window.pageXOffset;
  3735. };
  3736. WindowScrollController.prototype.setScrollTop = function (n) {
  3737. window.scroll(window.pageXOffset, n);
  3738. };
  3739. WindowScrollController.prototype.setScrollLeft = function (n) {
  3740. window.scroll(n, window.pageYOffset);
  3741. };
  3742. WindowScrollController.prototype.getScrollWidth = function () {
  3743. return document.documentElement.scrollWidth;
  3744. };
  3745. WindowScrollController.prototype.getScrollHeight = function () {
  3746. return document.documentElement.scrollHeight;
  3747. };
  3748. WindowScrollController.prototype.getClientHeight = function () {
  3749. return document.documentElement.clientHeight;
  3750. };
  3751. WindowScrollController.prototype.getClientWidth = function () {
  3752. return document.documentElement.clientWidth;
  3753. };
  3754. return WindowScrollController;
  3755. }(ScrollController));
  3756. /*
  3757. Embodies a div that has potential scrollbars
  3758. */
  3759. var ScrollComponent = /** @class */ (function (_super) {
  3760. __extends(ScrollComponent, _super);
  3761. function ScrollComponent(overflowX, overflowY) {
  3762. var _this = _super.call(this, createElement('div', {
  3763. className: 'fc-scroller'
  3764. })) || this;
  3765. _this.overflowX = overflowX;
  3766. _this.overflowY = overflowY;
  3767. _this.applyOverflow();
  3768. return _this;
  3769. }
  3770. // sets to natural height, unlocks overflow
  3771. ScrollComponent.prototype.clear = function () {
  3772. this.setHeight('auto');
  3773. this.applyOverflow();
  3774. };
  3775. ScrollComponent.prototype.destroy = function () {
  3776. removeElement(this.el);
  3777. };
  3778. // Overflow
  3779. // -----------------------------------------------------------------------------------------------------------------
  3780. ScrollComponent.prototype.applyOverflow = function () {
  3781. applyStyle(this.el, {
  3782. overflowX: this.overflowX,
  3783. overflowY: this.overflowY
  3784. });
  3785. };
  3786. // Causes any 'auto' overflow values to resolves to 'scroll' or 'hidden'.
  3787. // Useful for preserving scrollbar widths regardless of future resizes.
  3788. // Can pass in scrollbarWidths for optimization.
  3789. ScrollComponent.prototype.lockOverflow = function (scrollbarWidths) {
  3790. var overflowX = this.overflowX;
  3791. var overflowY = this.overflowY;
  3792. scrollbarWidths = scrollbarWidths || this.getScrollbarWidths();
  3793. if (overflowX === 'auto') {
  3794. overflowX = (scrollbarWidths.bottom || // horizontal scrollbars?
  3795. this.canScrollHorizontally() // OR scrolling pane with massless scrollbars?
  3796. ) ? 'scroll' : 'hidden';
  3797. }
  3798. if (overflowY === 'auto') {
  3799. overflowY = (scrollbarWidths.left || scrollbarWidths.right || // horizontal scrollbars?
  3800. this.canScrollVertically() // OR scrolling pane with massless scrollbars?
  3801. ) ? 'scroll' : 'hidden';
  3802. }
  3803. applyStyle(this.el, { overflowX: overflowX, overflowY: overflowY });
  3804. };
  3805. ScrollComponent.prototype.setHeight = function (height) {
  3806. applyStyleProp(this.el, 'height', height);
  3807. };
  3808. ScrollComponent.prototype.getScrollbarWidths = function () {
  3809. var edges = computeEdges(this.el);
  3810. return {
  3811. left: edges.scrollbarLeft,
  3812. right: edges.scrollbarRight,
  3813. bottom: edges.scrollbarBottom
  3814. };
  3815. };
  3816. return ScrollComponent;
  3817. }(ElementScrollController));
  3818. var Theme = /** @class */ (function () {
  3819. function Theme(calendarOptions) {
  3820. this.calendarOptions = calendarOptions;
  3821. this.processIconOverride();
  3822. }
  3823. Theme.prototype.processIconOverride = function () {
  3824. if (this.iconOverrideOption) {
  3825. this.setIconOverride(this.calendarOptions[this.iconOverrideOption]);
  3826. }
  3827. };
  3828. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  3829. var iconClassesCopy;
  3830. var buttonName;
  3831. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  3832. iconClassesCopy = __assign({}, this.iconClasses);
  3833. for (buttonName in iconOverrideHash) {
  3834. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  3835. }
  3836. this.iconClasses = iconClassesCopy;
  3837. }
  3838. else if (iconOverrideHash === false) {
  3839. this.iconClasses = {};
  3840. }
  3841. };
  3842. Theme.prototype.applyIconOverridePrefix = function (className) {
  3843. var prefix = this.iconOverridePrefix;
  3844. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  3845. className = prefix + className;
  3846. }
  3847. return className;
  3848. };
  3849. Theme.prototype.getClass = function (key) {
  3850. return this.classes[key] || '';
  3851. };
  3852. Theme.prototype.getIconClass = function (buttonName) {
  3853. var className = this.iconClasses[buttonName];
  3854. if (className) {
  3855. return this.baseIconClass + ' ' + className;
  3856. }
  3857. return '';
  3858. };
  3859. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  3860. var className;
  3861. if (this.iconOverrideCustomButtonOption) {
  3862. className = customButtonProps[this.iconOverrideCustomButtonOption];
  3863. if (className) {
  3864. return this.baseIconClass + ' ' + this.applyIconOverridePrefix(className);
  3865. }
  3866. }
  3867. return '';
  3868. };
  3869. return Theme;
  3870. }());
  3871. Theme.prototype.classes = {};
  3872. Theme.prototype.iconClasses = {};
  3873. Theme.prototype.baseIconClass = '';
  3874. Theme.prototype.iconOverridePrefix = '';
  3875. var guid = 0;
  3876. var ComponentContext = /** @class */ (function () {
  3877. function ComponentContext(calendar, theme, dateEnv, options, view) {
  3878. this.calendar = calendar;
  3879. this.theme = theme;
  3880. this.dateEnv = dateEnv;
  3881. this.options = options;
  3882. this.view = view;
  3883. this.isRtl = options.dir === 'rtl';
  3884. this.eventOrderSpecs = parseFieldSpecs(options.eventOrder);
  3885. this.nextDayThreshold = createDuration(options.nextDayThreshold);
  3886. }
  3887. ComponentContext.prototype.extend = function (options, view) {
  3888. return new ComponentContext(this.calendar, this.theme, this.dateEnv, options || this.options, view || this.view);
  3889. };
  3890. return ComponentContext;
  3891. }());
  3892. var Component = /** @class */ (function () {
  3893. function Component() {
  3894. this.everRendered = false;
  3895. this.uid = String(guid++);
  3896. }
  3897. Component.addEqualityFuncs = function (newFuncs) {
  3898. this.prototype.equalityFuncs = __assign({}, this.prototype.equalityFuncs, newFuncs);
  3899. };
  3900. Component.prototype.receiveProps = function (props, context) {
  3901. this.receiveContext(context);
  3902. var _a = recycleProps(this.props || {}, props, this.equalityFuncs), anyChanges = _a.anyChanges, comboProps = _a.comboProps;
  3903. this.props = comboProps;
  3904. if (anyChanges) {
  3905. if (this.everRendered) {
  3906. this.beforeUpdate();
  3907. }
  3908. this.render(comboProps, context);
  3909. if (this.everRendered) {
  3910. this.afterUpdate();
  3911. }
  3912. }
  3913. this.everRendered = true;
  3914. };
  3915. Component.prototype.receiveContext = function (context) {
  3916. var oldContext = this.context;
  3917. this.context = context;
  3918. if (!oldContext) {
  3919. this.firstContext(context);
  3920. }
  3921. };
  3922. Component.prototype.render = function (props, context) {
  3923. };
  3924. Component.prototype.firstContext = function (context) {
  3925. };
  3926. Component.prototype.beforeUpdate = function () {
  3927. };
  3928. Component.prototype.afterUpdate = function () {
  3929. };
  3930. // after destroy is called, this component won't ever be used again
  3931. Component.prototype.destroy = function () {
  3932. };
  3933. return Component;
  3934. }());
  3935. Component.prototype.equalityFuncs = {};
  3936. /*
  3937. Reuses old values when equal. If anything is unequal, returns newProps as-is.
  3938. Great for PureComponent, but won't be feasible with React, so just eliminate and use React's DOM diffing.
  3939. */
  3940. function recycleProps(oldProps, newProps, equalityFuncs) {
  3941. var comboProps = {}; // some old, some new
  3942. var anyChanges = false;
  3943. for (var key in newProps) {
  3944. if (key in oldProps && (oldProps[key] === newProps[key] ||
  3945. (equalityFuncs[key] && equalityFuncs[key](oldProps[key], newProps[key])))) {
  3946. // equal to old? use old prop
  3947. comboProps[key] = oldProps[key];
  3948. }
  3949. else {
  3950. comboProps[key] = newProps[key];
  3951. anyChanges = true;
  3952. }
  3953. }
  3954. for (var key in oldProps) {
  3955. if (!(key in newProps)) {
  3956. anyChanges = true;
  3957. break;
  3958. }
  3959. }
  3960. return { anyChanges: anyChanges, comboProps: comboProps };
  3961. }
  3962. /*
  3963. PURPOSES:
  3964. - hook up to fg, fill, and mirror renderers
  3965. - interface for dragging and hits
  3966. */
  3967. var DateComponent = /** @class */ (function (_super) {
  3968. __extends(DateComponent, _super);
  3969. function DateComponent(el) {
  3970. var _this = _super.call(this) || this;
  3971. _this.el = el;
  3972. return _this;
  3973. }
  3974. DateComponent.prototype.destroy = function () {
  3975. _super.prototype.destroy.call(this);
  3976. removeElement(this.el);
  3977. };
  3978. // Hit System
  3979. // -----------------------------------------------------------------------------------------------------------------
  3980. DateComponent.prototype.buildPositionCaches = function () {
  3981. };
  3982. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  3983. return null; // this should be abstract
  3984. };
  3985. // Validation
  3986. // -----------------------------------------------------------------------------------------------------------------
  3987. DateComponent.prototype.isInteractionValid = function (interaction) {
  3988. var calendar = this.context.calendar;
  3989. var dateProfile = this.props.dateProfile; // HACK
  3990. var instances = interaction.mutatedEvents.instances;
  3991. if (dateProfile) { // HACK for DayTile
  3992. for (var instanceId in instances) {
  3993. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  3994. return false;
  3995. }
  3996. }
  3997. }
  3998. return isInteractionValid(interaction, calendar);
  3999. };
  4000. DateComponent.prototype.isDateSelectionValid = function (selection) {
  4001. var calendar = this.context.calendar;
  4002. var dateProfile = this.props.dateProfile; // HACK
  4003. if (dateProfile && // HACK for DayTile
  4004. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  4005. return false;
  4006. }
  4007. return isDateSelectionValid(selection, calendar);
  4008. };
  4009. // Pointer Interaction Utils
  4010. // -----------------------------------------------------------------------------------------------------------------
  4011. DateComponent.prototype.isValidSegDownEl = function (el) {
  4012. return !this.props.eventDrag && // HACK
  4013. !this.props.eventResize && // HACK
  4014. !elementClosest(el, '.fc-mirror') &&
  4015. (this.isPopover() || !this.isInPopover(el));
  4016. // ^above line ensures we don't detect a seg interaction within a nested component.
  4017. // it's a HACK because it only supports a popover as the nested component.
  4018. };
  4019. DateComponent.prototype.isValidDateDownEl = function (el) {
  4020. var segEl = elementClosest(el, this.fgSegSelector);
  4021. return (!segEl || segEl.classList.contains('fc-mirror')) &&
  4022. !elementClosest(el, '.fc-more') && // a "more.." link
  4023. !elementClosest(el, 'a[data-goto]') && // a clickable nav link
  4024. !this.isInPopover(el);
  4025. };
  4026. DateComponent.prototype.isPopover = function () {
  4027. return this.el.classList.contains('fc-popover');
  4028. };
  4029. DateComponent.prototype.isInPopover = function (el) {
  4030. return Boolean(elementClosest(el, '.fc-popover'));
  4031. };
  4032. return DateComponent;
  4033. }(Component));
  4034. DateComponent.prototype.fgSegSelector = '.fc-event-container > *';
  4035. DateComponent.prototype.bgSegSelector = '.fc-bgevent:not(.fc-nonbusiness)';
  4036. var uid$1 = 0;
  4037. function createPlugin(input) {
  4038. return {
  4039. id: String(uid$1++),
  4040. deps: input.deps || [],
  4041. reducers: input.reducers || [],
  4042. eventDefParsers: input.eventDefParsers || [],
  4043. isDraggableTransformers: input.isDraggableTransformers || [],
  4044. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  4045. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  4046. dateSelectionTransformers: input.dateSelectionTransformers || [],
  4047. datePointTransforms: input.datePointTransforms || [],
  4048. dateSpanTransforms: input.dateSpanTransforms || [],
  4049. views: input.views || {},
  4050. viewPropsTransformers: input.viewPropsTransformers || [],
  4051. isPropsValid: input.isPropsValid || null,
  4052. externalDefTransforms: input.externalDefTransforms || [],
  4053. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  4054. viewContainerModifiers: input.viewContainerModifiers || [],
  4055. eventDropTransformers: input.eventDropTransformers || [],
  4056. componentInteractions: input.componentInteractions || [],
  4057. calendarInteractions: input.calendarInteractions || [],
  4058. themeClasses: input.themeClasses || {},
  4059. eventSourceDefs: input.eventSourceDefs || [],
  4060. cmdFormatter: input.cmdFormatter,
  4061. recurringTypes: input.recurringTypes || [],
  4062. namedTimeZonedImpl: input.namedTimeZonedImpl,
  4063. defaultView: input.defaultView || '',
  4064. elementDraggingImpl: input.elementDraggingImpl,
  4065. optionChangeHandlers: input.optionChangeHandlers || {}
  4066. };
  4067. }
  4068. var PluginSystem = /** @class */ (function () {
  4069. function PluginSystem() {
  4070. this.hooks = {
  4071. reducers: [],
  4072. eventDefParsers: [],
  4073. isDraggableTransformers: [],
  4074. eventDragMutationMassagers: [],
  4075. eventDefMutationAppliers: [],
  4076. dateSelectionTransformers: [],
  4077. datePointTransforms: [],
  4078. dateSpanTransforms: [],
  4079. views: {},
  4080. viewPropsTransformers: [],
  4081. isPropsValid: null,
  4082. externalDefTransforms: [],
  4083. eventResizeJoinTransforms: [],
  4084. viewContainerModifiers: [],
  4085. eventDropTransformers: [],
  4086. componentInteractions: [],
  4087. calendarInteractions: [],
  4088. themeClasses: {},
  4089. eventSourceDefs: [],
  4090. cmdFormatter: null,
  4091. recurringTypes: [],
  4092. namedTimeZonedImpl: null,
  4093. defaultView: '',
  4094. elementDraggingImpl: null,
  4095. optionChangeHandlers: {}
  4096. };
  4097. this.addedHash = {};
  4098. }
  4099. PluginSystem.prototype.add = function (plugin) {
  4100. if (!this.addedHash[plugin.id]) {
  4101. this.addedHash[plugin.id] = true;
  4102. for (var _i = 0, _a = plugin.deps; _i < _a.length; _i++) {
  4103. var dep = _a[_i];
  4104. this.add(dep);
  4105. }
  4106. this.hooks = combineHooks(this.hooks, plugin);
  4107. }
  4108. };
  4109. return PluginSystem;
  4110. }());
  4111. function combineHooks(hooks0, hooks1) {
  4112. return {
  4113. reducers: hooks0.reducers.concat(hooks1.reducers),
  4114. eventDefParsers: hooks0.eventDefParsers.concat(hooks1.eventDefParsers),
  4115. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  4116. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  4117. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  4118. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  4119. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  4120. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  4121. views: __assign({}, hooks0.views, hooks1.views),
  4122. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  4123. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  4124. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  4125. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  4126. viewContainerModifiers: hooks0.viewContainerModifiers.concat(hooks1.viewContainerModifiers),
  4127. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  4128. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  4129. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  4130. themeClasses: __assign({}, hooks0.themeClasses, hooks1.themeClasses),
  4131. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  4132. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  4133. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  4134. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  4135. defaultView: hooks0.defaultView || hooks1.defaultView,
  4136. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  4137. optionChangeHandlers: __assign({}, hooks0.optionChangeHandlers, hooks1.optionChangeHandlers)
  4138. };
  4139. }
  4140. var eventSourceDef = {
  4141. ignoreRange: true,
  4142. parseMeta: function (raw) {
  4143. if (Array.isArray(raw)) { // short form
  4144. return raw;
  4145. }
  4146. else if (Array.isArray(raw.events)) {
  4147. return raw.events;
  4148. }
  4149. return null;
  4150. },
  4151. fetch: function (arg, success) {
  4152. success({
  4153. rawEvents: arg.eventSource.meta
  4154. });
  4155. }
  4156. };
  4157. var ArrayEventSourcePlugin = createPlugin({
  4158. eventSourceDefs: [eventSourceDef]
  4159. });
  4160. var eventSourceDef$1 = {
  4161. parseMeta: function (raw) {
  4162. if (typeof raw === 'function') { // short form
  4163. return raw;
  4164. }
  4165. else if (typeof raw.events === 'function') {
  4166. return raw.events;
  4167. }
  4168. return null;
  4169. },
  4170. fetch: function (arg, success, failure) {
  4171. var dateEnv = arg.calendar.dateEnv;
  4172. var func = arg.eventSource.meta;
  4173. unpromisify(func.bind(null, {
  4174. start: dateEnv.toDate(arg.range.start),
  4175. end: dateEnv.toDate(arg.range.end),
  4176. startStr: dateEnv.formatIso(arg.range.start),
  4177. endStr: dateEnv.formatIso(arg.range.end),
  4178. timeZone: dateEnv.timeZone
  4179. }), function (rawEvents) {
  4180. success({ rawEvents: rawEvents }); // needs an object response
  4181. }, failure // send errorObj directly to failure callback
  4182. );
  4183. }
  4184. };
  4185. var FuncEventSourcePlugin = createPlugin({
  4186. eventSourceDefs: [eventSourceDef$1]
  4187. });
  4188. function requestJson(method, url, params, successCallback, failureCallback) {
  4189. method = method.toUpperCase();
  4190. var body = null;
  4191. if (method === 'GET') {
  4192. url = injectQueryStringParams(url, params);
  4193. }
  4194. else {
  4195. body = encodeParams(params);
  4196. }
  4197. var xhr = new XMLHttpRequest();
  4198. xhr.open(method, url, true);
  4199. if (method !== 'GET') {
  4200. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  4201. }
  4202. xhr.onload = function () {
  4203. if (xhr.status >= 200 && xhr.status < 400) {
  4204. try {
  4205. var res = JSON.parse(xhr.responseText);
  4206. successCallback(res, xhr);
  4207. }
  4208. catch (err) {
  4209. failureCallback('Failure parsing JSON', xhr);
  4210. }
  4211. }
  4212. else {
  4213. failureCallback('Request failed', xhr);
  4214. }
  4215. };
  4216. xhr.onerror = function () {
  4217. failureCallback('Request failed', xhr);
  4218. };
  4219. xhr.send(body);
  4220. }
  4221. function injectQueryStringParams(url, params) {
  4222. return url +
  4223. (url.indexOf('?') === -1 ? '?' : '&') +
  4224. encodeParams(params);
  4225. }
  4226. function encodeParams(params) {
  4227. var parts = [];
  4228. for (var key in params) {
  4229. parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  4230. }
  4231. return parts.join('&');
  4232. }
  4233. var eventSourceDef$2 = {
  4234. parseMeta: function (raw) {
  4235. if (typeof raw === 'string') { // short form
  4236. raw = { url: raw };
  4237. }
  4238. else if (!raw || typeof raw !== 'object' || !raw.url) {
  4239. return null;
  4240. }
  4241. return {
  4242. url: raw.url,
  4243. method: (raw.method || 'GET').toUpperCase(),
  4244. extraParams: raw.extraParams,
  4245. startParam: raw.startParam,
  4246. endParam: raw.endParam,
  4247. timeZoneParam: raw.timeZoneParam
  4248. };
  4249. },
  4250. fetch: function (arg, success, failure) {
  4251. var meta = arg.eventSource.meta;
  4252. var requestParams = buildRequestParams(meta, arg.range, arg.calendar);
  4253. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  4254. success({ rawEvents: rawEvents, xhr: xhr });
  4255. }, function (errorMessage, xhr) {
  4256. failure({ message: errorMessage, xhr: xhr });
  4257. });
  4258. }
  4259. };
  4260. var JsonFeedEventSourcePlugin = createPlugin({
  4261. eventSourceDefs: [eventSourceDef$2]
  4262. });
  4263. function buildRequestParams(meta, range, calendar) {
  4264. var dateEnv = calendar.dateEnv;
  4265. var startParam;
  4266. var endParam;
  4267. var timeZoneParam;
  4268. var customRequestParams;
  4269. var params = {};
  4270. startParam = meta.startParam;
  4271. if (startParam == null) {
  4272. startParam = calendar.opt('startParam');
  4273. }
  4274. endParam = meta.endParam;
  4275. if (endParam == null) {
  4276. endParam = calendar.opt('endParam');
  4277. }
  4278. timeZoneParam = meta.timeZoneParam;
  4279. if (timeZoneParam == null) {
  4280. timeZoneParam = calendar.opt('timeZoneParam');
  4281. }
  4282. // retrieve any outbound GET/POST data from the options
  4283. if (typeof meta.extraParams === 'function') {
  4284. // supplied as a function that returns a key/value object
  4285. customRequestParams = meta.extraParams();
  4286. }
  4287. else {
  4288. // probably supplied as a straight key/value object
  4289. customRequestParams = meta.extraParams || {};
  4290. }
  4291. __assign(params, customRequestParams);
  4292. params[startParam] = dateEnv.formatIso(range.start);
  4293. params[endParam] = dateEnv.formatIso(range.end);
  4294. if (dateEnv.timeZone !== 'local') {
  4295. params[timeZoneParam] = dateEnv.timeZone;
  4296. }
  4297. return params;
  4298. }
  4299. var recurring = {
  4300. parse: function (rawEvent, leftoverProps, dateEnv) {
  4301. var createMarker = dateEnv.createMarker.bind(dateEnv);
  4302. var processors = {
  4303. daysOfWeek: null,
  4304. startTime: createDuration,
  4305. endTime: createDuration,
  4306. startRecur: createMarker,
  4307. endRecur: createMarker
  4308. };
  4309. var props = refineProps(rawEvent, processors, {}, leftoverProps);
  4310. var anyValid = false;
  4311. for (var propName in props) {
  4312. if (props[propName] != null) {
  4313. anyValid = true;
  4314. break;
  4315. }
  4316. }
  4317. if (anyValid) {
  4318. var duration = null;
  4319. if ('duration' in leftoverProps) {
  4320. duration = createDuration(leftoverProps.duration);
  4321. delete leftoverProps.duration;
  4322. }
  4323. if (!duration && props.startTime && props.endTime) {
  4324. duration = subtractDurations(props.endTime, props.startTime);
  4325. }
  4326. return {
  4327. allDayGuess: Boolean(!props.startTime && !props.endTime),
  4328. duration: duration,
  4329. typeData: props // doesn't need endTime anymore but oh well
  4330. };
  4331. }
  4332. return null;
  4333. },
  4334. expand: function (typeData, framingRange, dateEnv) {
  4335. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  4336. if (clippedFramingRange) {
  4337. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  4338. }
  4339. else {
  4340. return [];
  4341. }
  4342. }
  4343. };
  4344. var SimpleRecurrencePlugin = createPlugin({
  4345. recurringTypes: [recurring]
  4346. });
  4347. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  4348. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  4349. var dayMarker = startOfDay(framingRange.start);
  4350. var endMarker = framingRange.end;
  4351. var instanceStarts = [];
  4352. while (dayMarker < endMarker) {
  4353. var instanceStart
  4354. // if everyday, or this particular day-of-week
  4355. = void 0;
  4356. // if everyday, or this particular day-of-week
  4357. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  4358. if (startTime) {
  4359. instanceStart = dateEnv.add(dayMarker, startTime);
  4360. }
  4361. else {
  4362. instanceStart = dayMarker;
  4363. }
  4364. instanceStarts.push(instanceStart);
  4365. }
  4366. dayMarker = addDays(dayMarker, 1);
  4367. }
  4368. return instanceStarts;
  4369. }
  4370. var DefaultOptionChangeHandlers = createPlugin({
  4371. optionChangeHandlers: {
  4372. events: function (events, calendar, deepEqual) {
  4373. handleEventSources([events], calendar, deepEqual);
  4374. },
  4375. eventSources: handleEventSources,
  4376. plugins: handlePlugins
  4377. }
  4378. });
  4379. function handleEventSources(inputs, calendar, deepEqual) {
  4380. var unfoundSources = hashValuesToArray(calendar.state.eventSources);
  4381. var newInputs = [];
  4382. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  4383. var input = inputs_1[_i];
  4384. var inputFound = false;
  4385. for (var i = 0; i < unfoundSources.length; i++) {
  4386. if (deepEqual(unfoundSources[i]._raw, input)) {
  4387. unfoundSources.splice(i, 1); // delete
  4388. inputFound = true;
  4389. break;
  4390. }
  4391. }
  4392. if (!inputFound) {
  4393. newInputs.push(input);
  4394. }
  4395. }
  4396. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  4397. var unfoundSource = unfoundSources_1[_a];
  4398. calendar.dispatch({
  4399. type: 'REMOVE_EVENT_SOURCE',
  4400. sourceId: unfoundSource.sourceId
  4401. });
  4402. }
  4403. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  4404. var newInput = newInputs_1[_b];
  4405. calendar.addEventSource(newInput);
  4406. }
  4407. }
  4408. // shortcoming: won't remove plugins
  4409. function handlePlugins(inputs, calendar) {
  4410. calendar.addPluginInputs(inputs); // will gracefully handle duplicates
  4411. }
  4412. var config = {}; // TODO: make these options
  4413. var globalDefaults = {
  4414. defaultRangeSeparator: ' - ',
  4415. titleRangeSeparator: ' \u2013 ',
  4416. defaultTimedEventDuration: '01:00:00',
  4417. defaultAllDayEventDuration: { day: 1 },
  4418. forceEventDuration: false,
  4419. nextDayThreshold: '00:00:00',
  4420. // display
  4421. columnHeader: true,
  4422. defaultView: '',
  4423. aspectRatio: 1.35,
  4424. header: {
  4425. left: 'title',
  4426. center: '',
  4427. right: 'today prev,next'
  4428. },
  4429. weekends: true,
  4430. weekNumbers: false,
  4431. weekNumberCalculation: 'local',
  4432. editable: false,
  4433. // nowIndicator: false,
  4434. scrollTime: '06:00:00',
  4435. minTime: '00:00:00',
  4436. maxTime: '24:00:00',
  4437. showNonCurrentDates: true,
  4438. // event ajax
  4439. lazyFetching: true,
  4440. startParam: 'start',
  4441. endParam: 'end',
  4442. timeZoneParam: 'timeZone',
  4443. timeZone: 'local',
  4444. // allDayDefault: undefined,
  4445. // locale
  4446. locales: [],
  4447. locale: '',
  4448. // dir: will get this from the default locale
  4449. // buttonIcons: null,
  4450. // allows setting a min-height to the event segment to prevent short events overlapping each other
  4451. timeGridEventMinHeight: 0,
  4452. themeSystem: 'standard',
  4453. // eventResizableFromStart: false,
  4454. dragRevertDuration: 500,
  4455. dragScroll: true,
  4456. allDayMaintainDuration: false,
  4457. // selectable: false,
  4458. unselectAuto: true,
  4459. // selectMinDistance: 0,
  4460. dropAccept: '*',
  4461. eventOrder: 'start,-duration,allDay,title',
  4462. // ^ if start tie, longer events go before shorter. final tie-breaker is title text
  4463. // rerenderDelay: null,
  4464. eventLimit: false,
  4465. eventLimitClick: 'popover',
  4466. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  4467. handleWindowResize: true,
  4468. windowResizeDelay: 100,
  4469. longPressDelay: 1000,
  4470. eventDragMinDistance: 5 // only applies to mouse
  4471. };
  4472. var rtlDefaults = {
  4473. header: {
  4474. left: 'next,prev today',
  4475. center: '',
  4476. right: 'title'
  4477. },
  4478. buttonIcons: {
  4479. // TODO: make RTL support the responibility of the theme
  4480. prev: 'fc-icon-chevron-right',
  4481. next: 'fc-icon-chevron-left',
  4482. prevYear: 'fc-icon-chevrons-right',
  4483. nextYear: 'fc-icon-chevrons-left'
  4484. }
  4485. };
  4486. var complexOptions = [
  4487. 'header',
  4488. 'footer',
  4489. 'buttonText',
  4490. 'buttonIcons'
  4491. ];
  4492. // Merges an array of option objects into a single object
  4493. function mergeOptions(optionObjs) {
  4494. return mergeProps(optionObjs, complexOptions);
  4495. }
  4496. // TODO: move this stuff to a "plugin"-related file...
  4497. var INTERNAL_PLUGINS = [
  4498. ArrayEventSourcePlugin,
  4499. FuncEventSourcePlugin,
  4500. JsonFeedEventSourcePlugin,
  4501. SimpleRecurrencePlugin,
  4502. DefaultOptionChangeHandlers
  4503. ];
  4504. function refinePluginDefs(pluginInputs) {
  4505. var plugins = [];
  4506. for (var _i = 0, pluginInputs_1 = pluginInputs; _i < pluginInputs_1.length; _i++) {
  4507. var pluginInput = pluginInputs_1[_i];
  4508. if (typeof pluginInput === 'string') {
  4509. var globalName = 'FullCalendar' + capitaliseFirstLetter(pluginInput);
  4510. if (!window[globalName]) {
  4511. console.warn('Plugin file not loaded for ' + pluginInput);
  4512. }
  4513. else {
  4514. plugins.push(window[globalName].default); // is an ES6 module
  4515. }
  4516. }
  4517. else {
  4518. plugins.push(pluginInput);
  4519. }
  4520. }
  4521. return INTERNAL_PLUGINS.concat(plugins);
  4522. }
  4523. var RAW_EN_LOCALE = {
  4524. code: 'en',
  4525. week: {
  4526. dow: 0,
  4527. doy: 4 // 4 days need to be within the year to be considered the first week
  4528. },
  4529. dir: 'ltr',
  4530. buttonText: {
  4531. prev: 'prev',
  4532. next: 'next',
  4533. prevYear: 'prev year',
  4534. nextYear: 'next year',
  4535. year: 'year',
  4536. today: 'today',
  4537. month: 'month',
  4538. week: 'week',
  4539. day: 'day',
  4540. list: 'list'
  4541. },
  4542. weekLabel: 'W',
  4543. allDayText: 'all-day',
  4544. eventLimitText: 'more',
  4545. noEventsMessage: 'No events to display'
  4546. };
  4547. function parseRawLocales(explicitRawLocales) {
  4548. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4549. var globalArray = window['FullCalendarLocalesAll'] || []; // from locales-all.js
  4550. var globalObject = window['FullCalendarLocales'] || {}; // from locales/*.js. keys are meaningless
  4551. var allRawLocales = globalArray.concat(// globalArray is low prio
  4552. hashValuesToArray(globalObject), // medium prio
  4553. explicitRawLocales // highest prio
  4554. );
  4555. var rawLocaleMap = {
  4556. en: RAW_EN_LOCALE // necessary?
  4557. };
  4558. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4559. var rawLocale = allRawLocales_1[_i];
  4560. rawLocaleMap[rawLocale.code] = rawLocale;
  4561. }
  4562. return {
  4563. map: rawLocaleMap,
  4564. defaultCode: defaultCode
  4565. };
  4566. }
  4567. function buildLocale(inputSingular, available) {
  4568. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4569. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4570. }
  4571. else {
  4572. return queryLocale(inputSingular, available);
  4573. }
  4574. }
  4575. function queryLocale(codeArg, available) {
  4576. var codes = [].concat(codeArg || []); // will convert to array
  4577. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4578. return parseLocale(codeArg, codes, raw);
  4579. }
  4580. function queryRawLocale(codes, available) {
  4581. for (var i = 0; i < codes.length; i++) {
  4582. var parts = codes[i].toLocaleLowerCase().split('-');
  4583. for (var j = parts.length; j > 0; j--) {
  4584. var simpleId = parts.slice(0, j).join('-');
  4585. if (available[simpleId]) {
  4586. return available[simpleId];
  4587. }
  4588. }
  4589. }
  4590. return null;
  4591. }
  4592. function parseLocale(codeArg, codes, raw) {
  4593. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4594. delete merged.code; // don't want this part of the options
  4595. var week = merged.week;
  4596. delete merged.week;
  4597. return {
  4598. codeArg: codeArg,
  4599. codes: codes,
  4600. week: week,
  4601. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4602. options: merged
  4603. };
  4604. }
  4605. var OptionsManager = /** @class */ (function () {
  4606. function OptionsManager(overrides) {
  4607. this.overrides = __assign({}, overrides); // make a copy
  4608. this.dynamicOverrides = {};
  4609. this.compute();
  4610. }
  4611. OptionsManager.prototype.mutate = function (updates, removals, isDynamic) {
  4612. if (!Object.keys(updates).length && !removals.length) {
  4613. return;
  4614. }
  4615. var overrideHash = isDynamic ? this.dynamicOverrides : this.overrides;
  4616. __assign(overrideHash, updates);
  4617. for (var _i = 0, removals_1 = removals; _i < removals_1.length; _i++) {
  4618. var propName = removals_1[_i];
  4619. delete overrideHash[propName];
  4620. }
  4621. this.compute();
  4622. };
  4623. // Computes the flattened options hash for the calendar and assigns to `this.options`.
  4624. // Assumes this.overrides and this.dynamicOverrides have already been initialized.
  4625. OptionsManager.prototype.compute = function () {
  4626. // TODO: not a very efficient system
  4627. var locales = firstDefined(// explicit locale option given?
  4628. this.dynamicOverrides.locales, this.overrides.locales, globalDefaults.locales);
  4629. var locale = firstDefined(// explicit locales option given?
  4630. this.dynamicOverrides.locale, this.overrides.locale, globalDefaults.locale);
  4631. var available = parseRawLocales(locales);
  4632. var localeDefaults = buildLocale(locale || available.defaultCode, available.map).options;
  4633. var dir = firstDefined(// based on options computed so far, is direction RTL?
  4634. this.dynamicOverrides.dir, this.overrides.dir, localeDefaults.dir);
  4635. var dirDefaults = dir === 'rtl' ? rtlDefaults : {};
  4636. this.dirDefaults = dirDefaults;
  4637. this.localeDefaults = localeDefaults;
  4638. this.computed = mergeOptions([
  4639. globalDefaults,
  4640. dirDefaults,
  4641. localeDefaults,
  4642. this.overrides,
  4643. this.dynamicOverrides
  4644. ]);
  4645. };
  4646. return OptionsManager;
  4647. }());
  4648. var calendarSystemClassMap = {};
  4649. function registerCalendarSystem(name, theClass) {
  4650. calendarSystemClassMap[name] = theClass;
  4651. }
  4652. function createCalendarSystem(name) {
  4653. return new calendarSystemClassMap[name]();
  4654. }
  4655. var GregorianCalendarSystem = /** @class */ (function () {
  4656. function GregorianCalendarSystem() {
  4657. }
  4658. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  4659. return d.getUTCFullYear();
  4660. };
  4661. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  4662. return d.getUTCMonth();
  4663. };
  4664. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  4665. return d.getUTCDate();
  4666. };
  4667. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  4668. return arrayToUtcDate(arr);
  4669. };
  4670. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  4671. return dateToUtcArray(marker);
  4672. };
  4673. return GregorianCalendarSystem;
  4674. }());
  4675. registerCalendarSystem('gregory', GregorianCalendarSystem);
  4676. var ISO_RE = /^\s*(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  4677. function parse(str) {
  4678. var m = ISO_RE.exec(str);
  4679. if (m) {
  4680. var marker = new Date(Date.UTC(Number(m[1]), m[3] ? Number(m[3]) - 1 : 0, Number(m[5] || 1), Number(m[7] || 0), Number(m[8] || 0), Number(m[10] || 0), m[12] ? Number('0.' + m[12]) * 1000 : 0));
  4681. if (isValidDate(marker)) {
  4682. var timeZoneOffset = null;
  4683. if (m[13]) {
  4684. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  4685. Number(m[18] || 0));
  4686. }
  4687. return {
  4688. marker: marker,
  4689. isTimeUnspecified: !m[6],
  4690. timeZoneOffset: timeZoneOffset
  4691. };
  4692. }
  4693. }
  4694. return null;
  4695. }
  4696. var DateEnv = /** @class */ (function () {
  4697. function DateEnv(settings) {
  4698. var timeZone = this.timeZone = settings.timeZone;
  4699. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  4700. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  4701. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  4702. }
  4703. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  4704. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  4705. this.locale = settings.locale;
  4706. this.weekDow = settings.locale.week.dow;
  4707. this.weekDoy = settings.locale.week.doy;
  4708. if (settings.weekNumberCalculation === 'ISO') {
  4709. this.weekDow = 1;
  4710. this.weekDoy = 4;
  4711. }
  4712. if (typeof settings.firstDay === 'number') {
  4713. this.weekDow = settings.firstDay;
  4714. }
  4715. if (typeof settings.weekNumberCalculation === 'function') {
  4716. this.weekNumberFunc = settings.weekNumberCalculation;
  4717. }
  4718. this.weekLabel = settings.weekLabel != null ? settings.weekLabel : settings.locale.options.weekLabel;
  4719. this.cmdFormatter = settings.cmdFormatter;
  4720. }
  4721. // Creating / Parsing
  4722. DateEnv.prototype.createMarker = function (input) {
  4723. var meta = this.createMarkerMeta(input);
  4724. if (meta === null) {
  4725. return null;
  4726. }
  4727. return meta.marker;
  4728. };
  4729. DateEnv.prototype.createNowMarker = function () {
  4730. if (this.canComputeOffset) {
  4731. return this.timestampToMarker(new Date().valueOf());
  4732. }
  4733. else {
  4734. // if we can't compute the current date val for a timezone,
  4735. // better to give the current local date vals than UTC
  4736. return arrayToUtcDate(dateToLocalArray(new Date()));
  4737. }
  4738. };
  4739. DateEnv.prototype.createMarkerMeta = function (input) {
  4740. if (typeof input === 'string') {
  4741. return this.parse(input);
  4742. }
  4743. var marker = null;
  4744. if (typeof input === 'number') {
  4745. marker = this.timestampToMarker(input);
  4746. }
  4747. else if (input instanceof Date) {
  4748. input = input.valueOf();
  4749. if (!isNaN(input)) {
  4750. marker = this.timestampToMarker(input);
  4751. }
  4752. }
  4753. else if (Array.isArray(input)) {
  4754. marker = arrayToUtcDate(input);
  4755. }
  4756. if (marker === null || !isValidDate(marker)) {
  4757. return null;
  4758. }
  4759. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  4760. };
  4761. DateEnv.prototype.parse = function (s) {
  4762. var parts = parse(s);
  4763. if (parts === null) {
  4764. return null;
  4765. }
  4766. var marker = parts.marker;
  4767. var forcedTzo = null;
  4768. if (parts.timeZoneOffset !== null) {
  4769. if (this.canComputeOffset) {
  4770. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  4771. }
  4772. else {
  4773. forcedTzo = parts.timeZoneOffset;
  4774. }
  4775. }
  4776. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  4777. };
  4778. // Accessors
  4779. DateEnv.prototype.getYear = function (marker) {
  4780. return this.calendarSystem.getMarkerYear(marker);
  4781. };
  4782. DateEnv.prototype.getMonth = function (marker) {
  4783. return this.calendarSystem.getMarkerMonth(marker);
  4784. };
  4785. // Adding / Subtracting
  4786. DateEnv.prototype.add = function (marker, dur) {
  4787. var a = this.calendarSystem.markerToArray(marker);
  4788. a[0] += dur.years;
  4789. a[1] += dur.months;
  4790. a[2] += dur.days;
  4791. a[6] += dur.milliseconds;
  4792. return this.calendarSystem.arrayToMarker(a);
  4793. };
  4794. DateEnv.prototype.subtract = function (marker, dur) {
  4795. var a = this.calendarSystem.markerToArray(marker);
  4796. a[0] -= dur.years;
  4797. a[1] -= dur.months;
  4798. a[2] -= dur.days;
  4799. a[6] -= dur.milliseconds;
  4800. return this.calendarSystem.arrayToMarker(a);
  4801. };
  4802. DateEnv.prototype.addYears = function (marker, n) {
  4803. var a = this.calendarSystem.markerToArray(marker);
  4804. a[0] += n;
  4805. return this.calendarSystem.arrayToMarker(a);
  4806. };
  4807. DateEnv.prototype.addMonths = function (marker, n) {
  4808. var a = this.calendarSystem.markerToArray(marker);
  4809. a[1] += n;
  4810. return this.calendarSystem.arrayToMarker(a);
  4811. };
  4812. // Diffing Whole Units
  4813. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  4814. var calendarSystem = this.calendarSystem;
  4815. if (timeAsMs(m0) === timeAsMs(m1) &&
  4816. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  4817. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  4818. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  4819. }
  4820. return null;
  4821. };
  4822. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  4823. var calendarSystem = this.calendarSystem;
  4824. if (timeAsMs(m0) === timeAsMs(m1) &&
  4825. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  4826. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  4827. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  4828. }
  4829. return null;
  4830. };
  4831. // Range / Duration
  4832. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  4833. var n = this.diffWholeYears(m0, m1);
  4834. if (n !== null) {
  4835. return { unit: 'year', value: n };
  4836. }
  4837. n = this.diffWholeMonths(m0, m1);
  4838. if (n !== null) {
  4839. return { unit: 'month', value: n };
  4840. }
  4841. n = diffWholeWeeks(m0, m1);
  4842. if (n !== null) {
  4843. return { unit: 'week', value: n };
  4844. }
  4845. n = diffWholeDays(m0, m1);
  4846. if (n !== null) {
  4847. return { unit: 'day', value: n };
  4848. }
  4849. n = diffHours(m0, m1);
  4850. if (isInt(n)) {
  4851. return { unit: 'hour', value: n };
  4852. }
  4853. n = diffMinutes(m0, m1);
  4854. if (isInt(n)) {
  4855. return { unit: 'minute', value: n };
  4856. }
  4857. n = diffSeconds(m0, m1);
  4858. if (isInt(n)) {
  4859. return { unit: 'second', value: n };
  4860. }
  4861. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  4862. };
  4863. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  4864. // TODO: can use greatestWholeUnit
  4865. var diff;
  4866. if (d.years) {
  4867. diff = this.diffWholeYears(m0, m1);
  4868. if (diff !== null) {
  4869. return diff / asRoughYears(d);
  4870. }
  4871. }
  4872. if (d.months) {
  4873. diff = this.diffWholeMonths(m0, m1);
  4874. if (diff !== null) {
  4875. return diff / asRoughMonths(d);
  4876. }
  4877. }
  4878. if (d.days) {
  4879. diff = diffWholeDays(m0, m1);
  4880. if (diff !== null) {
  4881. return diff / asRoughDays(d);
  4882. }
  4883. }
  4884. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  4885. };
  4886. // Start-Of
  4887. DateEnv.prototype.startOf = function (m, unit) {
  4888. if (unit === 'year') {
  4889. return this.startOfYear(m);
  4890. }
  4891. else if (unit === 'month') {
  4892. return this.startOfMonth(m);
  4893. }
  4894. else if (unit === 'week') {
  4895. return this.startOfWeek(m);
  4896. }
  4897. else if (unit === 'day') {
  4898. return startOfDay(m);
  4899. }
  4900. else if (unit === 'hour') {
  4901. return startOfHour(m);
  4902. }
  4903. else if (unit === 'minute') {
  4904. return startOfMinute(m);
  4905. }
  4906. else if (unit === 'second') {
  4907. return startOfSecond(m);
  4908. }
  4909. };
  4910. DateEnv.prototype.startOfYear = function (m) {
  4911. return this.calendarSystem.arrayToMarker([
  4912. this.calendarSystem.getMarkerYear(m)
  4913. ]);
  4914. };
  4915. DateEnv.prototype.startOfMonth = function (m) {
  4916. return this.calendarSystem.arrayToMarker([
  4917. this.calendarSystem.getMarkerYear(m),
  4918. this.calendarSystem.getMarkerMonth(m)
  4919. ]);
  4920. };
  4921. DateEnv.prototype.startOfWeek = function (m) {
  4922. return this.calendarSystem.arrayToMarker([
  4923. this.calendarSystem.getMarkerYear(m),
  4924. this.calendarSystem.getMarkerMonth(m),
  4925. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7)
  4926. ]);
  4927. };
  4928. // Week Number
  4929. DateEnv.prototype.computeWeekNumber = function (marker) {
  4930. if (this.weekNumberFunc) {
  4931. return this.weekNumberFunc(this.toDate(marker));
  4932. }
  4933. else {
  4934. return weekOfYear(marker, this.weekDow, this.weekDoy);
  4935. }
  4936. };
  4937. // TODO: choke on timeZoneName: long
  4938. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  4939. if (dateOptions === void 0) { dateOptions = {}; }
  4940. return formatter.format({
  4941. marker: marker,
  4942. timeZoneOffset: dateOptions.forcedTzo != null ?
  4943. dateOptions.forcedTzo :
  4944. this.offsetForMarker(marker)
  4945. }, this);
  4946. };
  4947. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  4948. if (dateOptions === void 0) { dateOptions = {}; }
  4949. if (dateOptions.isEndExclusive) {
  4950. end = addMs(end, -1);
  4951. }
  4952. return formatter.formatRange({
  4953. marker: start,
  4954. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  4955. dateOptions.forcedStartTzo :
  4956. this.offsetForMarker(start)
  4957. }, {
  4958. marker: end,
  4959. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4960. dateOptions.forcedEndTzo :
  4961. this.offsetForMarker(end)
  4962. }, this);
  4963. };
  4964. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4965. if (extraOptions === void 0) { extraOptions = {}; }
  4966. var timeZoneOffset = null;
  4967. if (!extraOptions.omitTimeZoneOffset) {
  4968. if (extraOptions.forcedTzo != null) {
  4969. timeZoneOffset = extraOptions.forcedTzo;
  4970. }
  4971. else {
  4972. timeZoneOffset = this.offsetForMarker(marker);
  4973. }
  4974. }
  4975. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4976. };
  4977. // TimeZone
  4978. DateEnv.prototype.timestampToMarker = function (ms) {
  4979. if (this.timeZone === 'local') {
  4980. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4981. }
  4982. else if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4983. return new Date(ms);
  4984. }
  4985. else {
  4986. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4987. }
  4988. };
  4989. DateEnv.prototype.offsetForMarker = function (m) {
  4990. if (this.timeZone === 'local') {
  4991. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4992. }
  4993. else if (this.timeZone === 'UTC') {
  4994. return 0;
  4995. }
  4996. else if (this.namedTimeZoneImpl) {
  4997. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4998. }
  4999. return null;
  5000. };
  5001. // Conversion
  5002. DateEnv.prototype.toDate = function (m, forcedTzo) {
  5003. if (this.timeZone === 'local') {
  5004. return arrayToLocalDate(dateToUtcArray(m));
  5005. }
  5006. else if (this.timeZone === 'UTC') {
  5007. return new Date(m.valueOf()); // make sure it's a copy
  5008. }
  5009. else if (!this.namedTimeZoneImpl) {
  5010. return new Date(m.valueOf() - (forcedTzo || 0));
  5011. }
  5012. else {
  5013. return new Date(m.valueOf() -
  5014. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60 // convert minutes -> ms
  5015. );
  5016. }
  5017. };
  5018. return DateEnv;
  5019. }());
  5020. var SIMPLE_SOURCE_PROPS = {
  5021. id: String,
  5022. allDayDefault: Boolean,
  5023. eventDataTransform: Function,
  5024. success: Function,
  5025. failure: Function
  5026. };
  5027. var uid$2 = 0;
  5028. function doesSourceNeedRange(eventSource, calendar) {
  5029. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5030. return !defs[eventSource.sourceDefId].ignoreRange;
  5031. }
  5032. function parseEventSource(raw, calendar) {
  5033. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5034. for (var i = defs.length - 1; i >= 0; i--) { // later-added plugins take precedence
  5035. var def = defs[i];
  5036. var meta = def.parseMeta(raw);
  5037. if (meta) {
  5038. var res = parseEventSourceProps(typeof raw === 'object' ? raw : {}, meta, i, calendar);
  5039. res._raw = raw;
  5040. return res;
  5041. }
  5042. }
  5043. return null;
  5044. }
  5045. function parseEventSourceProps(raw, meta, sourceDefId, calendar) {
  5046. var leftovers0 = {};
  5047. var props = refineProps(raw, SIMPLE_SOURCE_PROPS, {}, leftovers0);
  5048. var leftovers1 = {};
  5049. var ui = processUnscopedUiProps(leftovers0, calendar, leftovers1);
  5050. props.isFetching = false;
  5051. props.latestFetchId = '';
  5052. props.fetchRange = null;
  5053. props.publicId = String(raw.id || '');
  5054. props.sourceId = String(uid$2++);
  5055. props.sourceDefId = sourceDefId;
  5056. props.meta = meta;
  5057. props.ui = ui;
  5058. props.extendedProps = leftovers1;
  5059. return props;
  5060. }
  5061. function reduceEventSources (eventSources, action, dateProfile, calendar) {
  5062. switch (action.type) {
  5063. case 'ADD_EVENT_SOURCES': // already parsed
  5064. return addSources(eventSources, action.sources, dateProfile ? dateProfile.activeRange : null, calendar);
  5065. case 'REMOVE_EVENT_SOURCE':
  5066. return removeSource(eventSources, action.sourceId);
  5067. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  5068. case 'NEXT':
  5069. case 'SET_DATE':
  5070. case 'SET_VIEW_TYPE':
  5071. if (dateProfile) {
  5072. return fetchDirtySources(eventSources, dateProfile.activeRange, calendar);
  5073. }
  5074. else {
  5075. return eventSources;
  5076. }
  5077. case 'FETCH_EVENT_SOURCES':
  5078. case 'CHANGE_TIMEZONE':
  5079. return fetchSourcesByIds(eventSources, action.sourceIds ?
  5080. arrayToHash(action.sourceIds) :
  5081. excludeStaticSources(eventSources, calendar), dateProfile ? dateProfile.activeRange : null, calendar);
  5082. case 'RECEIVE_EVENTS':
  5083. case 'RECEIVE_EVENT_ERROR':
  5084. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  5085. case 'REMOVE_ALL_EVENT_SOURCES':
  5086. return {};
  5087. default:
  5088. return eventSources;
  5089. }
  5090. }
  5091. var uid$3 = 0;
  5092. function addSources(eventSourceHash, sources, fetchRange, calendar) {
  5093. var hash = {};
  5094. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  5095. var source = sources_1[_i];
  5096. hash[source.sourceId] = source;
  5097. }
  5098. if (fetchRange) {
  5099. hash = fetchDirtySources(hash, fetchRange, calendar);
  5100. }
  5101. return __assign({}, eventSourceHash, hash);
  5102. }
  5103. function removeSource(eventSourceHash, sourceId) {
  5104. return filterHash(eventSourceHash, function (eventSource) {
  5105. return eventSource.sourceId !== sourceId;
  5106. });
  5107. }
  5108. function fetchDirtySources(sourceHash, fetchRange, calendar) {
  5109. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) {
  5110. return isSourceDirty(eventSource, fetchRange, calendar);
  5111. }), fetchRange, calendar);
  5112. }
  5113. function isSourceDirty(eventSource, fetchRange, calendar) {
  5114. if (!doesSourceNeedRange(eventSource, calendar)) {
  5115. return !eventSource.latestFetchId;
  5116. }
  5117. else {
  5118. return !calendar.opt('lazyFetching') ||
  5119. !eventSource.fetchRange ||
  5120. eventSource.isFetching || // always cancel outdated in-progress fetches
  5121. fetchRange.start < eventSource.fetchRange.start ||
  5122. fetchRange.end > eventSource.fetchRange.end;
  5123. }
  5124. }
  5125. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, calendar) {
  5126. var nextSources = {};
  5127. for (var sourceId in prevSources) {
  5128. var source = prevSources[sourceId];
  5129. if (sourceIdHash[sourceId]) {
  5130. nextSources[sourceId] = fetchSource(source, fetchRange, calendar);
  5131. }
  5132. else {
  5133. nextSources[sourceId] = source;
  5134. }
  5135. }
  5136. return nextSources;
  5137. }
  5138. function fetchSource(eventSource, fetchRange, calendar) {
  5139. var sourceDef = calendar.pluginSystem.hooks.eventSourceDefs[eventSource.sourceDefId];
  5140. var fetchId = String(uid$3++);
  5141. sourceDef.fetch({
  5142. eventSource: eventSource,
  5143. calendar: calendar,
  5144. range: fetchRange
  5145. }, function (res) {
  5146. var rawEvents = res.rawEvents;
  5147. var calSuccess = calendar.opt('eventSourceSuccess');
  5148. var calSuccessRes;
  5149. var sourceSuccessRes;
  5150. if (eventSource.success) {
  5151. sourceSuccessRes = eventSource.success(rawEvents, res.xhr);
  5152. }
  5153. if (calSuccess) {
  5154. calSuccessRes = calSuccess(rawEvents, res.xhr);
  5155. }
  5156. rawEvents = sourceSuccessRes || calSuccessRes || rawEvents;
  5157. calendar.dispatch({
  5158. type: 'RECEIVE_EVENTS',
  5159. sourceId: eventSource.sourceId,
  5160. fetchId: fetchId,
  5161. fetchRange: fetchRange,
  5162. rawEvents: rawEvents
  5163. });
  5164. }, function (error) {
  5165. var callFailure = calendar.opt('eventSourceFailure');
  5166. console.warn(error.message, error);
  5167. if (eventSource.failure) {
  5168. eventSource.failure(error);
  5169. }
  5170. if (callFailure) {
  5171. callFailure(error);
  5172. }
  5173. calendar.dispatch({
  5174. type: 'RECEIVE_EVENT_ERROR',
  5175. sourceId: eventSource.sourceId,
  5176. fetchId: fetchId,
  5177. fetchRange: fetchRange,
  5178. error: error
  5179. });
  5180. });
  5181. return __assign({}, eventSource, { isFetching: true, latestFetchId: fetchId });
  5182. }
  5183. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  5184. var _a;
  5185. var eventSource = sourceHash[sourceId];
  5186. if (eventSource && // not already removed
  5187. fetchId === eventSource.latestFetchId) {
  5188. return __assign({}, sourceHash, (_a = {}, _a[sourceId] = __assign({}, eventSource, { isFetching: false, fetchRange: fetchRange // also serves as a marker that at least one fetch has completed
  5189. }), _a));
  5190. }
  5191. return sourceHash;
  5192. }
  5193. function excludeStaticSources(eventSources, calendar) {
  5194. return filterHash(eventSources, function (eventSource) {
  5195. return doesSourceNeedRange(eventSource, calendar);
  5196. });
  5197. }
  5198. var DateProfileGenerator = /** @class */ (function () {
  5199. function DateProfileGenerator(viewSpec, calendar) {
  5200. this.viewSpec = viewSpec;
  5201. this.options = viewSpec.options;
  5202. this.dateEnv = calendar.dateEnv;
  5203. this.calendar = calendar;
  5204. this.initHiddenDays();
  5205. }
  5206. /* Date Range Computation
  5207. ------------------------------------------------------------------------------------------------------------------*/
  5208. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5209. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate) {
  5210. var dateEnv = this.dateEnv;
  5211. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5212. currentDateProfile.dateIncrement);
  5213. return this.build(prevDate, -1);
  5214. };
  5215. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5216. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate) {
  5217. var dateEnv = this.dateEnv;
  5218. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5219. currentDateProfile.dateIncrement);
  5220. return this.build(nextDate, 1);
  5221. };
  5222. // Builds a structure holding dates/ranges for rendering around the given date.
  5223. // Optional direction param indicates whether the date is being incremented/decremented
  5224. // from its previous value. decremented = -1, incremented = 1 (default).
  5225. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5226. if (forceToValid === void 0) { forceToValid = false; }
  5227. var validRange;
  5228. var minTime = null;
  5229. var maxTime = null;
  5230. var currentInfo;
  5231. var isRangeAllDay;
  5232. var renderRange;
  5233. var activeRange;
  5234. var isValid;
  5235. validRange = this.buildValidRange();
  5236. validRange = this.trimHiddenDays(validRange);
  5237. if (forceToValid) {
  5238. currentDate = constrainMarkerToRange(currentDate, validRange);
  5239. }
  5240. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5241. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5242. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5243. renderRange = this.trimHiddenDays(renderRange);
  5244. activeRange = renderRange;
  5245. if (!this.options.showNonCurrentDates) {
  5246. activeRange = intersectRanges(activeRange, currentInfo.range);
  5247. }
  5248. minTime = createDuration(this.options.minTime);
  5249. maxTime = createDuration(this.options.maxTime);
  5250. activeRange = this.adjustActiveRange(activeRange, minTime, maxTime);
  5251. activeRange = intersectRanges(activeRange, validRange); // might return null
  5252. // it's invalid if the originally requested date is not contained,
  5253. // or if the range is completely outside of the valid range.
  5254. isValid = rangesIntersect(currentInfo.range, validRange);
  5255. return {
  5256. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5257. // an object with optional start and end properties.
  5258. validRange: validRange,
  5259. // range the view is formally responsible for.
  5260. // for example, a month view might have 1st-31st, excluding padded dates
  5261. currentRange: currentInfo.range,
  5262. // name of largest unit being displayed, like "month" or "week"
  5263. currentRangeUnit: currentInfo.unit,
  5264. isRangeAllDay: isRangeAllDay,
  5265. // dates that display events and accept drag-n-drop
  5266. // will be `null` if no dates accept events
  5267. activeRange: activeRange,
  5268. // date range with a rendered skeleton
  5269. // includes not-active days that need some sort of DOM
  5270. renderRange: renderRange,
  5271. // Duration object that denotes the first visible time of any given day
  5272. minTime: minTime,
  5273. // Duration object that denotes the exclusive visible end time of any given day
  5274. maxTime: maxTime,
  5275. isValid: isValid,
  5276. // how far the current date will move for a prev/next operation
  5277. dateIncrement: this.buildDateIncrement(currentInfo.duration)
  5278. // pass a fallback (might be null) ^
  5279. };
  5280. };
  5281. // Builds an object with optional start/end properties.
  5282. // Indicates the minimum/maximum dates to display.
  5283. // not responsible for trimming hidden days.
  5284. DateProfileGenerator.prototype.buildValidRange = function () {
  5285. return this.getRangeOption('validRange', this.calendar.getNow()) ||
  5286. { start: null, end: null }; // completely open-ended
  5287. };
  5288. // Builds a structure with info about the "current" range, the range that is
  5289. // highlighted as being the current month for example.
  5290. // See build() for a description of `direction`.
  5291. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5292. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5293. var _a = this, viewSpec = _a.viewSpec, dateEnv = _a.dateEnv;
  5294. var duration = null;
  5295. var unit = null;
  5296. var range = null;
  5297. var dayCount;
  5298. if (viewSpec.duration) {
  5299. duration = viewSpec.duration;
  5300. unit = viewSpec.durationUnit;
  5301. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5302. }
  5303. else if ((dayCount = this.options.dayCount)) {
  5304. unit = 'day';
  5305. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5306. }
  5307. else if ((range = this.buildCustomVisibleRange(date))) {
  5308. unit = dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5309. }
  5310. else {
  5311. duration = this.getFallbackDuration();
  5312. unit = greatestDurationDenominator(duration).unit;
  5313. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5314. }
  5315. return { duration: duration, unit: unit, range: range };
  5316. };
  5317. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5318. return createDuration({ day: 1 });
  5319. };
  5320. // Returns a new activeRange to have time values (un-ambiguate)
  5321. // minTime or maxTime causes the range to expand.
  5322. DateProfileGenerator.prototype.adjustActiveRange = function (range, minTime, maxTime) {
  5323. var dateEnv = this.dateEnv;
  5324. var start = range.start;
  5325. var end = range.end;
  5326. if (this.viewSpec.class.prototype.usesMinMaxTime) {
  5327. // expand active range if minTime is negative (why not when positive?)
  5328. if (asRoughDays(minTime) < 0) {
  5329. start = startOfDay(start); // necessary?
  5330. start = dateEnv.add(start, minTime);
  5331. }
  5332. // expand active range if maxTime is beyond one day (why not when positive?)
  5333. if (asRoughDays(maxTime) > 1) {
  5334. end = startOfDay(end); // necessary?
  5335. end = addDays(end, -1);
  5336. end = dateEnv.add(end, maxTime);
  5337. }
  5338. }
  5339. return { start: start, end: end };
  5340. };
  5341. // Builds the "current" range when it is specified as an explicit duration.
  5342. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5343. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5344. var dateEnv = this.dateEnv;
  5345. var alignment = this.options.dateAlignment;
  5346. var dateIncrementInput;
  5347. var dateIncrementDuration;
  5348. var start;
  5349. var end;
  5350. var res;
  5351. // compute what the alignment should be
  5352. if (!alignment) {
  5353. dateIncrementInput = this.options.dateIncrement;
  5354. if (dateIncrementInput) {
  5355. dateIncrementDuration = createDuration(dateIncrementInput);
  5356. // use the smaller of the two units
  5357. if (asRoughMs(dateIncrementDuration) < asRoughMs(duration)) {
  5358. alignment = greatestDurationDenominator(dateIncrementDuration, !getWeeksFromInput(dateIncrementInput)).unit;
  5359. }
  5360. else {
  5361. alignment = unit;
  5362. }
  5363. }
  5364. else {
  5365. alignment = unit;
  5366. }
  5367. }
  5368. // if the view displays a single day or smaller
  5369. if (asRoughDays(duration) <= 1) {
  5370. if (this.isHiddenDay(start)) {
  5371. start = this.skipHiddenDays(start, direction);
  5372. start = startOfDay(start);
  5373. }
  5374. }
  5375. function computeRes() {
  5376. start = dateEnv.startOf(date, alignment);
  5377. end = dateEnv.add(start, duration);
  5378. res = { start: start, end: end };
  5379. }
  5380. computeRes();
  5381. // if range is completely enveloped by hidden days, go past the hidden days
  5382. if (!this.trimHiddenDays(res)) {
  5383. date = this.skipHiddenDays(date, direction);
  5384. computeRes();
  5385. }
  5386. return res;
  5387. };
  5388. // Builds the "current" range when a dayCount is specified.
  5389. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5390. var dateEnv = this.dateEnv;
  5391. var customAlignment = this.options.dateAlignment;
  5392. var runningCount = 0;
  5393. var start = date;
  5394. var end;
  5395. if (customAlignment) {
  5396. start = dateEnv.startOf(start, customAlignment);
  5397. }
  5398. start = startOfDay(start);
  5399. start = this.skipHiddenDays(start, direction);
  5400. end = start;
  5401. do {
  5402. end = addDays(end, 1);
  5403. if (!this.isHiddenDay(end)) {
  5404. runningCount++;
  5405. }
  5406. } while (runningCount < dayCount);
  5407. return { start: start, end: end };
  5408. };
  5409. // Builds a normalized range object for the "visible" range,
  5410. // which is a way to define the currentRange and activeRange at the same time.
  5411. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  5412. var dateEnv = this.dateEnv;
  5413. var visibleRange = this.getRangeOption('visibleRange', dateEnv.toDate(date));
  5414. if (visibleRange && (visibleRange.start == null || visibleRange.end == null)) {
  5415. return null;
  5416. }
  5417. return visibleRange;
  5418. };
  5419. // Computes the range that will represent the element/cells for *rendering*,
  5420. // but which may have voided days/times.
  5421. // not responsible for trimming hidden days.
  5422. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  5423. return currentRange;
  5424. };
  5425. // Compute the duration value that should be added/substracted to the current date
  5426. // when a prev/next operation happens.
  5427. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  5428. var dateIncrementInput = this.options.dateIncrement;
  5429. var customAlignment;
  5430. if (dateIncrementInput) {
  5431. return createDuration(dateIncrementInput);
  5432. }
  5433. else if ((customAlignment = this.options.dateAlignment)) {
  5434. return createDuration(1, customAlignment);
  5435. }
  5436. else if (fallback) {
  5437. return fallback;
  5438. }
  5439. else {
  5440. return createDuration({ days: 1 });
  5441. }
  5442. };
  5443. // Arguments after name will be forwarded to a hypothetical function value
  5444. // WARNING: passed-in arguments will be given to generator functions as-is and can cause side-effects.
  5445. // Always clone your objects if you fear mutation.
  5446. DateProfileGenerator.prototype.getRangeOption = function (name) {
  5447. var otherArgs = [];
  5448. for (var _i = 1; _i < arguments.length; _i++) {
  5449. otherArgs[_i - 1] = arguments[_i];
  5450. }
  5451. var val = this.options[name];
  5452. if (typeof val === 'function') {
  5453. val = val.apply(null, otherArgs);
  5454. }
  5455. if (val) {
  5456. val = parseRange(val, this.dateEnv);
  5457. }
  5458. if (val) {
  5459. val = computeVisibleDayRange(val);
  5460. }
  5461. return val;
  5462. };
  5463. /* Hidden Days
  5464. ------------------------------------------------------------------------------------------------------------------*/
  5465. // Initializes internal variables related to calculating hidden days-of-week
  5466. DateProfileGenerator.prototype.initHiddenDays = function () {
  5467. var hiddenDays = this.options.hiddenDays || []; // array of day-of-week indices that are hidden
  5468. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  5469. var dayCnt = 0;
  5470. var i;
  5471. if (this.options.weekends === false) {
  5472. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  5473. }
  5474. for (i = 0; i < 7; i++) {
  5475. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  5476. dayCnt++;
  5477. }
  5478. }
  5479. if (!dayCnt) {
  5480. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  5481. }
  5482. this.isHiddenDayHash = isHiddenDayHash;
  5483. };
  5484. // Remove days from the beginning and end of the range that are computed as hidden.
  5485. // If the whole range is trimmed off, returns null
  5486. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  5487. var start = range.start;
  5488. var end = range.end;
  5489. if (start) {
  5490. start = this.skipHiddenDays(start);
  5491. }
  5492. if (end) {
  5493. end = this.skipHiddenDays(end, -1, true);
  5494. }
  5495. if (start == null || end == null || start < end) {
  5496. return { start: start, end: end };
  5497. }
  5498. return null;
  5499. };
  5500. // Is the current day hidden?
  5501. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  5502. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  5503. if (day instanceof Date) {
  5504. day = day.getUTCDay();
  5505. }
  5506. return this.isHiddenDayHash[day];
  5507. };
  5508. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  5509. // DOES NOT CONSIDER validRange!
  5510. // If the initial value of `date` is not a hidden day, don't do anything.
  5511. // Pass `isExclusive` as `true` if you are dealing with an end date.
  5512. // `inc` defaults to `1` (increment one day forward each time)
  5513. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  5514. if (inc === void 0) { inc = 1; }
  5515. if (isExclusive === void 0) { isExclusive = false; }
  5516. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  5517. date = addDays(date, inc);
  5518. }
  5519. return date;
  5520. };
  5521. return DateProfileGenerator;
  5522. }());
  5523. // TODO: find a way to avoid comparing DateProfiles. it's tedious
  5524. function isDateProfilesEqual(p0, p1) {
  5525. return rangesEqual(p0.validRange, p1.validRange) &&
  5526. rangesEqual(p0.activeRange, p1.activeRange) &&
  5527. rangesEqual(p0.renderRange, p1.renderRange) &&
  5528. durationsEqual(p0.minTime, p1.minTime) &&
  5529. durationsEqual(p0.maxTime, p1.maxTime);
  5530. /*
  5531. TODO: compare more?
  5532. currentRange: DateRange
  5533. currentRangeUnit: string
  5534. isRangeAllDay: boolean
  5535. isValid: boolean
  5536. dateIncrement: Duration
  5537. */
  5538. }
  5539. function reduce (state, action, calendar) {
  5540. var viewType = reduceViewType(state.viewType, action);
  5541. var dateProfile = reduceDateProfile(state.dateProfile, action, state.currentDate, viewType, calendar);
  5542. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendar);
  5543. var nextState = __assign({}, state, { viewType: viewType,
  5544. dateProfile: dateProfile, currentDate: reduceCurrentDate(state.currentDate, action, dateProfile), eventSources: eventSources, eventStore: reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendar), dateSelection: reduceDateSelection(state.dateSelection, action, calendar), eventSelection: reduceSelectedEvent(state.eventSelection, action), eventDrag: reduceEventDrag(state.eventDrag, action, eventSources, calendar), eventResize: reduceEventResize(state.eventResize, action, eventSources, calendar), eventSourceLoadingLevel: computeLoadingLevel(eventSources), loadingLevel: computeLoadingLevel(eventSources) });
  5545. for (var _i = 0, _a = calendar.pluginSystem.hooks.reducers; _i < _a.length; _i++) {
  5546. var reducerFunc = _a[_i];
  5547. nextState = reducerFunc(nextState, action, calendar);
  5548. }
  5549. // console.log(action.type, nextState)
  5550. return nextState;
  5551. }
  5552. function reduceViewType(currentViewType, action) {
  5553. switch (action.type) {
  5554. case 'SET_VIEW_TYPE':
  5555. return action.viewType;
  5556. default:
  5557. return currentViewType;
  5558. }
  5559. }
  5560. function reduceDateProfile(currentDateProfile, action, currentDate, viewType, calendar) {
  5561. var newDateProfile;
  5562. switch (action.type) {
  5563. case 'PREV':
  5564. newDateProfile = calendar.dateProfileGenerators[viewType].buildPrev(currentDateProfile, currentDate);
  5565. break;
  5566. case 'NEXT':
  5567. newDateProfile = calendar.dateProfileGenerators[viewType].buildNext(currentDateProfile, currentDate);
  5568. break;
  5569. case 'SET_DATE':
  5570. if (!currentDateProfile.activeRange ||
  5571. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker)) {
  5572. newDateProfile = calendar.dateProfileGenerators[viewType].build(action.dateMarker, undefined, true // forceToValid
  5573. );
  5574. }
  5575. break;
  5576. case 'SET_VIEW_TYPE':
  5577. var generator = calendar.dateProfileGenerators[viewType];
  5578. if (!generator) {
  5579. throw new Error(viewType ?
  5580. 'The FullCalendar view "' + viewType + '" does not exist. Make sure your plugins are loaded correctly.' :
  5581. 'No available FullCalendar view plugins.');
  5582. }
  5583. newDateProfile = generator.build(action.dateMarker || currentDate, undefined, true // forceToValid
  5584. );
  5585. break;
  5586. }
  5587. if (newDateProfile &&
  5588. newDateProfile.isValid &&
  5589. !(currentDateProfile && isDateProfilesEqual(currentDateProfile, newDateProfile))) {
  5590. return newDateProfile;
  5591. }
  5592. else {
  5593. return currentDateProfile;
  5594. }
  5595. }
  5596. function reduceCurrentDate(currentDate, action, dateProfile) {
  5597. switch (action.type) {
  5598. case 'PREV':
  5599. case 'NEXT':
  5600. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  5601. return dateProfile.currentRange.start;
  5602. }
  5603. else {
  5604. return currentDate;
  5605. }
  5606. case 'SET_DATE':
  5607. case 'SET_VIEW_TYPE':
  5608. var newDate = action.dateMarker || currentDate;
  5609. if (dateProfile.activeRange && !rangeContainsMarker(dateProfile.activeRange, newDate)) {
  5610. return dateProfile.currentRange.start;
  5611. }
  5612. else {
  5613. return newDate;
  5614. }
  5615. default:
  5616. return currentDate;
  5617. }
  5618. }
  5619. function reduceDateSelection(currentSelection, action, calendar) {
  5620. switch (action.type) {
  5621. case 'SELECT_DATES':
  5622. return action.selection;
  5623. case 'UNSELECT_DATES':
  5624. return null;
  5625. default:
  5626. return currentSelection;
  5627. }
  5628. }
  5629. function reduceSelectedEvent(currentInstanceId, action) {
  5630. switch (action.type) {
  5631. case 'SELECT_EVENT':
  5632. return action.eventInstanceId;
  5633. case 'UNSELECT_EVENT':
  5634. return '';
  5635. default:
  5636. return currentInstanceId;
  5637. }
  5638. }
  5639. function reduceEventDrag(currentDrag, action, sources, calendar) {
  5640. switch (action.type) {
  5641. case 'SET_EVENT_DRAG':
  5642. var newDrag = action.state;
  5643. return {
  5644. affectedEvents: newDrag.affectedEvents,
  5645. mutatedEvents: newDrag.mutatedEvents,
  5646. isEvent: newDrag.isEvent,
  5647. origSeg: newDrag.origSeg
  5648. };
  5649. case 'UNSET_EVENT_DRAG':
  5650. return null;
  5651. default:
  5652. return currentDrag;
  5653. }
  5654. }
  5655. function reduceEventResize(currentResize, action, sources, calendar) {
  5656. switch (action.type) {
  5657. case 'SET_EVENT_RESIZE':
  5658. var newResize = action.state;
  5659. return {
  5660. affectedEvents: newResize.affectedEvents,
  5661. mutatedEvents: newResize.mutatedEvents,
  5662. isEvent: newResize.isEvent,
  5663. origSeg: newResize.origSeg
  5664. };
  5665. case 'UNSET_EVENT_RESIZE':
  5666. return null;
  5667. default:
  5668. return currentResize;
  5669. }
  5670. }
  5671. function computeLoadingLevel(eventSources) {
  5672. var cnt = 0;
  5673. for (var sourceId in eventSources) {
  5674. if (eventSources[sourceId].isFetching) {
  5675. cnt++;
  5676. }
  5677. }
  5678. return cnt;
  5679. }
  5680. var STANDARD_PROPS = {
  5681. start: null,
  5682. end: null,
  5683. allDay: Boolean
  5684. };
  5685. function parseDateSpan(raw, dateEnv, defaultDuration) {
  5686. var span = parseOpenDateSpan(raw, dateEnv);
  5687. var range = span.range;
  5688. if (!range.start) {
  5689. return null;
  5690. }
  5691. if (!range.end) {
  5692. if (defaultDuration == null) {
  5693. return null;
  5694. }
  5695. else {
  5696. range.end = dateEnv.add(range.start, defaultDuration);
  5697. }
  5698. }
  5699. return span;
  5700. }
  5701. /*
  5702. TODO: somehow combine with parseRange?
  5703. Will return null if the start/end props were present but parsed invalidly.
  5704. */
  5705. function parseOpenDateSpan(raw, dateEnv) {
  5706. var leftovers = {};
  5707. var standardProps = refineProps(raw, STANDARD_PROPS, {}, leftovers);
  5708. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  5709. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  5710. var allDay = standardProps.allDay;
  5711. if (allDay == null) {
  5712. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  5713. (!endMeta || endMeta.isTimeUnspecified);
  5714. }
  5715. // use this leftover object as the selection object
  5716. leftovers.range = {
  5717. start: startMeta ? startMeta.marker : null,
  5718. end: endMeta ? endMeta.marker : null
  5719. };
  5720. leftovers.allDay = allDay;
  5721. return leftovers;
  5722. }
  5723. function isDateSpansEqual(span0, span1) {
  5724. return rangesEqual(span0.range, span1.range) &&
  5725. span0.allDay === span1.allDay &&
  5726. isSpanPropsEqual(span0, span1);
  5727. }
  5728. // the NON-DATE-RELATED props
  5729. function isSpanPropsEqual(span0, span1) {
  5730. for (var propName in span1) {
  5731. if (propName !== 'range' && propName !== 'allDay') {
  5732. if (span0[propName] !== span1[propName]) {
  5733. return false;
  5734. }
  5735. }
  5736. }
  5737. // are there any props that span0 has that span1 DOESN'T have?
  5738. // both have range/allDay, so no need to special-case.
  5739. for (var propName in span0) {
  5740. if (!(propName in span1)) {
  5741. return false;
  5742. }
  5743. }
  5744. return true;
  5745. }
  5746. function buildDateSpanApi(span, dateEnv) {
  5747. return {
  5748. start: dateEnv.toDate(span.range.start),
  5749. end: dateEnv.toDate(span.range.end),
  5750. startStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5751. endStr: dateEnv.formatIso(span.range.end, { omitTime: span.allDay }),
  5752. allDay: span.allDay
  5753. };
  5754. }
  5755. function buildDatePointApi(span, dateEnv) {
  5756. return {
  5757. date: dateEnv.toDate(span.range.start),
  5758. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5759. allDay: span.allDay
  5760. };
  5761. }
  5762. function fabricateEventRange(dateSpan, eventUiBases, calendar) {
  5763. var def = parseEventDef({ editable: false }, '', // sourceId
  5764. dateSpan.allDay, true, // hasEnd
  5765. calendar);
  5766. return {
  5767. def: def,
  5768. ui: compileEventUi(def, eventUiBases),
  5769. instance: createEventInstance(def.defId, dateSpan.range),
  5770. range: dateSpan.range,
  5771. isStart: true,
  5772. isEnd: true
  5773. };
  5774. }
  5775. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5776. var hash = {};
  5777. var viewType;
  5778. for (viewType in defaultConfigs) {
  5779. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5780. }
  5781. for (viewType in overrideConfigs) {
  5782. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5783. }
  5784. return hash;
  5785. }
  5786. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5787. if (hash[viewType]) {
  5788. return hash[viewType];
  5789. }
  5790. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5791. if (viewDef) {
  5792. hash[viewType] = viewDef;
  5793. }
  5794. return viewDef;
  5795. }
  5796. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5797. var defaultConfig = defaultConfigs[viewType];
  5798. var overrideConfig = overrideConfigs[viewType];
  5799. var queryProp = function (name) {
  5800. return (defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5801. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null);
  5802. };
  5803. var theClass = queryProp('class');
  5804. var superType = queryProp('superType');
  5805. if (!superType && theClass) {
  5806. superType =
  5807. findViewNameBySubclass(theClass, overrideConfigs) ||
  5808. findViewNameBySubclass(theClass, defaultConfigs);
  5809. }
  5810. var superDef = null;
  5811. if (superType) {
  5812. if (superType === viewType) {
  5813. throw new Error('Can\'t have a custom view type that references itself');
  5814. }
  5815. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5816. }
  5817. if (!theClass && superDef) {
  5818. theClass = superDef.class;
  5819. }
  5820. if (!theClass) {
  5821. return null; // don't throw a warning, might be settings for a single-unit view
  5822. }
  5823. return {
  5824. type: viewType,
  5825. class: theClass,
  5826. defaults: __assign({}, (superDef ? superDef.defaults : {}), (defaultConfig ? defaultConfig.options : {})),
  5827. overrides: __assign({}, (superDef ? superDef.overrides : {}), (overrideConfig ? overrideConfig.options : {}))
  5828. };
  5829. }
  5830. function findViewNameBySubclass(viewSubclass, configs) {
  5831. var superProto = Object.getPrototypeOf(viewSubclass.prototype);
  5832. for (var viewType in configs) {
  5833. var parsed = configs[viewType];
  5834. // need DIRECT subclass, so instanceof won't do it
  5835. if (parsed.class && parsed.class.prototype === superProto) {
  5836. return viewType;
  5837. }
  5838. }
  5839. return '';
  5840. }
  5841. function parseViewConfigs(inputs) {
  5842. return mapHash(inputs, parseViewConfig);
  5843. }
  5844. var VIEW_DEF_PROPS = {
  5845. type: String,
  5846. class: null
  5847. };
  5848. function parseViewConfig(input) {
  5849. if (typeof input === 'function') {
  5850. input = { class: input };
  5851. }
  5852. var options = {};
  5853. var props = refineProps(input, VIEW_DEF_PROPS, {}, options);
  5854. return {
  5855. superType: props.type,
  5856. class: props.class,
  5857. options: options
  5858. };
  5859. }
  5860. function buildViewSpecs(defaultInputs, optionsManager) {
  5861. var defaultConfigs = parseViewConfigs(defaultInputs);
  5862. var overrideConfigs = parseViewConfigs(optionsManager.overrides.views);
  5863. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5864. return mapHash(viewDefs, function (viewDef) {
  5865. return buildViewSpec(viewDef, overrideConfigs, optionsManager);
  5866. });
  5867. }
  5868. function buildViewSpec(viewDef, overrideConfigs, optionsManager) {
  5869. var durationInput = viewDef.overrides.duration ||
  5870. viewDef.defaults.duration ||
  5871. optionsManager.dynamicOverrides.duration ||
  5872. optionsManager.overrides.duration;
  5873. var duration = null;
  5874. var durationUnit = '';
  5875. var singleUnit = '';
  5876. var singleUnitOverrides = {};
  5877. if (durationInput) {
  5878. duration = createDuration(durationInput);
  5879. if (duration) { // valid?
  5880. var denom = greatestDurationDenominator(duration, !getWeeksFromInput(durationInput));
  5881. durationUnit = denom.unit;
  5882. if (denom.value === 1) {
  5883. singleUnit = durationUnit;
  5884. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].options : {};
  5885. }
  5886. }
  5887. }
  5888. var queryButtonText = function (options) {
  5889. var buttonTextMap = options.buttonText || {};
  5890. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5891. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5892. return buttonTextMap[buttonTextKey];
  5893. }
  5894. if (buttonTextMap[viewDef.type] != null) {
  5895. return buttonTextMap[viewDef.type];
  5896. }
  5897. if (buttonTextMap[singleUnit] != null) {
  5898. return buttonTextMap[singleUnit];
  5899. }
  5900. };
  5901. return {
  5902. type: viewDef.type,
  5903. class: viewDef.class,
  5904. duration: duration,
  5905. durationUnit: durationUnit,
  5906. singleUnit: singleUnit,
  5907. options: __assign({}, globalDefaults, viewDef.defaults, optionsManager.dirDefaults, optionsManager.localeDefaults, optionsManager.overrides, singleUnitOverrides, viewDef.overrides, optionsManager.dynamicOverrides),
  5908. buttonTextOverride: queryButtonText(optionsManager.dynamicOverrides) ||
  5909. queryButtonText(optionsManager.overrides) || // constructor-specified buttonText lookup hash takes precedence
  5910. viewDef.overrides.buttonText,
  5911. buttonTextDefault: queryButtonText(optionsManager.localeDefaults) ||
  5912. queryButtonText(optionsManager.dirDefaults) ||
  5913. viewDef.defaults.buttonText ||
  5914. queryButtonText(globalDefaults) ||
  5915. viewDef.type // fall back to given view name
  5916. };
  5917. }
  5918. var Toolbar = /** @class */ (function (_super) {
  5919. __extends(Toolbar, _super);
  5920. function Toolbar(extraClassName) {
  5921. var _this = _super.call(this) || this;
  5922. _this._renderLayout = memoizeRendering(_this.renderLayout, _this.unrenderLayout);
  5923. _this._updateTitle = memoizeRendering(_this.updateTitle, null, [_this._renderLayout]);
  5924. _this._updateActiveButton = memoizeRendering(_this.updateActiveButton, null, [_this._renderLayout]);
  5925. _this._updateToday = memoizeRendering(_this.updateToday, null, [_this._renderLayout]);
  5926. _this._updatePrev = memoizeRendering(_this.updatePrev, null, [_this._renderLayout]);
  5927. _this._updateNext = memoizeRendering(_this.updateNext, null, [_this._renderLayout]);
  5928. _this.el = createElement('div', { className: 'fc-toolbar ' + extraClassName });
  5929. return _this;
  5930. }
  5931. Toolbar.prototype.destroy = function () {
  5932. _super.prototype.destroy.call(this);
  5933. this._renderLayout.unrender(); // should unrender everything else
  5934. removeElement(this.el);
  5935. };
  5936. Toolbar.prototype.render = function (props) {
  5937. this._renderLayout(props.layout);
  5938. this._updateTitle(props.title);
  5939. this._updateActiveButton(props.activeButton);
  5940. this._updateToday(props.isTodayEnabled);
  5941. this._updatePrev(props.isPrevEnabled);
  5942. this._updateNext(props.isNextEnabled);
  5943. };
  5944. Toolbar.prototype.renderLayout = function (layout) {
  5945. var el = this.el;
  5946. this.viewsWithButtons = [];
  5947. appendToElement(el, this.renderSection('left', layout.left));
  5948. appendToElement(el, this.renderSection('center', layout.center));
  5949. appendToElement(el, this.renderSection('right', layout.right));
  5950. };
  5951. Toolbar.prototype.unrenderLayout = function () {
  5952. this.el.innerHTML = '';
  5953. };
  5954. Toolbar.prototype.renderSection = function (position, buttonStr) {
  5955. var _this = this;
  5956. var _a = this.context, theme = _a.theme, calendar = _a.calendar;
  5957. var optionsManager = calendar.optionsManager;
  5958. var viewSpecs = calendar.viewSpecs;
  5959. var sectionEl = createElement('div', { className: 'fc-' + position });
  5960. var calendarCustomButtons = optionsManager.computed.customButtons || {};
  5961. var calendarButtonTextOverrides = optionsManager.overrides.buttonText || {};
  5962. var calendarButtonText = optionsManager.computed.buttonText || {};
  5963. if (buttonStr) {
  5964. buttonStr.split(' ').forEach(function (buttonGroupStr, i) {
  5965. var groupChildren = [];
  5966. var isOnlyButtons = true;
  5967. var groupEl;
  5968. buttonGroupStr.split(',').forEach(function (buttonName, j) {
  5969. var customButtonProps;
  5970. var viewSpec;
  5971. var buttonClick;
  5972. var buttonIcon; // only one of these will be set
  5973. var buttonText; // "
  5974. var buttonInnerHtml;
  5975. var buttonClasses;
  5976. var buttonEl;
  5977. var buttonAriaAttr;
  5978. if (buttonName === 'title') {
  5979. groupChildren.push(htmlToElement('<h2>&nbsp;</h2>')); // we always want it to take up height
  5980. isOnlyButtons = false;
  5981. }
  5982. else {
  5983. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  5984. buttonClick = function (ev) {
  5985. if (customButtonProps.click) {
  5986. customButtonProps.click.call(buttonEl, ev);
  5987. }
  5988. };
  5989. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  5990. (buttonIcon = theme.getIconClass(buttonName)) ||
  5991. (buttonText = customButtonProps.text);
  5992. }
  5993. else if ((viewSpec = viewSpecs[buttonName])) {
  5994. _this.viewsWithButtons.push(buttonName);
  5995. buttonClick = function () {
  5996. calendar.changeView(buttonName);
  5997. };
  5998. (buttonText = viewSpec.buttonTextOverride) ||
  5999. (buttonIcon = theme.getIconClass(buttonName)) ||
  6000. (buttonText = viewSpec.buttonTextDefault);
  6001. }
  6002. else if (calendar[buttonName]) { // a calendar method
  6003. buttonClick = function () {
  6004. calendar[buttonName]();
  6005. };
  6006. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6007. (buttonIcon = theme.getIconClass(buttonName)) ||
  6008. (buttonText = calendarButtonText[buttonName]);
  6009. // ^ everything else is considered default
  6010. }
  6011. if (buttonClick) {
  6012. buttonClasses = [
  6013. 'fc-' + buttonName + '-button',
  6014. theme.getClass('button')
  6015. ];
  6016. if (buttonText) {
  6017. buttonInnerHtml = htmlEscape(buttonText);
  6018. buttonAriaAttr = '';
  6019. }
  6020. else if (buttonIcon) {
  6021. buttonInnerHtml = "<span class='" + buttonIcon + "'></span>";
  6022. buttonAriaAttr = ' aria-label="' + buttonName + '"';
  6023. }
  6024. buttonEl = htmlToElement(// type="button" so that it doesn't submit a form
  6025. '<button type="button" class="' + buttonClasses.join(' ') + '"' +
  6026. buttonAriaAttr +
  6027. '>' + buttonInnerHtml + '</button>');
  6028. buttonEl.addEventListener('click', buttonClick);
  6029. groupChildren.push(buttonEl);
  6030. }
  6031. }
  6032. });
  6033. if (groupChildren.length > 1) {
  6034. groupEl = document.createElement('div');
  6035. var buttonGroupClassName = theme.getClass('buttonGroup');
  6036. if (isOnlyButtons && buttonGroupClassName) {
  6037. groupEl.classList.add(buttonGroupClassName);
  6038. }
  6039. appendToElement(groupEl, groupChildren);
  6040. sectionEl.appendChild(groupEl);
  6041. }
  6042. else {
  6043. appendToElement(sectionEl, groupChildren); // 1 or 0 children
  6044. }
  6045. });
  6046. }
  6047. return sectionEl;
  6048. };
  6049. Toolbar.prototype.updateToday = function (isTodayEnabled) {
  6050. this.toggleButtonEnabled('today', isTodayEnabled);
  6051. };
  6052. Toolbar.prototype.updatePrev = function (isPrevEnabled) {
  6053. this.toggleButtonEnabled('prev', isPrevEnabled);
  6054. };
  6055. Toolbar.prototype.updateNext = function (isNextEnabled) {
  6056. this.toggleButtonEnabled('next', isNextEnabled);
  6057. };
  6058. Toolbar.prototype.updateTitle = function (text) {
  6059. findElements(this.el, 'h2').forEach(function (titleEl) {
  6060. titleEl.innerText = text;
  6061. });
  6062. };
  6063. Toolbar.prototype.updateActiveButton = function (buttonName) {
  6064. var theme = this.context.theme;
  6065. var className = theme.getClass('buttonActive');
  6066. findElements(this.el, 'button').forEach(function (buttonEl) {
  6067. if (buttonName && buttonEl.classList.contains('fc-' + buttonName + '-button')) {
  6068. buttonEl.classList.add(className);
  6069. }
  6070. else {
  6071. buttonEl.classList.remove(className);
  6072. }
  6073. });
  6074. };
  6075. Toolbar.prototype.toggleButtonEnabled = function (buttonName, bool) {
  6076. findElements(this.el, '.fc-' + buttonName + '-button').forEach(function (buttonEl) {
  6077. buttonEl.disabled = !bool;
  6078. });
  6079. };
  6080. return Toolbar;
  6081. }(Component));
  6082. var CalendarComponent = /** @class */ (function (_super) {
  6083. __extends(CalendarComponent, _super);
  6084. function CalendarComponent(el) {
  6085. var _this = _super.call(this) || this;
  6086. _this.elClassNames = [];
  6087. _this.renderSkeleton = memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  6088. _this.renderToolbars = memoizeRendering(_this._renderToolbars, _this._unrenderToolbars, [_this.renderSkeleton]);
  6089. _this.buildComponentContext = memoize(buildComponentContext);
  6090. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  6091. _this.el = el;
  6092. _this.computeTitle = memoize(computeTitle);
  6093. _this.parseBusinessHours = memoize(function (input) {
  6094. return parseBusinessHours(input, _this.context.calendar);
  6095. });
  6096. return _this;
  6097. }
  6098. CalendarComponent.prototype.render = function (props, context) {
  6099. this.freezeHeight();
  6100. var title = this.computeTitle(props.dateProfile, props.viewSpec.options);
  6101. this.renderSkeleton(context);
  6102. this.renderToolbars(props.viewSpec, props.dateProfile, props.currentDate, title);
  6103. this.renderView(props, title);
  6104. this.updateSize();
  6105. this.thawHeight();
  6106. };
  6107. CalendarComponent.prototype.destroy = function () {
  6108. if (this.header) {
  6109. this.header.destroy();
  6110. }
  6111. if (this.footer) {
  6112. this.footer.destroy();
  6113. }
  6114. this.renderSkeleton.unrender(); // will call destroyView
  6115. _super.prototype.destroy.call(this);
  6116. };
  6117. CalendarComponent.prototype._renderSkeleton = function (context) {
  6118. this.updateElClassNames(context);
  6119. prependToElement(this.el, this.contentEl = createElement('div', { className: 'fc-view-container' }));
  6120. var calendar = context.calendar;
  6121. for (var _i = 0, _a = calendar.pluginSystem.hooks.viewContainerModifiers; _i < _a.length; _i++) {
  6122. var modifyViewContainer = _a[_i];
  6123. modifyViewContainer(this.contentEl, calendar);
  6124. }
  6125. };
  6126. CalendarComponent.prototype._unrenderSkeleton = function () {
  6127. // weird to have this here
  6128. if (this.view) {
  6129. this.savedScroll = this.view.queryScroll();
  6130. this.view.destroy();
  6131. this.view = null;
  6132. }
  6133. removeElement(this.contentEl);
  6134. this.removeElClassNames();
  6135. };
  6136. CalendarComponent.prototype.removeElClassNames = function () {
  6137. var classList = this.el.classList;
  6138. for (var _i = 0, _a = this.elClassNames; _i < _a.length; _i++) {
  6139. var className = _a[_i];
  6140. classList.remove(className);
  6141. }
  6142. this.elClassNames = [];
  6143. };
  6144. CalendarComponent.prototype.updateElClassNames = function (context) {
  6145. this.removeElClassNames();
  6146. var theme = context.theme, options = context.options;
  6147. this.elClassNames = [
  6148. 'fc',
  6149. 'fc-' + options.dir,
  6150. theme.getClass('widget')
  6151. ];
  6152. var classList = this.el.classList;
  6153. for (var _i = 0, _a = this.elClassNames; _i < _a.length; _i++) {
  6154. var className = _a[_i];
  6155. classList.add(className);
  6156. }
  6157. };
  6158. CalendarComponent.prototype._renderToolbars = function (viewSpec, dateProfile, currentDate, title) {
  6159. var _a = this, context = _a.context, header = _a.header, footer = _a.footer;
  6160. var options = context.options, calendar = context.calendar;
  6161. var headerLayout = options.header;
  6162. var footerLayout = options.footer;
  6163. var dateProfileGenerator = this.props.dateProfileGenerator;
  6164. var now = calendar.getNow();
  6165. var todayInfo = dateProfileGenerator.build(now);
  6166. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate);
  6167. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate);
  6168. var toolbarProps = {
  6169. title: title,
  6170. activeButton: viewSpec.type,
  6171. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  6172. isPrevEnabled: prevInfo.isValid,
  6173. isNextEnabled: nextInfo.isValid
  6174. };
  6175. if (headerLayout) {
  6176. if (!header) {
  6177. header = this.header = new Toolbar('fc-header-toolbar');
  6178. prependToElement(this.el, header.el);
  6179. }
  6180. header.receiveProps(__assign({ layout: headerLayout }, toolbarProps), context);
  6181. }
  6182. else if (header) {
  6183. header.destroy();
  6184. header = this.header = null;
  6185. }
  6186. if (footerLayout) {
  6187. if (!footer) {
  6188. footer = this.footer = new Toolbar('fc-footer-toolbar');
  6189. appendToElement(this.el, footer.el);
  6190. }
  6191. footer.receiveProps(__assign({ layout: footerLayout }, toolbarProps), context);
  6192. }
  6193. else if (footer) {
  6194. footer.destroy();
  6195. footer = this.footer = null;
  6196. }
  6197. };
  6198. CalendarComponent.prototype._unrenderToolbars = function () {
  6199. if (this.header) {
  6200. this.header.destroy();
  6201. this.header = null;
  6202. }
  6203. if (this.footer) {
  6204. this.footer.destroy();
  6205. this.footer = null;
  6206. }
  6207. };
  6208. CalendarComponent.prototype.renderView = function (props, title) {
  6209. var view = this.view;
  6210. var _a = this.context, calendar = _a.calendar, options = _a.options;
  6211. var viewSpec = props.viewSpec, dateProfileGenerator = props.dateProfileGenerator;
  6212. if (!view || view.viewSpec !== viewSpec) {
  6213. if (view) {
  6214. view.destroy();
  6215. }
  6216. view = this.view = new viewSpec['class'](viewSpec, this.contentEl);
  6217. if (this.savedScroll) {
  6218. view.addScroll(this.savedScroll, true);
  6219. this.savedScroll = null;
  6220. }
  6221. }
  6222. view.title = title; // for the API
  6223. var viewProps = {
  6224. dateProfileGenerator: dateProfileGenerator,
  6225. dateProfile: props.dateProfile,
  6226. businessHours: this.parseBusinessHours(viewSpec.options.businessHours),
  6227. eventStore: props.eventStore,
  6228. eventUiBases: props.eventUiBases,
  6229. dateSelection: props.dateSelection,
  6230. eventSelection: props.eventSelection,
  6231. eventDrag: props.eventDrag,
  6232. eventResize: props.eventResize
  6233. };
  6234. var transformers = this.buildViewPropTransformers(calendar.pluginSystem.hooks.viewPropsTransformers);
  6235. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  6236. var transformer = transformers_1[_i];
  6237. __assign(viewProps, transformer.transform(viewProps, viewSpec, props, options));
  6238. }
  6239. view.receiveProps(viewProps, this.buildComponentContext(this.context, viewSpec, view));
  6240. };
  6241. // Sizing
  6242. // -----------------------------------------------------------------------------------------------------------------
  6243. CalendarComponent.prototype.updateSize = function (isResize) {
  6244. if (isResize === void 0) { isResize = false; }
  6245. var view = this.view;
  6246. if (!view) {
  6247. return; // why?
  6248. }
  6249. if (isResize || this.isHeightAuto == null) {
  6250. this.computeHeightVars();
  6251. }
  6252. view.updateSize(isResize, this.viewHeight, this.isHeightAuto);
  6253. view.updateNowIndicator(); // we need to guarantee this will run after updateSize
  6254. view.popScroll(isResize);
  6255. };
  6256. CalendarComponent.prototype.computeHeightVars = function () {
  6257. var calendar = this.context.calendar; // yuck. need to handle dynamic options
  6258. var heightInput = calendar.opt('height');
  6259. var contentHeightInput = calendar.opt('contentHeight');
  6260. this.isHeightAuto = heightInput === 'auto' || contentHeightInput === 'auto';
  6261. if (typeof contentHeightInput === 'number') { // exists and not 'auto'
  6262. this.viewHeight = contentHeightInput;
  6263. }
  6264. else if (typeof contentHeightInput === 'function') { // exists and is a function
  6265. this.viewHeight = contentHeightInput();
  6266. }
  6267. else if (typeof heightInput === 'number') { // exists and not 'auto'
  6268. this.viewHeight = heightInput - this.queryToolbarsHeight();
  6269. }
  6270. else if (typeof heightInput === 'function') { // exists and is a function
  6271. this.viewHeight = heightInput() - this.queryToolbarsHeight();
  6272. }
  6273. else if (heightInput === 'parent') { // set to height of parent element
  6274. var parentEl = this.el.parentNode;
  6275. this.viewHeight = parentEl.getBoundingClientRect().height - this.queryToolbarsHeight();
  6276. }
  6277. else {
  6278. this.viewHeight = Math.round(this.contentEl.getBoundingClientRect().width /
  6279. Math.max(calendar.opt('aspectRatio'), .5));
  6280. }
  6281. };
  6282. CalendarComponent.prototype.queryToolbarsHeight = function () {
  6283. var height = 0;
  6284. if (this.header) {
  6285. height += computeHeightAndMargins(this.header.el);
  6286. }
  6287. if (this.footer) {
  6288. height += computeHeightAndMargins(this.footer.el);
  6289. }
  6290. return height;
  6291. };
  6292. // Height "Freezing"
  6293. // -----------------------------------------------------------------------------------------------------------------
  6294. CalendarComponent.prototype.freezeHeight = function () {
  6295. applyStyle(this.el, {
  6296. height: this.el.getBoundingClientRect().height,
  6297. overflow: 'hidden'
  6298. });
  6299. };
  6300. CalendarComponent.prototype.thawHeight = function () {
  6301. applyStyle(this.el, {
  6302. height: '',
  6303. overflow: ''
  6304. });
  6305. };
  6306. return CalendarComponent;
  6307. }(Component));
  6308. // Title and Date Formatting
  6309. // -----------------------------------------------------------------------------------------------------------------
  6310. // Computes what the title at the top of the calendar should be for this view
  6311. function computeTitle(dateProfile, viewOptions) {
  6312. var range;
  6313. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6314. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6315. range = dateProfile.currentRange;
  6316. }
  6317. else { // for day units or smaller, use the actual day range
  6318. range = dateProfile.activeRange;
  6319. }
  6320. return this.context.dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || computeTitleFormat(dateProfile), viewOptions.titleRangeSeparator), { isEndExclusive: dateProfile.isRangeAllDay });
  6321. }
  6322. // Generates the format string that should be used to generate the title for the current date range.
  6323. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6324. function computeTitleFormat(dateProfile) {
  6325. var currentRangeUnit = dateProfile.currentRangeUnit;
  6326. if (currentRangeUnit === 'year') {
  6327. return { year: 'numeric' };
  6328. }
  6329. else if (currentRangeUnit === 'month') {
  6330. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6331. }
  6332. else {
  6333. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6334. if (days !== null && days > 1) {
  6335. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6336. return { year: 'numeric', month: 'short', day: 'numeric' };
  6337. }
  6338. else {
  6339. // one day. longer, like "September 9 2014"
  6340. return { year: 'numeric', month: 'long', day: 'numeric' };
  6341. }
  6342. }
  6343. }
  6344. // build a context scoped to the view
  6345. function buildComponentContext(context, viewSpec, view) {
  6346. return context.extend(viewSpec.options, view);
  6347. }
  6348. // Plugin
  6349. // -----------------------------------------------------------------------------------------------------------------
  6350. function buildViewPropTransformers(theClasses) {
  6351. return theClasses.map(function (theClass) {
  6352. return new theClass();
  6353. });
  6354. }
  6355. var Interaction = /** @class */ (function () {
  6356. function Interaction(settings) {
  6357. this.component = settings.component;
  6358. }
  6359. Interaction.prototype.destroy = function () {
  6360. };
  6361. return Interaction;
  6362. }());
  6363. function parseInteractionSettings(component, input) {
  6364. return {
  6365. component: component,
  6366. el: input.el,
  6367. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true
  6368. };
  6369. }
  6370. function interactionSettingsToStore(settings) {
  6371. var _a;
  6372. return _a = {},
  6373. _a[settings.component.uid] = settings,
  6374. _a;
  6375. }
  6376. // global state
  6377. var interactionSettingsStore = {};
  6378. /*
  6379. Detects when the user clicks on an event within a DateComponent
  6380. */
  6381. var EventClicking = /** @class */ (function (_super) {
  6382. __extends(EventClicking, _super);
  6383. function EventClicking(settings) {
  6384. var _this = _super.call(this, settings) || this;
  6385. _this.handleSegClick = function (ev, segEl) {
  6386. var component = _this.component;
  6387. var _a = component.context, calendar = _a.calendar, view = _a.view;
  6388. var seg = getElSeg(segEl);
  6389. if (seg && // might be the <div> surrounding the more link
  6390. component.isValidSegDownEl(ev.target)) {
  6391. // our way to simulate a link click for elements that can't be <a> tags
  6392. // grab before trigger fired in case trigger trashes DOM thru rerendering
  6393. var hasUrlContainer = elementClosest(ev.target, '.fc-has-url');
  6394. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  6395. calendar.publiclyTrigger('eventClick', [
  6396. {
  6397. el: segEl,
  6398. event: new EventApi(component.context.calendar, seg.eventRange.def, seg.eventRange.instance),
  6399. jsEvent: ev,
  6400. view: view
  6401. }
  6402. ]);
  6403. if (url && !ev.defaultPrevented) {
  6404. window.location.href = url;
  6405. }
  6406. }
  6407. };
  6408. var component = settings.component;
  6409. _this.destroy = listenBySelector(component.el, 'click', component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegClick);
  6410. return _this;
  6411. }
  6412. return EventClicking;
  6413. }(Interaction));
  6414. /*
  6415. Triggers events and adds/removes core classNames when the user's pointer
  6416. enters/leaves event-elements of a component.
  6417. */
  6418. var EventHovering = /** @class */ (function (_super) {
  6419. __extends(EventHovering, _super);
  6420. function EventHovering(settings) {
  6421. var _this = _super.call(this, settings) || this;
  6422. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  6423. _this.handleEventElRemove = function (el) {
  6424. if (el === _this.currentSegEl) {
  6425. _this.handleSegLeave(null, _this.currentSegEl);
  6426. }
  6427. };
  6428. _this.handleSegEnter = function (ev, segEl) {
  6429. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  6430. segEl.classList.add('fc-allow-mouse-resize');
  6431. _this.currentSegEl = segEl;
  6432. _this.triggerEvent('eventMouseEnter', ev, segEl);
  6433. }
  6434. };
  6435. _this.handleSegLeave = function (ev, segEl) {
  6436. if (_this.currentSegEl) {
  6437. segEl.classList.remove('fc-allow-mouse-resize');
  6438. _this.currentSegEl = null;
  6439. _this.triggerEvent('eventMouseLeave', ev, segEl);
  6440. }
  6441. };
  6442. var component = settings.component;
  6443. _this.removeHoverListeners = listenToHoverBySelector(component.el, component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegEnter, _this.handleSegLeave);
  6444. // how to make sure component already has context?
  6445. component.context.calendar.on('eventElRemove', _this.handleEventElRemove);
  6446. return _this;
  6447. }
  6448. EventHovering.prototype.destroy = function () {
  6449. this.removeHoverListeners();
  6450. this.component.context.calendar.off('eventElRemove', this.handleEventElRemove);
  6451. };
  6452. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  6453. var component = this.component;
  6454. var _a = component.context, calendar = _a.calendar, view = _a.view;
  6455. var seg = getElSeg(segEl);
  6456. if (!ev || component.isValidSegDownEl(ev.target)) {
  6457. calendar.publiclyTrigger(publicEvName, [
  6458. {
  6459. el: segEl,
  6460. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  6461. jsEvent: ev,
  6462. view: view
  6463. }
  6464. ]);
  6465. }
  6466. };
  6467. return EventHovering;
  6468. }(Interaction));
  6469. var StandardTheme = /** @class */ (function (_super) {
  6470. __extends(StandardTheme, _super);
  6471. function StandardTheme() {
  6472. return _super !== null && _super.apply(this, arguments) || this;
  6473. }
  6474. return StandardTheme;
  6475. }(Theme));
  6476. StandardTheme.prototype.classes = {
  6477. widget: 'fc-unthemed',
  6478. widgetHeader: 'fc-widget-header',
  6479. widgetContent: 'fc-widget-content',
  6480. buttonGroup: 'fc-button-group',
  6481. button: 'fc-button fc-button-primary',
  6482. buttonActive: 'fc-button-active',
  6483. popoverHeader: 'fc-widget-header',
  6484. popoverContent: 'fc-widget-content',
  6485. // day grid
  6486. headerRow: 'fc-widget-header',
  6487. dayRow: 'fc-widget-content',
  6488. // list view
  6489. listView: 'fc-widget-content'
  6490. };
  6491. StandardTheme.prototype.baseIconClass = 'fc-icon';
  6492. StandardTheme.prototype.iconClasses = {
  6493. close: 'fc-icon-x',
  6494. prev: 'fc-icon-chevron-left',
  6495. next: 'fc-icon-chevron-right',
  6496. prevYear: 'fc-icon-chevrons-left',
  6497. nextYear: 'fc-icon-chevrons-right'
  6498. };
  6499. StandardTheme.prototype.iconOverrideOption = 'buttonIcons';
  6500. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  6501. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  6502. var Calendar = /** @class */ (function () {
  6503. function Calendar(el, overrides) {
  6504. var _this = this;
  6505. this.buildComponentContext = memoize(buildComponentContext$1);
  6506. this.parseRawLocales = memoize(parseRawLocales);
  6507. this.buildLocale = memoize(buildLocale);
  6508. this.buildDateEnv = memoize(buildDateEnv);
  6509. this.buildTheme = memoize(buildTheme);
  6510. this.buildEventUiSingleBase = memoize(this._buildEventUiSingleBase);
  6511. this.buildSelectionConfig = memoize(this._buildSelectionConfig);
  6512. this.buildEventUiBySource = memoizeOutput(buildEventUiBySource, isPropsEqual);
  6513. this.buildEventUiBases = memoize(buildEventUiBases);
  6514. this.interactionsStore = {};
  6515. this.actionQueue = [];
  6516. this.isReducing = false;
  6517. // isDisplaying: boolean = false // installed in DOM? accepting renders?
  6518. this.needsRerender = false; // needs a render?
  6519. this.isRendering = false; // currently in the executeRender function?
  6520. this.renderingPauseDepth = 0;
  6521. this.buildDelayedRerender = memoize(buildDelayedRerender);
  6522. this.afterSizingTriggers = {};
  6523. this.isViewUpdated = false;
  6524. this.isDatesUpdated = false;
  6525. this.isEventsUpdated = false;
  6526. this.el = el;
  6527. this.optionsManager = new OptionsManager(overrides || {});
  6528. this.pluginSystem = new PluginSystem();
  6529. // only do once. don't do in handleOptions. because can't remove plugins
  6530. this.addPluginInputs(this.optionsManager.computed.plugins || []);
  6531. this.handleOptions(this.optionsManager.computed);
  6532. this.publiclyTrigger('_init'); // for tests
  6533. this.hydrate();
  6534. this.calendarInteractions = this.pluginSystem.hooks.calendarInteractions
  6535. .map(function (calendarInteractionClass) {
  6536. return new calendarInteractionClass(_this);
  6537. });
  6538. }
  6539. Calendar.prototype.addPluginInputs = function (pluginInputs) {
  6540. var pluginDefs = refinePluginDefs(pluginInputs);
  6541. for (var _i = 0, pluginDefs_1 = pluginDefs; _i < pluginDefs_1.length; _i++) {
  6542. var pluginDef = pluginDefs_1[_i];
  6543. this.pluginSystem.add(pluginDef);
  6544. }
  6545. };
  6546. Object.defineProperty(Calendar.prototype, "view", {
  6547. // public API
  6548. get: function () {
  6549. return this.component ? this.component.view : null;
  6550. },
  6551. enumerable: true,
  6552. configurable: true
  6553. });
  6554. // Public API for rendering
  6555. // -----------------------------------------------------------------------------------------------------------------
  6556. Calendar.prototype.render = function () {
  6557. if (!this.component) {
  6558. this.component = new CalendarComponent(this.el);
  6559. this.renderableEventStore = createEmptyEventStore();
  6560. this.bindHandlers();
  6561. this.executeRender();
  6562. }
  6563. else {
  6564. this.requestRerender();
  6565. }
  6566. };
  6567. Calendar.prototype.destroy = function () {
  6568. if (this.component) {
  6569. this.unbindHandlers();
  6570. this.component.destroy(); // don't null-out. in case API needs access
  6571. this.component = null; // umm ???
  6572. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  6573. var interaction = _a[_i];
  6574. interaction.destroy();
  6575. }
  6576. this.publiclyTrigger('_destroyed');
  6577. }
  6578. };
  6579. // Handlers
  6580. // -----------------------------------------------------------------------------------------------------------------
  6581. Calendar.prototype.bindHandlers = function () {
  6582. var _this = this;
  6583. // event delegation for nav links
  6584. this.removeNavLinkListener = listenBySelector(this.el, 'click', 'a[data-goto]', function (ev, anchorEl) {
  6585. var gotoOptions = anchorEl.getAttribute('data-goto');
  6586. gotoOptions = gotoOptions ? JSON.parse(gotoOptions) : {};
  6587. var dateEnv = _this.dateEnv;
  6588. var dateMarker = dateEnv.createMarker(gotoOptions.date);
  6589. var viewType = gotoOptions.type;
  6590. // property like "navLinkDayClick". might be a string or a function
  6591. var customAction = _this.viewOpt('navLink' + capitaliseFirstLetter(viewType) + 'Click');
  6592. if (typeof customAction === 'function') {
  6593. customAction(dateEnv.toDate(dateMarker), ev);
  6594. }
  6595. else {
  6596. if (typeof customAction === 'string') {
  6597. viewType = customAction;
  6598. }
  6599. _this.zoomTo(dateMarker, viewType);
  6600. }
  6601. });
  6602. if (this.opt('handleWindowResize')) {
  6603. window.addEventListener('resize', this.windowResizeProxy = debounce(// prevents rapid calls
  6604. this.windowResize.bind(this), this.opt('windowResizeDelay')));
  6605. }
  6606. };
  6607. Calendar.prototype.unbindHandlers = function () {
  6608. this.removeNavLinkListener();
  6609. if (this.windowResizeProxy) {
  6610. window.removeEventListener('resize', this.windowResizeProxy);
  6611. this.windowResizeProxy = null;
  6612. }
  6613. };
  6614. // Dispatcher
  6615. // -----------------------------------------------------------------------------------------------------------------
  6616. Calendar.prototype.hydrate = function () {
  6617. var _this = this;
  6618. this.state = this.buildInitialState();
  6619. var rawSources = this.opt('eventSources') || [];
  6620. var singleRawSource = this.opt('events');
  6621. var sources = []; // parsed
  6622. if (singleRawSource) {
  6623. rawSources.unshift(singleRawSource);
  6624. }
  6625. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6626. var rawSource = rawSources_1[_i];
  6627. var source = parseEventSource(rawSource, this);
  6628. if (source) {
  6629. sources.push(source);
  6630. }
  6631. }
  6632. this.batchRendering(function () {
  6633. _this.dispatch({ type: 'INIT' }); // pass in sources here?
  6634. _this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: sources });
  6635. _this.dispatch({
  6636. type: 'SET_VIEW_TYPE',
  6637. viewType: _this.opt('defaultView') || _this.pluginSystem.hooks.defaultView
  6638. });
  6639. });
  6640. };
  6641. Calendar.prototype.buildInitialState = function () {
  6642. return {
  6643. viewType: null,
  6644. loadingLevel: 0,
  6645. eventSourceLoadingLevel: 0,
  6646. currentDate: this.getInitialDate(),
  6647. dateProfile: null,
  6648. eventSources: {},
  6649. eventStore: createEmptyEventStore(),
  6650. dateSelection: null,
  6651. eventSelection: '',
  6652. eventDrag: null,
  6653. eventResize: null
  6654. };
  6655. };
  6656. Calendar.prototype.dispatch = function (action) {
  6657. this.actionQueue.push(action);
  6658. if (!this.isReducing) {
  6659. this.isReducing = true;
  6660. var oldState = this.state;
  6661. while (this.actionQueue.length) {
  6662. this.state = this.reduce(this.state, this.actionQueue.shift(), this);
  6663. }
  6664. var newState = this.state;
  6665. this.isReducing = false;
  6666. if (!oldState.loadingLevel && newState.loadingLevel) {
  6667. this.publiclyTrigger('loading', [true]);
  6668. }
  6669. else if (oldState.loadingLevel && !newState.loadingLevel) {
  6670. this.publiclyTrigger('loading', [false]);
  6671. }
  6672. var view = this.component && this.component.view;
  6673. if (oldState.eventStore !== newState.eventStore) {
  6674. if (oldState.eventStore) {
  6675. this.isEventsUpdated = true;
  6676. }
  6677. }
  6678. if (oldState.dateProfile !== newState.dateProfile) {
  6679. if (oldState.dateProfile && view) { // why would view be null!?
  6680. this.publiclyTrigger('datesDestroy', [
  6681. {
  6682. view: view,
  6683. el: view.el
  6684. }
  6685. ]);
  6686. }
  6687. this.isDatesUpdated = true;
  6688. }
  6689. if (oldState.viewType !== newState.viewType) {
  6690. if (oldState.viewType && view) { // why would view be null!?
  6691. this.publiclyTrigger('viewSkeletonDestroy', [
  6692. {
  6693. view: view,
  6694. el: view.el
  6695. }
  6696. ]);
  6697. }
  6698. this.isViewUpdated = true;
  6699. }
  6700. this.requestRerender();
  6701. }
  6702. };
  6703. Calendar.prototype.reduce = function (state, action, calendar) {
  6704. return reduce(state, action, calendar);
  6705. };
  6706. // Render Queue
  6707. // -----------------------------------------------------------------------------------------------------------------
  6708. Calendar.prototype.requestRerender = function () {
  6709. this.needsRerender = true;
  6710. this.delayedRerender(); // will call a debounced-version of tryRerender
  6711. };
  6712. Calendar.prototype.tryRerender = function () {
  6713. if (this.component && // must be accepting renders
  6714. this.needsRerender && // indicates that a rerender was requested
  6715. !this.renderingPauseDepth && // not paused
  6716. !this.isRendering // not currently in the render loop
  6717. ) {
  6718. this.executeRender();
  6719. }
  6720. };
  6721. Calendar.prototype.batchRendering = function (func) {
  6722. this.renderingPauseDepth++;
  6723. func();
  6724. this.renderingPauseDepth--;
  6725. if (this.needsRerender) {
  6726. this.requestRerender();
  6727. }
  6728. };
  6729. // Rendering
  6730. // -----------------------------------------------------------------------------------------------------------------
  6731. Calendar.prototype.executeRender = function () {
  6732. // clear these BEFORE the render so that new values will accumulate during render
  6733. this.needsRerender = false;
  6734. this.isRendering = true;
  6735. this.renderComponent();
  6736. this.isRendering = false;
  6737. // received a rerender request while rendering
  6738. if (this.needsRerender) {
  6739. this.delayedRerender();
  6740. }
  6741. };
  6742. /*
  6743. don't call this directly. use executeRender instead
  6744. */
  6745. Calendar.prototype.renderComponent = function () {
  6746. var _a = this, state = _a.state, component = _a.component;
  6747. var viewType = state.viewType;
  6748. var viewSpec = this.viewSpecs[viewType];
  6749. if (!viewSpec) {
  6750. throw new Error("View type \"" + viewType + "\" is not valid");
  6751. }
  6752. // if event sources are still loading and progressive rendering hasn't been enabled,
  6753. // keep rendering the last fully loaded set of events
  6754. var renderableEventStore = this.renderableEventStore =
  6755. (state.eventSourceLoadingLevel && !this.opt('progressiveEventRendering')) ?
  6756. this.renderableEventStore :
  6757. state.eventStore;
  6758. var eventUiSingleBase = this.buildEventUiSingleBase(viewSpec.options);
  6759. var eventUiBySource = this.buildEventUiBySource(state.eventSources);
  6760. var eventUiBases = this.eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  6761. component.receiveProps(__assign({}, state, { viewSpec: viewSpec, dateProfileGenerator: this.dateProfileGenerators[viewType], dateProfile: state.dateProfile, eventStore: renderableEventStore, eventUiBases: eventUiBases, dateSelection: state.dateSelection, eventSelection: state.eventSelection, eventDrag: state.eventDrag, eventResize: state.eventResize }), this.buildComponentContext(this.theme, this.dateEnv, this.optionsManager.computed));
  6762. if (this.isViewUpdated) {
  6763. this.isViewUpdated = false;
  6764. this.publiclyTrigger('viewSkeletonRender', [
  6765. {
  6766. view: component.view,
  6767. el: component.view.el
  6768. }
  6769. ]);
  6770. }
  6771. if (this.isDatesUpdated) {
  6772. this.isDatesUpdated = false;
  6773. this.publiclyTrigger('datesRender', [
  6774. {
  6775. view: component.view,
  6776. el: component.view.el
  6777. }
  6778. ]);
  6779. }
  6780. if (this.isEventsUpdated) {
  6781. this.isEventsUpdated = false;
  6782. }
  6783. this.releaseAfterSizingTriggers();
  6784. };
  6785. // Options
  6786. // -----------------------------------------------------------------------------------------------------------------
  6787. Calendar.prototype.setOption = function (name, val) {
  6788. var _a;
  6789. this.mutateOptions((_a = {}, _a[name] = val, _a), [], true);
  6790. };
  6791. Calendar.prototype.getOption = function (name) {
  6792. return this.optionsManager.computed[name];
  6793. };
  6794. Calendar.prototype.opt = function (name) {
  6795. return this.optionsManager.computed[name];
  6796. };
  6797. Calendar.prototype.viewOpt = function (name) {
  6798. return this.viewOpts()[name];
  6799. };
  6800. Calendar.prototype.viewOpts = function () {
  6801. return this.viewSpecs[this.state.viewType].options;
  6802. };
  6803. /*
  6804. handles option changes (like a diff)
  6805. */
  6806. Calendar.prototype.mutateOptions = function (updates, removals, isDynamic, deepEqual) {
  6807. var _this = this;
  6808. var changeHandlers = this.pluginSystem.hooks.optionChangeHandlers;
  6809. var normalUpdates = {};
  6810. var specialUpdates = {};
  6811. var oldDateEnv = this.dateEnv; // do this before handleOptions
  6812. var isTimeZoneDirty = false;
  6813. var isSizeDirty = false;
  6814. var anyDifficultOptions = Boolean(removals.length);
  6815. for (var name_1 in updates) {
  6816. if (changeHandlers[name_1]) {
  6817. specialUpdates[name_1] = updates[name_1];
  6818. }
  6819. else {
  6820. normalUpdates[name_1] = updates[name_1];
  6821. }
  6822. }
  6823. for (var name_2 in normalUpdates) {
  6824. if (/^(height|contentHeight|aspectRatio)$/.test(name_2)) {
  6825. isSizeDirty = true;
  6826. }
  6827. else if (/^(defaultDate|defaultView)$/.test(name_2)) ;
  6828. else {
  6829. anyDifficultOptions = true;
  6830. if (name_2 === 'timeZone') {
  6831. isTimeZoneDirty = true;
  6832. }
  6833. }
  6834. }
  6835. this.optionsManager.mutate(normalUpdates, removals, isDynamic);
  6836. if (anyDifficultOptions) {
  6837. this.handleOptions(this.optionsManager.computed);
  6838. }
  6839. this.batchRendering(function () {
  6840. if (anyDifficultOptions) {
  6841. if (isTimeZoneDirty) {
  6842. _this.dispatch({
  6843. type: 'CHANGE_TIMEZONE',
  6844. oldDateEnv: oldDateEnv
  6845. });
  6846. }
  6847. /* HACK
  6848. has the same effect as calling this.requestRerender()
  6849. but recomputes the state's dateProfile
  6850. */
  6851. _this.dispatch({
  6852. type: 'SET_VIEW_TYPE',
  6853. viewType: _this.state.viewType
  6854. });
  6855. }
  6856. else if (isSizeDirty) {
  6857. _this.updateSize();
  6858. }
  6859. // special updates
  6860. if (deepEqual) {
  6861. for (var name_3 in specialUpdates) {
  6862. changeHandlers[name_3](specialUpdates[name_3], _this, deepEqual);
  6863. }
  6864. }
  6865. });
  6866. };
  6867. /*
  6868. rebuilds things based off of a complete set of refined options
  6869. */
  6870. Calendar.prototype.handleOptions = function (options) {
  6871. var _this = this;
  6872. var pluginHooks = this.pluginSystem.hooks;
  6873. this.defaultAllDayEventDuration = createDuration(options.defaultAllDayEventDuration);
  6874. this.defaultTimedEventDuration = createDuration(options.defaultTimedEventDuration);
  6875. this.delayedRerender = this.buildDelayedRerender(options.rerenderDelay);
  6876. this.theme = this.buildTheme(options);
  6877. var available = this.parseRawLocales(options.locales);
  6878. this.availableRawLocales = available.map;
  6879. var locale = this.buildLocale(options.locale || available.defaultCode, available.map);
  6880. this.dateEnv = this.buildDateEnv(locale, options.timeZone, pluginHooks.namedTimeZonedImpl, options.firstDay, options.weekNumberCalculation, options.weekLabel, pluginHooks.cmdFormatter);
  6881. this.selectionConfig = this.buildSelectionConfig(options); // needs dateEnv. do after :(
  6882. // ineffecient to do every time?
  6883. this.viewSpecs = buildViewSpecs(pluginHooks.views, this.optionsManager);
  6884. // ineffecient to do every time?
  6885. this.dateProfileGenerators = mapHash(this.viewSpecs, function (viewSpec) {
  6886. return new viewSpec.class.prototype.dateProfileGeneratorClass(viewSpec, _this);
  6887. });
  6888. };
  6889. Calendar.prototype.getAvailableLocaleCodes = function () {
  6890. return Object.keys(this.availableRawLocales);
  6891. };
  6892. Calendar.prototype._buildSelectionConfig = function (rawOpts) {
  6893. return processScopedUiProps('select', rawOpts, this);
  6894. };
  6895. Calendar.prototype._buildEventUiSingleBase = function (rawOpts) {
  6896. if (rawOpts.editable) { // so 'editable' affected events
  6897. rawOpts = __assign({}, rawOpts, { eventEditable: true });
  6898. }
  6899. return processScopedUiProps('event', rawOpts, this);
  6900. };
  6901. // Trigger
  6902. // -----------------------------------------------------------------------------------------------------------------
  6903. Calendar.prototype.hasPublicHandlers = function (name) {
  6904. return this.hasHandlers(name) ||
  6905. this.opt(name); // handler specified in options
  6906. };
  6907. Calendar.prototype.publiclyTrigger = function (name, args) {
  6908. var optHandler = this.opt(name);
  6909. this.triggerWith(name, this, args);
  6910. if (optHandler) {
  6911. return optHandler.apply(this, args);
  6912. }
  6913. };
  6914. Calendar.prototype.publiclyTriggerAfterSizing = function (name, args) {
  6915. var afterSizingTriggers = this.afterSizingTriggers;
  6916. (afterSizingTriggers[name] || (afterSizingTriggers[name] = [])).push(args);
  6917. };
  6918. Calendar.prototype.releaseAfterSizingTriggers = function () {
  6919. var afterSizingTriggers = this.afterSizingTriggers;
  6920. for (var name_4 in afterSizingTriggers) {
  6921. for (var _i = 0, _a = afterSizingTriggers[name_4]; _i < _a.length; _i++) {
  6922. var args = _a[_i];
  6923. this.publiclyTrigger(name_4, args);
  6924. }
  6925. }
  6926. this.afterSizingTriggers = {};
  6927. };
  6928. // View
  6929. // -----------------------------------------------------------------------------------------------------------------
  6930. // Returns a boolean about whether the view is okay to instantiate at some point
  6931. Calendar.prototype.isValidViewType = function (viewType) {
  6932. return Boolean(this.viewSpecs[viewType]);
  6933. };
  6934. Calendar.prototype.changeView = function (viewType, dateOrRange) {
  6935. var dateMarker = null;
  6936. if (dateOrRange) {
  6937. if (dateOrRange.start && dateOrRange.end) { // a range
  6938. this.optionsManager.mutate({ visibleRange: dateOrRange }, []); // will not rerender
  6939. this.handleOptions(this.optionsManager.computed); // ...but yuck
  6940. }
  6941. else { // a date
  6942. dateMarker = this.dateEnv.createMarker(dateOrRange); // just like gotoDate
  6943. }
  6944. }
  6945. this.unselect();
  6946. this.dispatch({
  6947. type: 'SET_VIEW_TYPE',
  6948. viewType: viewType,
  6949. dateMarker: dateMarker
  6950. });
  6951. };
  6952. // Forces navigation to a view for the given date.
  6953. // `viewType` can be a specific view name or a generic one like "week" or "day".
  6954. // needs to change
  6955. Calendar.prototype.zoomTo = function (dateMarker, viewType) {
  6956. var spec;
  6957. viewType = viewType || 'day'; // day is default zoom
  6958. spec = this.viewSpecs[viewType] ||
  6959. this.getUnitViewSpec(viewType);
  6960. this.unselect();
  6961. if (spec) {
  6962. this.dispatch({
  6963. type: 'SET_VIEW_TYPE',
  6964. viewType: spec.type,
  6965. dateMarker: dateMarker
  6966. });
  6967. }
  6968. else {
  6969. this.dispatch({
  6970. type: 'SET_DATE',
  6971. dateMarker: dateMarker
  6972. });
  6973. }
  6974. };
  6975. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  6976. // Preference is given to views that have corresponding buttons.
  6977. Calendar.prototype.getUnitViewSpec = function (unit) {
  6978. var component = this.component;
  6979. var viewTypes = [];
  6980. var i;
  6981. var spec;
  6982. // put views that have buttons first. there will be duplicates, but oh
  6983. if (component.header) {
  6984. viewTypes.push.apply(viewTypes, component.header.viewsWithButtons);
  6985. }
  6986. if (component.footer) {
  6987. viewTypes.push.apply(viewTypes, component.footer.viewsWithButtons);
  6988. }
  6989. for (var viewType in this.viewSpecs) {
  6990. viewTypes.push(viewType);
  6991. }
  6992. for (i = 0; i < viewTypes.length; i++) {
  6993. spec = this.viewSpecs[viewTypes[i]];
  6994. if (spec) {
  6995. if (spec.singleUnit === unit) {
  6996. return spec;
  6997. }
  6998. }
  6999. }
  7000. };
  7001. // Current Date
  7002. // -----------------------------------------------------------------------------------------------------------------
  7003. Calendar.prototype.getInitialDate = function () {
  7004. var defaultDateInput = this.opt('defaultDate');
  7005. // compute the initial ambig-timezone date
  7006. if (defaultDateInput != null) {
  7007. return this.dateEnv.createMarker(defaultDateInput);
  7008. }
  7009. else {
  7010. return this.getNow(); // getNow already returns unzoned
  7011. }
  7012. };
  7013. Calendar.prototype.prev = function () {
  7014. this.unselect();
  7015. this.dispatch({ type: 'PREV' });
  7016. };
  7017. Calendar.prototype.next = function () {
  7018. this.unselect();
  7019. this.dispatch({ type: 'NEXT' });
  7020. };
  7021. Calendar.prototype.prevYear = function () {
  7022. this.unselect();
  7023. this.dispatch({
  7024. type: 'SET_DATE',
  7025. dateMarker: this.dateEnv.addYears(this.state.currentDate, -1)
  7026. });
  7027. };
  7028. Calendar.prototype.nextYear = function () {
  7029. this.unselect();
  7030. this.dispatch({
  7031. type: 'SET_DATE',
  7032. dateMarker: this.dateEnv.addYears(this.state.currentDate, 1)
  7033. });
  7034. };
  7035. Calendar.prototype.today = function () {
  7036. this.unselect();
  7037. this.dispatch({
  7038. type: 'SET_DATE',
  7039. dateMarker: this.getNow()
  7040. });
  7041. };
  7042. Calendar.prototype.gotoDate = function (zonedDateInput) {
  7043. this.unselect();
  7044. this.dispatch({
  7045. type: 'SET_DATE',
  7046. dateMarker: this.dateEnv.createMarker(zonedDateInput)
  7047. });
  7048. };
  7049. Calendar.prototype.incrementDate = function (deltaInput) {
  7050. var delta = createDuration(deltaInput);
  7051. if (delta) { // else, warn about invalid input?
  7052. this.unselect();
  7053. this.dispatch({
  7054. type: 'SET_DATE',
  7055. dateMarker: this.dateEnv.add(this.state.currentDate, delta)
  7056. });
  7057. }
  7058. };
  7059. // for external API
  7060. Calendar.prototype.getDate = function () {
  7061. return this.dateEnv.toDate(this.state.currentDate);
  7062. };
  7063. // Date Formatting Utils
  7064. // -----------------------------------------------------------------------------------------------------------------
  7065. Calendar.prototype.formatDate = function (d, formatter) {
  7066. var dateEnv = this.dateEnv;
  7067. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  7068. };
  7069. // `settings` is for formatter AND isEndExclusive
  7070. Calendar.prototype.formatRange = function (d0, d1, settings) {
  7071. var dateEnv = this.dateEnv;
  7072. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings, this.opt('defaultRangeSeparator')), settings);
  7073. };
  7074. Calendar.prototype.formatIso = function (d, omitTime) {
  7075. var dateEnv = this.dateEnv;
  7076. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  7077. };
  7078. // Sizing
  7079. // -----------------------------------------------------------------------------------------------------------------
  7080. Calendar.prototype.windowResize = function (ev) {
  7081. if (!this.isHandlingWindowResize &&
  7082. this.component && // why?
  7083. ev.target === window // not a jqui resize event
  7084. ) {
  7085. this.isHandlingWindowResize = true;
  7086. this.updateSize();
  7087. this.publiclyTrigger('windowResize', [this.view]);
  7088. this.isHandlingWindowResize = false;
  7089. }
  7090. };
  7091. Calendar.prototype.updateSize = function () {
  7092. if (this.component) { // when?
  7093. this.component.updateSize(true);
  7094. }
  7095. };
  7096. // Component Registration
  7097. // -----------------------------------------------------------------------------------------------------------------
  7098. Calendar.prototype.registerInteractiveComponent = function (component, settingsInput) {
  7099. var settings = parseInteractionSettings(component, settingsInput);
  7100. var DEFAULT_INTERACTIONS = [
  7101. EventClicking,
  7102. EventHovering
  7103. ];
  7104. var interactionClasses = DEFAULT_INTERACTIONS.concat(this.pluginSystem.hooks.componentInteractions);
  7105. var interactions = interactionClasses.map(function (interactionClass) {
  7106. return new interactionClass(settings);
  7107. });
  7108. this.interactionsStore[component.uid] = interactions;
  7109. interactionSettingsStore[component.uid] = settings;
  7110. };
  7111. Calendar.prototype.unregisterInteractiveComponent = function (component) {
  7112. for (var _i = 0, _a = this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7113. var listener = _a[_i];
  7114. listener.destroy();
  7115. }
  7116. delete this.interactionsStore[component.uid];
  7117. delete interactionSettingsStore[component.uid];
  7118. };
  7119. // Date Selection / Event Selection / DayClick
  7120. // -----------------------------------------------------------------------------------------------------------------
  7121. // this public method receives start/end dates in any format, with any timezone
  7122. // NOTE: args were changed from v3
  7123. Calendar.prototype.select = function (dateOrObj, endDate) {
  7124. var selectionInput;
  7125. if (endDate == null) {
  7126. if (dateOrObj.start != null) {
  7127. selectionInput = dateOrObj;
  7128. }
  7129. else {
  7130. selectionInput = {
  7131. start: dateOrObj,
  7132. end: null
  7133. };
  7134. }
  7135. }
  7136. else {
  7137. selectionInput = {
  7138. start: dateOrObj,
  7139. end: endDate
  7140. };
  7141. }
  7142. var selection = parseDateSpan(selectionInput, this.dateEnv, createDuration({ days: 1 }) // TODO: cache this?
  7143. );
  7144. if (selection) { // throw parse error otherwise?
  7145. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  7146. this.triggerDateSelect(selection);
  7147. }
  7148. };
  7149. // public method
  7150. Calendar.prototype.unselect = function (pev) {
  7151. if (this.state.dateSelection) {
  7152. this.dispatch({ type: 'UNSELECT_DATES' });
  7153. this.triggerDateUnselect(pev);
  7154. }
  7155. };
  7156. Calendar.prototype.triggerDateSelect = function (selection, pev) {
  7157. var arg = __assign({}, this.buildDateSpanApi(selection), { jsEvent: pev ? pev.origEvent : null, view: this.view });
  7158. this.publiclyTrigger('select', [arg]);
  7159. };
  7160. Calendar.prototype.triggerDateUnselect = function (pev) {
  7161. this.publiclyTrigger('unselect', [
  7162. {
  7163. jsEvent: pev ? pev.origEvent : null,
  7164. view: this.view
  7165. }
  7166. ]);
  7167. };
  7168. // TODO: receive pev?
  7169. Calendar.prototype.triggerDateClick = function (dateSpan, dayEl, view, ev) {
  7170. var arg = __assign({}, this.buildDatePointApi(dateSpan), { dayEl: dayEl, jsEvent: ev, // Is this always a mouse event? See #4655
  7171. view: view });
  7172. this.publiclyTrigger('dateClick', [arg]);
  7173. };
  7174. Calendar.prototype.buildDatePointApi = function (dateSpan) {
  7175. var props = {};
  7176. for (var _i = 0, _a = this.pluginSystem.hooks.datePointTransforms; _i < _a.length; _i++) {
  7177. var transform = _a[_i];
  7178. __assign(props, transform(dateSpan, this));
  7179. }
  7180. __assign(props, buildDatePointApi(dateSpan, this.dateEnv));
  7181. return props;
  7182. };
  7183. Calendar.prototype.buildDateSpanApi = function (dateSpan) {
  7184. var props = {};
  7185. for (var _i = 0, _a = this.pluginSystem.hooks.dateSpanTransforms; _i < _a.length; _i++) {
  7186. var transform = _a[_i];
  7187. __assign(props, transform(dateSpan, this));
  7188. }
  7189. __assign(props, buildDateSpanApi(dateSpan, this.dateEnv));
  7190. return props;
  7191. };
  7192. // Date Utils
  7193. // -----------------------------------------------------------------------------------------------------------------
  7194. // Returns a DateMarker for the current date, as defined by the client's computer or from the `now` option
  7195. Calendar.prototype.getNow = function () {
  7196. var now = this.opt('now');
  7197. if (typeof now === 'function') {
  7198. now = now();
  7199. }
  7200. if (now == null) {
  7201. return this.dateEnv.createNowMarker();
  7202. }
  7203. return this.dateEnv.createMarker(now);
  7204. };
  7205. // Event-Date Utilities
  7206. // -----------------------------------------------------------------------------------------------------------------
  7207. // Given an event's allDay status and start date, return what its fallback end date should be.
  7208. // TODO: rename to computeDefaultEventEnd
  7209. Calendar.prototype.getDefaultEventEnd = function (allDay, marker) {
  7210. var end = marker;
  7211. if (allDay) {
  7212. end = startOfDay(end);
  7213. end = this.dateEnv.add(end, this.defaultAllDayEventDuration);
  7214. }
  7215. else {
  7216. end = this.dateEnv.add(end, this.defaultTimedEventDuration);
  7217. }
  7218. return end;
  7219. };
  7220. // Public Events API
  7221. // -----------------------------------------------------------------------------------------------------------------
  7222. Calendar.prototype.addEvent = function (eventInput, sourceInput) {
  7223. if (eventInput instanceof EventApi) {
  7224. var def = eventInput._def;
  7225. var instance = eventInput._instance;
  7226. // not already present? don't want to add an old snapshot
  7227. if (!this.state.eventStore.defs[def.defId]) {
  7228. this.dispatch({
  7229. type: 'ADD_EVENTS',
  7230. eventStore: eventTupleToStore({ def: def, instance: instance }) // TODO: better util for two args?
  7231. });
  7232. }
  7233. return eventInput;
  7234. }
  7235. var sourceId;
  7236. if (sourceInput instanceof EventSourceApi) {
  7237. sourceId = sourceInput.internalEventSource.sourceId;
  7238. }
  7239. else if (sourceInput != null) {
  7240. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  7241. if (!sourceApi) {
  7242. console.warn('Could not find an event source with ID "' + sourceInput + '"'); // TODO: test
  7243. return null;
  7244. }
  7245. else {
  7246. sourceId = sourceApi.internalEventSource.sourceId;
  7247. }
  7248. }
  7249. var tuple = parseEvent(eventInput, sourceId, this);
  7250. if (tuple) {
  7251. this.dispatch({
  7252. type: 'ADD_EVENTS',
  7253. eventStore: eventTupleToStore(tuple)
  7254. });
  7255. return new EventApi(this, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  7256. }
  7257. return null;
  7258. };
  7259. // TODO: optimize
  7260. Calendar.prototype.getEventById = function (id) {
  7261. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7262. id = String(id);
  7263. for (var defId in defs) {
  7264. var def = defs[defId];
  7265. if (def.publicId === id) {
  7266. if (def.recurringDef) {
  7267. return new EventApi(this, def, null);
  7268. }
  7269. else {
  7270. for (var instanceId in instances) {
  7271. var instance = instances[instanceId];
  7272. if (instance.defId === def.defId) {
  7273. return new EventApi(this, def, instance);
  7274. }
  7275. }
  7276. }
  7277. }
  7278. }
  7279. return null;
  7280. };
  7281. Calendar.prototype.getEvents = function () {
  7282. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7283. var eventApis = [];
  7284. for (var id in instances) {
  7285. var instance = instances[id];
  7286. var def = defs[instance.defId];
  7287. eventApis.push(new EventApi(this, def, instance));
  7288. }
  7289. return eventApis;
  7290. };
  7291. Calendar.prototype.removeAllEvents = function () {
  7292. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  7293. };
  7294. Calendar.prototype.rerenderEvents = function () {
  7295. this.dispatch({ type: 'RESET_EVENTS' });
  7296. };
  7297. // Public Event Sources API
  7298. // -----------------------------------------------------------------------------------------------------------------
  7299. Calendar.prototype.getEventSources = function () {
  7300. var sourceHash = this.state.eventSources;
  7301. var sourceApis = [];
  7302. for (var internalId in sourceHash) {
  7303. sourceApis.push(new EventSourceApi(this, sourceHash[internalId]));
  7304. }
  7305. return sourceApis;
  7306. };
  7307. Calendar.prototype.getEventSourceById = function (id) {
  7308. var sourceHash = this.state.eventSources;
  7309. id = String(id);
  7310. for (var sourceId in sourceHash) {
  7311. if (sourceHash[sourceId].publicId === id) {
  7312. return new EventSourceApi(this, sourceHash[sourceId]);
  7313. }
  7314. }
  7315. return null;
  7316. };
  7317. Calendar.prototype.addEventSource = function (sourceInput) {
  7318. if (sourceInput instanceof EventSourceApi) {
  7319. // not already present? don't want to add an old snapshot
  7320. if (!this.state.eventSources[sourceInput.internalEventSource.sourceId]) {
  7321. this.dispatch({
  7322. type: 'ADD_EVENT_SOURCES',
  7323. sources: [sourceInput.internalEventSource]
  7324. });
  7325. }
  7326. return sourceInput;
  7327. }
  7328. var eventSource = parseEventSource(sourceInput, this);
  7329. if (eventSource) { // TODO: error otherwise?
  7330. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  7331. return new EventSourceApi(this, eventSource);
  7332. }
  7333. return null;
  7334. };
  7335. Calendar.prototype.removeAllEventSources = function () {
  7336. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  7337. };
  7338. Calendar.prototype.refetchEvents = function () {
  7339. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  7340. };
  7341. // Scroll
  7342. // -----------------------------------------------------------------------------------------------------------------
  7343. Calendar.prototype.scrollToTime = function (timeInput) {
  7344. var duration = createDuration(timeInput);
  7345. if (duration) {
  7346. this.component.view.scrollToDuration(duration);
  7347. }
  7348. };
  7349. return Calendar;
  7350. }());
  7351. EmitterMixin.mixInto(Calendar);
  7352. // for memoizers
  7353. // -----------------------------------------------------------------------------------------------------------------
  7354. function buildComponentContext$1(theme, dateEnv, options) {
  7355. return new ComponentContext(this, theme, dateEnv, options, null);
  7356. }
  7357. function buildDateEnv(locale, timeZone, namedTimeZoneImpl, firstDay, weekNumberCalculation, weekLabel, cmdFormatter) {
  7358. return new DateEnv({
  7359. calendarSystem: 'gregory',
  7360. timeZone: timeZone,
  7361. namedTimeZoneImpl: namedTimeZoneImpl,
  7362. locale: locale,
  7363. weekNumberCalculation: weekNumberCalculation,
  7364. firstDay: firstDay,
  7365. weekLabel: weekLabel,
  7366. cmdFormatter: cmdFormatter
  7367. });
  7368. }
  7369. function buildTheme(calendarOptions) {
  7370. var themeClass = this.pluginSystem.hooks.themeClasses[calendarOptions.themeSystem] || StandardTheme;
  7371. return new themeClass(calendarOptions);
  7372. }
  7373. function buildDelayedRerender(wait) {
  7374. var func = this.tryRerender.bind(this);
  7375. if (wait != null) {
  7376. func = debounce(func, wait);
  7377. }
  7378. return func;
  7379. }
  7380. function buildEventUiBySource(eventSources) {
  7381. return mapHash(eventSources, function (eventSource) {
  7382. return eventSource.ui;
  7383. });
  7384. }
  7385. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7386. var eventUiBases = { '': eventUiSingleBase };
  7387. for (var defId in eventDefs) {
  7388. var def = eventDefs[defId];
  7389. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7390. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7391. }
  7392. }
  7393. return eventUiBases;
  7394. }
  7395. var View = /** @class */ (function (_super) {
  7396. __extends(View, _super);
  7397. function View(viewSpec, parentEl) {
  7398. var _this = _super.call(this, createElement('div', { className: 'fc-view fc-' + viewSpec.type + '-view' })) || this;
  7399. _this.renderDatesMem = memoizeRendering(_this.renderDatesWrap, _this.unrenderDatesWrap);
  7400. _this.renderBusinessHoursMem = memoizeRendering(_this.renderBusinessHours, _this.unrenderBusinessHours, [_this.renderDatesMem]);
  7401. _this.renderDateSelectionMem = memoizeRendering(_this.renderDateSelectionWrap, _this.unrenderDateSelectionWrap, [_this.renderDatesMem]);
  7402. _this.renderEventsMem = memoizeRendering(_this.renderEvents, _this.unrenderEvents, [_this.renderDatesMem]);
  7403. _this.renderEventSelectionMem = memoizeRendering(_this.renderEventSelectionWrap, _this.unrenderEventSelectionWrap, [_this.renderEventsMem]);
  7404. _this.renderEventDragMem = memoizeRendering(_this.renderEventDragWrap, _this.unrenderEventDragWrap, [_this.renderDatesMem]);
  7405. _this.renderEventResizeMem = memoizeRendering(_this.renderEventResizeWrap, _this.unrenderEventResizeWrap, [_this.renderDatesMem]);
  7406. _this.viewSpec = viewSpec;
  7407. _this.type = viewSpec.type;
  7408. parentEl.appendChild(_this.el);
  7409. _this.initialize();
  7410. return _this;
  7411. }
  7412. View.prototype.initialize = function () {
  7413. };
  7414. Object.defineProperty(View.prototype, "activeStart", {
  7415. // Date Setting/Unsetting
  7416. // -----------------------------------------------------------------------------------------------------------------
  7417. get: function () {
  7418. return this.context.dateEnv.toDate(this.props.dateProfile.activeRange.start);
  7419. },
  7420. enumerable: true,
  7421. configurable: true
  7422. });
  7423. Object.defineProperty(View.prototype, "activeEnd", {
  7424. get: function () {
  7425. return this.context.dateEnv.toDate(this.props.dateProfile.activeRange.end);
  7426. },
  7427. enumerable: true,
  7428. configurable: true
  7429. });
  7430. Object.defineProperty(View.prototype, "currentStart", {
  7431. get: function () {
  7432. return this.context.dateEnv.toDate(this.props.dateProfile.currentRange.start);
  7433. },
  7434. enumerable: true,
  7435. configurable: true
  7436. });
  7437. Object.defineProperty(View.prototype, "currentEnd", {
  7438. get: function () {
  7439. return this.context.dateEnv.toDate(this.props.dateProfile.currentRange.end);
  7440. },
  7441. enumerable: true,
  7442. configurable: true
  7443. });
  7444. // General Rendering
  7445. // -----------------------------------------------------------------------------------------------------------------
  7446. View.prototype.render = function (props, context) {
  7447. this.renderDatesMem(props.dateProfile);
  7448. this.renderBusinessHoursMem(props.businessHours);
  7449. this.renderDateSelectionMem(props.dateSelection);
  7450. this.renderEventsMem(props.eventStore);
  7451. this.renderEventSelectionMem(props.eventSelection);
  7452. this.renderEventDragMem(props.eventDrag);
  7453. this.renderEventResizeMem(props.eventResize);
  7454. };
  7455. View.prototype.beforeUpdate = function () {
  7456. this.addScroll(this.queryScroll());
  7457. };
  7458. View.prototype.destroy = function () {
  7459. _super.prototype.destroy.call(this);
  7460. this.renderDatesMem.unrender(); // should unrender everything else
  7461. };
  7462. // Sizing
  7463. // -----------------------------------------------------------------------------------------------------------------
  7464. View.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  7465. var calendar = this.context.calendar;
  7466. if (isResize) {
  7467. this.addScroll(this.queryScroll()); // NOTE: same code as in beforeUpdate
  7468. }
  7469. if (isResize || // HACKS...
  7470. calendar.isViewUpdated ||
  7471. calendar.isDatesUpdated ||
  7472. calendar.isEventsUpdated) {
  7473. // sort of the catch-all sizing
  7474. // anything that might cause dimension changes
  7475. this.updateBaseSize(isResize, viewHeight, isAuto);
  7476. }
  7477. // NOTE: popScroll is called by CalendarComponent
  7478. };
  7479. View.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  7480. };
  7481. // Date Rendering
  7482. // -----------------------------------------------------------------------------------------------------------------
  7483. View.prototype.renderDatesWrap = function (dateProfile) {
  7484. this.renderDates(dateProfile);
  7485. this.addScroll({
  7486. duration: createDuration(this.context.options.scrollTime)
  7487. });
  7488. };
  7489. View.prototype.unrenderDatesWrap = function () {
  7490. this.stopNowIndicator();
  7491. this.unrenderDates();
  7492. };
  7493. View.prototype.renderDates = function (dateProfile) { };
  7494. View.prototype.unrenderDates = function () { };
  7495. // Business Hours
  7496. // -----------------------------------------------------------------------------------------------------------------
  7497. View.prototype.renderBusinessHours = function (businessHours) { };
  7498. View.prototype.unrenderBusinessHours = function () { };
  7499. // Date Selection
  7500. // -----------------------------------------------------------------------------------------------------------------
  7501. View.prototype.renderDateSelectionWrap = function (selection) {
  7502. if (selection) {
  7503. this.renderDateSelection(selection);
  7504. }
  7505. };
  7506. View.prototype.unrenderDateSelectionWrap = function (selection) {
  7507. if (selection) {
  7508. this.unrenderDateSelection(selection);
  7509. }
  7510. };
  7511. View.prototype.renderDateSelection = function (selection) { };
  7512. View.prototype.unrenderDateSelection = function (selection) { };
  7513. // Event Rendering
  7514. // -----------------------------------------------------------------------------------------------------------------
  7515. View.prototype.renderEvents = function (eventStore) { };
  7516. View.prototype.unrenderEvents = function () { };
  7517. // util for subclasses
  7518. View.prototype.sliceEvents = function (eventStore, allDay) {
  7519. var props = this.props;
  7520. return sliceEventStore(eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? this.context.nextDayThreshold : null).fg;
  7521. };
  7522. // Event Selection
  7523. // -----------------------------------------------------------------------------------------------------------------
  7524. View.prototype.renderEventSelectionWrap = function (instanceId) {
  7525. if (instanceId) {
  7526. this.renderEventSelection(instanceId);
  7527. }
  7528. };
  7529. View.prototype.unrenderEventSelectionWrap = function (instanceId) {
  7530. if (instanceId) {
  7531. this.unrenderEventSelection(instanceId);
  7532. }
  7533. };
  7534. View.prototype.renderEventSelection = function (instanceId) { };
  7535. View.prototype.unrenderEventSelection = function (instanceId) { };
  7536. // Event Drag
  7537. // -----------------------------------------------------------------------------------------------------------------
  7538. View.prototype.renderEventDragWrap = function (state) {
  7539. if (state) {
  7540. this.renderEventDrag(state);
  7541. }
  7542. };
  7543. View.prototype.unrenderEventDragWrap = function (state) {
  7544. if (state) {
  7545. this.unrenderEventDrag(state);
  7546. }
  7547. };
  7548. View.prototype.renderEventDrag = function (state) { };
  7549. View.prototype.unrenderEventDrag = function (state) { };
  7550. // Event Resize
  7551. // -----------------------------------------------------------------------------------------------------------------
  7552. View.prototype.renderEventResizeWrap = function (state) {
  7553. if (state) {
  7554. this.renderEventResize(state);
  7555. }
  7556. };
  7557. View.prototype.unrenderEventResizeWrap = function (state) {
  7558. if (state) {
  7559. this.unrenderEventResize(state);
  7560. }
  7561. };
  7562. View.prototype.renderEventResize = function (state) { };
  7563. View.prototype.unrenderEventResize = function (state) { };
  7564. /* Now Indicator
  7565. ------------------------------------------------------------------------------------------------------------------*/
  7566. // Immediately render the current time indicator and begins re-rendering it at an interval,
  7567. // which is defined by this.getNowIndicatorUnit().
  7568. // TODO: somehow do this for the current whole day's background too
  7569. // USAGE: must be called manually from subclasses' render methods! don't need to call stopNowIndicator tho
  7570. View.prototype.startNowIndicator = function (dateProfile, dateProfileGenerator) {
  7571. var _this = this;
  7572. var _a = this.context, calendar = _a.calendar, dateEnv = _a.dateEnv, options = _a.options;
  7573. var unit;
  7574. var update;
  7575. var delay; // ms wait value
  7576. if (options.nowIndicator && !this.initialNowDate) {
  7577. unit = this.getNowIndicatorUnit(dateProfile, dateProfileGenerator);
  7578. if (unit) {
  7579. update = this.updateNowIndicator.bind(this);
  7580. this.initialNowDate = calendar.getNow();
  7581. this.initialNowQueriedMs = new Date().valueOf();
  7582. // wait until the beginning of the next interval
  7583. delay = dateEnv.add(dateEnv.startOf(this.initialNowDate, unit), createDuration(1, unit)).valueOf() - this.initialNowDate.valueOf();
  7584. // TODO: maybe always use setTimeout, waiting until start of next unit
  7585. this.nowIndicatorTimeoutID = setTimeout(function () {
  7586. _this.nowIndicatorTimeoutID = null;
  7587. update();
  7588. if (unit === 'second') {
  7589. delay = 1000; // every second
  7590. }
  7591. else {
  7592. delay = 1000 * 60; // otherwise, every minute
  7593. }
  7594. _this.nowIndicatorIntervalID = setInterval(update, delay); // update every interval
  7595. }, delay);
  7596. }
  7597. // rendering will be initiated in updateSize
  7598. }
  7599. };
  7600. // rerenders the now indicator, computing the new current time from the amount of time that has passed
  7601. // since the initial getNow call.
  7602. View.prototype.updateNowIndicator = function () {
  7603. if (this.props.dateProfile && // a way to determine if dates were rendered yet
  7604. this.initialNowDate // activated before?
  7605. ) {
  7606. this.unrenderNowIndicator(); // won't unrender if unnecessary
  7607. this.renderNowIndicator(addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs));
  7608. this.isNowIndicatorRendered = true;
  7609. }
  7610. };
  7611. // Immediately unrenders the view's current time indicator and stops any re-rendering timers.
  7612. // Won't cause side effects if indicator isn't rendered.
  7613. View.prototype.stopNowIndicator = function () {
  7614. if (this.nowIndicatorTimeoutID) {
  7615. clearTimeout(this.nowIndicatorTimeoutID);
  7616. this.nowIndicatorTimeoutID = null;
  7617. }
  7618. if (this.nowIndicatorIntervalID) {
  7619. clearInterval(this.nowIndicatorIntervalID);
  7620. this.nowIndicatorIntervalID = null;
  7621. }
  7622. if (this.isNowIndicatorRendered) {
  7623. this.unrenderNowIndicator();
  7624. this.isNowIndicatorRendered = false;
  7625. }
  7626. };
  7627. View.prototype.getNowIndicatorUnit = function (dateProfile, dateProfileGenerator) {
  7628. // subclasses should implement
  7629. };
  7630. // Renders a current time indicator at the given datetime
  7631. View.prototype.renderNowIndicator = function (date) {
  7632. // SUBCLASSES MUST PASS TO CHILDREN!
  7633. };
  7634. // Undoes the rendering actions from renderNowIndicator
  7635. View.prototype.unrenderNowIndicator = function () {
  7636. // SUBCLASSES MUST PASS TO CHILDREN!
  7637. };
  7638. /* Scroller
  7639. ------------------------------------------------------------------------------------------------------------------*/
  7640. View.prototype.addScroll = function (scroll, isForced) {
  7641. if (isForced) {
  7642. scroll.isForced = isForced;
  7643. }
  7644. __assign(this.queuedScroll || (this.queuedScroll = {}), scroll);
  7645. };
  7646. View.prototype.popScroll = function (isResize) {
  7647. this.applyQueuedScroll(isResize);
  7648. this.queuedScroll = null;
  7649. };
  7650. View.prototype.applyQueuedScroll = function (isResize) {
  7651. if (this.queuedScroll) {
  7652. this.applyScroll(this.queuedScroll, isResize);
  7653. }
  7654. };
  7655. View.prototype.queryScroll = function () {
  7656. var scroll = {};
  7657. if (this.props.dateProfile) { // dates rendered yet?
  7658. __assign(scroll, this.queryDateScroll());
  7659. }
  7660. return scroll;
  7661. };
  7662. View.prototype.applyScroll = function (scroll, isResize) {
  7663. var duration = scroll.duration, isForced = scroll.isForced;
  7664. if (duration != null && !isForced) {
  7665. delete scroll.duration;
  7666. if (this.props.dateProfile) { // dates rendered yet?
  7667. __assign(scroll, this.computeDateScroll(duration));
  7668. }
  7669. }
  7670. if (this.props.dateProfile) { // dates rendered yet?
  7671. this.applyDateScroll(scroll);
  7672. }
  7673. };
  7674. View.prototype.computeDateScroll = function (duration) {
  7675. return {}; // subclasses must implement
  7676. };
  7677. View.prototype.queryDateScroll = function () {
  7678. return {}; // subclasses must implement
  7679. };
  7680. View.prototype.applyDateScroll = function (scroll) {
  7681. // subclasses must implement
  7682. };
  7683. // for API
  7684. View.prototype.scrollToDuration = function (duration) {
  7685. this.applyScroll({ duration: duration }, false);
  7686. };
  7687. return View;
  7688. }(DateComponent));
  7689. EmitterMixin.mixInto(View);
  7690. View.prototype.usesMinMaxTime = false;
  7691. View.prototype.dateProfileGeneratorClass = DateProfileGenerator;
  7692. var FgEventRenderer = /** @class */ (function () {
  7693. function FgEventRenderer() {
  7694. this.segs = [];
  7695. this.isSizeDirty = false;
  7696. }
  7697. FgEventRenderer.prototype.renderSegs = function (context, segs, mirrorInfo) {
  7698. this.context = context;
  7699. this.rangeUpdated(); // called too frequently :(
  7700. // render an `.el` on each seg
  7701. // returns a subset of the segs. segs that were actually rendered
  7702. segs = this.renderSegEls(segs, mirrorInfo);
  7703. this.segs = segs;
  7704. this.attachSegs(segs, mirrorInfo);
  7705. this.isSizeDirty = true;
  7706. triggerRenderedSegs(this.context, this.segs, Boolean(mirrorInfo));
  7707. };
  7708. FgEventRenderer.prototype.unrender = function (context, _segs, mirrorInfo) {
  7709. triggerWillRemoveSegs(this.context, this.segs, Boolean(mirrorInfo));
  7710. this.detachSegs(this.segs);
  7711. this.segs = [];
  7712. };
  7713. // Updates values that rely on options and also relate to range
  7714. FgEventRenderer.prototype.rangeUpdated = function () {
  7715. var options = this.context.options;
  7716. var displayEventTime;
  7717. var displayEventEnd;
  7718. this.eventTimeFormat = createFormatter(options.eventTimeFormat || this.computeEventTimeFormat(), options.defaultRangeSeparator);
  7719. displayEventTime = options.displayEventTime;
  7720. if (displayEventTime == null) {
  7721. displayEventTime = this.computeDisplayEventTime(); // might be based off of range
  7722. }
  7723. displayEventEnd = options.displayEventEnd;
  7724. if (displayEventEnd == null) {
  7725. displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range
  7726. }
  7727. this.displayEventTime = displayEventTime;
  7728. this.displayEventEnd = displayEventEnd;
  7729. };
  7730. // Renders and assigns an `el` property for each foreground event segment.
  7731. // Only returns segments that successfully rendered.
  7732. FgEventRenderer.prototype.renderSegEls = function (segs, mirrorInfo) {
  7733. var html = '';
  7734. var i;
  7735. if (segs.length) { // don't build an empty html string
  7736. // build a large concatenation of event segment HTML
  7737. for (i = 0; i < segs.length; i++) {
  7738. html += this.renderSegHtml(segs[i], mirrorInfo);
  7739. }
  7740. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7741. // Then, compute the 'el' for each segment. An el might be null if the eventRender callback returned false.
  7742. htmlToElements(html).forEach(function (el, i) {
  7743. var seg = segs[i];
  7744. if (el) {
  7745. seg.el = el;
  7746. }
  7747. });
  7748. segs = filterSegsViaEls(this.context, segs, Boolean(mirrorInfo));
  7749. }
  7750. return segs;
  7751. };
  7752. // Generic utility for generating the HTML classNames for an event segment's element
  7753. FgEventRenderer.prototype.getSegClasses = function (seg, isDraggable, isResizable, mirrorInfo) {
  7754. var classes = [
  7755. 'fc-event',
  7756. seg.isStart ? 'fc-start' : 'fc-not-start',
  7757. seg.isEnd ? 'fc-end' : 'fc-not-end'
  7758. ].concat(seg.eventRange.ui.classNames);
  7759. if (isDraggable) {
  7760. classes.push('fc-draggable');
  7761. }
  7762. if (isResizable) {
  7763. classes.push('fc-resizable');
  7764. }
  7765. if (mirrorInfo) {
  7766. classes.push('fc-mirror');
  7767. if (mirrorInfo.isDragging) {
  7768. classes.push('fc-dragging');
  7769. }
  7770. if (mirrorInfo.isResizing) {
  7771. classes.push('fc-resizing');
  7772. }
  7773. }
  7774. return classes;
  7775. };
  7776. // Compute the text that should be displayed on an event's element.
  7777. // `range` can be the Event object itself, or something range-like, with at least a `start`.
  7778. // If event times are disabled, or the event has no time, will return a blank string.
  7779. // If not specified, formatter will default to the eventTimeFormat setting,
  7780. // and displayEnd will default to the displayEventEnd setting.
  7781. FgEventRenderer.prototype.getTimeText = function (eventRange, formatter, displayEnd) {
  7782. var def = eventRange.def, instance = eventRange.instance;
  7783. return this._getTimeText(instance.range.start, def.hasEnd ? instance.range.end : null, def.allDay, formatter, displayEnd, instance.forcedStartTzo, instance.forcedEndTzo);
  7784. };
  7785. FgEventRenderer.prototype._getTimeText = function (start, end, allDay, formatter, displayEnd, forcedStartTzo, forcedEndTzo) {
  7786. var dateEnv = this.context.dateEnv;
  7787. if (formatter == null) {
  7788. formatter = this.eventTimeFormat;
  7789. }
  7790. if (displayEnd == null) {
  7791. displayEnd = this.displayEventEnd;
  7792. }
  7793. if (this.displayEventTime && !allDay) {
  7794. if (displayEnd && end) {
  7795. return dateEnv.formatRange(start, end, formatter, {
  7796. forcedStartTzo: forcedStartTzo,
  7797. forcedEndTzo: forcedEndTzo
  7798. });
  7799. }
  7800. else {
  7801. return dateEnv.format(start, formatter, {
  7802. forcedTzo: forcedStartTzo
  7803. });
  7804. }
  7805. }
  7806. return '';
  7807. };
  7808. FgEventRenderer.prototype.computeEventTimeFormat = function () {
  7809. return {
  7810. hour: 'numeric',
  7811. minute: '2-digit',
  7812. omitZeroMinute: true
  7813. };
  7814. };
  7815. FgEventRenderer.prototype.computeDisplayEventTime = function () {
  7816. return true;
  7817. };
  7818. FgEventRenderer.prototype.computeDisplayEventEnd = function () {
  7819. return true;
  7820. };
  7821. // Utility for generating event skin-related CSS properties
  7822. FgEventRenderer.prototype.getSkinCss = function (ui) {
  7823. return {
  7824. 'background-color': ui.backgroundColor,
  7825. 'border-color': ui.borderColor,
  7826. color: ui.textColor
  7827. };
  7828. };
  7829. FgEventRenderer.prototype.sortEventSegs = function (segs) {
  7830. var specs = this.context.eventOrderSpecs;
  7831. var objs = segs.map(buildSegCompareObj);
  7832. objs.sort(function (obj0, obj1) {
  7833. return compareByFieldSpecs(obj0, obj1, specs);
  7834. });
  7835. return objs.map(function (c) {
  7836. return c._seg;
  7837. });
  7838. };
  7839. FgEventRenderer.prototype.computeSizes = function (force) {
  7840. if (force || this.isSizeDirty) {
  7841. this.computeSegSizes(this.segs);
  7842. }
  7843. };
  7844. FgEventRenderer.prototype.assignSizes = function (force) {
  7845. if (force || this.isSizeDirty) {
  7846. this.assignSegSizes(this.segs);
  7847. this.isSizeDirty = false;
  7848. }
  7849. };
  7850. FgEventRenderer.prototype.computeSegSizes = function (segs) {
  7851. };
  7852. FgEventRenderer.prototype.assignSegSizes = function (segs) {
  7853. };
  7854. // Manipulation on rendered segs
  7855. FgEventRenderer.prototype.hideByHash = function (hash) {
  7856. if (hash) {
  7857. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7858. var seg = _a[_i];
  7859. if (hash[seg.eventRange.instance.instanceId]) {
  7860. seg.el.style.visibility = 'hidden';
  7861. }
  7862. }
  7863. }
  7864. };
  7865. FgEventRenderer.prototype.showByHash = function (hash) {
  7866. if (hash) {
  7867. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7868. var seg = _a[_i];
  7869. if (hash[seg.eventRange.instance.instanceId]) {
  7870. seg.el.style.visibility = '';
  7871. }
  7872. }
  7873. }
  7874. };
  7875. FgEventRenderer.prototype.selectByInstanceId = function (instanceId) {
  7876. if (instanceId) {
  7877. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7878. var seg = _a[_i];
  7879. var eventInstance = seg.eventRange.instance;
  7880. if (eventInstance && eventInstance.instanceId === instanceId &&
  7881. seg.el // necessary?
  7882. ) {
  7883. seg.el.classList.add('fc-selected');
  7884. }
  7885. }
  7886. }
  7887. };
  7888. FgEventRenderer.prototype.unselectByInstanceId = function (instanceId) {
  7889. if (instanceId) {
  7890. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7891. var seg = _a[_i];
  7892. if (seg.el) { // necessary?
  7893. seg.el.classList.remove('fc-selected');
  7894. }
  7895. }
  7896. }
  7897. };
  7898. return FgEventRenderer;
  7899. }());
  7900. // returns a object with all primitive props that can be compared
  7901. function buildSegCompareObj(seg) {
  7902. var eventDef = seg.eventRange.def;
  7903. var range = seg.eventRange.instance.range;
  7904. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  7905. var end = range.end ? range.end.valueOf() : 0; // "
  7906. return __assign({}, eventDef.extendedProps, eventDef, { id: eventDef.publicId, start: start,
  7907. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg // for later retrieval
  7908. });
  7909. }
  7910. /*
  7911. TODO: when refactoring this class, make a new FillRenderer instance for each `type`
  7912. */
  7913. var FillRenderer = /** @class */ (function () {
  7914. function FillRenderer() {
  7915. this.fillSegTag = 'div';
  7916. this.dirtySizeFlags = {};
  7917. this.containerElsByType = {};
  7918. this.segsByType = {};
  7919. }
  7920. FillRenderer.prototype.getSegsByType = function (type) {
  7921. return this.segsByType[type] || [];
  7922. };
  7923. FillRenderer.prototype.renderSegs = function (type, context, segs) {
  7924. var _a;
  7925. this.context = context;
  7926. var renderedSegs = this.renderSegEls(type, segs); // assignes `.el` to each seg. returns successfully rendered segs
  7927. var containerEls = this.attachSegs(type, renderedSegs);
  7928. if (containerEls) {
  7929. (_a = (this.containerElsByType[type] || (this.containerElsByType[type] = []))).push.apply(_a, containerEls);
  7930. }
  7931. this.segsByType[type] = renderedSegs;
  7932. if (type === 'bgEvent') {
  7933. triggerRenderedSegs(context, renderedSegs, false); // isMirror=false
  7934. }
  7935. this.dirtySizeFlags[type] = true;
  7936. };
  7937. // Unrenders a specific type of fill that is currently rendered on the grid
  7938. FillRenderer.prototype.unrender = function (type, context) {
  7939. var segs = this.segsByType[type];
  7940. if (segs) {
  7941. if (type === 'bgEvent') {
  7942. triggerWillRemoveSegs(context, segs, false); // isMirror=false
  7943. }
  7944. this.detachSegs(type, segs);
  7945. }
  7946. };
  7947. // Renders and assigns an `el` property for each fill segment. Generic enough to work with different types.
  7948. // Only returns segments that successfully rendered.
  7949. FillRenderer.prototype.renderSegEls = function (type, segs) {
  7950. var _this = this;
  7951. var html = '';
  7952. var i;
  7953. if (segs.length) {
  7954. // build a large concatenation of segment HTML
  7955. for (i = 0; i < segs.length; i++) {
  7956. html += this.renderSegHtml(type, segs[i]);
  7957. }
  7958. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7959. // Then, compute the 'el' for each segment.
  7960. htmlToElements(html).forEach(function (el, i) {
  7961. var seg = segs[i];
  7962. if (el) {
  7963. seg.el = el;
  7964. }
  7965. });
  7966. if (type === 'bgEvent') {
  7967. segs = filterSegsViaEls(this.context, segs, false // isMirror. background events can never be mirror elements
  7968. );
  7969. }
  7970. // correct element type? (would be bad if a non-TD were inserted into a table for example)
  7971. segs = segs.filter(function (seg) {
  7972. return elementMatches(seg.el, _this.fillSegTag);
  7973. });
  7974. }
  7975. return segs;
  7976. };
  7977. // Builds the HTML needed for one fill segment. Generic enough to work with different types.
  7978. FillRenderer.prototype.renderSegHtml = function (type, seg) {
  7979. var css = null;
  7980. var classNames = [];
  7981. if (type !== 'highlight' && type !== 'businessHours') {
  7982. css = {
  7983. 'background-color': seg.eventRange.ui.backgroundColor
  7984. };
  7985. }
  7986. if (type !== 'highlight') {
  7987. classNames = classNames.concat(seg.eventRange.ui.classNames);
  7988. }
  7989. if (type === 'businessHours') {
  7990. classNames.push('fc-bgevent');
  7991. }
  7992. else {
  7993. classNames.push('fc-' + type.toLowerCase());
  7994. }
  7995. return '<' + this.fillSegTag +
  7996. (classNames.length ? ' class="' + classNames.join(' ') + '"' : '') +
  7997. (css ? ' style="' + cssToStr(css) + '"' : '') +
  7998. '></' + this.fillSegTag + '>';
  7999. };
  8000. FillRenderer.prototype.detachSegs = function (type, segs) {
  8001. var containerEls = this.containerElsByType[type];
  8002. if (containerEls) {
  8003. containerEls.forEach(removeElement);
  8004. delete this.containerElsByType[type];
  8005. }
  8006. };
  8007. FillRenderer.prototype.computeSizes = function (force) {
  8008. for (var type in this.segsByType) {
  8009. if (force || this.dirtySizeFlags[type]) {
  8010. this.computeSegSizes(this.segsByType[type]);
  8011. }
  8012. }
  8013. };
  8014. FillRenderer.prototype.assignSizes = function (force) {
  8015. for (var type in this.segsByType) {
  8016. if (force || this.dirtySizeFlags[type]) {
  8017. this.assignSegSizes(this.segsByType[type]);
  8018. }
  8019. }
  8020. this.dirtySizeFlags = {};
  8021. };
  8022. FillRenderer.prototype.computeSegSizes = function (segs) {
  8023. };
  8024. FillRenderer.prototype.assignSegSizes = function (segs) {
  8025. };
  8026. return FillRenderer;
  8027. }());
  8028. var NamedTimeZoneImpl = /** @class */ (function () {
  8029. function NamedTimeZoneImpl(timeZoneName) {
  8030. this.timeZoneName = timeZoneName;
  8031. }
  8032. return NamedTimeZoneImpl;
  8033. }());
  8034. /*
  8035. An abstraction for a dragging interaction originating on an event.
  8036. Does higher-level things than PointerDragger, such as possibly:
  8037. - a "mirror" that moves with the pointer
  8038. - a minimum number of pixels or other criteria for a true drag to begin
  8039. subclasses must emit:
  8040. - pointerdown
  8041. - dragstart
  8042. - dragmove
  8043. - pointerup
  8044. - dragend
  8045. */
  8046. var ElementDragging = /** @class */ (function () {
  8047. function ElementDragging(el) {
  8048. this.emitter = new EmitterMixin();
  8049. }
  8050. ElementDragging.prototype.destroy = function () {
  8051. };
  8052. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  8053. // optional if subclass doesn't want to support a mirror
  8054. };
  8055. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  8056. // optional if subclass doesn't want to support a mirror
  8057. };
  8058. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  8059. // optional
  8060. };
  8061. return ElementDragging;
  8062. }());
  8063. function formatDate(dateInput, settings) {
  8064. if (settings === void 0) { settings = {}; }
  8065. var dateEnv = buildDateEnv$1(settings);
  8066. var formatter = createFormatter(settings);
  8067. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  8068. if (!dateMeta) { // TODO: warning?
  8069. return '';
  8070. }
  8071. return dateEnv.format(dateMeta.marker, formatter, {
  8072. forcedTzo: dateMeta.forcedTzo
  8073. });
  8074. }
  8075. function formatRange(startInput, endInput, settings // mixture of env and formatter settings
  8076. ) {
  8077. var dateEnv = buildDateEnv$1(typeof settings === 'object' && settings ? settings : {}); // pass in if non-null object
  8078. var formatter = createFormatter(settings, globalDefaults.defaultRangeSeparator);
  8079. var startMeta = dateEnv.createMarkerMeta(startInput);
  8080. var endMeta = dateEnv.createMarkerMeta(endInput);
  8081. if (!startMeta || !endMeta) { // TODO: warning?
  8082. return '';
  8083. }
  8084. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  8085. forcedStartTzo: startMeta.forcedTzo,
  8086. forcedEndTzo: endMeta.forcedTzo,
  8087. isEndExclusive: settings.isEndExclusive
  8088. });
  8089. }
  8090. // TODO: more DRY and optimized
  8091. function buildDateEnv$1(settings) {
  8092. var locale = buildLocale(settings.locale || 'en', parseRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  8093. // ensure required settings
  8094. settings = __assign({ timeZone: globalDefaults.timeZone, calendarSystem: 'gregory' }, settings, { locale: locale });
  8095. return new DateEnv(settings);
  8096. }
  8097. var DRAG_META_PROPS = {
  8098. startTime: createDuration,
  8099. duration: createDuration,
  8100. create: Boolean,
  8101. sourceId: String
  8102. };
  8103. var DRAG_META_DEFAULTS = {
  8104. create: true
  8105. };
  8106. function parseDragMeta(raw) {
  8107. var leftoverProps = {};
  8108. var refined = refineProps(raw, DRAG_META_PROPS, DRAG_META_DEFAULTS, leftoverProps);
  8109. refined.leftoverProps = leftoverProps;
  8110. return refined;
  8111. }
  8112. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  8113. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  8114. // if more than one week row, or if there are a lot of columns with not much space,
  8115. // put just the day numbers will be in each cell
  8116. if (!datesRepDistinctDays || dayCnt > 10) {
  8117. return { weekday: 'short' }; // "Sat"
  8118. }
  8119. else if (dayCnt > 1) {
  8120. return { weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }; // "Sat 11/12"
  8121. }
  8122. else {
  8123. return { weekday: 'long' }; // "Saturday"
  8124. }
  8125. }
  8126. function renderDateCell(dateMarker, dateProfile, datesRepDistinctDays, colCnt, colHeadFormat, context, colspan, otherAttrs) {
  8127. var dateEnv = context.dateEnv, theme = context.theme, options = context.options;
  8128. var isDateValid = rangeContainsMarker(dateProfile.activeRange, dateMarker); // TODO: called too frequently. cache somehow.
  8129. var classNames = [
  8130. 'fc-day-header',
  8131. theme.getClass('widgetHeader')
  8132. ];
  8133. var innerHtml;
  8134. if (typeof options.columnHeaderHtml === 'function') {
  8135. innerHtml = options.columnHeaderHtml(dateEnv.toDate(dateMarker));
  8136. }
  8137. else if (typeof options.columnHeaderText === 'function') {
  8138. innerHtml = htmlEscape(options.columnHeaderText(dateEnv.toDate(dateMarker)));
  8139. }
  8140. else {
  8141. innerHtml = htmlEscape(dateEnv.format(dateMarker, colHeadFormat));
  8142. }
  8143. // if only one row of days, the classNames on the header can represent the specific days beneath
  8144. if (datesRepDistinctDays) {
  8145. classNames = classNames.concat(
  8146. // includes the day-of-week class
  8147. // noThemeHighlight=true (don't highlight the header)
  8148. getDayClasses(dateMarker, dateProfile, context, true));
  8149. }
  8150. else {
  8151. classNames.push('fc-' + DAY_IDS[dateMarker.getUTCDay()]); // only add the day-of-week class
  8152. }
  8153. return '' +
  8154. '<th class="' + classNames.join(' ') + '"' +
  8155. ((isDateValid && datesRepDistinctDays) ?
  8156. ' data-date="' + dateEnv.formatIso(dateMarker, { omitTime: true }) + '"' :
  8157. '') +
  8158. (colspan > 1 ?
  8159. ' colspan="' + colspan + '"' :
  8160. '') +
  8161. (otherAttrs ?
  8162. ' ' + otherAttrs :
  8163. '') +
  8164. '>' +
  8165. (isDateValid ?
  8166. // don't make a link if the heading could represent multiple days, or if there's only one day (forceOff)
  8167. buildGotoAnchorHtml(options, dateEnv, { date: dateMarker, forceOff: !datesRepDistinctDays || colCnt === 1 }, innerHtml) :
  8168. // if not valid, display text, but no link
  8169. innerHtml) +
  8170. '</th>';
  8171. }
  8172. var DayHeader = /** @class */ (function (_super) {
  8173. __extends(DayHeader, _super);
  8174. function DayHeader(parentEl) {
  8175. var _this = _super.call(this) || this;
  8176. _this.renderSkeleton = memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  8177. _this.parentEl = parentEl;
  8178. return _this;
  8179. }
  8180. DayHeader.prototype.render = function (props, context) {
  8181. var dates = props.dates, datesRepDistinctDays = props.datesRepDistinctDays;
  8182. var parts = [];
  8183. this.renderSkeleton(context);
  8184. if (props.renderIntroHtml) {
  8185. parts.push(props.renderIntroHtml());
  8186. }
  8187. var colHeadFormat = createFormatter(context.options.columnHeaderFormat ||
  8188. computeFallbackHeaderFormat(datesRepDistinctDays, dates.length));
  8189. for (var _i = 0, dates_1 = dates; _i < dates_1.length; _i++) {
  8190. var date = dates_1[_i];
  8191. parts.push(renderDateCell(date, props.dateProfile, datesRepDistinctDays, dates.length, colHeadFormat, context));
  8192. }
  8193. if (context.isRtl) {
  8194. parts.reverse();
  8195. }
  8196. this.thead.innerHTML = '<tr>' + parts.join('') + '</tr>';
  8197. };
  8198. DayHeader.prototype.destroy = function () {
  8199. _super.prototype.destroy.call(this);
  8200. this.renderSkeleton.unrender();
  8201. };
  8202. DayHeader.prototype._renderSkeleton = function (context) {
  8203. var theme = context.theme;
  8204. var parentEl = this.parentEl;
  8205. parentEl.innerHTML = ''; // because might be nbsp
  8206. parentEl.appendChild(this.el = htmlToElement('<div class="fc-row ' + theme.getClass('headerRow') + '">' +
  8207. '<table class="' + theme.getClass('tableGrid') + '">' +
  8208. '<thead></thead>' +
  8209. '</table>' +
  8210. '</div>'));
  8211. this.thead = this.el.querySelector('thead');
  8212. };
  8213. DayHeader.prototype._unrenderSkeleton = function () {
  8214. removeElement(this.el);
  8215. };
  8216. return DayHeader;
  8217. }(Component));
  8218. var DaySeries = /** @class */ (function () {
  8219. function DaySeries(range, dateProfileGenerator) {
  8220. var date = range.start;
  8221. var end = range.end;
  8222. var indices = [];
  8223. var dates = [];
  8224. var dayIndex = -1;
  8225. while (date < end) { // loop each day from start to end
  8226. if (dateProfileGenerator.isHiddenDay(date)) {
  8227. indices.push(dayIndex + 0.5); // mark that it's between indices
  8228. }
  8229. else {
  8230. dayIndex++;
  8231. indices.push(dayIndex);
  8232. dates.push(date);
  8233. }
  8234. date = addDays(date, 1);
  8235. }
  8236. this.dates = dates;
  8237. this.indices = indices;
  8238. this.cnt = dates.length;
  8239. }
  8240. DaySeries.prototype.sliceRange = function (range) {
  8241. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8242. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8243. var clippedFirstIndex = Math.max(0, firstIndex);
  8244. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8245. // deal with in-between indices
  8246. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8247. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8248. if (clippedFirstIndex <= clippedLastIndex) {
  8249. return {
  8250. firstIndex: clippedFirstIndex,
  8251. lastIndex: clippedLastIndex,
  8252. isStart: firstIndex === clippedFirstIndex,
  8253. isEnd: lastIndex === clippedLastIndex
  8254. };
  8255. }
  8256. else {
  8257. return null;
  8258. }
  8259. };
  8260. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8261. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8262. // If before the first offset, returns a negative number.
  8263. // If after the last offset, returns an offset past the last cell offset.
  8264. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8265. DaySeries.prototype.getDateDayIndex = function (date) {
  8266. var indices = this.indices;
  8267. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8268. if (dayOffset < 0) {
  8269. return indices[0] - 1;
  8270. }
  8271. else if (dayOffset >= indices.length) {
  8272. return indices[indices.length - 1] + 1;
  8273. }
  8274. else {
  8275. return indices[dayOffset];
  8276. }
  8277. };
  8278. return DaySeries;
  8279. }());
  8280. var DayTable = /** @class */ (function () {
  8281. function DayTable(daySeries, breakOnWeeks) {
  8282. var dates = daySeries.dates;
  8283. var daysPerRow;
  8284. var firstDay;
  8285. var rowCnt;
  8286. if (breakOnWeeks) {
  8287. // count columns until the day-of-week repeats
  8288. firstDay = dates[0].getUTCDay();
  8289. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow++) {
  8290. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8291. break;
  8292. }
  8293. }
  8294. rowCnt = Math.ceil(dates.length / daysPerRow);
  8295. }
  8296. else {
  8297. rowCnt = 1;
  8298. daysPerRow = dates.length;
  8299. }
  8300. this.rowCnt = rowCnt;
  8301. this.colCnt = daysPerRow;
  8302. this.daySeries = daySeries;
  8303. this.cells = this.buildCells();
  8304. this.headerDates = this.buildHeaderDates();
  8305. }
  8306. DayTable.prototype.buildCells = function () {
  8307. var rows = [];
  8308. for (var row = 0; row < this.rowCnt; row++) {
  8309. var cells = [];
  8310. for (var col = 0; col < this.colCnt; col++) {
  8311. cells.push(this.buildCell(row, col));
  8312. }
  8313. rows.push(cells);
  8314. }
  8315. return rows;
  8316. };
  8317. DayTable.prototype.buildCell = function (row, col) {
  8318. return {
  8319. date: this.daySeries.dates[row * this.colCnt + col]
  8320. };
  8321. };
  8322. DayTable.prototype.buildHeaderDates = function () {
  8323. var dates = [];
  8324. for (var col = 0; col < this.colCnt; col++) {
  8325. dates.push(this.cells[0][col].date);
  8326. }
  8327. return dates;
  8328. };
  8329. DayTable.prototype.sliceRange = function (range) {
  8330. var colCnt = this.colCnt;
  8331. var seriesSeg = this.daySeries.sliceRange(range);
  8332. var segs = [];
  8333. if (seriesSeg) {
  8334. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8335. var index = firstIndex;
  8336. while (index <= lastIndex) {
  8337. var row = Math.floor(index / colCnt);
  8338. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8339. segs.push({
  8340. row: row,
  8341. firstCol: index % colCnt,
  8342. lastCol: (nextIndex - 1) % colCnt,
  8343. isStart: seriesSeg.isStart && index === firstIndex,
  8344. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex
  8345. });
  8346. index = nextIndex;
  8347. }
  8348. }
  8349. return segs;
  8350. };
  8351. return DayTable;
  8352. }());
  8353. var Slicer = /** @class */ (function () {
  8354. function Slicer() {
  8355. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8356. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8357. this.sliceEventStore = memoize(this._sliceEventStore);
  8358. this.sliceEventDrag = memoize(this._sliceInteraction);
  8359. this.sliceEventResize = memoize(this._sliceInteraction);
  8360. }
  8361. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, calendar, component) {
  8362. var extraArgs = [];
  8363. for (var _i = 5; _i < arguments.length; _i++) {
  8364. extraArgs[_i - 5] = arguments[_i];
  8365. }
  8366. var eventUiBases = props.eventUiBases;
  8367. var eventSegs = this.sliceEventStore.apply(this, [props.eventStore, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs));
  8368. return {
  8369. dateSelectionSegs: this.sliceDateSelection.apply(this, [props.dateSelection, eventUiBases, component].concat(extraArgs)),
  8370. businessHourSegs: this.sliceBusinessHours.apply(this, [props.businessHours, dateProfile, nextDayThreshold, calendar, component].concat(extraArgs)),
  8371. fgEventSegs: eventSegs.fg,
  8372. bgEventSegs: eventSegs.bg,
  8373. eventDrag: this.sliceEventDrag.apply(this, [props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8374. eventResize: this.sliceEventResize.apply(this, [props.eventResize, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8375. eventSelection: props.eventSelection
  8376. }; // TODO: give interactionSegs?
  8377. };
  8378. Slicer.prototype.sliceNowDate = function (// does not memoize
  8379. date, component) {
  8380. var extraArgs = [];
  8381. for (var _i = 2; _i < arguments.length; _i++) {
  8382. extraArgs[_i - 2] = arguments[_i];
  8383. }
  8384. return this._sliceDateSpan.apply(this, [{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8385. {},
  8386. component].concat(extraArgs));
  8387. };
  8388. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, calendar, component) {
  8389. var extraArgs = [];
  8390. for (var _i = 5; _i < arguments.length; _i++) {
  8391. extraArgs[_i - 5] = arguments[_i];
  8392. }
  8393. if (!businessHours) {
  8394. return [];
  8395. }
  8396. return this._sliceEventStore.apply(this, [expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), calendar),
  8397. {},
  8398. dateProfile,
  8399. nextDayThreshold,
  8400. component].concat(extraArgs)).bg;
  8401. };
  8402. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold, component) {
  8403. var extraArgs = [];
  8404. for (var _i = 5; _i < arguments.length; _i++) {
  8405. extraArgs[_i - 5] = arguments[_i];
  8406. }
  8407. if (eventStore) {
  8408. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8409. return {
  8410. bg: this.sliceEventRanges(rangeRes.bg, component, extraArgs),
  8411. fg: this.sliceEventRanges(rangeRes.fg, component, extraArgs)
  8412. };
  8413. }
  8414. else {
  8415. return { bg: [], fg: [] };
  8416. }
  8417. };
  8418. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold, component) {
  8419. var extraArgs = [];
  8420. for (var _i = 5; _i < arguments.length; _i++) {
  8421. extraArgs[_i - 5] = arguments[_i];
  8422. }
  8423. if (!interaction) {
  8424. return null;
  8425. }
  8426. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8427. return {
  8428. segs: this.sliceEventRanges(rangeRes.fg, component, extraArgs),
  8429. affectedInstances: interaction.affectedEvents.instances,
  8430. isEvent: interaction.isEvent,
  8431. sourceSeg: interaction.origSeg
  8432. };
  8433. };
  8434. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, component) {
  8435. var extraArgs = [];
  8436. for (var _i = 3; _i < arguments.length; _i++) {
  8437. extraArgs[_i - 3] = arguments[_i];
  8438. }
  8439. if (!dateSpan) {
  8440. return [];
  8441. }
  8442. var eventRange = fabricateEventRange(dateSpan, eventUiBases, component.context.calendar);
  8443. var segs = this.sliceRange.apply(this, [dateSpan.range].concat(extraArgs));
  8444. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8445. var seg = segs_1[_a];
  8446. seg.component = component;
  8447. seg.eventRange = eventRange;
  8448. }
  8449. return segs;
  8450. };
  8451. /*
  8452. "complete" seg means it has component and eventRange
  8453. */
  8454. Slicer.prototype.sliceEventRanges = function (eventRanges, component, // TODO: kill
  8455. extraArgs) {
  8456. var segs = [];
  8457. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8458. var eventRange = eventRanges_1[_i];
  8459. segs.push.apply(segs, this.sliceEventRange(eventRange, component, extraArgs));
  8460. }
  8461. return segs;
  8462. };
  8463. /*
  8464. "complete" seg means it has component and eventRange
  8465. */
  8466. Slicer.prototype.sliceEventRange = function (eventRange, component, // TODO: kill
  8467. extraArgs) {
  8468. var segs = this.sliceRange.apply(this, [eventRange.range].concat(extraArgs));
  8469. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8470. var seg = segs_2[_i];
  8471. seg.component = component;
  8472. seg.eventRange = eventRange;
  8473. seg.isStart = eventRange.isStart && seg.isStart;
  8474. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8475. }
  8476. return segs;
  8477. };
  8478. return Slicer;
  8479. }());
  8480. /*
  8481. for incorporating minTime/maxTime if appropriate
  8482. TODO: should be part of DateProfile!
  8483. TimelineDateProfile already does this btw
  8484. */
  8485. function computeActiveRange(dateProfile, isComponentAllDay) {
  8486. var range = dateProfile.activeRange;
  8487. if (isComponentAllDay) {
  8488. return range;
  8489. }
  8490. return {
  8491. start: addMs(range.start, dateProfile.minTime.milliseconds),
  8492. end: addMs(range.end, dateProfile.maxTime.milliseconds - 864e5) // 864e5 = ms in a day
  8493. };
  8494. }
  8495. // exports
  8496. // --------------------------------------------------------------------------------------------------
  8497. var version = '4.4.2';
  8498. exports.Calendar = Calendar;
  8499. exports.Component = Component;
  8500. exports.ComponentContext = ComponentContext;
  8501. exports.DateComponent = DateComponent;
  8502. exports.DateEnv = DateEnv;
  8503. exports.DateProfileGenerator = DateProfileGenerator;
  8504. exports.DayHeader = DayHeader;
  8505. exports.DaySeries = DaySeries;
  8506. exports.DayTable = DayTable;
  8507. exports.ElementDragging = ElementDragging;
  8508. exports.ElementScrollController = ElementScrollController;
  8509. exports.EmitterMixin = EmitterMixin;
  8510. exports.EventApi = EventApi;
  8511. exports.FgEventRenderer = FgEventRenderer;
  8512. exports.FillRenderer = FillRenderer;
  8513. exports.Interaction = Interaction;
  8514. exports.Mixin = Mixin;
  8515. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  8516. exports.PositionCache = PositionCache;
  8517. exports.ScrollComponent = ScrollComponent;
  8518. exports.ScrollController = ScrollController;
  8519. exports.Slicer = Slicer;
  8520. exports.Splitter = Splitter;
  8521. exports.Theme = Theme;
  8522. exports.View = View;
  8523. exports.WindowScrollController = WindowScrollController;
  8524. exports.addDays = addDays;
  8525. exports.addDurations = addDurations;
  8526. exports.addMs = addMs;
  8527. exports.addWeeks = addWeeks;
  8528. exports.allowContextMenu = allowContextMenu;
  8529. exports.allowSelection = allowSelection;
  8530. exports.appendToElement = appendToElement;
  8531. exports.applyAll = applyAll;
  8532. exports.applyMutationToEventStore = applyMutationToEventStore;
  8533. exports.applyStyle = applyStyle;
  8534. exports.applyStyleProp = applyStyleProp;
  8535. exports.asRoughMinutes = asRoughMinutes;
  8536. exports.asRoughMs = asRoughMs;
  8537. exports.asRoughSeconds = asRoughSeconds;
  8538. exports.buildGotoAnchorHtml = buildGotoAnchorHtml;
  8539. exports.buildSegCompareObj = buildSegCompareObj;
  8540. exports.capitaliseFirstLetter = capitaliseFirstLetter;
  8541. exports.combineEventUis = combineEventUis;
  8542. exports.compareByFieldSpec = compareByFieldSpec;
  8543. exports.compareByFieldSpecs = compareByFieldSpecs;
  8544. exports.compareNumbers = compareNumbers;
  8545. exports.compensateScroll = compensateScroll;
  8546. exports.computeClippingRect = computeClippingRect;
  8547. exports.computeEdges = computeEdges;
  8548. exports.computeEventDraggable = computeEventDraggable;
  8549. exports.computeEventEndResizable = computeEventEndResizable;
  8550. exports.computeEventStartResizable = computeEventStartResizable;
  8551. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  8552. exports.computeHeightAndMargins = computeHeightAndMargins;
  8553. exports.computeInnerRect = computeInnerRect;
  8554. exports.computeRect = computeRect;
  8555. exports.computeVisibleDayRange = computeVisibleDayRange;
  8556. exports.config = config;
  8557. exports.constrainPoint = constrainPoint;
  8558. exports.createDuration = createDuration;
  8559. exports.createElement = createElement;
  8560. exports.createEmptyEventStore = createEmptyEventStore;
  8561. exports.createEventInstance = createEventInstance;
  8562. exports.createFormatter = createFormatter;
  8563. exports.createPlugin = createPlugin;
  8564. exports.cssToStr = cssToStr;
  8565. exports.debounce = debounce;
  8566. exports.diffDates = diffDates;
  8567. exports.diffDayAndTime = diffDayAndTime;
  8568. exports.diffDays = diffDays;
  8569. exports.diffPoints = diffPoints;
  8570. exports.diffWeeks = diffWeeks;
  8571. exports.diffWholeDays = diffWholeDays;
  8572. exports.diffWholeWeeks = diffWholeWeeks;
  8573. exports.disableCursor = disableCursor;
  8574. exports.distributeHeight = distributeHeight;
  8575. exports.elementClosest = elementClosest;
  8576. exports.elementMatches = elementMatches;
  8577. exports.enableCursor = enableCursor;
  8578. exports.eventTupleToStore = eventTupleToStore;
  8579. exports.filterEventStoreDefs = filterEventStoreDefs;
  8580. exports.filterHash = filterHash;
  8581. exports.findChildren = findChildren;
  8582. exports.findElements = findElements;
  8583. exports.flexibleCompare = flexibleCompare;
  8584. exports.forceClassName = forceClassName;
  8585. exports.formatDate = formatDate;
  8586. exports.formatIsoTimeString = formatIsoTimeString;
  8587. exports.formatRange = formatRange;
  8588. exports.getAllDayHtml = getAllDayHtml;
  8589. exports.getClippingParents = getClippingParents;
  8590. exports.getDayClasses = getDayClasses;
  8591. exports.getElSeg = getElSeg;
  8592. exports.getRectCenter = getRectCenter;
  8593. exports.getRelevantEvents = getRelevantEvents;
  8594. exports.globalDefaults = globalDefaults;
  8595. exports.greatestDurationDenominator = greatestDurationDenominator;
  8596. exports.hasBgRendering = hasBgRendering;
  8597. exports.htmlEscape = htmlEscape;
  8598. exports.htmlToElement = htmlToElement;
  8599. exports.insertAfterElement = insertAfterElement;
  8600. exports.interactionSettingsStore = interactionSettingsStore;
  8601. exports.interactionSettingsToStore = interactionSettingsToStore;
  8602. exports.intersectRanges = intersectRanges;
  8603. exports.intersectRects = intersectRects;
  8604. exports.isArraysEqual = isArraysEqual;
  8605. exports.isDateSpansEqual = isDateSpansEqual;
  8606. exports.isInt = isInt;
  8607. exports.isInteractionValid = isInteractionValid;
  8608. exports.isMultiDayRange = isMultiDayRange;
  8609. exports.isPropsEqual = isPropsEqual;
  8610. exports.isPropsValid = isPropsValid;
  8611. exports.isSingleDay = isSingleDay;
  8612. exports.isValidDate = isValidDate;
  8613. exports.listenBySelector = listenBySelector;
  8614. exports.mapHash = mapHash;
  8615. exports.matchCellWidths = matchCellWidths;
  8616. exports.memoize = memoize;
  8617. exports.memoizeOutput = memoizeOutput;
  8618. exports.memoizeRendering = memoizeRendering;
  8619. exports.mergeEventStores = mergeEventStores;
  8620. exports.multiplyDuration = multiplyDuration;
  8621. exports.padStart = padStart;
  8622. exports.parseBusinessHours = parseBusinessHours;
  8623. exports.parseDragMeta = parseDragMeta;
  8624. exports.parseEventDef = parseEventDef;
  8625. exports.parseFieldSpecs = parseFieldSpecs;
  8626. exports.parseMarker = parse;
  8627. exports.pointInsideRect = pointInsideRect;
  8628. exports.prependToElement = prependToElement;
  8629. exports.preventContextMenu = preventContextMenu;
  8630. exports.preventDefault = preventDefault;
  8631. exports.preventSelection = preventSelection;
  8632. exports.processScopedUiProps = processScopedUiProps;
  8633. exports.rangeContainsMarker = rangeContainsMarker;
  8634. exports.rangeContainsRange = rangeContainsRange;
  8635. exports.rangesEqual = rangesEqual;
  8636. exports.rangesIntersect = rangesIntersect;
  8637. exports.refineProps = refineProps;
  8638. exports.removeElement = removeElement;
  8639. exports.removeExact = removeExact;
  8640. exports.renderDateCell = renderDateCell;
  8641. exports.requestJson = requestJson;
  8642. exports.sliceEventStore = sliceEventStore;
  8643. exports.startOfDay = startOfDay;
  8644. exports.subtractInnerElHeight = subtractInnerElHeight;
  8645. exports.translateRect = translateRect;
  8646. exports.uncompensateScroll = uncompensateScroll;
  8647. exports.undistributeHeight = undistributeHeight;
  8648. exports.unpromisify = unpromisify;
  8649. exports.version = version;
  8650. exports.whenTransitionDone = whenTransitionDone;
  8651. exports.wholeDivideDurations = wholeDivideDurations;
  8652. Object.defineProperty(exports, '__esModule', { value: true });
  8653. }));