fullcalendar.bundle.js 635 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412
  1. /*!
  2. FullCalendar Core Package v4.4.0
  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. All rights reserved.
  1125. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  1126. this file except in compliance with the License. You may obtain a copy of the
  1127. License at http://www.apache.org/licenses/LICENSE-2.0
  1128. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1129. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  1130. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  1131. MERCHANTABLITY OR NON-INFRINGEMENT.
  1132. See the Apache Version 2.0 License for specific language governing permissions
  1133. and limitations under the License.
  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.loadingLevel) { // 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.uid = String(guid++);
  3895. }
  3896. Component.addEqualityFuncs = function (newFuncs) {
  3897. this.prototype.equalityFuncs = __assign({}, this.prototype.equalityFuncs, newFuncs);
  3898. };
  3899. Component.prototype.receiveProps = function (props, context) {
  3900. var oldContext = this.context;
  3901. this.context = context;
  3902. if (!oldContext) {
  3903. this.firstContext(context);
  3904. }
  3905. var _a = recycleProps(this.props || {}, props, this.equalityFuncs), anyChanges = _a.anyChanges, comboProps = _a.comboProps;
  3906. this.props = comboProps;
  3907. if (anyChanges) {
  3908. if (oldContext) {
  3909. this.beforeUpdate();
  3910. }
  3911. this.render(comboProps, context);
  3912. if (oldContext) {
  3913. this.afterUpdate();
  3914. }
  3915. }
  3916. };
  3917. Component.prototype.render = function (props, context) {
  3918. };
  3919. Component.prototype.firstContext = function (context) {
  3920. };
  3921. Component.prototype.beforeUpdate = function () {
  3922. };
  3923. Component.prototype.afterUpdate = function () {
  3924. };
  3925. // after destroy is called, this component won't ever be used again
  3926. Component.prototype.destroy = function () {
  3927. };
  3928. return Component;
  3929. }());
  3930. Component.prototype.equalityFuncs = {};
  3931. /*
  3932. Reuses old values when equal. If anything is unequal, returns newProps as-is.
  3933. Great for PureComponent, but won't be feasible with React, so just eliminate and use React's DOM diffing.
  3934. */
  3935. function recycleProps(oldProps, newProps, equalityFuncs) {
  3936. var comboProps = {}; // some old, some new
  3937. var anyChanges = false;
  3938. for (var key in newProps) {
  3939. if (key in oldProps && (oldProps[key] === newProps[key] ||
  3940. (equalityFuncs[key] && equalityFuncs[key](oldProps[key], newProps[key])))) {
  3941. // equal to old? use old prop
  3942. comboProps[key] = oldProps[key];
  3943. }
  3944. else {
  3945. comboProps[key] = newProps[key];
  3946. anyChanges = true;
  3947. }
  3948. }
  3949. for (var key in oldProps) {
  3950. if (!(key in newProps)) {
  3951. anyChanges = true;
  3952. break;
  3953. }
  3954. }
  3955. return { anyChanges: anyChanges, comboProps: comboProps };
  3956. }
  3957. /*
  3958. PURPOSES:
  3959. - hook up to fg, fill, and mirror renderers
  3960. - interface for dragging and hits
  3961. */
  3962. var DateComponent = /** @class */ (function (_super) {
  3963. __extends(DateComponent, _super);
  3964. function DateComponent(el) {
  3965. var _this = _super.call(this) || this;
  3966. _this.el = el;
  3967. return _this;
  3968. }
  3969. DateComponent.prototype.destroy = function () {
  3970. _super.prototype.destroy.call(this);
  3971. removeElement(this.el);
  3972. };
  3973. // Hit System
  3974. // -----------------------------------------------------------------------------------------------------------------
  3975. DateComponent.prototype.buildPositionCaches = function () {
  3976. };
  3977. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  3978. return null; // this should be abstract
  3979. };
  3980. // Validation
  3981. // -----------------------------------------------------------------------------------------------------------------
  3982. DateComponent.prototype.isInteractionValid = function (interaction) {
  3983. var calendar = this.context.calendar;
  3984. var dateProfile = this.props.dateProfile; // HACK
  3985. var instances = interaction.mutatedEvents.instances;
  3986. if (dateProfile) { // HACK for DayTile
  3987. for (var instanceId in instances) {
  3988. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  3989. return false;
  3990. }
  3991. }
  3992. }
  3993. return isInteractionValid(interaction, calendar);
  3994. };
  3995. DateComponent.prototype.isDateSelectionValid = function (selection) {
  3996. var calendar = this.context.calendar;
  3997. var dateProfile = this.props.dateProfile; // HACK
  3998. if (dateProfile && // HACK for DayTile
  3999. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  4000. return false;
  4001. }
  4002. return isDateSelectionValid(selection, calendar);
  4003. };
  4004. // Pointer Interaction Utils
  4005. // -----------------------------------------------------------------------------------------------------------------
  4006. DateComponent.prototype.isValidSegDownEl = function (el) {
  4007. return !this.props.eventDrag && // HACK
  4008. !this.props.eventResize && // HACK
  4009. !elementClosest(el, '.fc-mirror') &&
  4010. (this.isPopover() || !this.isInPopover(el));
  4011. // ^above line ensures we don't detect a seg interaction within a nested component.
  4012. // it's a HACK because it only supports a popover as the nested component.
  4013. };
  4014. DateComponent.prototype.isValidDateDownEl = function (el) {
  4015. var segEl = elementClosest(el, this.fgSegSelector);
  4016. return (!segEl || segEl.classList.contains('fc-mirror')) &&
  4017. !elementClosest(el, '.fc-more') && // a "more.." link
  4018. !elementClosest(el, 'a[data-goto]') && // a clickable nav link
  4019. !this.isInPopover(el);
  4020. };
  4021. DateComponent.prototype.isPopover = function () {
  4022. return this.el.classList.contains('fc-popover');
  4023. };
  4024. DateComponent.prototype.isInPopover = function (el) {
  4025. return Boolean(elementClosest(el, '.fc-popover'));
  4026. };
  4027. return DateComponent;
  4028. }(Component));
  4029. DateComponent.prototype.fgSegSelector = '.fc-event-container > *';
  4030. DateComponent.prototype.bgSegSelector = '.fc-bgevent:not(.fc-nonbusiness)';
  4031. var uid$1 = 0;
  4032. function createPlugin(input) {
  4033. return {
  4034. id: String(uid$1++),
  4035. deps: input.deps || [],
  4036. reducers: input.reducers || [],
  4037. eventDefParsers: input.eventDefParsers || [],
  4038. isDraggableTransformers: input.isDraggableTransformers || [],
  4039. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  4040. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  4041. dateSelectionTransformers: input.dateSelectionTransformers || [],
  4042. datePointTransforms: input.datePointTransforms || [],
  4043. dateSpanTransforms: input.dateSpanTransforms || [],
  4044. views: input.views || {},
  4045. viewPropsTransformers: input.viewPropsTransformers || [],
  4046. isPropsValid: input.isPropsValid || null,
  4047. externalDefTransforms: input.externalDefTransforms || [],
  4048. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  4049. viewContainerModifiers: input.viewContainerModifiers || [],
  4050. eventDropTransformers: input.eventDropTransformers || [],
  4051. componentInteractions: input.componentInteractions || [],
  4052. calendarInteractions: input.calendarInteractions || [],
  4053. themeClasses: input.themeClasses || {},
  4054. eventSourceDefs: input.eventSourceDefs || [],
  4055. cmdFormatter: input.cmdFormatter,
  4056. recurringTypes: input.recurringTypes || [],
  4057. namedTimeZonedImpl: input.namedTimeZonedImpl,
  4058. defaultView: input.defaultView || '',
  4059. elementDraggingImpl: input.elementDraggingImpl,
  4060. optionChangeHandlers: input.optionChangeHandlers || {}
  4061. };
  4062. }
  4063. var PluginSystem = /** @class */ (function () {
  4064. function PluginSystem() {
  4065. this.hooks = {
  4066. reducers: [],
  4067. eventDefParsers: [],
  4068. isDraggableTransformers: [],
  4069. eventDragMutationMassagers: [],
  4070. eventDefMutationAppliers: [],
  4071. dateSelectionTransformers: [],
  4072. datePointTransforms: [],
  4073. dateSpanTransforms: [],
  4074. views: {},
  4075. viewPropsTransformers: [],
  4076. isPropsValid: null,
  4077. externalDefTransforms: [],
  4078. eventResizeJoinTransforms: [],
  4079. viewContainerModifiers: [],
  4080. eventDropTransformers: [],
  4081. componentInteractions: [],
  4082. calendarInteractions: [],
  4083. themeClasses: {},
  4084. eventSourceDefs: [],
  4085. cmdFormatter: null,
  4086. recurringTypes: [],
  4087. namedTimeZonedImpl: null,
  4088. defaultView: '',
  4089. elementDraggingImpl: null,
  4090. optionChangeHandlers: {}
  4091. };
  4092. this.addedHash = {};
  4093. }
  4094. PluginSystem.prototype.add = function (plugin) {
  4095. if (!this.addedHash[plugin.id]) {
  4096. this.addedHash[plugin.id] = true;
  4097. for (var _i = 0, _a = plugin.deps; _i < _a.length; _i++) {
  4098. var dep = _a[_i];
  4099. this.add(dep);
  4100. }
  4101. this.hooks = combineHooks(this.hooks, plugin);
  4102. }
  4103. };
  4104. return PluginSystem;
  4105. }());
  4106. function combineHooks(hooks0, hooks1) {
  4107. return {
  4108. reducers: hooks0.reducers.concat(hooks1.reducers),
  4109. eventDefParsers: hooks0.eventDefParsers.concat(hooks1.eventDefParsers),
  4110. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  4111. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  4112. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  4113. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  4114. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  4115. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  4116. views: __assign({}, hooks0.views, hooks1.views),
  4117. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  4118. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  4119. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  4120. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  4121. viewContainerModifiers: hooks0.viewContainerModifiers.concat(hooks1.viewContainerModifiers),
  4122. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  4123. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  4124. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  4125. themeClasses: __assign({}, hooks0.themeClasses, hooks1.themeClasses),
  4126. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  4127. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  4128. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  4129. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  4130. defaultView: hooks0.defaultView || hooks1.defaultView,
  4131. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  4132. optionChangeHandlers: __assign({}, hooks0.optionChangeHandlers, hooks1.optionChangeHandlers)
  4133. };
  4134. }
  4135. var eventSourceDef = {
  4136. ignoreRange: true,
  4137. parseMeta: function (raw) {
  4138. if (Array.isArray(raw)) { // short form
  4139. return raw;
  4140. }
  4141. else if (Array.isArray(raw.events)) {
  4142. return raw.events;
  4143. }
  4144. return null;
  4145. },
  4146. fetch: function (arg, success) {
  4147. success({
  4148. rawEvents: arg.eventSource.meta
  4149. });
  4150. }
  4151. };
  4152. var ArrayEventSourcePlugin = createPlugin({
  4153. eventSourceDefs: [eventSourceDef]
  4154. });
  4155. var eventSourceDef$1 = {
  4156. parseMeta: function (raw) {
  4157. if (typeof raw === 'function') { // short form
  4158. return raw;
  4159. }
  4160. else if (typeof raw.events === 'function') {
  4161. return raw.events;
  4162. }
  4163. return null;
  4164. },
  4165. fetch: function (arg, success, failure) {
  4166. var dateEnv = arg.calendar.dateEnv;
  4167. var func = arg.eventSource.meta;
  4168. unpromisify(func.bind(null, {
  4169. start: dateEnv.toDate(arg.range.start),
  4170. end: dateEnv.toDate(arg.range.end),
  4171. startStr: dateEnv.formatIso(arg.range.start),
  4172. endStr: dateEnv.formatIso(arg.range.end),
  4173. timeZone: dateEnv.timeZone
  4174. }), function (rawEvents) {
  4175. success({ rawEvents: rawEvents }); // needs an object response
  4176. }, failure // send errorObj directly to failure callback
  4177. );
  4178. }
  4179. };
  4180. var FuncEventSourcePlugin = createPlugin({
  4181. eventSourceDefs: [eventSourceDef$1]
  4182. });
  4183. function requestJson(method, url, params, successCallback, failureCallback) {
  4184. method = method.toUpperCase();
  4185. var body = null;
  4186. if (method === 'GET') {
  4187. url = injectQueryStringParams(url, params);
  4188. }
  4189. else {
  4190. body = encodeParams(params);
  4191. }
  4192. var xhr = new XMLHttpRequest();
  4193. xhr.open(method, url, true);
  4194. if (method !== 'GET') {
  4195. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  4196. }
  4197. xhr.onload = function () {
  4198. if (xhr.status >= 200 && xhr.status < 400) {
  4199. try {
  4200. var res = JSON.parse(xhr.responseText);
  4201. successCallback(res, xhr);
  4202. }
  4203. catch (err) {
  4204. failureCallback('Failure parsing JSON', xhr);
  4205. }
  4206. }
  4207. else {
  4208. failureCallback('Request failed', xhr);
  4209. }
  4210. };
  4211. xhr.onerror = function () {
  4212. failureCallback('Request failed', xhr);
  4213. };
  4214. xhr.send(body);
  4215. }
  4216. function injectQueryStringParams(url, params) {
  4217. return url +
  4218. (url.indexOf('?') === -1 ? '?' : '&') +
  4219. encodeParams(params);
  4220. }
  4221. function encodeParams(params) {
  4222. var parts = [];
  4223. for (var key in params) {
  4224. parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  4225. }
  4226. return parts.join('&');
  4227. }
  4228. var eventSourceDef$2 = {
  4229. parseMeta: function (raw) {
  4230. if (typeof raw === 'string') { // short form
  4231. raw = { url: raw };
  4232. }
  4233. else if (!raw || typeof raw !== 'object' || !raw.url) {
  4234. return null;
  4235. }
  4236. return {
  4237. url: raw.url,
  4238. method: (raw.method || 'GET').toUpperCase(),
  4239. extraParams: raw.extraParams,
  4240. startParam: raw.startParam,
  4241. endParam: raw.endParam,
  4242. timeZoneParam: raw.timeZoneParam
  4243. };
  4244. },
  4245. fetch: function (arg, success, failure) {
  4246. var meta = arg.eventSource.meta;
  4247. var requestParams = buildRequestParams(meta, arg.range, arg.calendar);
  4248. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  4249. success({ rawEvents: rawEvents, xhr: xhr });
  4250. }, function (errorMessage, xhr) {
  4251. failure({ message: errorMessage, xhr: xhr });
  4252. });
  4253. }
  4254. };
  4255. var JsonFeedEventSourcePlugin = createPlugin({
  4256. eventSourceDefs: [eventSourceDef$2]
  4257. });
  4258. function buildRequestParams(meta, range, calendar) {
  4259. var dateEnv = calendar.dateEnv;
  4260. var startParam;
  4261. var endParam;
  4262. var timeZoneParam;
  4263. var customRequestParams;
  4264. var params = {};
  4265. startParam = meta.startParam;
  4266. if (startParam == null) {
  4267. startParam = calendar.opt('startParam');
  4268. }
  4269. endParam = meta.endParam;
  4270. if (endParam == null) {
  4271. endParam = calendar.opt('endParam');
  4272. }
  4273. timeZoneParam = meta.timeZoneParam;
  4274. if (timeZoneParam == null) {
  4275. timeZoneParam = calendar.opt('timeZoneParam');
  4276. }
  4277. // retrieve any outbound GET/POST data from the options
  4278. if (typeof meta.extraParams === 'function') {
  4279. // supplied as a function that returns a key/value object
  4280. customRequestParams = meta.extraParams();
  4281. }
  4282. else {
  4283. // probably supplied as a straight key/value object
  4284. customRequestParams = meta.extraParams || {};
  4285. }
  4286. __assign(params, customRequestParams);
  4287. params[startParam] = dateEnv.formatIso(range.start);
  4288. params[endParam] = dateEnv.formatIso(range.end);
  4289. if (dateEnv.timeZone !== 'local') {
  4290. params[timeZoneParam] = dateEnv.timeZone;
  4291. }
  4292. return params;
  4293. }
  4294. var recurring = {
  4295. parse: function (rawEvent, leftoverProps, dateEnv) {
  4296. var createMarker = dateEnv.createMarker.bind(dateEnv);
  4297. var processors = {
  4298. daysOfWeek: null,
  4299. startTime: createDuration,
  4300. endTime: createDuration,
  4301. startRecur: createMarker,
  4302. endRecur: createMarker
  4303. };
  4304. var props = refineProps(rawEvent, processors, {}, leftoverProps);
  4305. var anyValid = false;
  4306. for (var propName in props) {
  4307. if (props[propName] != null) {
  4308. anyValid = true;
  4309. break;
  4310. }
  4311. }
  4312. if (anyValid) {
  4313. var duration = null;
  4314. if ('duration' in leftoverProps) {
  4315. duration = createDuration(leftoverProps.duration);
  4316. delete leftoverProps.duration;
  4317. }
  4318. if (!duration && props.startTime && props.endTime) {
  4319. duration = subtractDurations(props.endTime, props.startTime);
  4320. }
  4321. return {
  4322. allDayGuess: Boolean(!props.startTime && !props.endTime),
  4323. duration: duration,
  4324. typeData: props // doesn't need endTime anymore but oh well
  4325. };
  4326. }
  4327. return null;
  4328. },
  4329. expand: function (typeData, framingRange, dateEnv) {
  4330. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  4331. if (clippedFramingRange) {
  4332. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  4333. }
  4334. else {
  4335. return [];
  4336. }
  4337. }
  4338. };
  4339. var SimpleRecurrencePlugin = createPlugin({
  4340. recurringTypes: [recurring]
  4341. });
  4342. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  4343. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  4344. var dayMarker = startOfDay(framingRange.start);
  4345. var endMarker = framingRange.end;
  4346. var instanceStarts = [];
  4347. while (dayMarker < endMarker) {
  4348. var instanceStart
  4349. // if everyday, or this particular day-of-week
  4350. = void 0;
  4351. // if everyday, or this particular day-of-week
  4352. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  4353. if (startTime) {
  4354. instanceStart = dateEnv.add(dayMarker, startTime);
  4355. }
  4356. else {
  4357. instanceStart = dayMarker;
  4358. }
  4359. instanceStarts.push(instanceStart);
  4360. }
  4361. dayMarker = addDays(dayMarker, 1);
  4362. }
  4363. return instanceStarts;
  4364. }
  4365. var DefaultOptionChangeHandlers = createPlugin({
  4366. optionChangeHandlers: {
  4367. events: function (events, calendar, deepEqual) {
  4368. handleEventSources([events], calendar, deepEqual);
  4369. },
  4370. eventSources: handleEventSources,
  4371. plugins: handlePlugins
  4372. }
  4373. });
  4374. function handleEventSources(inputs, calendar, deepEqual) {
  4375. var unfoundSources = hashValuesToArray(calendar.state.eventSources);
  4376. var newInputs = [];
  4377. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  4378. var input = inputs_1[_i];
  4379. var inputFound = false;
  4380. for (var i = 0; i < unfoundSources.length; i++) {
  4381. if (deepEqual(unfoundSources[i]._raw, input)) {
  4382. unfoundSources.splice(i, 1); // delete
  4383. inputFound = true;
  4384. break;
  4385. }
  4386. }
  4387. if (!inputFound) {
  4388. newInputs.push(input);
  4389. }
  4390. }
  4391. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  4392. var unfoundSource = unfoundSources_1[_a];
  4393. calendar.dispatch({
  4394. type: 'REMOVE_EVENT_SOURCE',
  4395. sourceId: unfoundSource.sourceId
  4396. });
  4397. }
  4398. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  4399. var newInput = newInputs_1[_b];
  4400. calendar.addEventSource(newInput);
  4401. }
  4402. }
  4403. // shortcoming: won't remove plugins
  4404. function handlePlugins(inputs, calendar) {
  4405. calendar.addPluginInputs(inputs); // will gracefully handle duplicates
  4406. }
  4407. var config = {}; // TODO: make these options
  4408. var globalDefaults = {
  4409. defaultRangeSeparator: ' - ',
  4410. titleRangeSeparator: ' \u2013 ',
  4411. defaultTimedEventDuration: '01:00:00',
  4412. defaultAllDayEventDuration: { day: 1 },
  4413. forceEventDuration: false,
  4414. nextDayThreshold: '00:00:00',
  4415. // display
  4416. columnHeader: true,
  4417. defaultView: '',
  4418. aspectRatio: 1.35,
  4419. header: {
  4420. left: 'title',
  4421. center: '',
  4422. right: 'today prev,next'
  4423. },
  4424. weekends: true,
  4425. weekNumbers: false,
  4426. weekNumberCalculation: 'local',
  4427. editable: false,
  4428. // nowIndicator: false,
  4429. scrollTime: '06:00:00',
  4430. minTime: '00:00:00',
  4431. maxTime: '24:00:00',
  4432. showNonCurrentDates: true,
  4433. // event ajax
  4434. lazyFetching: true,
  4435. startParam: 'start',
  4436. endParam: 'end',
  4437. timeZoneParam: 'timeZone',
  4438. timeZone: 'local',
  4439. // allDayDefault: undefined,
  4440. // locale
  4441. locales: [],
  4442. locale: '',
  4443. // dir: will get this from the default locale
  4444. // buttonIcons: null,
  4445. // allows setting a min-height to the event segment to prevent short events overlapping each other
  4446. timeGridEventMinHeight: 0,
  4447. themeSystem: 'standard',
  4448. // eventResizableFromStart: false,
  4449. dragRevertDuration: 500,
  4450. dragScroll: true,
  4451. allDayMaintainDuration: false,
  4452. // selectable: false,
  4453. unselectAuto: true,
  4454. // selectMinDistance: 0,
  4455. dropAccept: '*',
  4456. eventOrder: 'start,-duration,allDay,title',
  4457. // ^ if start tie, longer events go before shorter. final tie-breaker is title text
  4458. // rerenderDelay: null,
  4459. eventLimit: false,
  4460. eventLimitClick: 'popover',
  4461. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  4462. handleWindowResize: true,
  4463. windowResizeDelay: 100,
  4464. longPressDelay: 1000,
  4465. eventDragMinDistance: 5 // only applies to mouse
  4466. };
  4467. var rtlDefaults = {
  4468. header: {
  4469. left: 'next,prev today',
  4470. center: '',
  4471. right: 'title'
  4472. },
  4473. buttonIcons: {
  4474. // TODO: make RTL support the responibility of the theme
  4475. prev: 'fc-icon-chevron-right',
  4476. next: 'fc-icon-chevron-left',
  4477. prevYear: 'fc-icon-chevrons-right',
  4478. nextYear: 'fc-icon-chevrons-left'
  4479. }
  4480. };
  4481. var complexOptions = [
  4482. 'header',
  4483. 'footer',
  4484. 'buttonText',
  4485. 'buttonIcons'
  4486. ];
  4487. // Merges an array of option objects into a single object
  4488. function mergeOptions(optionObjs) {
  4489. return mergeProps(optionObjs, complexOptions);
  4490. }
  4491. // TODO: move this stuff to a "plugin"-related file...
  4492. var INTERNAL_PLUGINS = [
  4493. ArrayEventSourcePlugin,
  4494. FuncEventSourcePlugin,
  4495. JsonFeedEventSourcePlugin,
  4496. SimpleRecurrencePlugin,
  4497. DefaultOptionChangeHandlers
  4498. ];
  4499. function refinePluginDefs(pluginInputs) {
  4500. var plugins = [];
  4501. for (var _i = 0, pluginInputs_1 = pluginInputs; _i < pluginInputs_1.length; _i++) {
  4502. var pluginInput = pluginInputs_1[_i];
  4503. if (typeof pluginInput === 'string') {
  4504. var globalName = 'FullCalendar' + capitaliseFirstLetter(pluginInput);
  4505. if (!window[globalName]) {
  4506. console.warn('Plugin file not loaded for ' + pluginInput);
  4507. }
  4508. else {
  4509. plugins.push(window[globalName].default); // is an ES6 module
  4510. }
  4511. }
  4512. else {
  4513. plugins.push(pluginInput);
  4514. }
  4515. }
  4516. return INTERNAL_PLUGINS.concat(plugins);
  4517. }
  4518. var RAW_EN_LOCALE = {
  4519. code: 'en',
  4520. week: {
  4521. dow: 0,
  4522. doy: 4 // 4 days need to be within the year to be considered the first week
  4523. },
  4524. dir: 'ltr',
  4525. buttonText: {
  4526. prev: 'prev',
  4527. next: 'next',
  4528. prevYear: 'prev year',
  4529. nextYear: 'next year',
  4530. year: 'year',
  4531. today: 'today',
  4532. month: 'month',
  4533. week: 'week',
  4534. day: 'day',
  4535. list: 'list'
  4536. },
  4537. weekLabel: 'W',
  4538. allDayText: 'all-day',
  4539. eventLimitText: 'more',
  4540. noEventsMessage: 'No events to display'
  4541. };
  4542. function parseRawLocales(explicitRawLocales) {
  4543. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4544. var globalArray = window['FullCalendarLocalesAll'] || []; // from locales-all.js
  4545. var globalObject = window['FullCalendarLocales'] || {}; // from locales/*.js. keys are meaningless
  4546. var allRawLocales = globalArray.concat(// globalArray is low prio
  4547. hashValuesToArray(globalObject), // medium prio
  4548. explicitRawLocales // highest prio
  4549. );
  4550. var rawLocaleMap = {
  4551. en: RAW_EN_LOCALE // necessary?
  4552. };
  4553. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4554. var rawLocale = allRawLocales_1[_i];
  4555. rawLocaleMap[rawLocale.code] = rawLocale;
  4556. }
  4557. return {
  4558. map: rawLocaleMap,
  4559. defaultCode: defaultCode
  4560. };
  4561. }
  4562. function buildLocale(inputSingular, available) {
  4563. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4564. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4565. }
  4566. else {
  4567. return queryLocale(inputSingular, available);
  4568. }
  4569. }
  4570. function queryLocale(codeArg, available) {
  4571. var codes = [].concat(codeArg || []); // will convert to array
  4572. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4573. return parseLocale(codeArg, codes, raw);
  4574. }
  4575. function queryRawLocale(codes, available) {
  4576. for (var i = 0; i < codes.length; i++) {
  4577. var parts = codes[i].toLocaleLowerCase().split('-');
  4578. for (var j = parts.length; j > 0; j--) {
  4579. var simpleId = parts.slice(0, j).join('-');
  4580. if (available[simpleId]) {
  4581. return available[simpleId];
  4582. }
  4583. }
  4584. }
  4585. return null;
  4586. }
  4587. function parseLocale(codeArg, codes, raw) {
  4588. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4589. delete merged.code; // don't want this part of the options
  4590. var week = merged.week;
  4591. delete merged.week;
  4592. return {
  4593. codeArg: codeArg,
  4594. codes: codes,
  4595. week: week,
  4596. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4597. options: merged
  4598. };
  4599. }
  4600. var OptionsManager = /** @class */ (function () {
  4601. function OptionsManager(overrides) {
  4602. this.overrides = __assign({}, overrides); // make a copy
  4603. this.dynamicOverrides = {};
  4604. this.compute();
  4605. }
  4606. OptionsManager.prototype.mutate = function (updates, removals, isDynamic) {
  4607. if (!Object.keys(updates).length && !removals.length) {
  4608. return;
  4609. }
  4610. var overrideHash = isDynamic ? this.dynamicOverrides : this.overrides;
  4611. __assign(overrideHash, updates);
  4612. for (var _i = 0, removals_1 = removals; _i < removals_1.length; _i++) {
  4613. var propName = removals_1[_i];
  4614. delete overrideHash[propName];
  4615. }
  4616. this.compute();
  4617. };
  4618. // Computes the flattened options hash for the calendar and assigns to `this.options`.
  4619. // Assumes this.overrides and this.dynamicOverrides have already been initialized.
  4620. OptionsManager.prototype.compute = function () {
  4621. // TODO: not a very efficient system
  4622. var locales = firstDefined(// explicit locale option given?
  4623. this.dynamicOverrides.locales, this.overrides.locales, globalDefaults.locales);
  4624. var locale = firstDefined(// explicit locales option given?
  4625. this.dynamicOverrides.locale, this.overrides.locale, globalDefaults.locale);
  4626. var available = parseRawLocales(locales);
  4627. var localeDefaults = buildLocale(locale || available.defaultCode, available.map).options;
  4628. var dir = firstDefined(// based on options computed so far, is direction RTL?
  4629. this.dynamicOverrides.dir, this.overrides.dir, localeDefaults.dir);
  4630. var dirDefaults = dir === 'rtl' ? rtlDefaults : {};
  4631. this.dirDefaults = dirDefaults;
  4632. this.localeDefaults = localeDefaults;
  4633. this.computed = mergeOptions([
  4634. globalDefaults,
  4635. dirDefaults,
  4636. localeDefaults,
  4637. this.overrides,
  4638. this.dynamicOverrides
  4639. ]);
  4640. };
  4641. return OptionsManager;
  4642. }());
  4643. var calendarSystemClassMap = {};
  4644. function registerCalendarSystem(name, theClass) {
  4645. calendarSystemClassMap[name] = theClass;
  4646. }
  4647. function createCalendarSystem(name) {
  4648. return new calendarSystemClassMap[name]();
  4649. }
  4650. var GregorianCalendarSystem = /** @class */ (function () {
  4651. function GregorianCalendarSystem() {
  4652. }
  4653. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  4654. return d.getUTCFullYear();
  4655. };
  4656. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  4657. return d.getUTCMonth();
  4658. };
  4659. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  4660. return d.getUTCDate();
  4661. };
  4662. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  4663. return arrayToUtcDate(arr);
  4664. };
  4665. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  4666. return dateToUtcArray(marker);
  4667. };
  4668. return GregorianCalendarSystem;
  4669. }());
  4670. registerCalendarSystem('gregory', GregorianCalendarSystem);
  4671. var ISO_RE = /^\s*(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  4672. function parse(str) {
  4673. var m = ISO_RE.exec(str);
  4674. if (m) {
  4675. 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));
  4676. if (isValidDate(marker)) {
  4677. var timeZoneOffset = null;
  4678. if (m[13]) {
  4679. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  4680. Number(m[18] || 0));
  4681. }
  4682. return {
  4683. marker: marker,
  4684. isTimeUnspecified: !m[6],
  4685. timeZoneOffset: timeZoneOffset
  4686. };
  4687. }
  4688. }
  4689. return null;
  4690. }
  4691. var DateEnv = /** @class */ (function () {
  4692. function DateEnv(settings) {
  4693. var timeZone = this.timeZone = settings.timeZone;
  4694. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  4695. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  4696. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  4697. }
  4698. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  4699. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  4700. this.locale = settings.locale;
  4701. this.weekDow = settings.locale.week.dow;
  4702. this.weekDoy = settings.locale.week.doy;
  4703. if (settings.weekNumberCalculation === 'ISO') {
  4704. this.weekDow = 1;
  4705. this.weekDoy = 4;
  4706. }
  4707. if (typeof settings.firstDay === 'number') {
  4708. this.weekDow = settings.firstDay;
  4709. }
  4710. if (typeof settings.weekNumberCalculation === 'function') {
  4711. this.weekNumberFunc = settings.weekNumberCalculation;
  4712. }
  4713. this.weekLabel = settings.weekLabel != null ? settings.weekLabel : settings.locale.options.weekLabel;
  4714. this.cmdFormatter = settings.cmdFormatter;
  4715. }
  4716. // Creating / Parsing
  4717. DateEnv.prototype.createMarker = function (input) {
  4718. var meta = this.createMarkerMeta(input);
  4719. if (meta === null) {
  4720. return null;
  4721. }
  4722. return meta.marker;
  4723. };
  4724. DateEnv.prototype.createNowMarker = function () {
  4725. if (this.canComputeOffset) {
  4726. return this.timestampToMarker(new Date().valueOf());
  4727. }
  4728. else {
  4729. // if we can't compute the current date val for a timezone,
  4730. // better to give the current local date vals than UTC
  4731. return arrayToUtcDate(dateToLocalArray(new Date()));
  4732. }
  4733. };
  4734. DateEnv.prototype.createMarkerMeta = function (input) {
  4735. if (typeof input === 'string') {
  4736. return this.parse(input);
  4737. }
  4738. var marker = null;
  4739. if (typeof input === 'number') {
  4740. marker = this.timestampToMarker(input);
  4741. }
  4742. else if (input instanceof Date) {
  4743. input = input.valueOf();
  4744. if (!isNaN(input)) {
  4745. marker = this.timestampToMarker(input);
  4746. }
  4747. }
  4748. else if (Array.isArray(input)) {
  4749. marker = arrayToUtcDate(input);
  4750. }
  4751. if (marker === null || !isValidDate(marker)) {
  4752. return null;
  4753. }
  4754. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  4755. };
  4756. DateEnv.prototype.parse = function (s) {
  4757. var parts = parse(s);
  4758. if (parts === null) {
  4759. return null;
  4760. }
  4761. var marker = parts.marker;
  4762. var forcedTzo = null;
  4763. if (parts.timeZoneOffset !== null) {
  4764. if (this.canComputeOffset) {
  4765. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  4766. }
  4767. else {
  4768. forcedTzo = parts.timeZoneOffset;
  4769. }
  4770. }
  4771. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  4772. };
  4773. // Accessors
  4774. DateEnv.prototype.getYear = function (marker) {
  4775. return this.calendarSystem.getMarkerYear(marker);
  4776. };
  4777. DateEnv.prototype.getMonth = function (marker) {
  4778. return this.calendarSystem.getMarkerMonth(marker);
  4779. };
  4780. // Adding / Subtracting
  4781. DateEnv.prototype.add = function (marker, dur) {
  4782. var a = this.calendarSystem.markerToArray(marker);
  4783. a[0] += dur.years;
  4784. a[1] += dur.months;
  4785. a[2] += dur.days;
  4786. a[6] += dur.milliseconds;
  4787. return this.calendarSystem.arrayToMarker(a);
  4788. };
  4789. DateEnv.prototype.subtract = function (marker, dur) {
  4790. var a = this.calendarSystem.markerToArray(marker);
  4791. a[0] -= dur.years;
  4792. a[1] -= dur.months;
  4793. a[2] -= dur.days;
  4794. a[6] -= dur.milliseconds;
  4795. return this.calendarSystem.arrayToMarker(a);
  4796. };
  4797. DateEnv.prototype.addYears = function (marker, n) {
  4798. var a = this.calendarSystem.markerToArray(marker);
  4799. a[0] += n;
  4800. return this.calendarSystem.arrayToMarker(a);
  4801. };
  4802. DateEnv.prototype.addMonths = function (marker, n) {
  4803. var a = this.calendarSystem.markerToArray(marker);
  4804. a[1] += n;
  4805. return this.calendarSystem.arrayToMarker(a);
  4806. };
  4807. // Diffing Whole Units
  4808. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  4809. var calendarSystem = this.calendarSystem;
  4810. if (timeAsMs(m0) === timeAsMs(m1) &&
  4811. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  4812. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  4813. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  4814. }
  4815. return null;
  4816. };
  4817. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  4818. var calendarSystem = this.calendarSystem;
  4819. if (timeAsMs(m0) === timeAsMs(m1) &&
  4820. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  4821. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  4822. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  4823. }
  4824. return null;
  4825. };
  4826. // Range / Duration
  4827. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  4828. var n = this.diffWholeYears(m0, m1);
  4829. if (n !== null) {
  4830. return { unit: 'year', value: n };
  4831. }
  4832. n = this.diffWholeMonths(m0, m1);
  4833. if (n !== null) {
  4834. return { unit: 'month', value: n };
  4835. }
  4836. n = diffWholeWeeks(m0, m1);
  4837. if (n !== null) {
  4838. return { unit: 'week', value: n };
  4839. }
  4840. n = diffWholeDays(m0, m1);
  4841. if (n !== null) {
  4842. return { unit: 'day', value: n };
  4843. }
  4844. n = diffHours(m0, m1);
  4845. if (isInt(n)) {
  4846. return { unit: 'hour', value: n };
  4847. }
  4848. n = diffMinutes(m0, m1);
  4849. if (isInt(n)) {
  4850. return { unit: 'minute', value: n };
  4851. }
  4852. n = diffSeconds(m0, m1);
  4853. if (isInt(n)) {
  4854. return { unit: 'second', value: n };
  4855. }
  4856. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  4857. };
  4858. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  4859. // TODO: can use greatestWholeUnit
  4860. var diff;
  4861. if (d.years) {
  4862. diff = this.diffWholeYears(m0, m1);
  4863. if (diff !== null) {
  4864. return diff / asRoughYears(d);
  4865. }
  4866. }
  4867. if (d.months) {
  4868. diff = this.diffWholeMonths(m0, m1);
  4869. if (diff !== null) {
  4870. return diff / asRoughMonths(d);
  4871. }
  4872. }
  4873. if (d.days) {
  4874. diff = diffWholeDays(m0, m1);
  4875. if (diff !== null) {
  4876. return diff / asRoughDays(d);
  4877. }
  4878. }
  4879. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  4880. };
  4881. // Start-Of
  4882. DateEnv.prototype.startOf = function (m, unit) {
  4883. if (unit === 'year') {
  4884. return this.startOfYear(m);
  4885. }
  4886. else if (unit === 'month') {
  4887. return this.startOfMonth(m);
  4888. }
  4889. else if (unit === 'week') {
  4890. return this.startOfWeek(m);
  4891. }
  4892. else if (unit === 'day') {
  4893. return startOfDay(m);
  4894. }
  4895. else if (unit === 'hour') {
  4896. return startOfHour(m);
  4897. }
  4898. else if (unit === 'minute') {
  4899. return startOfMinute(m);
  4900. }
  4901. else if (unit === 'second') {
  4902. return startOfSecond(m);
  4903. }
  4904. };
  4905. DateEnv.prototype.startOfYear = function (m) {
  4906. return this.calendarSystem.arrayToMarker([
  4907. this.calendarSystem.getMarkerYear(m)
  4908. ]);
  4909. };
  4910. DateEnv.prototype.startOfMonth = function (m) {
  4911. return this.calendarSystem.arrayToMarker([
  4912. this.calendarSystem.getMarkerYear(m),
  4913. this.calendarSystem.getMarkerMonth(m)
  4914. ]);
  4915. };
  4916. DateEnv.prototype.startOfWeek = function (m) {
  4917. return this.calendarSystem.arrayToMarker([
  4918. this.calendarSystem.getMarkerYear(m),
  4919. this.calendarSystem.getMarkerMonth(m),
  4920. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7)
  4921. ]);
  4922. };
  4923. // Week Number
  4924. DateEnv.prototype.computeWeekNumber = function (marker) {
  4925. if (this.weekNumberFunc) {
  4926. return this.weekNumberFunc(this.toDate(marker));
  4927. }
  4928. else {
  4929. return weekOfYear(marker, this.weekDow, this.weekDoy);
  4930. }
  4931. };
  4932. // TODO: choke on timeZoneName: long
  4933. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  4934. if (dateOptions === void 0) { dateOptions = {}; }
  4935. return formatter.format({
  4936. marker: marker,
  4937. timeZoneOffset: dateOptions.forcedTzo != null ?
  4938. dateOptions.forcedTzo :
  4939. this.offsetForMarker(marker)
  4940. }, this);
  4941. };
  4942. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  4943. if (dateOptions === void 0) { dateOptions = {}; }
  4944. if (dateOptions.isEndExclusive) {
  4945. end = addMs(end, -1);
  4946. }
  4947. return formatter.formatRange({
  4948. marker: start,
  4949. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  4950. dateOptions.forcedStartTzo :
  4951. this.offsetForMarker(start)
  4952. }, {
  4953. marker: end,
  4954. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4955. dateOptions.forcedEndTzo :
  4956. this.offsetForMarker(end)
  4957. }, this);
  4958. };
  4959. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4960. if (extraOptions === void 0) { extraOptions = {}; }
  4961. var timeZoneOffset = null;
  4962. if (!extraOptions.omitTimeZoneOffset) {
  4963. if (extraOptions.forcedTzo != null) {
  4964. timeZoneOffset = extraOptions.forcedTzo;
  4965. }
  4966. else {
  4967. timeZoneOffset = this.offsetForMarker(marker);
  4968. }
  4969. }
  4970. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4971. };
  4972. // TimeZone
  4973. DateEnv.prototype.timestampToMarker = function (ms) {
  4974. if (this.timeZone === 'local') {
  4975. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4976. }
  4977. else if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4978. return new Date(ms);
  4979. }
  4980. else {
  4981. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4982. }
  4983. };
  4984. DateEnv.prototype.offsetForMarker = function (m) {
  4985. if (this.timeZone === 'local') {
  4986. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4987. }
  4988. else if (this.timeZone === 'UTC') {
  4989. return 0;
  4990. }
  4991. else if (this.namedTimeZoneImpl) {
  4992. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4993. }
  4994. return null;
  4995. };
  4996. // Conversion
  4997. DateEnv.prototype.toDate = function (m, forcedTzo) {
  4998. if (this.timeZone === 'local') {
  4999. return arrayToLocalDate(dateToUtcArray(m));
  5000. }
  5001. else if (this.timeZone === 'UTC') {
  5002. return new Date(m.valueOf()); // make sure it's a copy
  5003. }
  5004. else if (!this.namedTimeZoneImpl) {
  5005. return new Date(m.valueOf() - (forcedTzo || 0));
  5006. }
  5007. else {
  5008. return new Date(m.valueOf() -
  5009. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60 // convert minutes -> ms
  5010. );
  5011. }
  5012. };
  5013. return DateEnv;
  5014. }());
  5015. var SIMPLE_SOURCE_PROPS = {
  5016. id: String,
  5017. allDayDefault: Boolean,
  5018. eventDataTransform: Function,
  5019. success: Function,
  5020. failure: Function
  5021. };
  5022. var uid$2 = 0;
  5023. function doesSourceNeedRange(eventSource, calendar) {
  5024. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5025. return !defs[eventSource.sourceDefId].ignoreRange;
  5026. }
  5027. function parseEventSource(raw, calendar) {
  5028. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5029. for (var i = defs.length - 1; i >= 0; i--) { // later-added plugins take precedence
  5030. var def = defs[i];
  5031. var meta = def.parseMeta(raw);
  5032. if (meta) {
  5033. var res = parseEventSourceProps(typeof raw === 'object' ? raw : {}, meta, i, calendar);
  5034. res._raw = raw;
  5035. return res;
  5036. }
  5037. }
  5038. return null;
  5039. }
  5040. function parseEventSourceProps(raw, meta, sourceDefId, calendar) {
  5041. var leftovers0 = {};
  5042. var props = refineProps(raw, SIMPLE_SOURCE_PROPS, {}, leftovers0);
  5043. var leftovers1 = {};
  5044. var ui = processUnscopedUiProps(leftovers0, calendar, leftovers1);
  5045. props.isFetching = false;
  5046. props.latestFetchId = '';
  5047. props.fetchRange = null;
  5048. props.publicId = String(raw.id || '');
  5049. props.sourceId = String(uid$2++);
  5050. props.sourceDefId = sourceDefId;
  5051. props.meta = meta;
  5052. props.ui = ui;
  5053. props.extendedProps = leftovers1;
  5054. return props;
  5055. }
  5056. function reduceEventSources (eventSources, action, dateProfile, calendar) {
  5057. switch (action.type) {
  5058. case 'ADD_EVENT_SOURCES': // already parsed
  5059. return addSources(eventSources, action.sources, dateProfile ? dateProfile.activeRange : null, calendar);
  5060. case 'REMOVE_EVENT_SOURCE':
  5061. return removeSource(eventSources, action.sourceId);
  5062. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  5063. case 'NEXT':
  5064. case 'SET_DATE':
  5065. case 'SET_VIEW_TYPE':
  5066. if (dateProfile) {
  5067. return fetchDirtySources(eventSources, dateProfile.activeRange, calendar);
  5068. }
  5069. else {
  5070. return eventSources;
  5071. }
  5072. case 'FETCH_EVENT_SOURCES':
  5073. case 'CHANGE_TIMEZONE':
  5074. return fetchSourcesByIds(eventSources, action.sourceIds ?
  5075. arrayToHash(action.sourceIds) :
  5076. excludeStaticSources(eventSources, calendar), dateProfile ? dateProfile.activeRange : null, calendar);
  5077. case 'RECEIVE_EVENTS':
  5078. case 'RECEIVE_EVENT_ERROR':
  5079. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  5080. case 'REMOVE_ALL_EVENT_SOURCES':
  5081. return {};
  5082. default:
  5083. return eventSources;
  5084. }
  5085. }
  5086. var uid$3 = 0;
  5087. function addSources(eventSourceHash, sources, fetchRange, calendar) {
  5088. var hash = {};
  5089. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  5090. var source = sources_1[_i];
  5091. hash[source.sourceId] = source;
  5092. }
  5093. if (fetchRange) {
  5094. hash = fetchDirtySources(hash, fetchRange, calendar);
  5095. }
  5096. return __assign({}, eventSourceHash, hash);
  5097. }
  5098. function removeSource(eventSourceHash, sourceId) {
  5099. return filterHash(eventSourceHash, function (eventSource) {
  5100. return eventSource.sourceId !== sourceId;
  5101. });
  5102. }
  5103. function fetchDirtySources(sourceHash, fetchRange, calendar) {
  5104. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) {
  5105. return isSourceDirty(eventSource, fetchRange, calendar);
  5106. }), fetchRange, calendar);
  5107. }
  5108. function isSourceDirty(eventSource, fetchRange, calendar) {
  5109. if (!doesSourceNeedRange(eventSource, calendar)) {
  5110. return !eventSource.latestFetchId;
  5111. }
  5112. else {
  5113. return !calendar.opt('lazyFetching') ||
  5114. !eventSource.fetchRange ||
  5115. eventSource.isFetching || // always cancel outdated in-progress fetches
  5116. fetchRange.start < eventSource.fetchRange.start ||
  5117. fetchRange.end > eventSource.fetchRange.end;
  5118. }
  5119. }
  5120. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, calendar) {
  5121. var nextSources = {};
  5122. for (var sourceId in prevSources) {
  5123. var source = prevSources[sourceId];
  5124. if (sourceIdHash[sourceId]) {
  5125. nextSources[sourceId] = fetchSource(source, fetchRange, calendar);
  5126. }
  5127. else {
  5128. nextSources[sourceId] = source;
  5129. }
  5130. }
  5131. return nextSources;
  5132. }
  5133. function fetchSource(eventSource, fetchRange, calendar) {
  5134. var sourceDef = calendar.pluginSystem.hooks.eventSourceDefs[eventSource.sourceDefId];
  5135. var fetchId = String(uid$3++);
  5136. sourceDef.fetch({
  5137. eventSource: eventSource,
  5138. calendar: calendar,
  5139. range: fetchRange
  5140. }, function (res) {
  5141. var rawEvents = res.rawEvents;
  5142. var calSuccess = calendar.opt('eventSourceSuccess');
  5143. var calSuccessRes;
  5144. var sourceSuccessRes;
  5145. if (eventSource.success) {
  5146. sourceSuccessRes = eventSource.success(rawEvents, res.xhr);
  5147. }
  5148. if (calSuccess) {
  5149. calSuccessRes = calSuccess(rawEvents, res.xhr);
  5150. }
  5151. rawEvents = sourceSuccessRes || calSuccessRes || rawEvents;
  5152. calendar.dispatch({
  5153. type: 'RECEIVE_EVENTS',
  5154. sourceId: eventSource.sourceId,
  5155. fetchId: fetchId,
  5156. fetchRange: fetchRange,
  5157. rawEvents: rawEvents
  5158. });
  5159. }, function (error) {
  5160. var callFailure = calendar.opt('eventSourceFailure');
  5161. console.warn(error.message, error);
  5162. if (eventSource.failure) {
  5163. eventSource.failure(error);
  5164. }
  5165. if (callFailure) {
  5166. callFailure(error);
  5167. }
  5168. calendar.dispatch({
  5169. type: 'RECEIVE_EVENT_ERROR',
  5170. sourceId: eventSource.sourceId,
  5171. fetchId: fetchId,
  5172. fetchRange: fetchRange,
  5173. error: error
  5174. });
  5175. });
  5176. return __assign({}, eventSource, { isFetching: true, latestFetchId: fetchId });
  5177. }
  5178. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  5179. var _a;
  5180. var eventSource = sourceHash[sourceId];
  5181. if (eventSource && // not already removed
  5182. fetchId === eventSource.latestFetchId) {
  5183. return __assign({}, sourceHash, (_a = {}, _a[sourceId] = __assign({}, eventSource, { isFetching: false, fetchRange: fetchRange // also serves as a marker that at least one fetch has completed
  5184. }), _a));
  5185. }
  5186. return sourceHash;
  5187. }
  5188. function excludeStaticSources(eventSources, calendar) {
  5189. return filterHash(eventSources, function (eventSource) {
  5190. return doesSourceNeedRange(eventSource, calendar);
  5191. });
  5192. }
  5193. var DateProfileGenerator = /** @class */ (function () {
  5194. function DateProfileGenerator(viewSpec, calendar) {
  5195. this.viewSpec = viewSpec;
  5196. this.options = viewSpec.options;
  5197. this.dateEnv = calendar.dateEnv;
  5198. this.calendar = calendar;
  5199. this.initHiddenDays();
  5200. }
  5201. /* Date Range Computation
  5202. ------------------------------------------------------------------------------------------------------------------*/
  5203. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5204. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate) {
  5205. var dateEnv = this.dateEnv;
  5206. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5207. currentDateProfile.dateIncrement);
  5208. return this.build(prevDate, -1);
  5209. };
  5210. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5211. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate) {
  5212. var dateEnv = this.dateEnv;
  5213. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5214. currentDateProfile.dateIncrement);
  5215. return this.build(nextDate, 1);
  5216. };
  5217. // Builds a structure holding dates/ranges for rendering around the given date.
  5218. // Optional direction param indicates whether the date is being incremented/decremented
  5219. // from its previous value. decremented = -1, incremented = 1 (default).
  5220. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5221. if (forceToValid === void 0) { forceToValid = false; }
  5222. var validRange;
  5223. var minTime = null;
  5224. var maxTime = null;
  5225. var currentInfo;
  5226. var isRangeAllDay;
  5227. var renderRange;
  5228. var activeRange;
  5229. var isValid;
  5230. validRange = this.buildValidRange();
  5231. validRange = this.trimHiddenDays(validRange);
  5232. if (forceToValid) {
  5233. currentDate = constrainMarkerToRange(currentDate, validRange);
  5234. }
  5235. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5236. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5237. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5238. renderRange = this.trimHiddenDays(renderRange);
  5239. activeRange = renderRange;
  5240. if (!this.options.showNonCurrentDates) {
  5241. activeRange = intersectRanges(activeRange, currentInfo.range);
  5242. }
  5243. minTime = createDuration(this.options.minTime);
  5244. maxTime = createDuration(this.options.maxTime);
  5245. activeRange = this.adjustActiveRange(activeRange, minTime, maxTime);
  5246. activeRange = intersectRanges(activeRange, validRange); // might return null
  5247. // it's invalid if the originally requested date is not contained,
  5248. // or if the range is completely outside of the valid range.
  5249. isValid = rangesIntersect(currentInfo.range, validRange);
  5250. return {
  5251. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5252. // an object with optional start and end properties.
  5253. validRange: validRange,
  5254. // range the view is formally responsible for.
  5255. // for example, a month view might have 1st-31st, excluding padded dates
  5256. currentRange: currentInfo.range,
  5257. // name of largest unit being displayed, like "month" or "week"
  5258. currentRangeUnit: currentInfo.unit,
  5259. isRangeAllDay: isRangeAllDay,
  5260. // dates that display events and accept drag-n-drop
  5261. // will be `null` if no dates accept events
  5262. activeRange: activeRange,
  5263. // date range with a rendered skeleton
  5264. // includes not-active days that need some sort of DOM
  5265. renderRange: renderRange,
  5266. // Duration object that denotes the first visible time of any given day
  5267. minTime: minTime,
  5268. // Duration object that denotes the exclusive visible end time of any given day
  5269. maxTime: maxTime,
  5270. isValid: isValid,
  5271. // how far the current date will move for a prev/next operation
  5272. dateIncrement: this.buildDateIncrement(currentInfo.duration)
  5273. // pass a fallback (might be null) ^
  5274. };
  5275. };
  5276. // Builds an object with optional start/end properties.
  5277. // Indicates the minimum/maximum dates to display.
  5278. // not responsible for trimming hidden days.
  5279. DateProfileGenerator.prototype.buildValidRange = function () {
  5280. return this.getRangeOption('validRange', this.calendar.getNow()) ||
  5281. { start: null, end: null }; // completely open-ended
  5282. };
  5283. // Builds a structure with info about the "current" range, the range that is
  5284. // highlighted as being the current month for example.
  5285. // See build() for a description of `direction`.
  5286. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5287. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5288. var _a = this, viewSpec = _a.viewSpec, dateEnv = _a.dateEnv;
  5289. var duration = null;
  5290. var unit = null;
  5291. var range = null;
  5292. var dayCount;
  5293. if (viewSpec.duration) {
  5294. duration = viewSpec.duration;
  5295. unit = viewSpec.durationUnit;
  5296. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5297. }
  5298. else if ((dayCount = this.options.dayCount)) {
  5299. unit = 'day';
  5300. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5301. }
  5302. else if ((range = this.buildCustomVisibleRange(date))) {
  5303. unit = dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5304. }
  5305. else {
  5306. duration = this.getFallbackDuration();
  5307. unit = greatestDurationDenominator(duration).unit;
  5308. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5309. }
  5310. return { duration: duration, unit: unit, range: range };
  5311. };
  5312. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5313. return createDuration({ day: 1 });
  5314. };
  5315. // Returns a new activeRange to have time values (un-ambiguate)
  5316. // minTime or maxTime causes the range to expand.
  5317. DateProfileGenerator.prototype.adjustActiveRange = function (range, minTime, maxTime) {
  5318. var dateEnv = this.dateEnv;
  5319. var start = range.start;
  5320. var end = range.end;
  5321. if (this.viewSpec.class.prototype.usesMinMaxTime) {
  5322. // expand active range if minTime is negative (why not when positive?)
  5323. if (asRoughDays(minTime) < 0) {
  5324. start = startOfDay(start); // necessary?
  5325. start = dateEnv.add(start, minTime);
  5326. }
  5327. // expand active range if maxTime is beyond one day (why not when positive?)
  5328. if (asRoughDays(maxTime) > 1) {
  5329. end = startOfDay(end); // necessary?
  5330. end = addDays(end, -1);
  5331. end = dateEnv.add(end, maxTime);
  5332. }
  5333. }
  5334. return { start: start, end: end };
  5335. };
  5336. // Builds the "current" range when it is specified as an explicit duration.
  5337. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5338. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5339. var dateEnv = this.dateEnv;
  5340. var alignment = this.options.dateAlignment;
  5341. var dateIncrementInput;
  5342. var dateIncrementDuration;
  5343. var start;
  5344. var end;
  5345. var res;
  5346. // compute what the alignment should be
  5347. if (!alignment) {
  5348. dateIncrementInput = this.options.dateIncrement;
  5349. if (dateIncrementInput) {
  5350. dateIncrementDuration = createDuration(dateIncrementInput);
  5351. // use the smaller of the two units
  5352. if (asRoughMs(dateIncrementDuration) < asRoughMs(duration)) {
  5353. alignment = greatestDurationDenominator(dateIncrementDuration, !getWeeksFromInput(dateIncrementInput)).unit;
  5354. }
  5355. else {
  5356. alignment = unit;
  5357. }
  5358. }
  5359. else {
  5360. alignment = unit;
  5361. }
  5362. }
  5363. // if the view displays a single day or smaller
  5364. if (asRoughDays(duration) <= 1) {
  5365. if (this.isHiddenDay(start)) {
  5366. start = this.skipHiddenDays(start, direction);
  5367. start = startOfDay(start);
  5368. }
  5369. }
  5370. function computeRes() {
  5371. start = dateEnv.startOf(date, alignment);
  5372. end = dateEnv.add(start, duration);
  5373. res = { start: start, end: end };
  5374. }
  5375. computeRes();
  5376. // if range is completely enveloped by hidden days, go past the hidden days
  5377. if (!this.trimHiddenDays(res)) {
  5378. date = this.skipHiddenDays(date, direction);
  5379. computeRes();
  5380. }
  5381. return res;
  5382. };
  5383. // Builds the "current" range when a dayCount is specified.
  5384. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5385. var dateEnv = this.dateEnv;
  5386. var customAlignment = this.options.dateAlignment;
  5387. var runningCount = 0;
  5388. var start = date;
  5389. var end;
  5390. if (customAlignment) {
  5391. start = dateEnv.startOf(start, customAlignment);
  5392. }
  5393. start = startOfDay(start);
  5394. start = this.skipHiddenDays(start, direction);
  5395. end = start;
  5396. do {
  5397. end = addDays(end, 1);
  5398. if (!this.isHiddenDay(end)) {
  5399. runningCount++;
  5400. }
  5401. } while (runningCount < dayCount);
  5402. return { start: start, end: end };
  5403. };
  5404. // Builds a normalized range object for the "visible" range,
  5405. // which is a way to define the currentRange and activeRange at the same time.
  5406. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  5407. var dateEnv = this.dateEnv;
  5408. var visibleRange = this.getRangeOption('visibleRange', dateEnv.toDate(date));
  5409. if (visibleRange && (visibleRange.start == null || visibleRange.end == null)) {
  5410. return null;
  5411. }
  5412. return visibleRange;
  5413. };
  5414. // Computes the range that will represent the element/cells for *rendering*,
  5415. // but which may have voided days/times.
  5416. // not responsible for trimming hidden days.
  5417. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  5418. return currentRange;
  5419. };
  5420. // Compute the duration value that should be added/substracted to the current date
  5421. // when a prev/next operation happens.
  5422. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  5423. var dateIncrementInput = this.options.dateIncrement;
  5424. var customAlignment;
  5425. if (dateIncrementInput) {
  5426. return createDuration(dateIncrementInput);
  5427. }
  5428. else if ((customAlignment = this.options.dateAlignment)) {
  5429. return createDuration(1, customAlignment);
  5430. }
  5431. else if (fallback) {
  5432. return fallback;
  5433. }
  5434. else {
  5435. return createDuration({ days: 1 });
  5436. }
  5437. };
  5438. // Arguments after name will be forwarded to a hypothetical function value
  5439. // WARNING: passed-in arguments will be given to generator functions as-is and can cause side-effects.
  5440. // Always clone your objects if you fear mutation.
  5441. DateProfileGenerator.prototype.getRangeOption = function (name) {
  5442. var otherArgs = [];
  5443. for (var _i = 1; _i < arguments.length; _i++) {
  5444. otherArgs[_i - 1] = arguments[_i];
  5445. }
  5446. var val = this.options[name];
  5447. if (typeof val === 'function') {
  5448. val = val.apply(null, otherArgs);
  5449. }
  5450. if (val) {
  5451. val = parseRange(val, this.dateEnv);
  5452. }
  5453. if (val) {
  5454. val = computeVisibleDayRange(val);
  5455. }
  5456. return val;
  5457. };
  5458. /* Hidden Days
  5459. ------------------------------------------------------------------------------------------------------------------*/
  5460. // Initializes internal variables related to calculating hidden days-of-week
  5461. DateProfileGenerator.prototype.initHiddenDays = function () {
  5462. var hiddenDays = this.options.hiddenDays || []; // array of day-of-week indices that are hidden
  5463. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  5464. var dayCnt = 0;
  5465. var i;
  5466. if (this.options.weekends === false) {
  5467. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  5468. }
  5469. for (i = 0; i < 7; i++) {
  5470. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  5471. dayCnt++;
  5472. }
  5473. }
  5474. if (!dayCnt) {
  5475. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  5476. }
  5477. this.isHiddenDayHash = isHiddenDayHash;
  5478. };
  5479. // Remove days from the beginning and end of the range that are computed as hidden.
  5480. // If the whole range is trimmed off, returns null
  5481. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  5482. var start = range.start;
  5483. var end = range.end;
  5484. if (start) {
  5485. start = this.skipHiddenDays(start);
  5486. }
  5487. if (end) {
  5488. end = this.skipHiddenDays(end, -1, true);
  5489. }
  5490. if (start == null || end == null || start < end) {
  5491. return { start: start, end: end };
  5492. }
  5493. return null;
  5494. };
  5495. // Is the current day hidden?
  5496. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  5497. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  5498. if (day instanceof Date) {
  5499. day = day.getUTCDay();
  5500. }
  5501. return this.isHiddenDayHash[day];
  5502. };
  5503. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  5504. // DOES NOT CONSIDER validRange!
  5505. // If the initial value of `date` is not a hidden day, don't do anything.
  5506. // Pass `isExclusive` as `true` if you are dealing with an end date.
  5507. // `inc` defaults to `1` (increment one day forward each time)
  5508. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  5509. if (inc === void 0) { inc = 1; }
  5510. if (isExclusive === void 0) { isExclusive = false; }
  5511. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  5512. date = addDays(date, inc);
  5513. }
  5514. return date;
  5515. };
  5516. return DateProfileGenerator;
  5517. }());
  5518. // TODO: find a way to avoid comparing DateProfiles. it's tedious
  5519. function isDateProfilesEqual(p0, p1) {
  5520. return rangesEqual(p0.validRange, p1.validRange) &&
  5521. rangesEqual(p0.activeRange, p1.activeRange) &&
  5522. rangesEqual(p0.renderRange, p1.renderRange) &&
  5523. durationsEqual(p0.minTime, p1.minTime) &&
  5524. durationsEqual(p0.maxTime, p1.maxTime);
  5525. /*
  5526. TODO: compare more?
  5527. currentRange: DateRange
  5528. currentRangeUnit: string
  5529. isRangeAllDay: boolean
  5530. isValid: boolean
  5531. dateIncrement: Duration
  5532. */
  5533. }
  5534. function reduce (state, action, calendar) {
  5535. var viewType = reduceViewType(state.viewType, action);
  5536. var dateProfile = reduceDateProfile(state.dateProfile, action, state.currentDate, viewType, calendar);
  5537. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendar);
  5538. var nextState = __assign({}, state, { viewType: viewType,
  5539. 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) });
  5540. for (var _i = 0, _a = calendar.pluginSystem.hooks.reducers; _i < _a.length; _i++) {
  5541. var reducerFunc = _a[_i];
  5542. nextState = reducerFunc(nextState, action, calendar);
  5543. }
  5544. // console.log(action.type, nextState)
  5545. return nextState;
  5546. }
  5547. function reduceViewType(currentViewType, action) {
  5548. switch (action.type) {
  5549. case 'SET_VIEW_TYPE':
  5550. return action.viewType;
  5551. default:
  5552. return currentViewType;
  5553. }
  5554. }
  5555. function reduceDateProfile(currentDateProfile, action, currentDate, viewType, calendar) {
  5556. var newDateProfile;
  5557. switch (action.type) {
  5558. case 'PREV':
  5559. newDateProfile = calendar.dateProfileGenerators[viewType].buildPrev(currentDateProfile, currentDate);
  5560. break;
  5561. case 'NEXT':
  5562. newDateProfile = calendar.dateProfileGenerators[viewType].buildNext(currentDateProfile, currentDate);
  5563. break;
  5564. case 'SET_DATE':
  5565. if (!currentDateProfile.activeRange ||
  5566. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker)) {
  5567. newDateProfile = calendar.dateProfileGenerators[viewType].build(action.dateMarker, undefined, true // forceToValid
  5568. );
  5569. }
  5570. break;
  5571. case 'SET_VIEW_TYPE':
  5572. var generator = calendar.dateProfileGenerators[viewType];
  5573. if (!generator) {
  5574. throw new Error(viewType ?
  5575. 'The FullCalendar view "' + viewType + '" does not exist. Make sure your plugins are loaded correctly.' :
  5576. 'No available FullCalendar view plugins.');
  5577. }
  5578. newDateProfile = generator.build(action.dateMarker || currentDate, undefined, true // forceToValid
  5579. );
  5580. break;
  5581. }
  5582. if (newDateProfile &&
  5583. newDateProfile.isValid &&
  5584. !(currentDateProfile && isDateProfilesEqual(currentDateProfile, newDateProfile))) {
  5585. return newDateProfile;
  5586. }
  5587. else {
  5588. return currentDateProfile;
  5589. }
  5590. }
  5591. function reduceCurrentDate(currentDate, action, dateProfile) {
  5592. switch (action.type) {
  5593. case 'PREV':
  5594. case 'NEXT':
  5595. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  5596. return dateProfile.currentRange.start;
  5597. }
  5598. else {
  5599. return currentDate;
  5600. }
  5601. case 'SET_DATE':
  5602. case 'SET_VIEW_TYPE':
  5603. var newDate = action.dateMarker || currentDate;
  5604. if (dateProfile.activeRange && !rangeContainsMarker(dateProfile.activeRange, newDate)) {
  5605. return dateProfile.currentRange.start;
  5606. }
  5607. else {
  5608. return newDate;
  5609. }
  5610. default:
  5611. return currentDate;
  5612. }
  5613. }
  5614. function reduceDateSelection(currentSelection, action, calendar) {
  5615. switch (action.type) {
  5616. case 'SELECT_DATES':
  5617. return action.selection;
  5618. case 'UNSELECT_DATES':
  5619. return null;
  5620. default:
  5621. return currentSelection;
  5622. }
  5623. }
  5624. function reduceSelectedEvent(currentInstanceId, action) {
  5625. switch (action.type) {
  5626. case 'SELECT_EVENT':
  5627. return action.eventInstanceId;
  5628. case 'UNSELECT_EVENT':
  5629. return '';
  5630. default:
  5631. return currentInstanceId;
  5632. }
  5633. }
  5634. function reduceEventDrag(currentDrag, action, sources, calendar) {
  5635. switch (action.type) {
  5636. case 'SET_EVENT_DRAG':
  5637. var newDrag = action.state;
  5638. return {
  5639. affectedEvents: newDrag.affectedEvents,
  5640. mutatedEvents: newDrag.mutatedEvents,
  5641. isEvent: newDrag.isEvent,
  5642. origSeg: newDrag.origSeg
  5643. };
  5644. case 'UNSET_EVENT_DRAG':
  5645. return null;
  5646. default:
  5647. return currentDrag;
  5648. }
  5649. }
  5650. function reduceEventResize(currentResize, action, sources, calendar) {
  5651. switch (action.type) {
  5652. case 'SET_EVENT_RESIZE':
  5653. var newResize = action.state;
  5654. return {
  5655. affectedEvents: newResize.affectedEvents,
  5656. mutatedEvents: newResize.mutatedEvents,
  5657. isEvent: newResize.isEvent,
  5658. origSeg: newResize.origSeg
  5659. };
  5660. case 'UNSET_EVENT_RESIZE':
  5661. return null;
  5662. default:
  5663. return currentResize;
  5664. }
  5665. }
  5666. function computeLoadingLevel(eventSources) {
  5667. var cnt = 0;
  5668. for (var sourceId in eventSources) {
  5669. if (eventSources[sourceId].isFetching) {
  5670. cnt++;
  5671. }
  5672. }
  5673. return cnt;
  5674. }
  5675. var STANDARD_PROPS = {
  5676. start: null,
  5677. end: null,
  5678. allDay: Boolean
  5679. };
  5680. function parseDateSpan(raw, dateEnv, defaultDuration) {
  5681. var span = parseOpenDateSpan(raw, dateEnv);
  5682. var range = span.range;
  5683. if (!range.start) {
  5684. return null;
  5685. }
  5686. if (!range.end) {
  5687. if (defaultDuration == null) {
  5688. return null;
  5689. }
  5690. else {
  5691. range.end = dateEnv.add(range.start, defaultDuration);
  5692. }
  5693. }
  5694. return span;
  5695. }
  5696. /*
  5697. TODO: somehow combine with parseRange?
  5698. Will return null if the start/end props were present but parsed invalidly.
  5699. */
  5700. function parseOpenDateSpan(raw, dateEnv) {
  5701. var leftovers = {};
  5702. var standardProps = refineProps(raw, STANDARD_PROPS, {}, leftovers);
  5703. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  5704. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  5705. var allDay = standardProps.allDay;
  5706. if (allDay == null) {
  5707. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  5708. (!endMeta || endMeta.isTimeUnspecified);
  5709. }
  5710. // use this leftover object as the selection object
  5711. leftovers.range = {
  5712. start: startMeta ? startMeta.marker : null,
  5713. end: endMeta ? endMeta.marker : null
  5714. };
  5715. leftovers.allDay = allDay;
  5716. return leftovers;
  5717. }
  5718. function isDateSpansEqual(span0, span1) {
  5719. return rangesEqual(span0.range, span1.range) &&
  5720. span0.allDay === span1.allDay &&
  5721. isSpanPropsEqual(span0, span1);
  5722. }
  5723. // the NON-DATE-RELATED props
  5724. function isSpanPropsEqual(span0, span1) {
  5725. for (var propName in span1) {
  5726. if (propName !== 'range' && propName !== 'allDay') {
  5727. if (span0[propName] !== span1[propName]) {
  5728. return false;
  5729. }
  5730. }
  5731. }
  5732. // are there any props that span0 has that span1 DOESN'T have?
  5733. // both have range/allDay, so no need to special-case.
  5734. for (var propName in span0) {
  5735. if (!(propName in span1)) {
  5736. return false;
  5737. }
  5738. }
  5739. return true;
  5740. }
  5741. function buildDateSpanApi(span, dateEnv) {
  5742. return {
  5743. start: dateEnv.toDate(span.range.start),
  5744. end: dateEnv.toDate(span.range.end),
  5745. startStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5746. endStr: dateEnv.formatIso(span.range.end, { omitTime: span.allDay }),
  5747. allDay: span.allDay
  5748. };
  5749. }
  5750. function buildDatePointApi(span, dateEnv) {
  5751. return {
  5752. date: dateEnv.toDate(span.range.start),
  5753. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5754. allDay: span.allDay
  5755. };
  5756. }
  5757. function fabricateEventRange(dateSpan, eventUiBases, calendar) {
  5758. var def = parseEventDef({ editable: false }, '', // sourceId
  5759. dateSpan.allDay, true, // hasEnd
  5760. calendar);
  5761. return {
  5762. def: def,
  5763. ui: compileEventUi(def, eventUiBases),
  5764. instance: createEventInstance(def.defId, dateSpan.range),
  5765. range: dateSpan.range,
  5766. isStart: true,
  5767. isEnd: true
  5768. };
  5769. }
  5770. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5771. var hash = {};
  5772. var viewType;
  5773. for (viewType in defaultConfigs) {
  5774. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5775. }
  5776. for (viewType in overrideConfigs) {
  5777. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5778. }
  5779. return hash;
  5780. }
  5781. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5782. if (hash[viewType]) {
  5783. return hash[viewType];
  5784. }
  5785. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5786. if (viewDef) {
  5787. hash[viewType] = viewDef;
  5788. }
  5789. return viewDef;
  5790. }
  5791. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5792. var defaultConfig = defaultConfigs[viewType];
  5793. var overrideConfig = overrideConfigs[viewType];
  5794. var queryProp = function (name) {
  5795. return (defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5796. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null);
  5797. };
  5798. var theClass = queryProp('class');
  5799. var superType = queryProp('superType');
  5800. if (!superType && theClass) {
  5801. superType =
  5802. findViewNameBySubclass(theClass, overrideConfigs) ||
  5803. findViewNameBySubclass(theClass, defaultConfigs);
  5804. }
  5805. var superDef = null;
  5806. if (superType) {
  5807. if (superType === viewType) {
  5808. throw new Error('Can\'t have a custom view type that references itself');
  5809. }
  5810. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5811. }
  5812. if (!theClass && superDef) {
  5813. theClass = superDef.class;
  5814. }
  5815. if (!theClass) {
  5816. return null; // don't throw a warning, might be settings for a single-unit view
  5817. }
  5818. return {
  5819. type: viewType,
  5820. class: theClass,
  5821. defaults: __assign({}, (superDef ? superDef.defaults : {}), (defaultConfig ? defaultConfig.options : {})),
  5822. overrides: __assign({}, (superDef ? superDef.overrides : {}), (overrideConfig ? overrideConfig.options : {}))
  5823. };
  5824. }
  5825. function findViewNameBySubclass(viewSubclass, configs) {
  5826. var superProto = Object.getPrototypeOf(viewSubclass.prototype);
  5827. for (var viewType in configs) {
  5828. var parsed = configs[viewType];
  5829. // need DIRECT subclass, so instanceof won't do it
  5830. if (parsed.class && parsed.class.prototype === superProto) {
  5831. return viewType;
  5832. }
  5833. }
  5834. return '';
  5835. }
  5836. function parseViewConfigs(inputs) {
  5837. return mapHash(inputs, parseViewConfig);
  5838. }
  5839. var VIEW_DEF_PROPS = {
  5840. type: String,
  5841. class: null
  5842. };
  5843. function parseViewConfig(input) {
  5844. if (typeof input === 'function') {
  5845. input = { class: input };
  5846. }
  5847. var options = {};
  5848. var props = refineProps(input, VIEW_DEF_PROPS, {}, options);
  5849. return {
  5850. superType: props.type,
  5851. class: props.class,
  5852. options: options
  5853. };
  5854. }
  5855. function buildViewSpecs(defaultInputs, optionsManager) {
  5856. var defaultConfigs = parseViewConfigs(defaultInputs);
  5857. var overrideConfigs = parseViewConfigs(optionsManager.overrides.views);
  5858. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5859. return mapHash(viewDefs, function (viewDef) {
  5860. return buildViewSpec(viewDef, overrideConfigs, optionsManager);
  5861. });
  5862. }
  5863. function buildViewSpec(viewDef, overrideConfigs, optionsManager) {
  5864. var durationInput = viewDef.overrides.duration ||
  5865. viewDef.defaults.duration ||
  5866. optionsManager.dynamicOverrides.duration ||
  5867. optionsManager.overrides.duration;
  5868. var duration = null;
  5869. var durationUnit = '';
  5870. var singleUnit = '';
  5871. var singleUnitOverrides = {};
  5872. if (durationInput) {
  5873. duration = createDuration(durationInput);
  5874. if (duration) { // valid?
  5875. var denom = greatestDurationDenominator(duration, !getWeeksFromInput(durationInput));
  5876. durationUnit = denom.unit;
  5877. if (denom.value === 1) {
  5878. singleUnit = durationUnit;
  5879. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].options : {};
  5880. }
  5881. }
  5882. }
  5883. var queryButtonText = function (options) {
  5884. var buttonTextMap = options.buttonText || {};
  5885. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5886. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5887. return buttonTextMap[buttonTextKey];
  5888. }
  5889. if (buttonTextMap[viewDef.type] != null) {
  5890. return buttonTextMap[viewDef.type];
  5891. }
  5892. if (buttonTextMap[singleUnit] != null) {
  5893. return buttonTextMap[singleUnit];
  5894. }
  5895. };
  5896. return {
  5897. type: viewDef.type,
  5898. class: viewDef.class,
  5899. duration: duration,
  5900. durationUnit: durationUnit,
  5901. singleUnit: singleUnit,
  5902. options: __assign({}, globalDefaults, viewDef.defaults, optionsManager.dirDefaults, optionsManager.localeDefaults, optionsManager.overrides, singleUnitOverrides, viewDef.overrides, optionsManager.dynamicOverrides),
  5903. buttonTextOverride: queryButtonText(optionsManager.dynamicOverrides) ||
  5904. queryButtonText(optionsManager.overrides) || // constructor-specified buttonText lookup hash takes precedence
  5905. viewDef.overrides.buttonText,
  5906. buttonTextDefault: queryButtonText(optionsManager.localeDefaults) ||
  5907. queryButtonText(optionsManager.dirDefaults) ||
  5908. viewDef.defaults.buttonText ||
  5909. queryButtonText(globalDefaults) ||
  5910. viewDef.type // fall back to given view name
  5911. };
  5912. }
  5913. var Toolbar = /** @class */ (function (_super) {
  5914. __extends(Toolbar, _super);
  5915. function Toolbar(extraClassName) {
  5916. var _this = _super.call(this) || this;
  5917. _this._renderLayout = memoizeRendering(_this.renderLayout, _this.unrenderLayout);
  5918. _this._updateTitle = memoizeRendering(_this.updateTitle, null, [_this._renderLayout]);
  5919. _this._updateActiveButton = memoizeRendering(_this.updateActiveButton, null, [_this._renderLayout]);
  5920. _this._updateToday = memoizeRendering(_this.updateToday, null, [_this._renderLayout]);
  5921. _this._updatePrev = memoizeRendering(_this.updatePrev, null, [_this._renderLayout]);
  5922. _this._updateNext = memoizeRendering(_this.updateNext, null, [_this._renderLayout]);
  5923. _this.el = createElement('div', { className: 'fc-toolbar ' + extraClassName });
  5924. return _this;
  5925. }
  5926. Toolbar.prototype.destroy = function () {
  5927. _super.prototype.destroy.call(this);
  5928. this._renderLayout.unrender(); // should unrender everything else
  5929. removeElement(this.el);
  5930. };
  5931. Toolbar.prototype.render = function (props) {
  5932. this._renderLayout(props.layout);
  5933. this._updateTitle(props.title);
  5934. this._updateActiveButton(props.activeButton);
  5935. this._updateToday(props.isTodayEnabled);
  5936. this._updatePrev(props.isPrevEnabled);
  5937. this._updateNext(props.isNextEnabled);
  5938. };
  5939. Toolbar.prototype.renderLayout = function (layout) {
  5940. var el = this.el;
  5941. this.viewsWithButtons = [];
  5942. appendToElement(el, this.renderSection('left', layout.left));
  5943. appendToElement(el, this.renderSection('center', layout.center));
  5944. appendToElement(el, this.renderSection('right', layout.right));
  5945. };
  5946. Toolbar.prototype.unrenderLayout = function () {
  5947. this.el.innerHTML = '';
  5948. };
  5949. Toolbar.prototype.renderSection = function (position, buttonStr) {
  5950. var _this = this;
  5951. var _a = this.context, theme = _a.theme, calendar = _a.calendar;
  5952. var optionsManager = calendar.optionsManager;
  5953. var viewSpecs = calendar.viewSpecs;
  5954. var sectionEl = createElement('div', { className: 'fc-' + position });
  5955. var calendarCustomButtons = optionsManager.computed.customButtons || {};
  5956. var calendarButtonTextOverrides = optionsManager.overrides.buttonText || {};
  5957. var calendarButtonText = optionsManager.computed.buttonText || {};
  5958. if (buttonStr) {
  5959. buttonStr.split(' ').forEach(function (buttonGroupStr, i) {
  5960. var groupChildren = [];
  5961. var isOnlyButtons = true;
  5962. var groupEl;
  5963. buttonGroupStr.split(',').forEach(function (buttonName, j) {
  5964. var customButtonProps;
  5965. var viewSpec;
  5966. var buttonClick;
  5967. var buttonIcon; // only one of these will be set
  5968. var buttonText; // "
  5969. var buttonInnerHtml;
  5970. var buttonClasses;
  5971. var buttonEl;
  5972. var buttonAriaAttr;
  5973. if (buttonName === 'title') {
  5974. groupChildren.push(htmlToElement('<h2>&nbsp;</h2>')); // we always want it to take up height
  5975. isOnlyButtons = false;
  5976. }
  5977. else {
  5978. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  5979. buttonClick = function (ev) {
  5980. if (customButtonProps.click) {
  5981. customButtonProps.click.call(buttonEl, ev);
  5982. }
  5983. };
  5984. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  5985. (buttonIcon = theme.getIconClass(buttonName)) ||
  5986. (buttonText = customButtonProps.text);
  5987. }
  5988. else if ((viewSpec = viewSpecs[buttonName])) {
  5989. _this.viewsWithButtons.push(buttonName);
  5990. buttonClick = function () {
  5991. calendar.changeView(buttonName);
  5992. };
  5993. (buttonText = viewSpec.buttonTextOverride) ||
  5994. (buttonIcon = theme.getIconClass(buttonName)) ||
  5995. (buttonText = viewSpec.buttonTextDefault);
  5996. }
  5997. else if (calendar[buttonName]) { // a calendar method
  5998. buttonClick = function () {
  5999. calendar[buttonName]();
  6000. };
  6001. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6002. (buttonIcon = theme.getIconClass(buttonName)) ||
  6003. (buttonText = calendarButtonText[buttonName]);
  6004. // ^ everything else is considered default
  6005. }
  6006. if (buttonClick) {
  6007. buttonClasses = [
  6008. 'fc-' + buttonName + '-button',
  6009. theme.getClass('button')
  6010. ];
  6011. if (buttonText) {
  6012. buttonInnerHtml = htmlEscape(buttonText);
  6013. buttonAriaAttr = '';
  6014. }
  6015. else if (buttonIcon) {
  6016. buttonInnerHtml = "<span class='" + buttonIcon + "'></span>";
  6017. buttonAriaAttr = ' aria-label="' + buttonName + '"';
  6018. }
  6019. buttonEl = htmlToElement(// type="button" so that it doesn't submit a form
  6020. '<button type="button" class="' + buttonClasses.join(' ') + '"' +
  6021. buttonAriaAttr +
  6022. '>' + buttonInnerHtml + '</button>');
  6023. buttonEl.addEventListener('click', buttonClick);
  6024. groupChildren.push(buttonEl);
  6025. }
  6026. }
  6027. });
  6028. if (groupChildren.length > 1) {
  6029. groupEl = document.createElement('div');
  6030. var buttonGroupClassName = theme.getClass('buttonGroup');
  6031. if (isOnlyButtons && buttonGroupClassName) {
  6032. groupEl.classList.add(buttonGroupClassName);
  6033. }
  6034. appendToElement(groupEl, groupChildren);
  6035. sectionEl.appendChild(groupEl);
  6036. }
  6037. else {
  6038. appendToElement(sectionEl, groupChildren); // 1 or 0 children
  6039. }
  6040. });
  6041. }
  6042. return sectionEl;
  6043. };
  6044. Toolbar.prototype.updateToday = function (isTodayEnabled) {
  6045. this.toggleButtonEnabled('today', isTodayEnabled);
  6046. };
  6047. Toolbar.prototype.updatePrev = function (isPrevEnabled) {
  6048. this.toggleButtonEnabled('prev', isPrevEnabled);
  6049. };
  6050. Toolbar.prototype.updateNext = function (isNextEnabled) {
  6051. this.toggleButtonEnabled('next', isNextEnabled);
  6052. };
  6053. Toolbar.prototype.updateTitle = function (text) {
  6054. findElements(this.el, 'h2').forEach(function (titleEl) {
  6055. titleEl.innerText = text;
  6056. });
  6057. };
  6058. Toolbar.prototype.updateActiveButton = function (buttonName) {
  6059. var theme = this.context.theme;
  6060. var className = theme.getClass('buttonActive');
  6061. findElements(this.el, 'button').forEach(function (buttonEl) {
  6062. if (buttonName && buttonEl.classList.contains('fc-' + buttonName + '-button')) {
  6063. buttonEl.classList.add(className);
  6064. }
  6065. else {
  6066. buttonEl.classList.remove(className);
  6067. }
  6068. });
  6069. };
  6070. Toolbar.prototype.toggleButtonEnabled = function (buttonName, bool) {
  6071. findElements(this.el, '.fc-' + buttonName + '-button').forEach(function (buttonEl) {
  6072. buttonEl.disabled = !bool;
  6073. });
  6074. };
  6075. return Toolbar;
  6076. }(Component));
  6077. var CalendarComponent = /** @class */ (function (_super) {
  6078. __extends(CalendarComponent, _super);
  6079. function CalendarComponent(el) {
  6080. var _this = _super.call(this) || this;
  6081. _this.elClassNames = [];
  6082. _this.renderSkeleton = memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  6083. _this.renderToolbars = memoizeRendering(_this._renderToolbars, _this._unrenderToolbars, [_this.renderSkeleton]);
  6084. _this.buildComponentContext = memoize(buildComponentContext);
  6085. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  6086. _this.el = el;
  6087. _this.computeTitle = memoize(computeTitle);
  6088. _this.parseBusinessHours = memoize(function (input) {
  6089. return parseBusinessHours(input, _this.context.calendar);
  6090. });
  6091. return _this;
  6092. }
  6093. CalendarComponent.prototype.render = function (props, context) {
  6094. this.freezeHeight();
  6095. var title = this.computeTitle(props.dateProfile, props.viewSpec.options);
  6096. this.renderSkeleton(context);
  6097. this.renderToolbars(props.viewSpec, props.dateProfile, props.currentDate, title);
  6098. this.renderView(props, title);
  6099. this.updateSize();
  6100. this.thawHeight();
  6101. };
  6102. CalendarComponent.prototype.destroy = function () {
  6103. if (this.header) {
  6104. this.header.destroy();
  6105. }
  6106. if (this.footer) {
  6107. this.footer.destroy();
  6108. }
  6109. this.renderSkeleton.unrender(); // will call destroyView
  6110. _super.prototype.destroy.call(this);
  6111. };
  6112. CalendarComponent.prototype._renderSkeleton = function (context) {
  6113. this.updateElClassNames(context);
  6114. prependToElement(this.el, this.contentEl = createElement('div', { className: 'fc-view-container' }));
  6115. var calendar = context.calendar;
  6116. for (var _i = 0, _a = calendar.pluginSystem.hooks.viewContainerModifiers; _i < _a.length; _i++) {
  6117. var modifyViewContainer = _a[_i];
  6118. modifyViewContainer(this.contentEl, calendar);
  6119. }
  6120. };
  6121. CalendarComponent.prototype._unrenderSkeleton = function () {
  6122. // weird to have this here
  6123. if (this.view) {
  6124. this.savedScroll = this.view.queryScroll();
  6125. this.view.destroy();
  6126. this.view = null;
  6127. }
  6128. removeElement(this.contentEl);
  6129. this.removeElClassNames();
  6130. };
  6131. CalendarComponent.prototype.removeElClassNames = function () {
  6132. var classList = this.el.classList;
  6133. for (var _i = 0, _a = this.elClassNames; _i < _a.length; _i++) {
  6134. var className = _a[_i];
  6135. classList.remove(className);
  6136. }
  6137. this.elClassNames = [];
  6138. };
  6139. CalendarComponent.prototype.updateElClassNames = function (context) {
  6140. this.removeElClassNames();
  6141. var theme = context.theme, options = context.options;
  6142. this.elClassNames = [
  6143. 'fc',
  6144. 'fc-' + options.dir,
  6145. theme.getClass('widget')
  6146. ];
  6147. var classList = this.el.classList;
  6148. for (var _i = 0, _a = this.elClassNames; _i < _a.length; _i++) {
  6149. var className = _a[_i];
  6150. classList.add(className);
  6151. }
  6152. };
  6153. CalendarComponent.prototype._renderToolbars = function (viewSpec, dateProfile, currentDate, title) {
  6154. var _a = this, context = _a.context, header = _a.header, footer = _a.footer;
  6155. var options = context.options, calendar = context.calendar;
  6156. var headerLayout = options.header;
  6157. var footerLayout = options.footer;
  6158. var dateProfileGenerator = this.props.dateProfileGenerator;
  6159. var now = calendar.getNow();
  6160. var todayInfo = dateProfileGenerator.build(now);
  6161. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate);
  6162. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate);
  6163. var toolbarProps = {
  6164. title: title,
  6165. activeButton: viewSpec.type,
  6166. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  6167. isPrevEnabled: prevInfo.isValid,
  6168. isNextEnabled: nextInfo.isValid
  6169. };
  6170. if (headerLayout) {
  6171. if (!header) {
  6172. header = this.header = new Toolbar('fc-header-toolbar');
  6173. prependToElement(this.el, header.el);
  6174. }
  6175. header.receiveProps(__assign({ layout: headerLayout }, toolbarProps), context);
  6176. }
  6177. else if (header) {
  6178. header.destroy();
  6179. header = this.header = null;
  6180. }
  6181. if (footerLayout) {
  6182. if (!footer) {
  6183. footer = this.footer = new Toolbar('fc-footer-toolbar');
  6184. appendToElement(this.el, footer.el);
  6185. }
  6186. footer.receiveProps(__assign({ layout: footerLayout }, toolbarProps), context);
  6187. }
  6188. else if (footer) {
  6189. footer.destroy();
  6190. footer = this.footer = null;
  6191. }
  6192. };
  6193. CalendarComponent.prototype._unrenderToolbars = function () {
  6194. if (this.header) {
  6195. this.header.destroy();
  6196. this.header = null;
  6197. }
  6198. if (this.footer) {
  6199. this.footer.destroy();
  6200. this.footer = null;
  6201. }
  6202. };
  6203. CalendarComponent.prototype.renderView = function (props, title) {
  6204. var view = this.view;
  6205. var _a = this.context, calendar = _a.calendar, options = _a.options;
  6206. var viewSpec = props.viewSpec, dateProfileGenerator = props.dateProfileGenerator;
  6207. if (!view || view.viewSpec !== viewSpec) {
  6208. if (view) {
  6209. view.destroy();
  6210. }
  6211. view = this.view = new viewSpec['class'](viewSpec, this.contentEl);
  6212. if (this.savedScroll) {
  6213. view.addScroll(this.savedScroll, true);
  6214. this.savedScroll = null;
  6215. }
  6216. }
  6217. view.title = title; // for the API
  6218. var viewProps = {
  6219. dateProfileGenerator: dateProfileGenerator,
  6220. dateProfile: props.dateProfile,
  6221. businessHours: this.parseBusinessHours(viewSpec.options.businessHours),
  6222. eventStore: props.eventStore,
  6223. eventUiBases: props.eventUiBases,
  6224. dateSelection: props.dateSelection,
  6225. eventSelection: props.eventSelection,
  6226. eventDrag: props.eventDrag,
  6227. eventResize: props.eventResize
  6228. };
  6229. var transformers = this.buildViewPropTransformers(calendar.pluginSystem.hooks.viewPropsTransformers);
  6230. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  6231. var transformer = transformers_1[_i];
  6232. __assign(viewProps, transformer.transform(viewProps, viewSpec, props, options));
  6233. }
  6234. view.receiveProps(viewProps, this.buildComponentContext(this.context, viewSpec, view));
  6235. };
  6236. // Sizing
  6237. // -----------------------------------------------------------------------------------------------------------------
  6238. CalendarComponent.prototype.updateSize = function (isResize) {
  6239. if (isResize === void 0) { isResize = false; }
  6240. var view = this.view;
  6241. if (!view) {
  6242. return; // why?
  6243. }
  6244. if (isResize || this.isHeightAuto == null) {
  6245. this.computeHeightVars();
  6246. }
  6247. view.updateSize(isResize, this.viewHeight, this.isHeightAuto);
  6248. view.updateNowIndicator(); // we need to guarantee this will run after updateSize
  6249. view.popScroll(isResize);
  6250. };
  6251. CalendarComponent.prototype.computeHeightVars = function () {
  6252. var calendar = this.context.calendar; // yuck. need to handle dynamic options
  6253. var heightInput = calendar.opt('height');
  6254. var contentHeightInput = calendar.opt('contentHeight');
  6255. this.isHeightAuto = heightInput === 'auto' || contentHeightInput === 'auto';
  6256. if (typeof contentHeightInput === 'number') { // exists and not 'auto'
  6257. this.viewHeight = contentHeightInput;
  6258. }
  6259. else if (typeof contentHeightInput === 'function') { // exists and is a function
  6260. this.viewHeight = contentHeightInput();
  6261. }
  6262. else if (typeof heightInput === 'number') { // exists and not 'auto'
  6263. this.viewHeight = heightInput - this.queryToolbarsHeight();
  6264. }
  6265. else if (typeof heightInput === 'function') { // exists and is a function
  6266. this.viewHeight = heightInput() - this.queryToolbarsHeight();
  6267. }
  6268. else if (heightInput === 'parent') { // set to height of parent element
  6269. var parentEl = this.el.parentNode;
  6270. this.viewHeight = parentEl.getBoundingClientRect().height - this.queryToolbarsHeight();
  6271. }
  6272. else {
  6273. this.viewHeight = Math.round(this.contentEl.getBoundingClientRect().width /
  6274. Math.max(calendar.opt('aspectRatio'), .5));
  6275. }
  6276. };
  6277. CalendarComponent.prototype.queryToolbarsHeight = function () {
  6278. var height = 0;
  6279. if (this.header) {
  6280. height += computeHeightAndMargins(this.header.el);
  6281. }
  6282. if (this.footer) {
  6283. height += computeHeightAndMargins(this.footer.el);
  6284. }
  6285. return height;
  6286. };
  6287. // Height "Freezing"
  6288. // -----------------------------------------------------------------------------------------------------------------
  6289. CalendarComponent.prototype.freezeHeight = function () {
  6290. applyStyle(this.el, {
  6291. height: this.el.getBoundingClientRect().height,
  6292. overflow: 'hidden'
  6293. });
  6294. };
  6295. CalendarComponent.prototype.thawHeight = function () {
  6296. applyStyle(this.el, {
  6297. height: '',
  6298. overflow: ''
  6299. });
  6300. };
  6301. return CalendarComponent;
  6302. }(Component));
  6303. // Title and Date Formatting
  6304. // -----------------------------------------------------------------------------------------------------------------
  6305. // Computes what the title at the top of the calendar should be for this view
  6306. function computeTitle(dateProfile, viewOptions) {
  6307. var range;
  6308. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6309. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6310. range = dateProfile.currentRange;
  6311. }
  6312. else { // for day units or smaller, use the actual day range
  6313. range = dateProfile.activeRange;
  6314. }
  6315. return this.context.dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || computeTitleFormat(dateProfile), viewOptions.titleRangeSeparator), { isEndExclusive: dateProfile.isRangeAllDay });
  6316. }
  6317. // Generates the format string that should be used to generate the title for the current date range.
  6318. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6319. function computeTitleFormat(dateProfile) {
  6320. var currentRangeUnit = dateProfile.currentRangeUnit;
  6321. if (currentRangeUnit === 'year') {
  6322. return { year: 'numeric' };
  6323. }
  6324. else if (currentRangeUnit === 'month') {
  6325. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6326. }
  6327. else {
  6328. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6329. if (days !== null && days > 1) {
  6330. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6331. return { year: 'numeric', month: 'short', day: 'numeric' };
  6332. }
  6333. else {
  6334. // one day. longer, like "September 9 2014"
  6335. return { year: 'numeric', month: 'long', day: 'numeric' };
  6336. }
  6337. }
  6338. }
  6339. // build a context scoped to the view
  6340. function buildComponentContext(context, viewSpec, view) {
  6341. return context.extend(viewSpec.options, view);
  6342. }
  6343. // Plugin
  6344. // -----------------------------------------------------------------------------------------------------------------
  6345. function buildViewPropTransformers(theClasses) {
  6346. return theClasses.map(function (theClass) {
  6347. return new theClass();
  6348. });
  6349. }
  6350. var Interaction = /** @class */ (function () {
  6351. function Interaction(settings) {
  6352. this.component = settings.component;
  6353. }
  6354. Interaction.prototype.destroy = function () {
  6355. };
  6356. return Interaction;
  6357. }());
  6358. function parseInteractionSettings(component, input) {
  6359. return {
  6360. component: component,
  6361. el: input.el,
  6362. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true
  6363. };
  6364. }
  6365. function interactionSettingsToStore(settings) {
  6366. var _a;
  6367. return _a = {},
  6368. _a[settings.component.uid] = settings,
  6369. _a;
  6370. }
  6371. // global state
  6372. var interactionSettingsStore = {};
  6373. /*
  6374. Detects when the user clicks on an event within a DateComponent
  6375. */
  6376. var EventClicking = /** @class */ (function (_super) {
  6377. __extends(EventClicking, _super);
  6378. function EventClicking(settings) {
  6379. var _this = _super.call(this, settings) || this;
  6380. _this.handleSegClick = function (ev, segEl) {
  6381. var component = _this.component;
  6382. var _a = component.context, calendar = _a.calendar, view = _a.view;
  6383. var seg = getElSeg(segEl);
  6384. if (seg && // might be the <div> surrounding the more link
  6385. component.isValidSegDownEl(ev.target)) {
  6386. // our way to simulate a link click for elements that can't be <a> tags
  6387. // grab before trigger fired in case trigger trashes DOM thru rerendering
  6388. var hasUrlContainer = elementClosest(ev.target, '.fc-has-url');
  6389. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  6390. calendar.publiclyTrigger('eventClick', [
  6391. {
  6392. el: segEl,
  6393. event: new EventApi(component.context.calendar, seg.eventRange.def, seg.eventRange.instance),
  6394. jsEvent: ev,
  6395. view: view
  6396. }
  6397. ]);
  6398. if (url && !ev.defaultPrevented) {
  6399. window.location.href = url;
  6400. }
  6401. }
  6402. };
  6403. var component = settings.component;
  6404. _this.destroy = listenBySelector(component.el, 'click', component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegClick);
  6405. return _this;
  6406. }
  6407. return EventClicking;
  6408. }(Interaction));
  6409. /*
  6410. Triggers events and adds/removes core classNames when the user's pointer
  6411. enters/leaves event-elements of a component.
  6412. */
  6413. var EventHovering = /** @class */ (function (_super) {
  6414. __extends(EventHovering, _super);
  6415. function EventHovering(settings) {
  6416. var _this = _super.call(this, settings) || this;
  6417. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  6418. _this.handleEventElRemove = function (el) {
  6419. if (el === _this.currentSegEl) {
  6420. _this.handleSegLeave(null, _this.currentSegEl);
  6421. }
  6422. };
  6423. _this.handleSegEnter = function (ev, segEl) {
  6424. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  6425. segEl.classList.add('fc-allow-mouse-resize');
  6426. _this.currentSegEl = segEl;
  6427. _this.triggerEvent('eventMouseEnter', ev, segEl);
  6428. }
  6429. };
  6430. _this.handleSegLeave = function (ev, segEl) {
  6431. if (_this.currentSegEl) {
  6432. segEl.classList.remove('fc-allow-mouse-resize');
  6433. _this.currentSegEl = null;
  6434. _this.triggerEvent('eventMouseLeave', ev, segEl);
  6435. }
  6436. };
  6437. var component = settings.component;
  6438. _this.removeHoverListeners = listenToHoverBySelector(component.el, component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegEnter, _this.handleSegLeave);
  6439. // how to make sure component already has context?
  6440. component.context.calendar.on('eventElRemove', _this.handleEventElRemove);
  6441. return _this;
  6442. }
  6443. EventHovering.prototype.destroy = function () {
  6444. this.removeHoverListeners();
  6445. this.component.context.calendar.off('eventElRemove', this.handleEventElRemove);
  6446. };
  6447. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  6448. var component = this.component;
  6449. var _a = component.context, calendar = _a.calendar, view = _a.view;
  6450. var seg = getElSeg(segEl);
  6451. if (!ev || component.isValidSegDownEl(ev.target)) {
  6452. calendar.publiclyTrigger(publicEvName, [
  6453. {
  6454. el: segEl,
  6455. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  6456. jsEvent: ev,
  6457. view: view
  6458. }
  6459. ]);
  6460. }
  6461. };
  6462. return EventHovering;
  6463. }(Interaction));
  6464. var StandardTheme = /** @class */ (function (_super) {
  6465. __extends(StandardTheme, _super);
  6466. function StandardTheme() {
  6467. return _super !== null && _super.apply(this, arguments) || this;
  6468. }
  6469. return StandardTheme;
  6470. }(Theme));
  6471. StandardTheme.prototype.classes = {
  6472. widget: 'fc-unthemed',
  6473. widgetHeader: 'fc-widget-header',
  6474. widgetContent: 'fc-widget-content',
  6475. buttonGroup: 'fc-button-group',
  6476. button: 'fc-button fc-button-primary',
  6477. buttonActive: 'fc-button-active',
  6478. popoverHeader: 'fc-widget-header',
  6479. popoverContent: 'fc-widget-content',
  6480. // day grid
  6481. headerRow: 'fc-widget-header',
  6482. dayRow: 'fc-widget-content',
  6483. // list view
  6484. listView: 'fc-widget-content'
  6485. };
  6486. StandardTheme.prototype.baseIconClass = 'fc-icon';
  6487. StandardTheme.prototype.iconClasses = {
  6488. close: 'fc-icon-x',
  6489. prev: 'fc-icon-chevron-left',
  6490. next: 'fc-icon-chevron-right',
  6491. prevYear: 'fc-icon-chevrons-left',
  6492. nextYear: 'fc-icon-chevrons-right'
  6493. };
  6494. StandardTheme.prototype.iconOverrideOption = 'buttonIcons';
  6495. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  6496. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  6497. var Calendar = /** @class */ (function () {
  6498. function Calendar(el, overrides) {
  6499. var _this = this;
  6500. this.buildComponentContext = memoize(buildComponentContext$1);
  6501. this.parseRawLocales = memoize(parseRawLocales);
  6502. this.buildLocale = memoize(buildLocale);
  6503. this.buildDateEnv = memoize(buildDateEnv);
  6504. this.buildTheme = memoize(buildTheme);
  6505. this.buildEventUiSingleBase = memoize(this._buildEventUiSingleBase);
  6506. this.buildSelectionConfig = memoize(this._buildSelectionConfig);
  6507. this.buildEventUiBySource = memoizeOutput(buildEventUiBySource, isPropsEqual);
  6508. this.buildEventUiBases = memoize(buildEventUiBases);
  6509. this.interactionsStore = {};
  6510. this.actionQueue = [];
  6511. this.isReducing = false;
  6512. // isDisplaying: boolean = false // installed in DOM? accepting renders?
  6513. this.needsRerender = false; // needs a render?
  6514. this.isRendering = false; // currently in the executeRender function?
  6515. this.renderingPauseDepth = 0;
  6516. this.buildDelayedRerender = memoize(buildDelayedRerender);
  6517. this.afterSizingTriggers = {};
  6518. this.isViewUpdated = false;
  6519. this.isDatesUpdated = false;
  6520. this.isEventsUpdated = false;
  6521. this.el = el;
  6522. this.optionsManager = new OptionsManager(overrides || {});
  6523. this.pluginSystem = new PluginSystem();
  6524. // only do once. don't do in handleOptions. because can't remove plugins
  6525. this.addPluginInputs(this.optionsManager.computed.plugins || []);
  6526. this.handleOptions(this.optionsManager.computed);
  6527. this.publiclyTrigger('_init'); // for tests
  6528. this.hydrate();
  6529. this.calendarInteractions = this.pluginSystem.hooks.calendarInteractions
  6530. .map(function (calendarInteractionClass) {
  6531. return new calendarInteractionClass(_this);
  6532. });
  6533. }
  6534. Calendar.prototype.addPluginInputs = function (pluginInputs) {
  6535. var pluginDefs = refinePluginDefs(pluginInputs);
  6536. for (var _i = 0, pluginDefs_1 = pluginDefs; _i < pluginDefs_1.length; _i++) {
  6537. var pluginDef = pluginDefs_1[_i];
  6538. this.pluginSystem.add(pluginDef);
  6539. }
  6540. };
  6541. Object.defineProperty(Calendar.prototype, "view", {
  6542. // public API
  6543. get: function () {
  6544. return this.component ? this.component.view : null;
  6545. },
  6546. enumerable: true,
  6547. configurable: true
  6548. });
  6549. // Public API for rendering
  6550. // -----------------------------------------------------------------------------------------------------------------
  6551. Calendar.prototype.render = function () {
  6552. if (!this.component) {
  6553. this.component = new CalendarComponent(this.el);
  6554. this.renderableEventStore = createEmptyEventStore();
  6555. this.bindHandlers();
  6556. this.executeRender();
  6557. }
  6558. else {
  6559. this.requestRerender();
  6560. }
  6561. };
  6562. Calendar.prototype.destroy = function () {
  6563. if (this.component) {
  6564. this.unbindHandlers();
  6565. this.component.destroy(); // don't null-out. in case API needs access
  6566. this.component = null; // umm ???
  6567. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  6568. var interaction = _a[_i];
  6569. interaction.destroy();
  6570. }
  6571. this.publiclyTrigger('_destroyed');
  6572. }
  6573. };
  6574. // Handlers
  6575. // -----------------------------------------------------------------------------------------------------------------
  6576. Calendar.prototype.bindHandlers = function () {
  6577. var _this = this;
  6578. // event delegation for nav links
  6579. this.removeNavLinkListener = listenBySelector(this.el, 'click', 'a[data-goto]', function (ev, anchorEl) {
  6580. var gotoOptions = anchorEl.getAttribute('data-goto');
  6581. gotoOptions = gotoOptions ? JSON.parse(gotoOptions) : {};
  6582. var dateEnv = _this.dateEnv;
  6583. var dateMarker = dateEnv.createMarker(gotoOptions.date);
  6584. var viewType = gotoOptions.type;
  6585. // property like "navLinkDayClick". might be a string or a function
  6586. var customAction = _this.viewOpt('navLink' + capitaliseFirstLetter(viewType) + 'Click');
  6587. if (typeof customAction === 'function') {
  6588. customAction(dateEnv.toDate(dateMarker), ev);
  6589. }
  6590. else {
  6591. if (typeof customAction === 'string') {
  6592. viewType = customAction;
  6593. }
  6594. _this.zoomTo(dateMarker, viewType);
  6595. }
  6596. });
  6597. if (this.opt('handleWindowResize')) {
  6598. window.addEventListener('resize', this.windowResizeProxy = debounce(// prevents rapid calls
  6599. this.windowResize.bind(this), this.opt('windowResizeDelay')));
  6600. }
  6601. };
  6602. Calendar.prototype.unbindHandlers = function () {
  6603. this.removeNavLinkListener();
  6604. if (this.windowResizeProxy) {
  6605. window.removeEventListener('resize', this.windowResizeProxy);
  6606. this.windowResizeProxy = null;
  6607. }
  6608. };
  6609. // Dispatcher
  6610. // -----------------------------------------------------------------------------------------------------------------
  6611. Calendar.prototype.hydrate = function () {
  6612. var _this = this;
  6613. this.state = this.buildInitialState();
  6614. var rawSources = this.opt('eventSources') || [];
  6615. var singleRawSource = this.opt('events');
  6616. var sources = []; // parsed
  6617. if (singleRawSource) {
  6618. rawSources.unshift(singleRawSource);
  6619. }
  6620. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6621. var rawSource = rawSources_1[_i];
  6622. var source = parseEventSource(rawSource, this);
  6623. if (source) {
  6624. sources.push(source);
  6625. }
  6626. }
  6627. this.batchRendering(function () {
  6628. _this.dispatch({ type: 'INIT' }); // pass in sources here?
  6629. _this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: sources });
  6630. _this.dispatch({
  6631. type: 'SET_VIEW_TYPE',
  6632. viewType: _this.opt('defaultView') || _this.pluginSystem.hooks.defaultView
  6633. });
  6634. });
  6635. };
  6636. Calendar.prototype.buildInitialState = function () {
  6637. return {
  6638. viewType: null,
  6639. loadingLevel: 0,
  6640. eventSourceLoadingLevel: 0,
  6641. currentDate: this.getInitialDate(),
  6642. dateProfile: null,
  6643. eventSources: {},
  6644. eventStore: createEmptyEventStore(),
  6645. dateSelection: null,
  6646. eventSelection: '',
  6647. eventDrag: null,
  6648. eventResize: null
  6649. };
  6650. };
  6651. Calendar.prototype.dispatch = function (action) {
  6652. this.actionQueue.push(action);
  6653. if (!this.isReducing) {
  6654. this.isReducing = true;
  6655. var oldState = this.state;
  6656. while (this.actionQueue.length) {
  6657. this.state = this.reduce(this.state, this.actionQueue.shift(), this);
  6658. }
  6659. var newState = this.state;
  6660. this.isReducing = false;
  6661. if (!oldState.loadingLevel && newState.loadingLevel) {
  6662. this.publiclyTrigger('loading', [true]);
  6663. }
  6664. else if (oldState.loadingLevel && !newState.loadingLevel) {
  6665. this.publiclyTrigger('loading', [false]);
  6666. }
  6667. var view = this.component && this.component.view;
  6668. if (oldState.eventStore !== newState.eventStore) {
  6669. if (oldState.eventStore) {
  6670. this.isEventsUpdated = true;
  6671. }
  6672. }
  6673. if (oldState.dateProfile !== newState.dateProfile) {
  6674. if (oldState.dateProfile && view) { // why would view be null!?
  6675. this.publiclyTrigger('datesDestroy', [
  6676. {
  6677. view: view,
  6678. el: view.el
  6679. }
  6680. ]);
  6681. }
  6682. this.isDatesUpdated = true;
  6683. }
  6684. if (oldState.viewType !== newState.viewType) {
  6685. if (oldState.viewType && view) { // why would view be null!?
  6686. this.publiclyTrigger('viewSkeletonDestroy', [
  6687. {
  6688. view: view,
  6689. el: view.el
  6690. }
  6691. ]);
  6692. }
  6693. this.isViewUpdated = true;
  6694. }
  6695. this.requestRerender();
  6696. }
  6697. };
  6698. Calendar.prototype.reduce = function (state, action, calendar) {
  6699. return reduce(state, action, calendar);
  6700. };
  6701. // Render Queue
  6702. // -----------------------------------------------------------------------------------------------------------------
  6703. Calendar.prototype.requestRerender = function () {
  6704. this.needsRerender = true;
  6705. this.delayedRerender(); // will call a debounced-version of tryRerender
  6706. };
  6707. Calendar.prototype.tryRerender = function () {
  6708. if (this.component && // must be accepting renders
  6709. this.needsRerender && // indicates that a rerender was requested
  6710. !this.renderingPauseDepth && // not paused
  6711. !this.isRendering // not currently in the render loop
  6712. ) {
  6713. this.executeRender();
  6714. }
  6715. };
  6716. Calendar.prototype.batchRendering = function (func) {
  6717. this.renderingPauseDepth++;
  6718. func();
  6719. this.renderingPauseDepth--;
  6720. if (this.needsRerender) {
  6721. this.requestRerender();
  6722. }
  6723. };
  6724. // Rendering
  6725. // -----------------------------------------------------------------------------------------------------------------
  6726. Calendar.prototype.executeRender = function () {
  6727. // clear these BEFORE the render so that new values will accumulate during render
  6728. this.needsRerender = false;
  6729. this.isRendering = true;
  6730. this.renderComponent();
  6731. this.isRendering = false;
  6732. // received a rerender request while rendering
  6733. if (this.needsRerender) {
  6734. this.delayedRerender();
  6735. }
  6736. };
  6737. /*
  6738. don't call this directly. use executeRender instead
  6739. */
  6740. Calendar.prototype.renderComponent = function () {
  6741. var _a = this, state = _a.state, component = _a.component;
  6742. var viewType = state.viewType;
  6743. var viewSpec = this.viewSpecs[viewType];
  6744. if (!viewSpec) {
  6745. throw new Error("View type \"" + viewType + "\" is not valid");
  6746. }
  6747. // if event sources are still loading and progressive rendering hasn't been enabled,
  6748. // keep rendering the last fully loaded set of events
  6749. var renderableEventStore = this.renderableEventStore =
  6750. (state.eventSourceLoadingLevel && !this.opt('progressiveEventRendering')) ?
  6751. this.renderableEventStore :
  6752. state.eventStore;
  6753. var eventUiSingleBase = this.buildEventUiSingleBase(viewSpec.options);
  6754. var eventUiBySource = this.buildEventUiBySource(state.eventSources);
  6755. var eventUiBases = this.eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  6756. 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));
  6757. if (this.isViewUpdated) {
  6758. this.isViewUpdated = false;
  6759. this.publiclyTrigger('viewSkeletonRender', [
  6760. {
  6761. view: component.view,
  6762. el: component.view.el
  6763. }
  6764. ]);
  6765. }
  6766. if (this.isDatesUpdated) {
  6767. this.isDatesUpdated = false;
  6768. this.publiclyTrigger('datesRender', [
  6769. {
  6770. view: component.view,
  6771. el: component.view.el
  6772. }
  6773. ]);
  6774. }
  6775. if (this.isEventsUpdated) {
  6776. this.isEventsUpdated = false;
  6777. }
  6778. this.releaseAfterSizingTriggers();
  6779. };
  6780. // Options
  6781. // -----------------------------------------------------------------------------------------------------------------
  6782. Calendar.prototype.setOption = function (name, val) {
  6783. var _a;
  6784. this.mutateOptions((_a = {}, _a[name] = val, _a), [], true);
  6785. };
  6786. Calendar.prototype.getOption = function (name) {
  6787. return this.optionsManager.computed[name];
  6788. };
  6789. Calendar.prototype.opt = function (name) {
  6790. return this.optionsManager.computed[name];
  6791. };
  6792. Calendar.prototype.viewOpt = function (name) {
  6793. return this.viewOpts()[name];
  6794. };
  6795. Calendar.prototype.viewOpts = function () {
  6796. return this.viewSpecs[this.state.viewType].options;
  6797. };
  6798. /*
  6799. handles option changes (like a diff)
  6800. */
  6801. Calendar.prototype.mutateOptions = function (updates, removals, isDynamic, deepEqual) {
  6802. var _this = this;
  6803. var changeHandlers = this.pluginSystem.hooks.optionChangeHandlers;
  6804. var normalUpdates = {};
  6805. var specialUpdates = {};
  6806. var oldDateEnv = this.dateEnv; // do this before handleOptions
  6807. var isTimeZoneDirty = false;
  6808. var isSizeDirty = false;
  6809. var anyDifficultOptions = Boolean(removals.length);
  6810. for (var name_1 in updates) {
  6811. if (changeHandlers[name_1]) {
  6812. specialUpdates[name_1] = updates[name_1];
  6813. }
  6814. else {
  6815. normalUpdates[name_1] = updates[name_1];
  6816. }
  6817. }
  6818. for (var name_2 in normalUpdates) {
  6819. if (/^(height|contentHeight|aspectRatio)$/.test(name_2)) {
  6820. isSizeDirty = true;
  6821. }
  6822. else if (/^(defaultDate|defaultView)$/.test(name_2)) ;
  6823. else {
  6824. anyDifficultOptions = true;
  6825. if (name_2 === 'timeZone') {
  6826. isTimeZoneDirty = true;
  6827. }
  6828. }
  6829. }
  6830. this.optionsManager.mutate(normalUpdates, removals, isDynamic);
  6831. if (anyDifficultOptions) {
  6832. this.handleOptions(this.optionsManager.computed);
  6833. }
  6834. this.batchRendering(function () {
  6835. if (anyDifficultOptions) {
  6836. if (isTimeZoneDirty) {
  6837. _this.dispatch({
  6838. type: 'CHANGE_TIMEZONE',
  6839. oldDateEnv: oldDateEnv
  6840. });
  6841. }
  6842. /* HACK
  6843. has the same effect as calling this.requestRerender()
  6844. but recomputes the state's dateProfile
  6845. */
  6846. _this.dispatch({
  6847. type: 'SET_VIEW_TYPE',
  6848. viewType: _this.state.viewType
  6849. });
  6850. }
  6851. else if (isSizeDirty) {
  6852. _this.updateSize();
  6853. }
  6854. // special updates
  6855. if (deepEqual) {
  6856. for (var name_3 in specialUpdates) {
  6857. changeHandlers[name_3](specialUpdates[name_3], _this, deepEqual);
  6858. }
  6859. }
  6860. });
  6861. };
  6862. /*
  6863. rebuilds things based off of a complete set of refined options
  6864. */
  6865. Calendar.prototype.handleOptions = function (options) {
  6866. var _this = this;
  6867. var pluginHooks = this.pluginSystem.hooks;
  6868. this.defaultAllDayEventDuration = createDuration(options.defaultAllDayEventDuration);
  6869. this.defaultTimedEventDuration = createDuration(options.defaultTimedEventDuration);
  6870. this.delayedRerender = this.buildDelayedRerender(options.rerenderDelay);
  6871. this.theme = this.buildTheme(options);
  6872. var available = this.parseRawLocales(options.locales);
  6873. this.availableRawLocales = available.map;
  6874. var locale = this.buildLocale(options.locale || available.defaultCode, available.map);
  6875. this.dateEnv = this.buildDateEnv(locale, options.timeZone, pluginHooks.namedTimeZonedImpl, options.firstDay, options.weekNumberCalculation, options.weekLabel, pluginHooks.cmdFormatter);
  6876. this.selectionConfig = this.buildSelectionConfig(options); // needs dateEnv. do after :(
  6877. // ineffecient to do every time?
  6878. this.viewSpecs = buildViewSpecs(pluginHooks.views, this.optionsManager);
  6879. // ineffecient to do every time?
  6880. this.dateProfileGenerators = mapHash(this.viewSpecs, function (viewSpec) {
  6881. return new viewSpec.class.prototype.dateProfileGeneratorClass(viewSpec, _this);
  6882. });
  6883. };
  6884. Calendar.prototype.getAvailableLocaleCodes = function () {
  6885. return Object.keys(this.availableRawLocales);
  6886. };
  6887. Calendar.prototype._buildSelectionConfig = function (rawOpts) {
  6888. return processScopedUiProps('select', rawOpts, this);
  6889. };
  6890. Calendar.prototype._buildEventUiSingleBase = function (rawOpts) {
  6891. if (rawOpts.editable) { // so 'editable' affected events
  6892. rawOpts = __assign({}, rawOpts, { eventEditable: true });
  6893. }
  6894. return processScopedUiProps('event', rawOpts, this);
  6895. };
  6896. // Trigger
  6897. // -----------------------------------------------------------------------------------------------------------------
  6898. Calendar.prototype.hasPublicHandlers = function (name) {
  6899. return this.hasHandlers(name) ||
  6900. this.opt(name); // handler specified in options
  6901. };
  6902. Calendar.prototype.publiclyTrigger = function (name, args) {
  6903. var optHandler = this.opt(name);
  6904. this.triggerWith(name, this, args);
  6905. if (optHandler) {
  6906. return optHandler.apply(this, args);
  6907. }
  6908. };
  6909. Calendar.prototype.publiclyTriggerAfterSizing = function (name, args) {
  6910. var afterSizingTriggers = this.afterSizingTriggers;
  6911. (afterSizingTriggers[name] || (afterSizingTriggers[name] = [])).push(args);
  6912. };
  6913. Calendar.prototype.releaseAfterSizingTriggers = function () {
  6914. var afterSizingTriggers = this.afterSizingTriggers;
  6915. for (var name_4 in afterSizingTriggers) {
  6916. for (var _i = 0, _a = afterSizingTriggers[name_4]; _i < _a.length; _i++) {
  6917. var args = _a[_i];
  6918. this.publiclyTrigger(name_4, args);
  6919. }
  6920. }
  6921. this.afterSizingTriggers = {};
  6922. };
  6923. // View
  6924. // -----------------------------------------------------------------------------------------------------------------
  6925. // Returns a boolean about whether the view is okay to instantiate at some point
  6926. Calendar.prototype.isValidViewType = function (viewType) {
  6927. return Boolean(this.viewSpecs[viewType]);
  6928. };
  6929. Calendar.prototype.changeView = function (viewType, dateOrRange) {
  6930. var dateMarker = null;
  6931. if (dateOrRange) {
  6932. if (dateOrRange.start && dateOrRange.end) { // a range
  6933. this.optionsManager.mutate({ visibleRange: dateOrRange }, []); // will not rerender
  6934. this.handleOptions(this.optionsManager.computed); // ...but yuck
  6935. }
  6936. else { // a date
  6937. dateMarker = this.dateEnv.createMarker(dateOrRange); // just like gotoDate
  6938. }
  6939. }
  6940. this.unselect();
  6941. this.dispatch({
  6942. type: 'SET_VIEW_TYPE',
  6943. viewType: viewType,
  6944. dateMarker: dateMarker
  6945. });
  6946. };
  6947. // Forces navigation to a view for the given date.
  6948. // `viewType` can be a specific view name or a generic one like "week" or "day".
  6949. // needs to change
  6950. Calendar.prototype.zoomTo = function (dateMarker, viewType) {
  6951. var spec;
  6952. viewType = viewType || 'day'; // day is default zoom
  6953. spec = this.viewSpecs[viewType] ||
  6954. this.getUnitViewSpec(viewType);
  6955. this.unselect();
  6956. if (spec) {
  6957. this.dispatch({
  6958. type: 'SET_VIEW_TYPE',
  6959. viewType: spec.type,
  6960. dateMarker: dateMarker
  6961. });
  6962. }
  6963. else {
  6964. this.dispatch({
  6965. type: 'SET_DATE',
  6966. dateMarker: dateMarker
  6967. });
  6968. }
  6969. };
  6970. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  6971. // Preference is given to views that have corresponding buttons.
  6972. Calendar.prototype.getUnitViewSpec = function (unit) {
  6973. var component = this.component;
  6974. var viewTypes = [];
  6975. var i;
  6976. var spec;
  6977. // put views that have buttons first. there will be duplicates, but oh
  6978. if (component.header) {
  6979. viewTypes.push.apply(viewTypes, component.header.viewsWithButtons);
  6980. }
  6981. if (component.footer) {
  6982. viewTypes.push.apply(viewTypes, component.footer.viewsWithButtons);
  6983. }
  6984. for (var viewType in this.viewSpecs) {
  6985. viewTypes.push(viewType);
  6986. }
  6987. for (i = 0; i < viewTypes.length; i++) {
  6988. spec = this.viewSpecs[viewTypes[i]];
  6989. if (spec) {
  6990. if (spec.singleUnit === unit) {
  6991. return spec;
  6992. }
  6993. }
  6994. }
  6995. };
  6996. // Current Date
  6997. // -----------------------------------------------------------------------------------------------------------------
  6998. Calendar.prototype.getInitialDate = function () {
  6999. var defaultDateInput = this.opt('defaultDate');
  7000. // compute the initial ambig-timezone date
  7001. if (defaultDateInput != null) {
  7002. return this.dateEnv.createMarker(defaultDateInput);
  7003. }
  7004. else {
  7005. return this.getNow(); // getNow already returns unzoned
  7006. }
  7007. };
  7008. Calendar.prototype.prev = function () {
  7009. this.unselect();
  7010. this.dispatch({ type: 'PREV' });
  7011. };
  7012. Calendar.prototype.next = function () {
  7013. this.unselect();
  7014. this.dispatch({ type: 'NEXT' });
  7015. };
  7016. Calendar.prototype.prevYear = function () {
  7017. this.unselect();
  7018. this.dispatch({
  7019. type: 'SET_DATE',
  7020. dateMarker: this.dateEnv.addYears(this.state.currentDate, -1)
  7021. });
  7022. };
  7023. Calendar.prototype.nextYear = function () {
  7024. this.unselect();
  7025. this.dispatch({
  7026. type: 'SET_DATE',
  7027. dateMarker: this.dateEnv.addYears(this.state.currentDate, 1)
  7028. });
  7029. };
  7030. Calendar.prototype.today = function () {
  7031. this.unselect();
  7032. this.dispatch({
  7033. type: 'SET_DATE',
  7034. dateMarker: this.getNow()
  7035. });
  7036. };
  7037. Calendar.prototype.gotoDate = function (zonedDateInput) {
  7038. this.unselect();
  7039. this.dispatch({
  7040. type: 'SET_DATE',
  7041. dateMarker: this.dateEnv.createMarker(zonedDateInput)
  7042. });
  7043. };
  7044. Calendar.prototype.incrementDate = function (deltaInput) {
  7045. var delta = createDuration(deltaInput);
  7046. if (delta) { // else, warn about invalid input?
  7047. this.unselect();
  7048. this.dispatch({
  7049. type: 'SET_DATE',
  7050. dateMarker: this.dateEnv.add(this.state.currentDate, delta)
  7051. });
  7052. }
  7053. };
  7054. // for external API
  7055. Calendar.prototype.getDate = function () {
  7056. return this.dateEnv.toDate(this.state.currentDate);
  7057. };
  7058. // Date Formatting Utils
  7059. // -----------------------------------------------------------------------------------------------------------------
  7060. Calendar.prototype.formatDate = function (d, formatter) {
  7061. var dateEnv = this.dateEnv;
  7062. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  7063. };
  7064. // `settings` is for formatter AND isEndExclusive
  7065. Calendar.prototype.formatRange = function (d0, d1, settings) {
  7066. var dateEnv = this.dateEnv;
  7067. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings, this.opt('defaultRangeSeparator')), settings);
  7068. };
  7069. Calendar.prototype.formatIso = function (d, omitTime) {
  7070. var dateEnv = this.dateEnv;
  7071. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  7072. };
  7073. // Sizing
  7074. // -----------------------------------------------------------------------------------------------------------------
  7075. Calendar.prototype.windowResize = function (ev) {
  7076. if (!this.isHandlingWindowResize &&
  7077. this.component && // why?
  7078. ev.target === window // not a jqui resize event
  7079. ) {
  7080. this.isHandlingWindowResize = true;
  7081. this.updateSize();
  7082. this.publiclyTrigger('windowResize', [this.view]);
  7083. this.isHandlingWindowResize = false;
  7084. }
  7085. };
  7086. Calendar.prototype.updateSize = function () {
  7087. if (this.component) { // when?
  7088. this.component.updateSize(true);
  7089. }
  7090. };
  7091. // Component Registration
  7092. // -----------------------------------------------------------------------------------------------------------------
  7093. Calendar.prototype.registerInteractiveComponent = function (component, settingsInput) {
  7094. var settings = parseInteractionSettings(component, settingsInput);
  7095. var DEFAULT_INTERACTIONS = [
  7096. EventClicking,
  7097. EventHovering
  7098. ];
  7099. var interactionClasses = DEFAULT_INTERACTIONS.concat(this.pluginSystem.hooks.componentInteractions);
  7100. var interactions = interactionClasses.map(function (interactionClass) {
  7101. return new interactionClass(settings);
  7102. });
  7103. this.interactionsStore[component.uid] = interactions;
  7104. interactionSettingsStore[component.uid] = settings;
  7105. };
  7106. Calendar.prototype.unregisterInteractiveComponent = function (component) {
  7107. for (var _i = 0, _a = this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7108. var listener = _a[_i];
  7109. listener.destroy();
  7110. }
  7111. delete this.interactionsStore[component.uid];
  7112. delete interactionSettingsStore[component.uid];
  7113. };
  7114. // Date Selection / Event Selection / DayClick
  7115. // -----------------------------------------------------------------------------------------------------------------
  7116. // this public method receives start/end dates in any format, with any timezone
  7117. // NOTE: args were changed from v3
  7118. Calendar.prototype.select = function (dateOrObj, endDate) {
  7119. var selectionInput;
  7120. if (endDate == null) {
  7121. if (dateOrObj.start != null) {
  7122. selectionInput = dateOrObj;
  7123. }
  7124. else {
  7125. selectionInput = {
  7126. start: dateOrObj,
  7127. end: null
  7128. };
  7129. }
  7130. }
  7131. else {
  7132. selectionInput = {
  7133. start: dateOrObj,
  7134. end: endDate
  7135. };
  7136. }
  7137. var selection = parseDateSpan(selectionInput, this.dateEnv, createDuration({ days: 1 }) // TODO: cache this?
  7138. );
  7139. if (selection) { // throw parse error otherwise?
  7140. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  7141. this.triggerDateSelect(selection);
  7142. }
  7143. };
  7144. // public method
  7145. Calendar.prototype.unselect = function (pev) {
  7146. if (this.state.dateSelection) {
  7147. this.dispatch({ type: 'UNSELECT_DATES' });
  7148. this.triggerDateUnselect(pev);
  7149. }
  7150. };
  7151. Calendar.prototype.triggerDateSelect = function (selection, pev) {
  7152. var arg = __assign({}, this.buildDateSpanApi(selection), { jsEvent: pev ? pev.origEvent : null, view: this.view });
  7153. this.publiclyTrigger('select', [arg]);
  7154. };
  7155. Calendar.prototype.triggerDateUnselect = function (pev) {
  7156. this.publiclyTrigger('unselect', [
  7157. {
  7158. jsEvent: pev ? pev.origEvent : null,
  7159. view: this.view
  7160. }
  7161. ]);
  7162. };
  7163. // TODO: receive pev?
  7164. Calendar.prototype.triggerDateClick = function (dateSpan, dayEl, view, ev) {
  7165. var arg = __assign({}, this.buildDatePointApi(dateSpan), { dayEl: dayEl, jsEvent: ev, // Is this always a mouse event? See #4655
  7166. view: view });
  7167. this.publiclyTrigger('dateClick', [arg]);
  7168. };
  7169. Calendar.prototype.buildDatePointApi = function (dateSpan) {
  7170. var props = {};
  7171. for (var _i = 0, _a = this.pluginSystem.hooks.datePointTransforms; _i < _a.length; _i++) {
  7172. var transform = _a[_i];
  7173. __assign(props, transform(dateSpan, this));
  7174. }
  7175. __assign(props, buildDatePointApi(dateSpan, this.dateEnv));
  7176. return props;
  7177. };
  7178. Calendar.prototype.buildDateSpanApi = function (dateSpan) {
  7179. var props = {};
  7180. for (var _i = 0, _a = this.pluginSystem.hooks.dateSpanTransforms; _i < _a.length; _i++) {
  7181. var transform = _a[_i];
  7182. __assign(props, transform(dateSpan, this));
  7183. }
  7184. __assign(props, buildDateSpanApi(dateSpan, this.dateEnv));
  7185. return props;
  7186. };
  7187. // Date Utils
  7188. // -----------------------------------------------------------------------------------------------------------------
  7189. // Returns a DateMarker for the current date, as defined by the client's computer or from the `now` option
  7190. Calendar.prototype.getNow = function () {
  7191. var now = this.opt('now');
  7192. if (typeof now === 'function') {
  7193. now = now();
  7194. }
  7195. if (now == null) {
  7196. return this.dateEnv.createNowMarker();
  7197. }
  7198. return this.dateEnv.createMarker(now);
  7199. };
  7200. // Event-Date Utilities
  7201. // -----------------------------------------------------------------------------------------------------------------
  7202. // Given an event's allDay status and start date, return what its fallback end date should be.
  7203. // TODO: rename to computeDefaultEventEnd
  7204. Calendar.prototype.getDefaultEventEnd = function (allDay, marker) {
  7205. var end = marker;
  7206. if (allDay) {
  7207. end = startOfDay(end);
  7208. end = this.dateEnv.add(end, this.defaultAllDayEventDuration);
  7209. }
  7210. else {
  7211. end = this.dateEnv.add(end, this.defaultTimedEventDuration);
  7212. }
  7213. return end;
  7214. };
  7215. // Public Events API
  7216. // -----------------------------------------------------------------------------------------------------------------
  7217. Calendar.prototype.addEvent = function (eventInput, sourceInput) {
  7218. if (eventInput instanceof EventApi) {
  7219. var def = eventInput._def;
  7220. var instance = eventInput._instance;
  7221. // not already present? don't want to add an old snapshot
  7222. if (!this.state.eventStore.defs[def.defId]) {
  7223. this.dispatch({
  7224. type: 'ADD_EVENTS',
  7225. eventStore: eventTupleToStore({ def: def, instance: instance }) // TODO: better util for two args?
  7226. });
  7227. }
  7228. return eventInput;
  7229. }
  7230. var sourceId;
  7231. if (sourceInput instanceof EventSourceApi) {
  7232. sourceId = sourceInput.internalEventSource.sourceId;
  7233. }
  7234. else if (sourceInput != null) {
  7235. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  7236. if (!sourceApi) {
  7237. console.warn('Could not find an event source with ID "' + sourceInput + '"'); // TODO: test
  7238. return null;
  7239. }
  7240. else {
  7241. sourceId = sourceApi.internalEventSource.sourceId;
  7242. }
  7243. }
  7244. var tuple = parseEvent(eventInput, sourceId, this);
  7245. if (tuple) {
  7246. this.dispatch({
  7247. type: 'ADD_EVENTS',
  7248. eventStore: eventTupleToStore(tuple)
  7249. });
  7250. return new EventApi(this, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  7251. }
  7252. return null;
  7253. };
  7254. // TODO: optimize
  7255. Calendar.prototype.getEventById = function (id) {
  7256. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7257. id = String(id);
  7258. for (var defId in defs) {
  7259. var def = defs[defId];
  7260. if (def.publicId === id) {
  7261. if (def.recurringDef) {
  7262. return new EventApi(this, def, null);
  7263. }
  7264. else {
  7265. for (var instanceId in instances) {
  7266. var instance = instances[instanceId];
  7267. if (instance.defId === def.defId) {
  7268. return new EventApi(this, def, instance);
  7269. }
  7270. }
  7271. }
  7272. }
  7273. }
  7274. return null;
  7275. };
  7276. Calendar.prototype.getEvents = function () {
  7277. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7278. var eventApis = [];
  7279. for (var id in instances) {
  7280. var instance = instances[id];
  7281. var def = defs[instance.defId];
  7282. eventApis.push(new EventApi(this, def, instance));
  7283. }
  7284. return eventApis;
  7285. };
  7286. Calendar.prototype.removeAllEvents = function () {
  7287. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  7288. };
  7289. Calendar.prototype.rerenderEvents = function () {
  7290. this.dispatch({ type: 'RESET_EVENTS' });
  7291. };
  7292. // Public Event Sources API
  7293. // -----------------------------------------------------------------------------------------------------------------
  7294. Calendar.prototype.getEventSources = function () {
  7295. var sourceHash = this.state.eventSources;
  7296. var sourceApis = [];
  7297. for (var internalId in sourceHash) {
  7298. sourceApis.push(new EventSourceApi(this, sourceHash[internalId]));
  7299. }
  7300. return sourceApis;
  7301. };
  7302. Calendar.prototype.getEventSourceById = function (id) {
  7303. var sourceHash = this.state.eventSources;
  7304. id = String(id);
  7305. for (var sourceId in sourceHash) {
  7306. if (sourceHash[sourceId].publicId === id) {
  7307. return new EventSourceApi(this, sourceHash[sourceId]);
  7308. }
  7309. }
  7310. return null;
  7311. };
  7312. Calendar.prototype.addEventSource = function (sourceInput) {
  7313. if (sourceInput instanceof EventSourceApi) {
  7314. // not already present? don't want to add an old snapshot
  7315. if (!this.state.eventSources[sourceInput.internalEventSource.sourceId]) {
  7316. this.dispatch({
  7317. type: 'ADD_EVENT_SOURCES',
  7318. sources: [sourceInput.internalEventSource]
  7319. });
  7320. }
  7321. return sourceInput;
  7322. }
  7323. var eventSource = parseEventSource(sourceInput, this);
  7324. if (eventSource) { // TODO: error otherwise?
  7325. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  7326. return new EventSourceApi(this, eventSource);
  7327. }
  7328. return null;
  7329. };
  7330. Calendar.prototype.removeAllEventSources = function () {
  7331. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  7332. };
  7333. Calendar.prototype.refetchEvents = function () {
  7334. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  7335. };
  7336. // Scroll
  7337. // -----------------------------------------------------------------------------------------------------------------
  7338. Calendar.prototype.scrollToTime = function (timeInput) {
  7339. var duration = createDuration(timeInput);
  7340. if (duration) {
  7341. this.component.view.scrollToDuration(duration);
  7342. }
  7343. };
  7344. return Calendar;
  7345. }());
  7346. EmitterMixin.mixInto(Calendar);
  7347. // for memoizers
  7348. // -----------------------------------------------------------------------------------------------------------------
  7349. function buildComponentContext$1(theme, dateEnv, options) {
  7350. return new ComponentContext(this, theme, dateEnv, options, null);
  7351. }
  7352. function buildDateEnv(locale, timeZone, namedTimeZoneImpl, firstDay, weekNumberCalculation, weekLabel, cmdFormatter) {
  7353. return new DateEnv({
  7354. calendarSystem: 'gregory',
  7355. timeZone: timeZone,
  7356. namedTimeZoneImpl: namedTimeZoneImpl,
  7357. locale: locale,
  7358. weekNumberCalculation: weekNumberCalculation,
  7359. firstDay: firstDay,
  7360. weekLabel: weekLabel,
  7361. cmdFormatter: cmdFormatter
  7362. });
  7363. }
  7364. function buildTheme(calendarOptions) {
  7365. var themeClass = this.pluginSystem.hooks.themeClasses[calendarOptions.themeSystem] || StandardTheme;
  7366. return new themeClass(calendarOptions);
  7367. }
  7368. function buildDelayedRerender(wait) {
  7369. var func = this.tryRerender.bind(this);
  7370. if (wait != null) {
  7371. func = debounce(func, wait);
  7372. }
  7373. return func;
  7374. }
  7375. function buildEventUiBySource(eventSources) {
  7376. return mapHash(eventSources, function (eventSource) {
  7377. return eventSource.ui;
  7378. });
  7379. }
  7380. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7381. var eventUiBases = { '': eventUiSingleBase };
  7382. for (var defId in eventDefs) {
  7383. var def = eventDefs[defId];
  7384. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7385. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7386. }
  7387. }
  7388. return eventUiBases;
  7389. }
  7390. var View = /** @class */ (function (_super) {
  7391. __extends(View, _super);
  7392. function View(viewSpec, parentEl) {
  7393. var _this = _super.call(this, createElement('div', { className: 'fc-view fc-' + viewSpec.type + '-view' })) || this;
  7394. _this.renderDatesMem = memoizeRendering(_this.renderDatesWrap, _this.unrenderDatesWrap);
  7395. _this.renderBusinessHoursMem = memoizeRendering(_this.renderBusinessHours, _this.unrenderBusinessHours, [_this.renderDatesMem]);
  7396. _this.renderDateSelectionMem = memoizeRendering(_this.renderDateSelectionWrap, _this.unrenderDateSelectionWrap, [_this.renderDatesMem]);
  7397. _this.renderEventsMem = memoizeRendering(_this.renderEvents, _this.unrenderEvents, [_this.renderDatesMem]);
  7398. _this.renderEventSelectionMem = memoizeRendering(_this.renderEventSelectionWrap, _this.unrenderEventSelectionWrap, [_this.renderEventsMem]);
  7399. _this.renderEventDragMem = memoizeRendering(_this.renderEventDragWrap, _this.unrenderEventDragWrap, [_this.renderDatesMem]);
  7400. _this.renderEventResizeMem = memoizeRendering(_this.renderEventResizeWrap, _this.unrenderEventResizeWrap, [_this.renderDatesMem]);
  7401. _this.viewSpec = viewSpec;
  7402. _this.type = viewSpec.type;
  7403. parentEl.appendChild(_this.el);
  7404. _this.initialize();
  7405. return _this;
  7406. }
  7407. View.prototype.initialize = function () {
  7408. };
  7409. Object.defineProperty(View.prototype, "activeStart", {
  7410. // Date Setting/Unsetting
  7411. // -----------------------------------------------------------------------------------------------------------------
  7412. get: function () {
  7413. return this.context.dateEnv.toDate(this.props.dateProfile.activeRange.start);
  7414. },
  7415. enumerable: true,
  7416. configurable: true
  7417. });
  7418. Object.defineProperty(View.prototype, "activeEnd", {
  7419. get: function () {
  7420. return this.context.dateEnv.toDate(this.props.dateProfile.activeRange.end);
  7421. },
  7422. enumerable: true,
  7423. configurable: true
  7424. });
  7425. Object.defineProperty(View.prototype, "currentStart", {
  7426. get: function () {
  7427. return this.context.dateEnv.toDate(this.props.dateProfile.currentRange.start);
  7428. },
  7429. enumerable: true,
  7430. configurable: true
  7431. });
  7432. Object.defineProperty(View.prototype, "currentEnd", {
  7433. get: function () {
  7434. return this.context.dateEnv.toDate(this.props.dateProfile.currentRange.end);
  7435. },
  7436. enumerable: true,
  7437. configurable: true
  7438. });
  7439. // General Rendering
  7440. // -----------------------------------------------------------------------------------------------------------------
  7441. View.prototype.render = function (props, context) {
  7442. this.renderDatesMem(props.dateProfile);
  7443. this.renderBusinessHoursMem(props.businessHours);
  7444. this.renderDateSelectionMem(props.dateSelection);
  7445. this.renderEventsMem(props.eventStore);
  7446. this.renderEventSelectionMem(props.eventSelection);
  7447. this.renderEventDragMem(props.eventDrag);
  7448. this.renderEventResizeMem(props.eventResize);
  7449. };
  7450. View.prototype.beforeUpdate = function () {
  7451. this.addScroll(this.queryScroll());
  7452. };
  7453. View.prototype.destroy = function () {
  7454. _super.prototype.destroy.call(this);
  7455. this.renderDatesMem.unrender(); // should unrender everything else
  7456. };
  7457. // Sizing
  7458. // -----------------------------------------------------------------------------------------------------------------
  7459. View.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  7460. var calendar = this.context.calendar;
  7461. if (isResize) {
  7462. this.addScroll(this.queryScroll()); // NOTE: same code as in beforeUpdate
  7463. }
  7464. if (isResize || // HACKS...
  7465. calendar.isViewUpdated ||
  7466. calendar.isDatesUpdated ||
  7467. calendar.isEventsUpdated) {
  7468. // sort of the catch-all sizing
  7469. // anything that might cause dimension changes
  7470. this.updateBaseSize(isResize, viewHeight, isAuto);
  7471. }
  7472. // NOTE: popScroll is called by CalendarComponent
  7473. };
  7474. View.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  7475. };
  7476. // Date Rendering
  7477. // -----------------------------------------------------------------------------------------------------------------
  7478. View.prototype.renderDatesWrap = function (dateProfile) {
  7479. this.renderDates(dateProfile);
  7480. this.addScroll({
  7481. duration: createDuration(this.context.options.scrollTime)
  7482. });
  7483. };
  7484. View.prototype.unrenderDatesWrap = function () {
  7485. this.stopNowIndicator();
  7486. this.unrenderDates();
  7487. };
  7488. View.prototype.renderDates = function (dateProfile) { };
  7489. View.prototype.unrenderDates = function () { };
  7490. // Business Hours
  7491. // -----------------------------------------------------------------------------------------------------------------
  7492. View.prototype.renderBusinessHours = function (businessHours) { };
  7493. View.prototype.unrenderBusinessHours = function () { };
  7494. // Date Selection
  7495. // -----------------------------------------------------------------------------------------------------------------
  7496. View.prototype.renderDateSelectionWrap = function (selection) {
  7497. if (selection) {
  7498. this.renderDateSelection(selection);
  7499. }
  7500. };
  7501. View.prototype.unrenderDateSelectionWrap = function (selection) {
  7502. if (selection) {
  7503. this.unrenderDateSelection(selection);
  7504. }
  7505. };
  7506. View.prototype.renderDateSelection = function (selection) { };
  7507. View.prototype.unrenderDateSelection = function (selection) { };
  7508. // Event Rendering
  7509. // -----------------------------------------------------------------------------------------------------------------
  7510. View.prototype.renderEvents = function (eventStore) { };
  7511. View.prototype.unrenderEvents = function () { };
  7512. // util for subclasses
  7513. View.prototype.sliceEvents = function (eventStore, allDay) {
  7514. var props = this.props;
  7515. return sliceEventStore(eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? this.context.nextDayThreshold : null).fg;
  7516. };
  7517. // Event Selection
  7518. // -----------------------------------------------------------------------------------------------------------------
  7519. View.prototype.renderEventSelectionWrap = function (instanceId) {
  7520. if (instanceId) {
  7521. this.renderEventSelection(instanceId);
  7522. }
  7523. };
  7524. View.prototype.unrenderEventSelectionWrap = function (instanceId) {
  7525. if (instanceId) {
  7526. this.unrenderEventSelection(instanceId);
  7527. }
  7528. };
  7529. View.prototype.renderEventSelection = function (instanceId) { };
  7530. View.prototype.unrenderEventSelection = function (instanceId) { };
  7531. // Event Drag
  7532. // -----------------------------------------------------------------------------------------------------------------
  7533. View.prototype.renderEventDragWrap = function (state) {
  7534. if (state) {
  7535. this.renderEventDrag(state);
  7536. }
  7537. };
  7538. View.prototype.unrenderEventDragWrap = function (state) {
  7539. if (state) {
  7540. this.unrenderEventDrag(state);
  7541. }
  7542. };
  7543. View.prototype.renderEventDrag = function (state) { };
  7544. View.prototype.unrenderEventDrag = function (state) { };
  7545. // Event Resize
  7546. // -----------------------------------------------------------------------------------------------------------------
  7547. View.prototype.renderEventResizeWrap = function (state) {
  7548. if (state) {
  7549. this.renderEventResize(state);
  7550. }
  7551. };
  7552. View.prototype.unrenderEventResizeWrap = function (state) {
  7553. if (state) {
  7554. this.unrenderEventResize(state);
  7555. }
  7556. };
  7557. View.prototype.renderEventResize = function (state) { };
  7558. View.prototype.unrenderEventResize = function (state) { };
  7559. /* Now Indicator
  7560. ------------------------------------------------------------------------------------------------------------------*/
  7561. // Immediately render the current time indicator and begins re-rendering it at an interval,
  7562. // which is defined by this.getNowIndicatorUnit().
  7563. // TODO: somehow do this for the current whole day's background too
  7564. // USAGE: must be called manually from subclasses' render methods! don't need to call stopNowIndicator tho
  7565. View.prototype.startNowIndicator = function (dateProfile, dateProfileGenerator) {
  7566. var _this = this;
  7567. var _a = this.context, calendar = _a.calendar, dateEnv = _a.dateEnv, options = _a.options;
  7568. var unit;
  7569. var update;
  7570. var delay; // ms wait value
  7571. if (options.nowIndicator && !this.initialNowDate) {
  7572. unit = this.getNowIndicatorUnit(dateProfile, dateProfileGenerator);
  7573. if (unit) {
  7574. update = this.updateNowIndicator.bind(this);
  7575. this.initialNowDate = calendar.getNow();
  7576. this.initialNowQueriedMs = new Date().valueOf();
  7577. // wait until the beginning of the next interval
  7578. delay = dateEnv.add(dateEnv.startOf(this.initialNowDate, unit), createDuration(1, unit)).valueOf() - this.initialNowDate.valueOf();
  7579. // TODO: maybe always use setTimeout, waiting until start of next unit
  7580. this.nowIndicatorTimeoutID = setTimeout(function () {
  7581. _this.nowIndicatorTimeoutID = null;
  7582. update();
  7583. if (unit === 'second') {
  7584. delay = 1000; // every second
  7585. }
  7586. else {
  7587. delay = 1000 * 60; // otherwise, every minute
  7588. }
  7589. _this.nowIndicatorIntervalID = setInterval(update, delay); // update every interval
  7590. }, delay);
  7591. }
  7592. // rendering will be initiated in updateSize
  7593. }
  7594. };
  7595. // rerenders the now indicator, computing the new current time from the amount of time that has passed
  7596. // since the initial getNow call.
  7597. View.prototype.updateNowIndicator = function () {
  7598. if (this.props.dateProfile && // a way to determine if dates were rendered yet
  7599. this.initialNowDate // activated before?
  7600. ) {
  7601. this.unrenderNowIndicator(); // won't unrender if unnecessary
  7602. this.renderNowIndicator(addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs));
  7603. this.isNowIndicatorRendered = true;
  7604. }
  7605. };
  7606. // Immediately unrenders the view's current time indicator and stops any re-rendering timers.
  7607. // Won't cause side effects if indicator isn't rendered.
  7608. View.prototype.stopNowIndicator = function () {
  7609. if (this.nowIndicatorTimeoutID) {
  7610. clearTimeout(this.nowIndicatorTimeoutID);
  7611. this.nowIndicatorTimeoutID = null;
  7612. }
  7613. if (this.nowIndicatorIntervalID) {
  7614. clearInterval(this.nowIndicatorIntervalID);
  7615. this.nowIndicatorIntervalID = null;
  7616. }
  7617. if (this.isNowIndicatorRendered) {
  7618. this.unrenderNowIndicator();
  7619. this.isNowIndicatorRendered = false;
  7620. }
  7621. };
  7622. View.prototype.getNowIndicatorUnit = function (dateProfile, dateProfileGenerator) {
  7623. // subclasses should implement
  7624. };
  7625. // Renders a current time indicator at the given datetime
  7626. View.prototype.renderNowIndicator = function (date) {
  7627. // SUBCLASSES MUST PASS TO CHILDREN!
  7628. };
  7629. // Undoes the rendering actions from renderNowIndicator
  7630. View.prototype.unrenderNowIndicator = function () {
  7631. // SUBCLASSES MUST PASS TO CHILDREN!
  7632. };
  7633. /* Scroller
  7634. ------------------------------------------------------------------------------------------------------------------*/
  7635. View.prototype.addScroll = function (scroll, isForced) {
  7636. if (isForced) {
  7637. scroll.isForced = isForced;
  7638. }
  7639. __assign(this.queuedScroll || (this.queuedScroll = {}), scroll);
  7640. };
  7641. View.prototype.popScroll = function (isResize) {
  7642. this.applyQueuedScroll(isResize);
  7643. this.queuedScroll = null;
  7644. };
  7645. View.prototype.applyQueuedScroll = function (isResize) {
  7646. if (this.queuedScroll) {
  7647. this.applyScroll(this.queuedScroll, isResize);
  7648. }
  7649. };
  7650. View.prototype.queryScroll = function () {
  7651. var scroll = {};
  7652. if (this.props.dateProfile) { // dates rendered yet?
  7653. __assign(scroll, this.queryDateScroll());
  7654. }
  7655. return scroll;
  7656. };
  7657. View.prototype.applyScroll = function (scroll, isResize) {
  7658. var duration = scroll.duration, isForced = scroll.isForced;
  7659. if (duration != null && !isForced) {
  7660. delete scroll.duration;
  7661. if (this.props.dateProfile) { // dates rendered yet?
  7662. __assign(scroll, this.computeDateScroll(duration));
  7663. }
  7664. }
  7665. if (this.props.dateProfile) { // dates rendered yet?
  7666. this.applyDateScroll(scroll);
  7667. }
  7668. };
  7669. View.prototype.computeDateScroll = function (duration) {
  7670. return {}; // subclasses must implement
  7671. };
  7672. View.prototype.queryDateScroll = function () {
  7673. return {}; // subclasses must implement
  7674. };
  7675. View.prototype.applyDateScroll = function (scroll) {
  7676. // subclasses must implement
  7677. };
  7678. // for API
  7679. View.prototype.scrollToDuration = function (duration) {
  7680. this.applyScroll({ duration: duration }, false);
  7681. };
  7682. return View;
  7683. }(DateComponent));
  7684. EmitterMixin.mixInto(View);
  7685. View.prototype.usesMinMaxTime = false;
  7686. View.prototype.dateProfileGeneratorClass = DateProfileGenerator;
  7687. var FgEventRenderer = /** @class */ (function () {
  7688. function FgEventRenderer() {
  7689. this.segs = [];
  7690. this.isSizeDirty = false;
  7691. }
  7692. FgEventRenderer.prototype.renderSegs = function (context, segs, mirrorInfo) {
  7693. this.context = context;
  7694. this.rangeUpdated(); // called too frequently :(
  7695. // render an `.el` on each seg
  7696. // returns a subset of the segs. segs that were actually rendered
  7697. segs = this.renderSegEls(segs, mirrorInfo);
  7698. this.segs = segs;
  7699. this.attachSegs(segs, mirrorInfo);
  7700. this.isSizeDirty = true;
  7701. triggerRenderedSegs(this.context, this.segs, Boolean(mirrorInfo));
  7702. };
  7703. FgEventRenderer.prototype.unrender = function (context, _segs, mirrorInfo) {
  7704. triggerWillRemoveSegs(this.context, this.segs, Boolean(mirrorInfo));
  7705. this.detachSegs(this.segs);
  7706. this.segs = [];
  7707. };
  7708. // Updates values that rely on options and also relate to range
  7709. FgEventRenderer.prototype.rangeUpdated = function () {
  7710. var options = this.context.options;
  7711. var displayEventTime;
  7712. var displayEventEnd;
  7713. this.eventTimeFormat = createFormatter(options.eventTimeFormat || this.computeEventTimeFormat(), options.defaultRangeSeparator);
  7714. displayEventTime = options.displayEventTime;
  7715. if (displayEventTime == null) {
  7716. displayEventTime = this.computeDisplayEventTime(); // might be based off of range
  7717. }
  7718. displayEventEnd = options.displayEventEnd;
  7719. if (displayEventEnd == null) {
  7720. displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range
  7721. }
  7722. this.displayEventTime = displayEventTime;
  7723. this.displayEventEnd = displayEventEnd;
  7724. };
  7725. // Renders and assigns an `el` property for each foreground event segment.
  7726. // Only returns segments that successfully rendered.
  7727. FgEventRenderer.prototype.renderSegEls = function (segs, mirrorInfo) {
  7728. var html = '';
  7729. var i;
  7730. if (segs.length) { // don't build an empty html string
  7731. // build a large concatenation of event segment HTML
  7732. for (i = 0; i < segs.length; i++) {
  7733. html += this.renderSegHtml(segs[i], mirrorInfo);
  7734. }
  7735. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7736. // Then, compute the 'el' for each segment. An el might be null if the eventRender callback returned false.
  7737. htmlToElements(html).forEach(function (el, i) {
  7738. var seg = segs[i];
  7739. if (el) {
  7740. seg.el = el;
  7741. }
  7742. });
  7743. segs = filterSegsViaEls(this.context, segs, Boolean(mirrorInfo));
  7744. }
  7745. return segs;
  7746. };
  7747. // Generic utility for generating the HTML classNames for an event segment's element
  7748. FgEventRenderer.prototype.getSegClasses = function (seg, isDraggable, isResizable, mirrorInfo) {
  7749. var classes = [
  7750. 'fc-event',
  7751. seg.isStart ? 'fc-start' : 'fc-not-start',
  7752. seg.isEnd ? 'fc-end' : 'fc-not-end'
  7753. ].concat(seg.eventRange.ui.classNames);
  7754. if (isDraggable) {
  7755. classes.push('fc-draggable');
  7756. }
  7757. if (isResizable) {
  7758. classes.push('fc-resizable');
  7759. }
  7760. if (mirrorInfo) {
  7761. classes.push('fc-mirror');
  7762. if (mirrorInfo.isDragging) {
  7763. classes.push('fc-dragging');
  7764. }
  7765. if (mirrorInfo.isResizing) {
  7766. classes.push('fc-resizing');
  7767. }
  7768. }
  7769. return classes;
  7770. };
  7771. // Compute the text that should be displayed on an event's element.
  7772. // `range` can be the Event object itself, or something range-like, with at least a `start`.
  7773. // If event times are disabled, or the event has no time, will return a blank string.
  7774. // If not specified, formatter will default to the eventTimeFormat setting,
  7775. // and displayEnd will default to the displayEventEnd setting.
  7776. FgEventRenderer.prototype.getTimeText = function (eventRange, formatter, displayEnd) {
  7777. var def = eventRange.def, instance = eventRange.instance;
  7778. return this._getTimeText(instance.range.start, def.hasEnd ? instance.range.end : null, def.allDay, formatter, displayEnd, instance.forcedStartTzo, instance.forcedEndTzo);
  7779. };
  7780. FgEventRenderer.prototype._getTimeText = function (start, end, allDay, formatter, displayEnd, forcedStartTzo, forcedEndTzo) {
  7781. var dateEnv = this.context.dateEnv;
  7782. if (formatter == null) {
  7783. formatter = this.eventTimeFormat;
  7784. }
  7785. if (displayEnd == null) {
  7786. displayEnd = this.displayEventEnd;
  7787. }
  7788. if (this.displayEventTime && !allDay) {
  7789. if (displayEnd && end) {
  7790. return dateEnv.formatRange(start, end, formatter, {
  7791. forcedStartTzo: forcedStartTzo,
  7792. forcedEndTzo: forcedEndTzo
  7793. });
  7794. }
  7795. else {
  7796. return dateEnv.format(start, formatter, {
  7797. forcedTzo: forcedStartTzo
  7798. });
  7799. }
  7800. }
  7801. return '';
  7802. };
  7803. FgEventRenderer.prototype.computeEventTimeFormat = function () {
  7804. return {
  7805. hour: 'numeric',
  7806. minute: '2-digit',
  7807. omitZeroMinute: true
  7808. };
  7809. };
  7810. FgEventRenderer.prototype.computeDisplayEventTime = function () {
  7811. return true;
  7812. };
  7813. FgEventRenderer.prototype.computeDisplayEventEnd = function () {
  7814. return true;
  7815. };
  7816. // Utility for generating event skin-related CSS properties
  7817. FgEventRenderer.prototype.getSkinCss = function (ui) {
  7818. return {
  7819. 'background-color': ui.backgroundColor,
  7820. 'border-color': ui.borderColor,
  7821. color: ui.textColor
  7822. };
  7823. };
  7824. FgEventRenderer.prototype.sortEventSegs = function (segs) {
  7825. var specs = this.context.eventOrderSpecs;
  7826. var objs = segs.map(buildSegCompareObj);
  7827. objs.sort(function (obj0, obj1) {
  7828. return compareByFieldSpecs(obj0, obj1, specs);
  7829. });
  7830. return objs.map(function (c) {
  7831. return c._seg;
  7832. });
  7833. };
  7834. FgEventRenderer.prototype.computeSizes = function (force) {
  7835. if (force || this.isSizeDirty) {
  7836. this.computeSegSizes(this.segs);
  7837. }
  7838. };
  7839. FgEventRenderer.prototype.assignSizes = function (force) {
  7840. if (force || this.isSizeDirty) {
  7841. this.assignSegSizes(this.segs);
  7842. this.isSizeDirty = false;
  7843. }
  7844. };
  7845. FgEventRenderer.prototype.computeSegSizes = function (segs) {
  7846. };
  7847. FgEventRenderer.prototype.assignSegSizes = function (segs) {
  7848. };
  7849. // Manipulation on rendered segs
  7850. FgEventRenderer.prototype.hideByHash = function (hash) {
  7851. if (hash) {
  7852. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7853. var seg = _a[_i];
  7854. if (hash[seg.eventRange.instance.instanceId]) {
  7855. seg.el.style.visibility = 'hidden';
  7856. }
  7857. }
  7858. }
  7859. };
  7860. FgEventRenderer.prototype.showByHash = function (hash) {
  7861. if (hash) {
  7862. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7863. var seg = _a[_i];
  7864. if (hash[seg.eventRange.instance.instanceId]) {
  7865. seg.el.style.visibility = '';
  7866. }
  7867. }
  7868. }
  7869. };
  7870. FgEventRenderer.prototype.selectByInstanceId = function (instanceId) {
  7871. if (instanceId) {
  7872. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7873. var seg = _a[_i];
  7874. var eventInstance = seg.eventRange.instance;
  7875. if (eventInstance && eventInstance.instanceId === instanceId &&
  7876. seg.el // necessary?
  7877. ) {
  7878. seg.el.classList.add('fc-selected');
  7879. }
  7880. }
  7881. }
  7882. };
  7883. FgEventRenderer.prototype.unselectByInstanceId = function (instanceId) {
  7884. if (instanceId) {
  7885. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7886. var seg = _a[_i];
  7887. if (seg.el) { // necessary?
  7888. seg.el.classList.remove('fc-selected');
  7889. }
  7890. }
  7891. }
  7892. };
  7893. return FgEventRenderer;
  7894. }());
  7895. // returns a object with all primitive props that can be compared
  7896. function buildSegCompareObj(seg) {
  7897. var eventDef = seg.eventRange.def;
  7898. var range = seg.eventRange.instance.range;
  7899. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  7900. var end = range.end ? range.end.valueOf() : 0; // "
  7901. return __assign({}, eventDef.extendedProps, eventDef, { id: eventDef.publicId, start: start,
  7902. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg // for later retrieval
  7903. });
  7904. }
  7905. /*
  7906. TODO: when refactoring this class, make a new FillRenderer instance for each `type`
  7907. */
  7908. var FillRenderer = /** @class */ (function () {
  7909. function FillRenderer() {
  7910. this.fillSegTag = 'div';
  7911. this.dirtySizeFlags = {};
  7912. this.containerElsByType = {};
  7913. this.segsByType = {};
  7914. }
  7915. FillRenderer.prototype.getSegsByType = function (type) {
  7916. return this.segsByType[type] || [];
  7917. };
  7918. FillRenderer.prototype.renderSegs = function (type, context, segs) {
  7919. var _a;
  7920. this.context = context;
  7921. var renderedSegs = this.renderSegEls(type, segs); // assignes `.el` to each seg. returns successfully rendered segs
  7922. var containerEls = this.attachSegs(type, renderedSegs);
  7923. if (containerEls) {
  7924. (_a = (this.containerElsByType[type] || (this.containerElsByType[type] = []))).push.apply(_a, containerEls);
  7925. }
  7926. this.segsByType[type] = renderedSegs;
  7927. if (type === 'bgEvent') {
  7928. triggerRenderedSegs(context, renderedSegs, false); // isMirror=false
  7929. }
  7930. this.dirtySizeFlags[type] = true;
  7931. };
  7932. // Unrenders a specific type of fill that is currently rendered on the grid
  7933. FillRenderer.prototype.unrender = function (type, context) {
  7934. var segs = this.segsByType[type];
  7935. if (segs) {
  7936. if (type === 'bgEvent') {
  7937. triggerWillRemoveSegs(context, segs, false); // isMirror=false
  7938. }
  7939. this.detachSegs(type, segs);
  7940. }
  7941. };
  7942. // Renders and assigns an `el` property for each fill segment. Generic enough to work with different types.
  7943. // Only returns segments that successfully rendered.
  7944. FillRenderer.prototype.renderSegEls = function (type, segs) {
  7945. var _this = this;
  7946. var html = '';
  7947. var i;
  7948. if (segs.length) {
  7949. // build a large concatenation of segment HTML
  7950. for (i = 0; i < segs.length; i++) {
  7951. html += this.renderSegHtml(type, segs[i]);
  7952. }
  7953. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7954. // Then, compute the 'el' for each segment.
  7955. htmlToElements(html).forEach(function (el, i) {
  7956. var seg = segs[i];
  7957. if (el) {
  7958. seg.el = el;
  7959. }
  7960. });
  7961. if (type === 'bgEvent') {
  7962. segs = filterSegsViaEls(this.context, segs, false // isMirror. background events can never be mirror elements
  7963. );
  7964. }
  7965. // correct element type? (would be bad if a non-TD were inserted into a table for example)
  7966. segs = segs.filter(function (seg) {
  7967. return elementMatches(seg.el, _this.fillSegTag);
  7968. });
  7969. }
  7970. return segs;
  7971. };
  7972. // Builds the HTML needed for one fill segment. Generic enough to work with different types.
  7973. FillRenderer.prototype.renderSegHtml = function (type, seg) {
  7974. var css = null;
  7975. var classNames = [];
  7976. if (type !== 'highlight' && type !== 'businessHours') {
  7977. css = {
  7978. 'background-color': seg.eventRange.ui.backgroundColor
  7979. };
  7980. }
  7981. if (type !== 'highlight') {
  7982. classNames = classNames.concat(seg.eventRange.ui.classNames);
  7983. }
  7984. if (type === 'businessHours') {
  7985. classNames.push('fc-bgevent');
  7986. }
  7987. else {
  7988. classNames.push('fc-' + type.toLowerCase());
  7989. }
  7990. return '<' + this.fillSegTag +
  7991. (classNames.length ? ' class="' + classNames.join(' ') + '"' : '') +
  7992. (css ? ' style="' + cssToStr(css) + '"' : '') +
  7993. '></' + this.fillSegTag + '>';
  7994. };
  7995. FillRenderer.prototype.detachSegs = function (type, segs) {
  7996. var containerEls = this.containerElsByType[type];
  7997. if (containerEls) {
  7998. containerEls.forEach(removeElement);
  7999. delete this.containerElsByType[type];
  8000. }
  8001. };
  8002. FillRenderer.prototype.computeSizes = function (force) {
  8003. for (var type in this.segsByType) {
  8004. if (force || this.dirtySizeFlags[type]) {
  8005. this.computeSegSizes(this.segsByType[type]);
  8006. }
  8007. }
  8008. };
  8009. FillRenderer.prototype.assignSizes = function (force) {
  8010. for (var type in this.segsByType) {
  8011. if (force || this.dirtySizeFlags[type]) {
  8012. this.assignSegSizes(this.segsByType[type]);
  8013. }
  8014. }
  8015. this.dirtySizeFlags = {};
  8016. };
  8017. FillRenderer.prototype.computeSegSizes = function (segs) {
  8018. };
  8019. FillRenderer.prototype.assignSegSizes = function (segs) {
  8020. };
  8021. return FillRenderer;
  8022. }());
  8023. var NamedTimeZoneImpl = /** @class */ (function () {
  8024. function NamedTimeZoneImpl(timeZoneName) {
  8025. this.timeZoneName = timeZoneName;
  8026. }
  8027. return NamedTimeZoneImpl;
  8028. }());
  8029. /*
  8030. An abstraction for a dragging interaction originating on an event.
  8031. Does higher-level things than PointerDragger, such as possibly:
  8032. - a "mirror" that moves with the pointer
  8033. - a minimum number of pixels or other criteria for a true drag to begin
  8034. subclasses must emit:
  8035. - pointerdown
  8036. - dragstart
  8037. - dragmove
  8038. - pointerup
  8039. - dragend
  8040. */
  8041. var ElementDragging = /** @class */ (function () {
  8042. function ElementDragging(el) {
  8043. this.emitter = new EmitterMixin();
  8044. }
  8045. ElementDragging.prototype.destroy = function () {
  8046. };
  8047. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  8048. // optional if subclass doesn't want to support a mirror
  8049. };
  8050. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  8051. // optional if subclass doesn't want to support a mirror
  8052. };
  8053. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  8054. // optional
  8055. };
  8056. return ElementDragging;
  8057. }());
  8058. function formatDate(dateInput, settings) {
  8059. if (settings === void 0) { settings = {}; }
  8060. var dateEnv = buildDateEnv$1(settings);
  8061. var formatter = createFormatter(settings);
  8062. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  8063. if (!dateMeta) { // TODO: warning?
  8064. return '';
  8065. }
  8066. return dateEnv.format(dateMeta.marker, formatter, {
  8067. forcedTzo: dateMeta.forcedTzo
  8068. });
  8069. }
  8070. function formatRange(startInput, endInput, settings // mixture of env and formatter settings
  8071. ) {
  8072. var dateEnv = buildDateEnv$1(typeof settings === 'object' && settings ? settings : {}); // pass in if non-null object
  8073. var formatter = createFormatter(settings, globalDefaults.defaultRangeSeparator);
  8074. var startMeta = dateEnv.createMarkerMeta(startInput);
  8075. var endMeta = dateEnv.createMarkerMeta(endInput);
  8076. if (!startMeta || !endMeta) { // TODO: warning?
  8077. return '';
  8078. }
  8079. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  8080. forcedStartTzo: startMeta.forcedTzo,
  8081. forcedEndTzo: endMeta.forcedTzo,
  8082. isEndExclusive: settings.isEndExclusive
  8083. });
  8084. }
  8085. // TODO: more DRY and optimized
  8086. function buildDateEnv$1(settings) {
  8087. var locale = buildLocale(settings.locale || 'en', parseRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  8088. // ensure required settings
  8089. settings = __assign({ timeZone: globalDefaults.timeZone, calendarSystem: 'gregory' }, settings, { locale: locale });
  8090. return new DateEnv(settings);
  8091. }
  8092. var DRAG_META_PROPS = {
  8093. startTime: createDuration,
  8094. duration: createDuration,
  8095. create: Boolean,
  8096. sourceId: String
  8097. };
  8098. var DRAG_META_DEFAULTS = {
  8099. create: true
  8100. };
  8101. function parseDragMeta(raw) {
  8102. var leftoverProps = {};
  8103. var refined = refineProps(raw, DRAG_META_PROPS, DRAG_META_DEFAULTS, leftoverProps);
  8104. refined.leftoverProps = leftoverProps;
  8105. return refined;
  8106. }
  8107. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  8108. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  8109. // if more than one week row, or if there are a lot of columns with not much space,
  8110. // put just the day numbers will be in each cell
  8111. if (!datesRepDistinctDays || dayCnt > 10) {
  8112. return { weekday: 'short' }; // "Sat"
  8113. }
  8114. else if (dayCnt > 1) {
  8115. return { weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }; // "Sat 11/12"
  8116. }
  8117. else {
  8118. return { weekday: 'long' }; // "Saturday"
  8119. }
  8120. }
  8121. function renderDateCell(dateMarker, dateProfile, datesRepDistinctDays, colCnt, colHeadFormat, context, colspan, otherAttrs) {
  8122. var dateEnv = context.dateEnv, theme = context.theme, options = context.options;
  8123. var isDateValid = rangeContainsMarker(dateProfile.activeRange, dateMarker); // TODO: called too frequently. cache somehow.
  8124. var classNames = [
  8125. 'fc-day-header',
  8126. theme.getClass('widgetHeader')
  8127. ];
  8128. var innerHtml;
  8129. if (typeof options.columnHeaderHtml === 'function') {
  8130. innerHtml = options.columnHeaderHtml(dateEnv.toDate(dateMarker));
  8131. }
  8132. else if (typeof options.columnHeaderText === 'function') {
  8133. innerHtml = htmlEscape(options.columnHeaderText(dateEnv.toDate(dateMarker)));
  8134. }
  8135. else {
  8136. innerHtml = htmlEscape(dateEnv.format(dateMarker, colHeadFormat));
  8137. }
  8138. // if only one row of days, the classNames on the header can represent the specific days beneath
  8139. if (datesRepDistinctDays) {
  8140. classNames = classNames.concat(
  8141. // includes the day-of-week class
  8142. // noThemeHighlight=true (don't highlight the header)
  8143. getDayClasses(dateMarker, dateProfile, context, true));
  8144. }
  8145. else {
  8146. classNames.push('fc-' + DAY_IDS[dateMarker.getUTCDay()]); // only add the day-of-week class
  8147. }
  8148. return '' +
  8149. '<th class="' + classNames.join(' ') + '"' +
  8150. ((isDateValid && datesRepDistinctDays) ?
  8151. ' data-date="' + dateEnv.formatIso(dateMarker, { omitTime: true }) + '"' :
  8152. '') +
  8153. (colspan > 1 ?
  8154. ' colspan="' + colspan + '"' :
  8155. '') +
  8156. (otherAttrs ?
  8157. ' ' + otherAttrs :
  8158. '') +
  8159. '>' +
  8160. (isDateValid ?
  8161. // don't make a link if the heading could represent multiple days, or if there's only one day (forceOff)
  8162. buildGotoAnchorHtml(options, dateEnv, { date: dateMarker, forceOff: !datesRepDistinctDays || colCnt === 1 }, innerHtml) :
  8163. // if not valid, display text, but no link
  8164. innerHtml) +
  8165. '</th>';
  8166. }
  8167. var DayHeader = /** @class */ (function (_super) {
  8168. __extends(DayHeader, _super);
  8169. function DayHeader(parentEl) {
  8170. var _this = _super.call(this) || this;
  8171. _this.renderSkeleton = memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  8172. _this.parentEl = parentEl;
  8173. return _this;
  8174. }
  8175. DayHeader.prototype.render = function (props, context) {
  8176. var dates = props.dates, datesRepDistinctDays = props.datesRepDistinctDays;
  8177. var parts = [];
  8178. this.renderSkeleton(context);
  8179. if (props.renderIntroHtml) {
  8180. parts.push(props.renderIntroHtml());
  8181. }
  8182. var colHeadFormat = createFormatter(context.options.columnHeaderFormat ||
  8183. computeFallbackHeaderFormat(datesRepDistinctDays, dates.length));
  8184. for (var _i = 0, dates_1 = dates; _i < dates_1.length; _i++) {
  8185. var date = dates_1[_i];
  8186. parts.push(renderDateCell(date, props.dateProfile, datesRepDistinctDays, dates.length, colHeadFormat, context));
  8187. }
  8188. if (context.isRtl) {
  8189. parts.reverse();
  8190. }
  8191. this.thead.innerHTML = '<tr>' + parts.join('') + '</tr>';
  8192. };
  8193. DayHeader.prototype.destroy = function () {
  8194. _super.prototype.destroy.call(this);
  8195. this.renderSkeleton.unrender();
  8196. };
  8197. DayHeader.prototype._renderSkeleton = function (context) {
  8198. var theme = context.theme;
  8199. var parentEl = this.parentEl;
  8200. parentEl.innerHTML = ''; // because might be nbsp
  8201. parentEl.appendChild(this.el = htmlToElement('<div class="fc-row ' + theme.getClass('headerRow') + '">' +
  8202. '<table class="' + theme.getClass('tableGrid') + '">' +
  8203. '<thead></thead>' +
  8204. '</table>' +
  8205. '</div>'));
  8206. this.thead = this.el.querySelector('thead');
  8207. };
  8208. DayHeader.prototype._unrenderSkeleton = function () {
  8209. removeElement(this.el);
  8210. };
  8211. return DayHeader;
  8212. }(Component));
  8213. var DaySeries = /** @class */ (function () {
  8214. function DaySeries(range, dateProfileGenerator) {
  8215. var date = range.start;
  8216. var end = range.end;
  8217. var indices = [];
  8218. var dates = [];
  8219. var dayIndex = -1;
  8220. while (date < end) { // loop each day from start to end
  8221. if (dateProfileGenerator.isHiddenDay(date)) {
  8222. indices.push(dayIndex + 0.5); // mark that it's between indices
  8223. }
  8224. else {
  8225. dayIndex++;
  8226. indices.push(dayIndex);
  8227. dates.push(date);
  8228. }
  8229. date = addDays(date, 1);
  8230. }
  8231. this.dates = dates;
  8232. this.indices = indices;
  8233. this.cnt = dates.length;
  8234. }
  8235. DaySeries.prototype.sliceRange = function (range) {
  8236. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8237. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8238. var clippedFirstIndex = Math.max(0, firstIndex);
  8239. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8240. // deal with in-between indices
  8241. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8242. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8243. if (clippedFirstIndex <= clippedLastIndex) {
  8244. return {
  8245. firstIndex: clippedFirstIndex,
  8246. lastIndex: clippedLastIndex,
  8247. isStart: firstIndex === clippedFirstIndex,
  8248. isEnd: lastIndex === clippedLastIndex
  8249. };
  8250. }
  8251. else {
  8252. return null;
  8253. }
  8254. };
  8255. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8256. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8257. // If before the first offset, returns a negative number.
  8258. // If after the last offset, returns an offset past the last cell offset.
  8259. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8260. DaySeries.prototype.getDateDayIndex = function (date) {
  8261. var indices = this.indices;
  8262. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8263. if (dayOffset < 0) {
  8264. return indices[0] - 1;
  8265. }
  8266. else if (dayOffset >= indices.length) {
  8267. return indices[indices.length - 1] + 1;
  8268. }
  8269. else {
  8270. return indices[dayOffset];
  8271. }
  8272. };
  8273. return DaySeries;
  8274. }());
  8275. var DayTable = /** @class */ (function () {
  8276. function DayTable(daySeries, breakOnWeeks) {
  8277. var dates = daySeries.dates;
  8278. var daysPerRow;
  8279. var firstDay;
  8280. var rowCnt;
  8281. if (breakOnWeeks) {
  8282. // count columns until the day-of-week repeats
  8283. firstDay = dates[0].getUTCDay();
  8284. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow++) {
  8285. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8286. break;
  8287. }
  8288. }
  8289. rowCnt = Math.ceil(dates.length / daysPerRow);
  8290. }
  8291. else {
  8292. rowCnt = 1;
  8293. daysPerRow = dates.length;
  8294. }
  8295. this.rowCnt = rowCnt;
  8296. this.colCnt = daysPerRow;
  8297. this.daySeries = daySeries;
  8298. this.cells = this.buildCells();
  8299. this.headerDates = this.buildHeaderDates();
  8300. }
  8301. DayTable.prototype.buildCells = function () {
  8302. var rows = [];
  8303. for (var row = 0; row < this.rowCnt; row++) {
  8304. var cells = [];
  8305. for (var col = 0; col < this.colCnt; col++) {
  8306. cells.push(this.buildCell(row, col));
  8307. }
  8308. rows.push(cells);
  8309. }
  8310. return rows;
  8311. };
  8312. DayTable.prototype.buildCell = function (row, col) {
  8313. return {
  8314. date: this.daySeries.dates[row * this.colCnt + col]
  8315. };
  8316. };
  8317. DayTable.prototype.buildHeaderDates = function () {
  8318. var dates = [];
  8319. for (var col = 0; col < this.colCnt; col++) {
  8320. dates.push(this.cells[0][col].date);
  8321. }
  8322. return dates;
  8323. };
  8324. DayTable.prototype.sliceRange = function (range) {
  8325. var colCnt = this.colCnt;
  8326. var seriesSeg = this.daySeries.sliceRange(range);
  8327. var segs = [];
  8328. if (seriesSeg) {
  8329. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8330. var index = firstIndex;
  8331. while (index <= lastIndex) {
  8332. var row = Math.floor(index / colCnt);
  8333. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8334. segs.push({
  8335. row: row,
  8336. firstCol: index % colCnt,
  8337. lastCol: (nextIndex - 1) % colCnt,
  8338. isStart: seriesSeg.isStart && index === firstIndex,
  8339. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex
  8340. });
  8341. index = nextIndex;
  8342. }
  8343. }
  8344. return segs;
  8345. };
  8346. return DayTable;
  8347. }());
  8348. var Slicer = /** @class */ (function () {
  8349. function Slicer() {
  8350. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8351. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8352. this.sliceEventStore = memoize(this._sliceEventStore);
  8353. this.sliceEventDrag = memoize(this._sliceInteraction);
  8354. this.sliceEventResize = memoize(this._sliceInteraction);
  8355. }
  8356. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, calendar, component) {
  8357. var extraArgs = [];
  8358. for (var _i = 5; _i < arguments.length; _i++) {
  8359. extraArgs[_i - 5] = arguments[_i];
  8360. }
  8361. var eventUiBases = props.eventUiBases;
  8362. var eventSegs = this.sliceEventStore.apply(this, [props.eventStore, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs));
  8363. return {
  8364. dateSelectionSegs: this.sliceDateSelection.apply(this, [props.dateSelection, eventUiBases, component].concat(extraArgs)),
  8365. businessHourSegs: this.sliceBusinessHours.apply(this, [props.businessHours, dateProfile, nextDayThreshold, calendar, component].concat(extraArgs)),
  8366. fgEventSegs: eventSegs.fg,
  8367. bgEventSegs: eventSegs.bg,
  8368. eventDrag: this.sliceEventDrag.apply(this, [props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8369. eventResize: this.sliceEventResize.apply(this, [props.eventResize, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8370. eventSelection: props.eventSelection
  8371. }; // TODO: give interactionSegs?
  8372. };
  8373. Slicer.prototype.sliceNowDate = function (// does not memoize
  8374. date, component) {
  8375. var extraArgs = [];
  8376. for (var _i = 2; _i < arguments.length; _i++) {
  8377. extraArgs[_i - 2] = arguments[_i];
  8378. }
  8379. return this._sliceDateSpan.apply(this, [{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8380. {},
  8381. component].concat(extraArgs));
  8382. };
  8383. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, calendar, component) {
  8384. var extraArgs = [];
  8385. for (var _i = 5; _i < arguments.length; _i++) {
  8386. extraArgs[_i - 5] = arguments[_i];
  8387. }
  8388. if (!businessHours) {
  8389. return [];
  8390. }
  8391. return this._sliceEventStore.apply(this, [expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), calendar),
  8392. {},
  8393. dateProfile,
  8394. nextDayThreshold,
  8395. component].concat(extraArgs)).bg;
  8396. };
  8397. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold, component) {
  8398. var extraArgs = [];
  8399. for (var _i = 5; _i < arguments.length; _i++) {
  8400. extraArgs[_i - 5] = arguments[_i];
  8401. }
  8402. if (eventStore) {
  8403. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8404. return {
  8405. bg: this.sliceEventRanges(rangeRes.bg, component, extraArgs),
  8406. fg: this.sliceEventRanges(rangeRes.fg, component, extraArgs)
  8407. };
  8408. }
  8409. else {
  8410. return { bg: [], fg: [] };
  8411. }
  8412. };
  8413. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold, component) {
  8414. var extraArgs = [];
  8415. for (var _i = 5; _i < arguments.length; _i++) {
  8416. extraArgs[_i - 5] = arguments[_i];
  8417. }
  8418. if (!interaction) {
  8419. return null;
  8420. }
  8421. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8422. return {
  8423. segs: this.sliceEventRanges(rangeRes.fg, component, extraArgs),
  8424. affectedInstances: interaction.affectedEvents.instances,
  8425. isEvent: interaction.isEvent,
  8426. sourceSeg: interaction.origSeg
  8427. };
  8428. };
  8429. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, component) {
  8430. var extraArgs = [];
  8431. for (var _i = 3; _i < arguments.length; _i++) {
  8432. extraArgs[_i - 3] = arguments[_i];
  8433. }
  8434. if (!dateSpan) {
  8435. return [];
  8436. }
  8437. var eventRange = fabricateEventRange(dateSpan, eventUiBases, component.context.calendar);
  8438. var segs = this.sliceRange.apply(this, [dateSpan.range].concat(extraArgs));
  8439. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8440. var seg = segs_1[_a];
  8441. seg.component = component;
  8442. seg.eventRange = eventRange;
  8443. }
  8444. return segs;
  8445. };
  8446. /*
  8447. "complete" seg means it has component and eventRange
  8448. */
  8449. Slicer.prototype.sliceEventRanges = function (eventRanges, component, // TODO: kill
  8450. extraArgs) {
  8451. var segs = [];
  8452. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8453. var eventRange = eventRanges_1[_i];
  8454. segs.push.apply(segs, this.sliceEventRange(eventRange, component, extraArgs));
  8455. }
  8456. return segs;
  8457. };
  8458. /*
  8459. "complete" seg means it has component and eventRange
  8460. */
  8461. Slicer.prototype.sliceEventRange = function (eventRange, component, // TODO: kill
  8462. extraArgs) {
  8463. var segs = this.sliceRange.apply(this, [eventRange.range].concat(extraArgs));
  8464. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8465. var seg = segs_2[_i];
  8466. seg.component = component;
  8467. seg.eventRange = eventRange;
  8468. seg.isStart = eventRange.isStart && seg.isStart;
  8469. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8470. }
  8471. return segs;
  8472. };
  8473. return Slicer;
  8474. }());
  8475. /*
  8476. for incorporating minTime/maxTime if appropriate
  8477. TODO: should be part of DateProfile!
  8478. TimelineDateProfile already does this btw
  8479. */
  8480. function computeActiveRange(dateProfile, isComponentAllDay) {
  8481. var range = dateProfile.activeRange;
  8482. if (isComponentAllDay) {
  8483. return range;
  8484. }
  8485. return {
  8486. start: addMs(range.start, dateProfile.minTime.milliseconds),
  8487. end: addMs(range.end, dateProfile.maxTime.milliseconds - 864e5) // 864e5 = ms in a day
  8488. };
  8489. }
  8490. // exports
  8491. // --------------------------------------------------------------------------------------------------
  8492. var version = '4.4.0';
  8493. exports.Calendar = Calendar;
  8494. exports.Component = Component;
  8495. exports.ComponentContext = ComponentContext;
  8496. exports.DateComponent = DateComponent;
  8497. exports.DateEnv = DateEnv;
  8498. exports.DateProfileGenerator = DateProfileGenerator;
  8499. exports.DayHeader = DayHeader;
  8500. exports.DaySeries = DaySeries;
  8501. exports.DayTable = DayTable;
  8502. exports.ElementDragging = ElementDragging;
  8503. exports.ElementScrollController = ElementScrollController;
  8504. exports.EmitterMixin = EmitterMixin;
  8505. exports.EventApi = EventApi;
  8506. exports.FgEventRenderer = FgEventRenderer;
  8507. exports.FillRenderer = FillRenderer;
  8508. exports.Interaction = Interaction;
  8509. exports.Mixin = Mixin;
  8510. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  8511. exports.PositionCache = PositionCache;
  8512. exports.ScrollComponent = ScrollComponent;
  8513. exports.ScrollController = ScrollController;
  8514. exports.Slicer = Slicer;
  8515. exports.Splitter = Splitter;
  8516. exports.Theme = Theme;
  8517. exports.View = View;
  8518. exports.WindowScrollController = WindowScrollController;
  8519. exports.addDays = addDays;
  8520. exports.addDurations = addDurations;
  8521. exports.addMs = addMs;
  8522. exports.addWeeks = addWeeks;
  8523. exports.allowContextMenu = allowContextMenu;
  8524. exports.allowSelection = allowSelection;
  8525. exports.appendToElement = appendToElement;
  8526. exports.applyAll = applyAll;
  8527. exports.applyMutationToEventStore = applyMutationToEventStore;
  8528. exports.applyStyle = applyStyle;
  8529. exports.applyStyleProp = applyStyleProp;
  8530. exports.asRoughMinutes = asRoughMinutes;
  8531. exports.asRoughMs = asRoughMs;
  8532. exports.asRoughSeconds = asRoughSeconds;
  8533. exports.buildGotoAnchorHtml = buildGotoAnchorHtml;
  8534. exports.buildSegCompareObj = buildSegCompareObj;
  8535. exports.capitaliseFirstLetter = capitaliseFirstLetter;
  8536. exports.combineEventUis = combineEventUis;
  8537. exports.compareByFieldSpec = compareByFieldSpec;
  8538. exports.compareByFieldSpecs = compareByFieldSpecs;
  8539. exports.compareNumbers = compareNumbers;
  8540. exports.compensateScroll = compensateScroll;
  8541. exports.computeClippingRect = computeClippingRect;
  8542. exports.computeEdges = computeEdges;
  8543. exports.computeEventDraggable = computeEventDraggable;
  8544. exports.computeEventEndResizable = computeEventEndResizable;
  8545. exports.computeEventStartResizable = computeEventStartResizable;
  8546. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  8547. exports.computeHeightAndMargins = computeHeightAndMargins;
  8548. exports.computeInnerRect = computeInnerRect;
  8549. exports.computeRect = computeRect;
  8550. exports.computeVisibleDayRange = computeVisibleDayRange;
  8551. exports.config = config;
  8552. exports.constrainPoint = constrainPoint;
  8553. exports.createDuration = createDuration;
  8554. exports.createElement = createElement;
  8555. exports.createEmptyEventStore = createEmptyEventStore;
  8556. exports.createEventInstance = createEventInstance;
  8557. exports.createFormatter = createFormatter;
  8558. exports.createPlugin = createPlugin;
  8559. exports.cssToStr = cssToStr;
  8560. exports.debounce = debounce;
  8561. exports.diffDates = diffDates;
  8562. exports.diffDayAndTime = diffDayAndTime;
  8563. exports.diffDays = diffDays;
  8564. exports.diffPoints = diffPoints;
  8565. exports.diffWeeks = diffWeeks;
  8566. exports.diffWholeDays = diffWholeDays;
  8567. exports.diffWholeWeeks = diffWholeWeeks;
  8568. exports.disableCursor = disableCursor;
  8569. exports.distributeHeight = distributeHeight;
  8570. exports.elementClosest = elementClosest;
  8571. exports.elementMatches = elementMatches;
  8572. exports.enableCursor = enableCursor;
  8573. exports.eventTupleToStore = eventTupleToStore;
  8574. exports.filterEventStoreDefs = filterEventStoreDefs;
  8575. exports.filterHash = filterHash;
  8576. exports.findChildren = findChildren;
  8577. exports.findElements = findElements;
  8578. exports.flexibleCompare = flexibleCompare;
  8579. exports.forceClassName = forceClassName;
  8580. exports.formatDate = formatDate;
  8581. exports.formatIsoTimeString = formatIsoTimeString;
  8582. exports.formatRange = formatRange;
  8583. exports.getAllDayHtml = getAllDayHtml;
  8584. exports.getClippingParents = getClippingParents;
  8585. exports.getDayClasses = getDayClasses;
  8586. exports.getElSeg = getElSeg;
  8587. exports.getRectCenter = getRectCenter;
  8588. exports.getRelevantEvents = getRelevantEvents;
  8589. exports.globalDefaults = globalDefaults;
  8590. exports.greatestDurationDenominator = greatestDurationDenominator;
  8591. exports.hasBgRendering = hasBgRendering;
  8592. exports.htmlEscape = htmlEscape;
  8593. exports.htmlToElement = htmlToElement;
  8594. exports.insertAfterElement = insertAfterElement;
  8595. exports.interactionSettingsStore = interactionSettingsStore;
  8596. exports.interactionSettingsToStore = interactionSettingsToStore;
  8597. exports.intersectRanges = intersectRanges;
  8598. exports.intersectRects = intersectRects;
  8599. exports.isArraysEqual = isArraysEqual;
  8600. exports.isDateSpansEqual = isDateSpansEqual;
  8601. exports.isInt = isInt;
  8602. exports.isInteractionValid = isInteractionValid;
  8603. exports.isMultiDayRange = isMultiDayRange;
  8604. exports.isPropsEqual = isPropsEqual;
  8605. exports.isPropsValid = isPropsValid;
  8606. exports.isSingleDay = isSingleDay;
  8607. exports.isValidDate = isValidDate;
  8608. exports.listenBySelector = listenBySelector;
  8609. exports.mapHash = mapHash;
  8610. exports.matchCellWidths = matchCellWidths;
  8611. exports.memoize = memoize;
  8612. exports.memoizeOutput = memoizeOutput;
  8613. exports.memoizeRendering = memoizeRendering;
  8614. exports.mergeEventStores = mergeEventStores;
  8615. exports.multiplyDuration = multiplyDuration;
  8616. exports.padStart = padStart;
  8617. exports.parseBusinessHours = parseBusinessHours;
  8618. exports.parseDragMeta = parseDragMeta;
  8619. exports.parseEventDef = parseEventDef;
  8620. exports.parseFieldSpecs = parseFieldSpecs;
  8621. exports.parseMarker = parse;
  8622. exports.pointInsideRect = pointInsideRect;
  8623. exports.prependToElement = prependToElement;
  8624. exports.preventContextMenu = preventContextMenu;
  8625. exports.preventDefault = preventDefault;
  8626. exports.preventSelection = preventSelection;
  8627. exports.processScopedUiProps = processScopedUiProps;
  8628. exports.rangeContainsMarker = rangeContainsMarker;
  8629. exports.rangeContainsRange = rangeContainsRange;
  8630. exports.rangesEqual = rangesEqual;
  8631. exports.rangesIntersect = rangesIntersect;
  8632. exports.refineProps = refineProps;
  8633. exports.removeElement = removeElement;
  8634. exports.removeExact = removeExact;
  8635. exports.renderDateCell = renderDateCell;
  8636. exports.requestJson = requestJson;
  8637. exports.sliceEventStore = sliceEventStore;
  8638. exports.startOfDay = startOfDay;
  8639. exports.subtractInnerElHeight = subtractInnerElHeight;
  8640. exports.translateRect = translateRect;
  8641. exports.uncompensateScroll = uncompensateScroll;
  8642. exports.undistributeHeight = undistributeHeight;
  8643. exports.unpromisify = unpromisify;
  8644. exports.version = version;
  8645. exports.whenTransitionDone = whenTransitionDone;
  8646. exports.wholeDivideDurations = wholeDivideDurations;
  8647. Object.defineProperty(exports, '__esModule', { value: true });
  8648. }));
  8649. /*!
  8650. FullCalendar Day Grid Plugin v4.4.0
  8651. Docs & License: https://fullcalendar.io/
  8652. (c) 2019 Adam Shaw
  8653. */
  8654. (function (global, factory) {
  8655. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  8656. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  8657. (global = global || self, factory(global.FullCalendarDayGrid = {}, global.FullCalendar));
  8658. }(this, function (exports, core) { 'use strict';
  8659. /*! *****************************************************************************
  8660. Copyright (c) Microsoft Corporation. All rights reserved.
  8661. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  8662. this file except in compliance with the License. You may obtain a copy of the
  8663. License at http://www.apache.org/licenses/LICENSE-2.0
  8664. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  8665. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8666. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  8667. MERCHANTABLITY OR NON-INFRINGEMENT.
  8668. See the Apache Version 2.0 License for specific language governing permissions
  8669. and limitations under the License.
  8670. ***************************************************************************** */
  8671. /* global Reflect, Promise */
  8672. var extendStatics = function(d, b) {
  8673. extendStatics = Object.setPrototypeOf ||
  8674. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8675. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8676. return extendStatics(d, b);
  8677. };
  8678. function __extends(d, b) {
  8679. extendStatics(d, b);
  8680. function __() { this.constructor = d; }
  8681. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8682. }
  8683. var __assign = function() {
  8684. __assign = Object.assign || function __assign(t) {
  8685. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8686. s = arguments[i];
  8687. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8688. }
  8689. return t;
  8690. };
  8691. return __assign.apply(this, arguments);
  8692. };
  8693. var DayGridDateProfileGenerator = /** @class */ (function (_super) {
  8694. __extends(DayGridDateProfileGenerator, _super);
  8695. function DayGridDateProfileGenerator() {
  8696. return _super !== null && _super.apply(this, arguments) || this;
  8697. }
  8698. // Computes the date range that will be rendered.
  8699. DayGridDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  8700. var dateEnv = this.dateEnv;
  8701. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  8702. var start = renderRange.start;
  8703. var end = renderRange.end;
  8704. var endOfWeek;
  8705. // year and month views should be aligned with weeks. this is already done for week
  8706. if (/^(year|month)$/.test(currentRangeUnit)) {
  8707. start = dateEnv.startOfWeek(start);
  8708. // make end-of-week if not already
  8709. endOfWeek = dateEnv.startOfWeek(end);
  8710. if (endOfWeek.valueOf() !== end.valueOf()) {
  8711. end = core.addWeeks(endOfWeek, 1);
  8712. }
  8713. }
  8714. // ensure 6 weeks
  8715. if (this.options.monthMode &&
  8716. this.options.fixedWeekCount) {
  8717. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  8718. core.diffWeeks(start, end));
  8719. end = core.addWeeks(end, 6 - rowCnt);
  8720. }
  8721. return { start: start, end: end };
  8722. };
  8723. return DayGridDateProfileGenerator;
  8724. }(core.DateProfileGenerator));
  8725. /* A rectangular panel that is absolutely positioned over other content
  8726. ------------------------------------------------------------------------------------------------------------------------
  8727. Options:
  8728. - className (string)
  8729. - content (HTML string, element, or element array)
  8730. - parentEl
  8731. - top
  8732. - left
  8733. - right (the x coord of where the right edge should be. not a "CSS" right)
  8734. - autoHide (boolean)
  8735. - show (callback)
  8736. - hide (callback)
  8737. */
  8738. var Popover = /** @class */ (function () {
  8739. function Popover(options) {
  8740. var _this = this;
  8741. this.isHidden = true;
  8742. this.margin = 10; // the space required between the popover and the edges of the scroll container
  8743. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  8744. this.documentMousedown = function (ev) {
  8745. // only hide the popover if the click happened outside the popover
  8746. if (_this.el && !_this.el.contains(ev.target)) {
  8747. _this.hide();
  8748. }
  8749. };
  8750. this.options = options;
  8751. }
  8752. // Shows the popover on the specified position. Renders it if not already
  8753. Popover.prototype.show = function () {
  8754. if (this.isHidden) {
  8755. if (!this.el) {
  8756. this.render();
  8757. }
  8758. this.el.style.display = '';
  8759. this.position();
  8760. this.isHidden = false;
  8761. this.trigger('show');
  8762. }
  8763. };
  8764. // Hides the popover, through CSS, but does not remove it from the DOM
  8765. Popover.prototype.hide = function () {
  8766. if (!this.isHidden) {
  8767. this.el.style.display = 'none';
  8768. this.isHidden = true;
  8769. this.trigger('hide');
  8770. }
  8771. };
  8772. // Creates `this.el` and renders content inside of it
  8773. Popover.prototype.render = function () {
  8774. var _this = this;
  8775. var options = this.options;
  8776. var el = this.el = core.createElement('div', {
  8777. className: 'fc-popover ' + (options.className || ''),
  8778. style: {
  8779. top: '0',
  8780. left: '0'
  8781. }
  8782. });
  8783. if (typeof options.content === 'function') {
  8784. options.content(el);
  8785. }
  8786. options.parentEl.appendChild(el);
  8787. // when a click happens on anything inside with a 'fc-close' className, hide the popover
  8788. core.listenBySelector(el, 'click', '.fc-close', function (ev) {
  8789. _this.hide();
  8790. });
  8791. if (options.autoHide) {
  8792. document.addEventListener('mousedown', this.documentMousedown);
  8793. }
  8794. };
  8795. // Hides and unregisters any handlers
  8796. Popover.prototype.destroy = function () {
  8797. this.hide();
  8798. if (this.el) {
  8799. core.removeElement(this.el);
  8800. this.el = null;
  8801. }
  8802. document.removeEventListener('mousedown', this.documentMousedown);
  8803. };
  8804. // Positions the popover optimally, using the top/left/right options
  8805. Popover.prototype.position = function () {
  8806. var options = this.options;
  8807. var el = this.el;
  8808. var elDims = el.getBoundingClientRect(); // only used for width,height
  8809. var origin = core.computeRect(el.offsetParent);
  8810. var clippingRect = core.computeClippingRect(options.parentEl);
  8811. var top; // the "position" (not "offset") values for the popover
  8812. var left; //
  8813. // compute top and left
  8814. top = options.top || 0;
  8815. if (options.left !== undefined) {
  8816. left = options.left;
  8817. }
  8818. else if (options.right !== undefined) {
  8819. left = options.right - elDims.width; // derive the left value from the right value
  8820. }
  8821. else {
  8822. left = 0;
  8823. }
  8824. // constrain to the view port. if constrained by two edges, give precedence to top/left
  8825. top = Math.min(top, clippingRect.bottom - elDims.height - this.margin);
  8826. top = Math.max(top, clippingRect.top + this.margin);
  8827. left = Math.min(left, clippingRect.right - elDims.width - this.margin);
  8828. left = Math.max(left, clippingRect.left + this.margin);
  8829. core.applyStyle(el, {
  8830. top: top - origin.top,
  8831. left: left - origin.left
  8832. });
  8833. };
  8834. // Triggers a callback. Calls a function in the option hash of the same name.
  8835. // Arguments beyond the first `name` are forwarded on.
  8836. // TODO: better code reuse for this. Repeat code
  8837. // can kill this???
  8838. Popover.prototype.trigger = function (name) {
  8839. if (this.options[name]) {
  8840. this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
  8841. }
  8842. };
  8843. return Popover;
  8844. }());
  8845. /* Event-rendering methods for the DayGrid class
  8846. ----------------------------------------------------------------------------------------------------------------------*/
  8847. // "Simple" is bad a name. has nothing to do with SimpleDayGrid
  8848. var SimpleDayGridEventRenderer = /** @class */ (function (_super) {
  8849. __extends(SimpleDayGridEventRenderer, _super);
  8850. function SimpleDayGridEventRenderer() {
  8851. return _super !== null && _super.apply(this, arguments) || this;
  8852. }
  8853. // Builds the HTML to be used for the default element for an individual segment
  8854. SimpleDayGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
  8855. var context = this.context;
  8856. var eventRange = seg.eventRange;
  8857. var eventDef = eventRange.def;
  8858. var eventUi = eventRange.ui;
  8859. var allDay = eventDef.allDay;
  8860. var isDraggable = core.computeEventDraggable(context, eventDef, eventUi);
  8861. var isResizableFromStart = allDay && seg.isStart && core.computeEventStartResizable(context, eventDef, eventUi);
  8862. var isResizableFromEnd = allDay && seg.isEnd && core.computeEventEndResizable(context, eventDef, eventUi);
  8863. var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
  8864. var skinCss = core.cssToStr(this.getSkinCss(eventUi));
  8865. var timeHtml = '';
  8866. var timeText;
  8867. var titleHtml;
  8868. classes.unshift('fc-day-grid-event', 'fc-h-event');
  8869. // Only display a timed events time if it is the starting segment
  8870. if (seg.isStart) {
  8871. timeText = this.getTimeText(eventRange);
  8872. if (timeText) {
  8873. timeHtml = '<span class="fc-time">' + core.htmlEscape(timeText) + '</span>';
  8874. }
  8875. }
  8876. titleHtml =
  8877. '<span class="fc-title">' +
  8878. (core.htmlEscape(eventDef.title || '') || '&nbsp;') + // we always want one line of height
  8879. '</span>';
  8880. return '<a class="' + classes.join(' ') + '"' +
  8881. (eventDef.url ?
  8882. ' href="' + core.htmlEscape(eventDef.url) + '"' :
  8883. '') +
  8884. (skinCss ?
  8885. ' style="' + skinCss + '"' :
  8886. '') +
  8887. '>' +
  8888. '<div class="fc-content">' +
  8889. (context.options.dir === 'rtl' ?
  8890. titleHtml + ' ' + timeHtml : // put a natural space in between
  8891. timeHtml + ' ' + titleHtml //
  8892. ) +
  8893. '</div>' +
  8894. (isResizableFromStart ?
  8895. '<div class="fc-resizer fc-start-resizer"></div>' :
  8896. '') +
  8897. (isResizableFromEnd ?
  8898. '<div class="fc-resizer fc-end-resizer"></div>' :
  8899. '') +
  8900. '</a>';
  8901. };
  8902. // Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
  8903. SimpleDayGridEventRenderer.prototype.computeEventTimeFormat = function () {
  8904. return {
  8905. hour: 'numeric',
  8906. minute: '2-digit',
  8907. omitZeroMinute: true,
  8908. meridiem: 'narrow'
  8909. };
  8910. };
  8911. SimpleDayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  8912. return false; // TODO: somehow consider the originating DayGrid's column count
  8913. };
  8914. return SimpleDayGridEventRenderer;
  8915. }(core.FgEventRenderer));
  8916. /* Event-rendering methods for the DayGrid class
  8917. ----------------------------------------------------------------------------------------------------------------------*/
  8918. var DayGridEventRenderer = /** @class */ (function (_super) {
  8919. __extends(DayGridEventRenderer, _super);
  8920. function DayGridEventRenderer(dayGrid) {
  8921. var _this = _super.call(this) || this;
  8922. _this.dayGrid = dayGrid;
  8923. return _this;
  8924. }
  8925. // Renders the given foreground event segments onto the grid
  8926. DayGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  8927. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  8928. // append to each row's content skeleton
  8929. this.dayGrid.rowEls.forEach(function (rowNode, i) {
  8930. rowNode.querySelector('.fc-content-skeleton > table').appendChild(rowStructs[i].tbodyEl);
  8931. });
  8932. // removes the "more.." events popover
  8933. if (!mirrorInfo) {
  8934. this.dayGrid.removeSegPopover();
  8935. }
  8936. };
  8937. // Unrenders all currently rendered foreground event segments
  8938. DayGridEventRenderer.prototype.detachSegs = function () {
  8939. var rowStructs = this.rowStructs || [];
  8940. var rowStruct;
  8941. while ((rowStruct = rowStructs.pop())) {
  8942. core.removeElement(rowStruct.tbodyEl);
  8943. }
  8944. this.rowStructs = null;
  8945. };
  8946. // Uses the given events array to generate <tbody> elements that should be appended to each row's content skeleton.
  8947. // Returns an array of rowStruct objects (see the bottom of `renderSegRow`).
  8948. // PRECONDITION: each segment shoud already have a rendered and assigned `.el`
  8949. DayGridEventRenderer.prototype.renderSegRows = function (segs) {
  8950. var rowStructs = [];
  8951. var segRows;
  8952. var row;
  8953. segRows = this.groupSegRows(segs); // group into nested arrays
  8954. // iterate each row of segment groupings
  8955. for (row = 0; row < segRows.length; row++) {
  8956. rowStructs.push(this.renderSegRow(row, segRows[row]));
  8957. }
  8958. return rowStructs;
  8959. };
  8960. // Given a row # and an array of segments all in the same row, render a <tbody> element, a skeleton that contains
  8961. // the segments. Returns object with a bunch of internal data about how the render was calculated.
  8962. // NOTE: modifies rowSegs
  8963. DayGridEventRenderer.prototype.renderSegRow = function (row, rowSegs) {
  8964. var isRtl = this.context.isRtl;
  8965. var dayGrid = this.dayGrid;
  8966. var colCnt = dayGrid.colCnt;
  8967. var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels
  8968. var levelCnt = Math.max(1, segLevels.length); // ensure at least one level
  8969. var tbody = document.createElement('tbody');
  8970. var segMatrix = []; // lookup for which segments are rendered into which level+col cells
  8971. var cellMatrix = []; // lookup for all <td> elements of the level+col matrix
  8972. var loneCellMatrix = []; // lookup for <td> elements that only take up a single column
  8973. var i;
  8974. var levelSegs;
  8975. var col;
  8976. var tr;
  8977. var j;
  8978. var seg;
  8979. var td;
  8980. // populates empty cells from the current column (`col`) to `endCol`
  8981. function emptyCellsUntil(endCol) {
  8982. while (col < endCol) {
  8983. // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell
  8984. td = (loneCellMatrix[i - 1] || [])[col];
  8985. if (td) {
  8986. td.rowSpan = (td.rowSpan || 1) + 1;
  8987. }
  8988. else {
  8989. td = document.createElement('td');
  8990. tr.appendChild(td);
  8991. }
  8992. cellMatrix[i][col] = td;
  8993. loneCellMatrix[i][col] = td;
  8994. col++;
  8995. }
  8996. }
  8997. for (i = 0; i < levelCnt; i++) { // iterate through all levels
  8998. levelSegs = segLevels[i];
  8999. col = 0;
  9000. tr = document.createElement('tr');
  9001. segMatrix.push([]);
  9002. cellMatrix.push([]);
  9003. loneCellMatrix.push([]);
  9004. // levelCnt might be 1 even though there are no actual levels. protect against this.
  9005. // this single empty row is useful for styling.
  9006. if (levelSegs) {
  9007. for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
  9008. seg = levelSegs[j];
  9009. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  9010. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  9011. emptyCellsUntil(leftCol);
  9012. // create a container that occupies or more columns. append the event element.
  9013. td = core.createElement('td', { className: 'fc-event-container' }, seg.el);
  9014. if (leftCol !== rightCol) {
  9015. td.colSpan = rightCol - leftCol + 1;
  9016. }
  9017. else { // a single-column segment
  9018. loneCellMatrix[i][col] = td;
  9019. }
  9020. while (col <= rightCol) {
  9021. cellMatrix[i][col] = td;
  9022. segMatrix[i][col] = seg;
  9023. col++;
  9024. }
  9025. tr.appendChild(td);
  9026. }
  9027. }
  9028. emptyCellsUntil(colCnt); // finish off the row
  9029. var introHtml = dayGrid.renderProps.renderIntroHtml();
  9030. if (introHtml) {
  9031. if (isRtl) {
  9032. core.appendToElement(tr, introHtml);
  9033. }
  9034. else {
  9035. core.prependToElement(tr, introHtml);
  9036. }
  9037. }
  9038. tbody.appendChild(tr);
  9039. }
  9040. return {
  9041. row: row,
  9042. tbodyEl: tbody,
  9043. cellMatrix: cellMatrix,
  9044. segMatrix: segMatrix,
  9045. segLevels: segLevels,
  9046. segs: rowSegs
  9047. };
  9048. };
  9049. // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels.
  9050. // NOTE: modifies segs
  9051. DayGridEventRenderer.prototype.buildSegLevels = function (segs) {
  9052. var isRtl = this.context.isRtl;
  9053. var colCnt = this.dayGrid.colCnt;
  9054. var levels = [];
  9055. var i;
  9056. var seg;
  9057. var j;
  9058. // Give preference to elements with certain criteria, so they have
  9059. // a chance to be closer to the top.
  9060. segs = this.sortEventSegs(segs);
  9061. for (i = 0; i < segs.length; i++) {
  9062. seg = segs[i];
  9063. // loop through levels, starting with the topmost, until the segment doesn't collide with other segments
  9064. for (j = 0; j < levels.length; j++) {
  9065. if (!isDaySegCollision(seg, levels[j])) {
  9066. break;
  9067. }
  9068. }
  9069. // `j` now holds the desired subrow index
  9070. seg.level = j;
  9071. seg.leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol; // for sorting only
  9072. seg.rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol // for sorting only
  9073. ;
  9074. (levels[j] || (levels[j] = [])).push(seg);
  9075. }
  9076. // order segments left-to-right. very important if calendar is RTL
  9077. for (j = 0; j < levels.length; j++) {
  9078. levels[j].sort(compareDaySegCols);
  9079. }
  9080. return levels;
  9081. };
  9082. // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's row
  9083. DayGridEventRenderer.prototype.groupSegRows = function (segs) {
  9084. var segRows = [];
  9085. var i;
  9086. for (i = 0; i < this.dayGrid.rowCnt; i++) {
  9087. segRows.push([]);
  9088. }
  9089. for (i = 0; i < segs.length; i++) {
  9090. segRows[segs[i].row].push(segs[i]);
  9091. }
  9092. return segRows;
  9093. };
  9094. // Computes a default `displayEventEnd` value if one is not expliclty defined
  9095. DayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  9096. return this.dayGrid.colCnt === 1; // we'll likely have space if there's only one day
  9097. };
  9098. return DayGridEventRenderer;
  9099. }(SimpleDayGridEventRenderer));
  9100. // Computes whether two segments' columns collide. They are assumed to be in the same row.
  9101. function isDaySegCollision(seg, otherSegs) {
  9102. var i;
  9103. var otherSeg;
  9104. for (i = 0; i < otherSegs.length; i++) {
  9105. otherSeg = otherSegs[i];
  9106. if (otherSeg.firstCol <= seg.lastCol &&
  9107. otherSeg.lastCol >= seg.firstCol) {
  9108. return true;
  9109. }
  9110. }
  9111. return false;
  9112. }
  9113. // A cmp function for determining the leftmost event
  9114. function compareDaySegCols(a, b) {
  9115. return a.leftCol - b.leftCol;
  9116. }
  9117. var DayGridMirrorRenderer = /** @class */ (function (_super) {
  9118. __extends(DayGridMirrorRenderer, _super);
  9119. function DayGridMirrorRenderer() {
  9120. return _super !== null && _super.apply(this, arguments) || this;
  9121. }
  9122. DayGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  9123. var sourceSeg = mirrorInfo.sourceSeg;
  9124. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  9125. // inject each new event skeleton into each associated row
  9126. this.dayGrid.rowEls.forEach(function (rowNode, row) {
  9127. var skeletonEl = core.htmlToElement('<div class="fc-mirror-skeleton"><table></table></div>'); // will be absolutely positioned
  9128. var skeletonTopEl;
  9129. var skeletonTop;
  9130. // If there is an original segment, match the top position. Otherwise, put it at the row's top level
  9131. if (sourceSeg && sourceSeg.row === row) {
  9132. skeletonTopEl = sourceSeg.el;
  9133. }
  9134. else {
  9135. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton tbody');
  9136. if (!skeletonTopEl) { // when no events
  9137. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton table');
  9138. }
  9139. }
  9140. skeletonTop = skeletonTopEl.getBoundingClientRect().top -
  9141. rowNode.getBoundingClientRect().top; // the offsetParent origin
  9142. skeletonEl.style.top = skeletonTop + 'px';
  9143. skeletonEl.querySelector('table').appendChild(rowStructs[row].tbodyEl);
  9144. rowNode.appendChild(skeletonEl);
  9145. });
  9146. };
  9147. return DayGridMirrorRenderer;
  9148. }(DayGridEventRenderer));
  9149. var EMPTY_CELL_HTML = '<td style="pointer-events:none"></td>';
  9150. var DayGridFillRenderer = /** @class */ (function (_super) {
  9151. __extends(DayGridFillRenderer, _super);
  9152. function DayGridFillRenderer(dayGrid) {
  9153. var _this = _super.call(this) || this;
  9154. _this.fillSegTag = 'td'; // override the default tag name
  9155. _this.dayGrid = dayGrid;
  9156. return _this;
  9157. }
  9158. DayGridFillRenderer.prototype.renderSegs = function (type, context, segs) {
  9159. // don't render timed background events
  9160. if (type === 'bgEvent') {
  9161. segs = segs.filter(function (seg) {
  9162. return seg.eventRange.def.allDay;
  9163. });
  9164. }
  9165. _super.prototype.renderSegs.call(this, type, context, segs);
  9166. };
  9167. DayGridFillRenderer.prototype.attachSegs = function (type, segs) {
  9168. var els = [];
  9169. var i;
  9170. var seg;
  9171. var skeletonEl;
  9172. for (i = 0; i < segs.length; i++) {
  9173. seg = segs[i];
  9174. skeletonEl = this.renderFillRow(type, seg);
  9175. this.dayGrid.rowEls[seg.row].appendChild(skeletonEl);
  9176. els.push(skeletonEl);
  9177. }
  9178. return els;
  9179. };
  9180. // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered.
  9181. DayGridFillRenderer.prototype.renderFillRow = function (type, seg) {
  9182. var dayGrid = this.dayGrid;
  9183. var isRtl = this.context.isRtl;
  9184. var colCnt = dayGrid.colCnt;
  9185. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  9186. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  9187. var startCol = leftCol;
  9188. var endCol = rightCol + 1;
  9189. var className;
  9190. var skeletonEl;
  9191. var trEl;
  9192. if (type === 'businessHours') {
  9193. className = 'bgevent';
  9194. }
  9195. else {
  9196. className = type.toLowerCase();
  9197. }
  9198. skeletonEl = core.htmlToElement('<div class="fc-' + className + '-skeleton">' +
  9199. '<table><tr></tr></table>' +
  9200. '</div>');
  9201. trEl = skeletonEl.getElementsByTagName('tr')[0];
  9202. if (startCol > 0) {
  9203. core.appendToElement(trEl,
  9204. // will create (startCol + 1) td's
  9205. new Array(startCol + 1).join(EMPTY_CELL_HTML));
  9206. }
  9207. seg.el.colSpan = endCol - startCol;
  9208. trEl.appendChild(seg.el);
  9209. if (endCol < colCnt) {
  9210. core.appendToElement(trEl,
  9211. // will create (colCnt - endCol) td's
  9212. new Array(colCnt - endCol + 1).join(EMPTY_CELL_HTML));
  9213. }
  9214. var introHtml = dayGrid.renderProps.renderIntroHtml();
  9215. if (introHtml) {
  9216. if (isRtl) {
  9217. core.appendToElement(trEl, introHtml);
  9218. }
  9219. else {
  9220. core.prependToElement(trEl, introHtml);
  9221. }
  9222. }
  9223. return skeletonEl;
  9224. };
  9225. return DayGridFillRenderer;
  9226. }(core.FillRenderer));
  9227. var DayTile = /** @class */ (function (_super) {
  9228. __extends(DayTile, _super);
  9229. function DayTile(el) {
  9230. var _this = _super.call(this, el) || this;
  9231. var eventRenderer = _this.eventRenderer = new DayTileEventRenderer(_this);
  9232. var renderFrame = _this.renderFrame = core.memoizeRendering(_this._renderFrame);
  9233. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderFrame]);
  9234. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  9235. _this.renderEventDrag = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  9236. _this.renderEventResize = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  9237. return _this;
  9238. }
  9239. DayTile.prototype.firstContext = function (context) {
  9240. context.calendar.registerInteractiveComponent(this, {
  9241. el: this.el,
  9242. useEventCenter: false
  9243. });
  9244. };
  9245. DayTile.prototype.render = function (props, context) {
  9246. this.renderFrame(props.date);
  9247. this.renderFgEvents(context, props.fgSegs);
  9248. this.renderEventSelection(props.eventSelection);
  9249. this.renderEventDrag(props.eventDragInstances);
  9250. this.renderEventResize(props.eventResizeInstances);
  9251. };
  9252. DayTile.prototype.destroy = function () {
  9253. _super.prototype.destroy.call(this);
  9254. this.renderFrame.unrender(); // should unrender everything else
  9255. this.context.calendar.unregisterInteractiveComponent(this);
  9256. };
  9257. DayTile.prototype._renderFrame = function (date) {
  9258. var _a = this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options;
  9259. var title = dateEnv.format(date, core.createFormatter(options.dayPopoverFormat) // TODO: cache
  9260. );
  9261. this.el.innerHTML =
  9262. '<div class="fc-header ' + theme.getClass('popoverHeader') + '">' +
  9263. '<span class="fc-title">' +
  9264. core.htmlEscape(title) +
  9265. '</span>' +
  9266. '<span class="fc-close ' + theme.getIconClass('close') + '"></span>' +
  9267. '</div>' +
  9268. '<div class="fc-body ' + theme.getClass('popoverContent') + '">' +
  9269. '<div class="fc-event-container"></div>' +
  9270. '</div>';
  9271. this.segContainerEl = this.el.querySelector('.fc-event-container');
  9272. };
  9273. DayTile.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  9274. var date = this.props.date; // HACK
  9275. if (positionLeft < elWidth && positionTop < elHeight) {
  9276. return {
  9277. component: this,
  9278. dateSpan: {
  9279. allDay: true,
  9280. range: { start: date, end: core.addDays(date, 1) }
  9281. },
  9282. dayEl: this.el,
  9283. rect: {
  9284. left: 0,
  9285. top: 0,
  9286. right: elWidth,
  9287. bottom: elHeight
  9288. },
  9289. layer: 1
  9290. };
  9291. }
  9292. };
  9293. return DayTile;
  9294. }(core.DateComponent));
  9295. var DayTileEventRenderer = /** @class */ (function (_super) {
  9296. __extends(DayTileEventRenderer, _super);
  9297. function DayTileEventRenderer(dayTile) {
  9298. var _this = _super.call(this) || this;
  9299. _this.dayTile = dayTile;
  9300. return _this;
  9301. }
  9302. DayTileEventRenderer.prototype.attachSegs = function (segs) {
  9303. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  9304. var seg = segs_1[_i];
  9305. this.dayTile.segContainerEl.appendChild(seg.el);
  9306. }
  9307. };
  9308. DayTileEventRenderer.prototype.detachSegs = function (segs) {
  9309. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  9310. var seg = segs_2[_i];
  9311. core.removeElement(seg.el);
  9312. }
  9313. };
  9314. return DayTileEventRenderer;
  9315. }(SimpleDayGridEventRenderer));
  9316. var DayBgRow = /** @class */ (function () {
  9317. function DayBgRow(context) {
  9318. this.context = context;
  9319. }
  9320. DayBgRow.prototype.renderHtml = function (props) {
  9321. var parts = [];
  9322. if (props.renderIntroHtml) {
  9323. parts.push(props.renderIntroHtml());
  9324. }
  9325. for (var _i = 0, _a = props.cells; _i < _a.length; _i++) {
  9326. var cell = _a[_i];
  9327. parts.push(renderCellHtml(cell.date, props.dateProfile, this.context, cell.htmlAttrs));
  9328. }
  9329. if (!props.cells.length) {
  9330. parts.push('<td class="fc-day ' + this.context.theme.getClass('widgetContent') + '"></td>');
  9331. }
  9332. if (this.context.options.dir === 'rtl') {
  9333. parts.reverse();
  9334. }
  9335. return '<tr>' + parts.join('') + '</tr>';
  9336. };
  9337. return DayBgRow;
  9338. }());
  9339. function renderCellHtml(date, dateProfile, context, otherAttrs) {
  9340. var dateEnv = context.dateEnv, theme = context.theme;
  9341. var isDateValid = core.rangeContainsMarker(dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  9342. var classes = core.getDayClasses(date, dateProfile, context);
  9343. classes.unshift('fc-day', theme.getClass('widgetContent'));
  9344. return '<td class="' + classes.join(' ') + '"' +
  9345. (isDateValid ?
  9346. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  9347. '') +
  9348. (otherAttrs ?
  9349. ' ' + otherAttrs :
  9350. '') +
  9351. '></td>';
  9352. }
  9353. var DAY_NUM_FORMAT = core.createFormatter({ day: 'numeric' });
  9354. var WEEK_NUM_FORMAT = core.createFormatter({ week: 'numeric' });
  9355. var DayGrid = /** @class */ (function (_super) {
  9356. __extends(DayGrid, _super);
  9357. function DayGrid(el, renderProps) {
  9358. var _this = _super.call(this, el) || this;
  9359. _this.bottomCoordPadding = 0; // hack for extending the hit area for the last row of the coordinate grid
  9360. _this.isCellSizesDirty = false;
  9361. _this.renderProps = renderProps;
  9362. var eventRenderer = _this.eventRenderer = new DayGridEventRenderer(_this);
  9363. var fillRenderer = _this.fillRenderer = new DayGridFillRenderer(_this);
  9364. _this.mirrorRenderer = new DayGridMirrorRenderer(_this);
  9365. var renderCells = _this.renderCells = core.memoizeRendering(_this._renderCells, _this._unrenderCells);
  9366. _this.renderBusinessHours = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderCells]);
  9367. _this.renderDateSelection = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'highlight'), fillRenderer.unrender.bind(fillRenderer, 'highlight'), [renderCells]);
  9368. _this.renderBgEvents = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderCells]);
  9369. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderCells]);
  9370. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  9371. _this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderCells]);
  9372. _this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderCells]);
  9373. return _this;
  9374. }
  9375. DayGrid.prototype.render = function (props, context) {
  9376. var cells = props.cells;
  9377. this.rowCnt = cells.length;
  9378. this.colCnt = cells[0].length;
  9379. this.renderCells(cells, props.isRigid);
  9380. this.renderBusinessHours(context, props.businessHourSegs);
  9381. this.renderDateSelection(context, props.dateSelectionSegs);
  9382. this.renderBgEvents(context, props.bgEventSegs);
  9383. this.renderFgEvents(context, props.fgEventSegs);
  9384. this.renderEventSelection(props.eventSelection);
  9385. this.renderEventDrag(props.eventDrag);
  9386. this.renderEventResize(props.eventResize);
  9387. if (this.segPopoverTile) {
  9388. this.updateSegPopoverTile();
  9389. }
  9390. };
  9391. DayGrid.prototype.destroy = function () {
  9392. _super.prototype.destroy.call(this);
  9393. this.renderCells.unrender(); // will unrender everything else
  9394. };
  9395. DayGrid.prototype.getCellRange = function (row, col) {
  9396. var start = this.props.cells[row][col].date;
  9397. var end = core.addDays(start, 1);
  9398. return { start: start, end: end };
  9399. };
  9400. DayGrid.prototype.updateSegPopoverTile = function (date, segs) {
  9401. var ownProps = this.props;
  9402. this.segPopoverTile.receiveProps({
  9403. date: date || this.segPopoverTile.props.date,
  9404. fgSegs: segs || this.segPopoverTile.props.fgSegs,
  9405. eventSelection: ownProps.eventSelection,
  9406. eventDragInstances: ownProps.eventDrag ? ownProps.eventDrag.affectedInstances : null,
  9407. eventResizeInstances: ownProps.eventResize ? ownProps.eventResize.affectedInstances : null
  9408. }, this.context);
  9409. };
  9410. /* Date Rendering
  9411. ------------------------------------------------------------------------------------------------------------------*/
  9412. DayGrid.prototype._renderCells = function (cells, isRigid) {
  9413. var _a = this.context, calendar = _a.calendar, view = _a.view, isRtl = _a.isRtl, dateEnv = _a.dateEnv;
  9414. var _b = this, rowCnt = _b.rowCnt, colCnt = _b.colCnt;
  9415. var html = '';
  9416. var row;
  9417. var col;
  9418. for (row = 0; row < rowCnt; row++) {
  9419. html += this.renderDayRowHtml(row, isRigid);
  9420. }
  9421. this.el.innerHTML = html;
  9422. this.rowEls = core.findElements(this.el, '.fc-row');
  9423. this.cellEls = core.findElements(this.el, '.fc-day, .fc-disabled-day');
  9424. if (isRtl) {
  9425. this.cellEls.reverse();
  9426. }
  9427. this.rowPositions = new core.PositionCache(this.el, this.rowEls, false, true // vertical
  9428. );
  9429. this.colPositions = new core.PositionCache(this.el, this.cellEls.slice(0, colCnt), // only the first row
  9430. true, false // horizontal
  9431. );
  9432. // trigger dayRender with each cell's element
  9433. for (row = 0; row < rowCnt; row++) {
  9434. for (col = 0; col < colCnt; col++) {
  9435. calendar.publiclyTrigger('dayRender', [
  9436. {
  9437. date: dateEnv.toDate(cells[row][col].date),
  9438. el: this.getCellEl(row, col),
  9439. view: view
  9440. }
  9441. ]);
  9442. }
  9443. }
  9444. this.isCellSizesDirty = true;
  9445. };
  9446. DayGrid.prototype._unrenderCells = function () {
  9447. this.removeSegPopover();
  9448. };
  9449. // Generates the HTML for a single row, which is a div that wraps a table.
  9450. // `row` is the row number.
  9451. DayGrid.prototype.renderDayRowHtml = function (row, isRigid) {
  9452. var theme = this.context.theme;
  9453. var classes = ['fc-row', 'fc-week', theme.getClass('dayRow')];
  9454. if (isRigid) {
  9455. classes.push('fc-rigid');
  9456. }
  9457. var bgRow = new DayBgRow(this.context);
  9458. return '' +
  9459. '<div class="' + classes.join(' ') + '">' +
  9460. '<div class="fc-bg">' +
  9461. '<table class="' + theme.getClass('tableGrid') + '">' +
  9462. bgRow.renderHtml({
  9463. cells: this.props.cells[row],
  9464. dateProfile: this.props.dateProfile,
  9465. renderIntroHtml: this.renderProps.renderBgIntroHtml
  9466. }) +
  9467. '</table>' +
  9468. '</div>' +
  9469. '<div class="fc-content-skeleton">' +
  9470. '<table>' +
  9471. (this.getIsNumbersVisible() ?
  9472. '<thead>' +
  9473. this.renderNumberTrHtml(row) +
  9474. '</thead>' :
  9475. '') +
  9476. '</table>' +
  9477. '</div>' +
  9478. '</div>';
  9479. };
  9480. DayGrid.prototype.getIsNumbersVisible = function () {
  9481. return this.getIsDayNumbersVisible() ||
  9482. this.renderProps.cellWeekNumbersVisible ||
  9483. this.renderProps.colWeekNumbersVisible;
  9484. };
  9485. DayGrid.prototype.getIsDayNumbersVisible = function () {
  9486. return this.rowCnt > 1;
  9487. };
  9488. /* Grid Number Rendering
  9489. ------------------------------------------------------------------------------------------------------------------*/
  9490. DayGrid.prototype.renderNumberTrHtml = function (row) {
  9491. var isRtl = this.context.isRtl;
  9492. var intro = this.renderProps.renderNumberIntroHtml(row, this);
  9493. return '' +
  9494. '<tr>' +
  9495. (isRtl ? '' : intro) +
  9496. this.renderNumberCellsHtml(row) +
  9497. (isRtl ? intro : '') +
  9498. '</tr>';
  9499. };
  9500. DayGrid.prototype.renderNumberCellsHtml = function (row) {
  9501. var htmls = [];
  9502. var col;
  9503. var date;
  9504. for (col = 0; col < this.colCnt; col++) {
  9505. date = this.props.cells[row][col].date;
  9506. htmls.push(this.renderNumberCellHtml(date));
  9507. }
  9508. if (this.context.isRtl) {
  9509. htmls.reverse();
  9510. }
  9511. return htmls.join('');
  9512. };
  9513. // Generates the HTML for the <td>s of the "number" row in the DayGrid's content skeleton.
  9514. // The number row will only exist if either day numbers or week numbers are turned on.
  9515. DayGrid.prototype.renderNumberCellHtml = function (date) {
  9516. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
  9517. var html = '';
  9518. var isDateValid = core.rangeContainsMarker(this.props.dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  9519. var isDayNumberVisible = this.getIsDayNumbersVisible() && isDateValid;
  9520. var classes;
  9521. var weekCalcFirstDow;
  9522. if (!isDayNumberVisible && !this.renderProps.cellWeekNumbersVisible) {
  9523. // no numbers in day cell (week number must be along the side)
  9524. return '<td></td>'; // will create an empty space above events :(
  9525. }
  9526. classes = core.getDayClasses(date, this.props.dateProfile, this.context);
  9527. classes.unshift('fc-day-top');
  9528. if (this.renderProps.cellWeekNumbersVisible) {
  9529. weekCalcFirstDow = dateEnv.weekDow;
  9530. }
  9531. html += '<td class="' + classes.join(' ') + '"' +
  9532. (isDateValid ?
  9533. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  9534. '') +
  9535. '>';
  9536. if (this.renderProps.cellWeekNumbersVisible && (date.getUTCDay() === weekCalcFirstDow)) {
  9537. html += core.buildGotoAnchorHtml(options, dateEnv, { date: date, type: 'week' }, { 'class': 'fc-week-number' }, dateEnv.format(date, WEEK_NUM_FORMAT) // inner HTML
  9538. );
  9539. }
  9540. if (isDayNumberVisible) {
  9541. html += core.buildGotoAnchorHtml(options, dateEnv, date, { 'class': 'fc-day-number' }, dateEnv.format(date, DAY_NUM_FORMAT) // inner HTML
  9542. );
  9543. }
  9544. html += '</td>';
  9545. return html;
  9546. };
  9547. /* Sizing
  9548. ------------------------------------------------------------------------------------------------------------------*/
  9549. DayGrid.prototype.updateSize = function (isResize) {
  9550. var calendar = this.context.calendar;
  9551. var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
  9552. if (isResize ||
  9553. this.isCellSizesDirty ||
  9554. calendar.isEventsUpdated // hack
  9555. ) {
  9556. this.buildPositionCaches();
  9557. this.isCellSizesDirty = false;
  9558. }
  9559. fillRenderer.computeSizes(isResize);
  9560. eventRenderer.computeSizes(isResize);
  9561. mirrorRenderer.computeSizes(isResize);
  9562. fillRenderer.assignSizes(isResize);
  9563. eventRenderer.assignSizes(isResize);
  9564. mirrorRenderer.assignSizes(isResize);
  9565. };
  9566. DayGrid.prototype.buildPositionCaches = function () {
  9567. this.buildColPositions();
  9568. this.buildRowPositions();
  9569. };
  9570. DayGrid.prototype.buildColPositions = function () {
  9571. this.colPositions.build();
  9572. };
  9573. DayGrid.prototype.buildRowPositions = function () {
  9574. this.rowPositions.build();
  9575. this.rowPositions.bottoms[this.rowCnt - 1] += this.bottomCoordPadding; // hack
  9576. };
  9577. /* Hit System
  9578. ------------------------------------------------------------------------------------------------------------------*/
  9579. DayGrid.prototype.positionToHit = function (leftPosition, topPosition) {
  9580. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  9581. var col = colPositions.leftToIndex(leftPosition);
  9582. var row = rowPositions.topToIndex(topPosition);
  9583. if (row != null && col != null) {
  9584. return {
  9585. row: row,
  9586. col: col,
  9587. dateSpan: {
  9588. range: this.getCellRange(row, col),
  9589. allDay: true
  9590. },
  9591. dayEl: this.getCellEl(row, col),
  9592. relativeRect: {
  9593. left: colPositions.lefts[col],
  9594. right: colPositions.rights[col],
  9595. top: rowPositions.tops[row],
  9596. bottom: rowPositions.bottoms[row]
  9597. }
  9598. };
  9599. }
  9600. };
  9601. /* Cell System
  9602. ------------------------------------------------------------------------------------------------------------------*/
  9603. // FYI: the first column is the leftmost column, regardless of date
  9604. DayGrid.prototype.getCellEl = function (row, col) {
  9605. return this.cellEls[row * this.colCnt + col];
  9606. };
  9607. /* Event Drag Visualization
  9608. ------------------------------------------------------------------------------------------------------------------*/
  9609. DayGrid.prototype._renderEventDrag = function (state) {
  9610. if (state) {
  9611. this.eventRenderer.hideByHash(state.affectedInstances);
  9612. this.fillRenderer.renderSegs('highlight', this.context, state.segs);
  9613. }
  9614. };
  9615. DayGrid.prototype._unrenderEventDrag = function (state) {
  9616. if (state) {
  9617. this.eventRenderer.showByHash(state.affectedInstances);
  9618. this.fillRenderer.unrender('highlight', this.context);
  9619. }
  9620. };
  9621. /* Event Resize Visualization
  9622. ------------------------------------------------------------------------------------------------------------------*/
  9623. DayGrid.prototype._renderEventResize = function (state) {
  9624. if (state) {
  9625. this.eventRenderer.hideByHash(state.affectedInstances);
  9626. this.fillRenderer.renderSegs('highlight', this.context, state.segs);
  9627. this.mirrorRenderer.renderSegs(this.context, state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  9628. }
  9629. };
  9630. DayGrid.prototype._unrenderEventResize = function (state) {
  9631. if (state) {
  9632. this.eventRenderer.showByHash(state.affectedInstances);
  9633. this.fillRenderer.unrender('highlight', this.context);
  9634. this.mirrorRenderer.unrender(this.context, state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  9635. }
  9636. };
  9637. /* More+ Link Popover
  9638. ------------------------------------------------------------------------------------------------------------------*/
  9639. DayGrid.prototype.removeSegPopover = function () {
  9640. if (this.segPopover) {
  9641. this.segPopover.hide(); // in handler, will call segPopover's removeElement
  9642. }
  9643. };
  9644. // Limits the number of "levels" (vertically stacking layers of events) for each row of the grid.
  9645. // `levelLimit` can be false (don't limit), a number, or true (should be computed).
  9646. DayGrid.prototype.limitRows = function (levelLimit) {
  9647. var rowStructs = this.eventRenderer.rowStructs || [];
  9648. var row; // row #
  9649. var rowLevelLimit;
  9650. for (row = 0; row < rowStructs.length; row++) {
  9651. this.unlimitRow(row);
  9652. if (!levelLimit) {
  9653. rowLevelLimit = false;
  9654. }
  9655. else if (typeof levelLimit === 'number') {
  9656. rowLevelLimit = levelLimit;
  9657. }
  9658. else {
  9659. rowLevelLimit = this.computeRowLevelLimit(row);
  9660. }
  9661. if (rowLevelLimit !== false) {
  9662. this.limitRow(row, rowLevelLimit);
  9663. }
  9664. }
  9665. };
  9666. // Computes the number of levels a row will accomodate without going outside its bounds.
  9667. // Assumes the row is "rigid" (maintains a constant height regardless of what is inside).
  9668. // `row` is the row number.
  9669. DayGrid.prototype.computeRowLevelLimit = function (row) {
  9670. var rowEl = this.rowEls[row]; // the containing "fake" row div
  9671. var rowBottom = rowEl.getBoundingClientRect().bottom; // relative to viewport!
  9672. var trEls = core.findChildren(this.eventRenderer.rowStructs[row].tbodyEl);
  9673. var i;
  9674. var trEl;
  9675. // Reveal one level <tr> at a time and stop when we find one out of bounds
  9676. for (i = 0; i < trEls.length; i++) {
  9677. trEl = trEls[i];
  9678. trEl.classList.remove('fc-limited'); // reset to original state (reveal)
  9679. if (trEl.getBoundingClientRect().bottom > rowBottom) {
  9680. return i;
  9681. }
  9682. }
  9683. return false; // should not limit at all
  9684. };
  9685. // Limits the given grid row to the maximum number of levels and injects "more" links if necessary.
  9686. // `row` is the row number.
  9687. // `levelLimit` is a number for the maximum (inclusive) number of levels allowed.
  9688. DayGrid.prototype.limitRow = function (row, levelLimit) {
  9689. var _this = this;
  9690. var colCnt = this.colCnt;
  9691. var isRtl = this.context.isRtl;
  9692. var rowStruct = this.eventRenderer.rowStructs[row];
  9693. var moreNodes = []; // array of "more" <a> links and <td> DOM nodes
  9694. var col = 0; // col #, left-to-right (not chronologically)
  9695. var levelSegs; // array of segment objects in the last allowable level, ordered left-to-right
  9696. var cellMatrix; // a matrix (by level, then column) of all <td> elements in the row
  9697. var limitedNodes; // array of temporarily hidden level <tr> and segment <td> DOM nodes
  9698. var i;
  9699. var seg;
  9700. var segsBelow; // array of segment objects below `seg` in the current `col`
  9701. var totalSegsBelow; // total number of segments below `seg` in any of the columns `seg` occupies
  9702. var colSegsBelow; // array of segment arrays, below seg, one for each column (offset from segs's first column)
  9703. var td;
  9704. var rowSpan;
  9705. var segMoreNodes; // array of "more" <td> cells that will stand-in for the current seg's cell
  9706. var j;
  9707. var moreTd;
  9708. var moreWrap;
  9709. var moreLink;
  9710. // Iterates through empty level cells and places "more" links inside if need be
  9711. var emptyCellsUntil = function (endCol) {
  9712. while (col < endCol) {
  9713. segsBelow = _this.getCellSegs(row, col, levelLimit);
  9714. if (segsBelow.length) {
  9715. td = cellMatrix[levelLimit - 1][col];
  9716. moreLink = _this.renderMoreLink(row, col, segsBelow);
  9717. moreWrap = core.createElement('div', null, moreLink);
  9718. td.appendChild(moreWrap);
  9719. moreNodes.push(moreWrap);
  9720. }
  9721. col++;
  9722. }
  9723. };
  9724. if (levelLimit && levelLimit < rowStruct.segLevels.length) { // is it actually over the limit?
  9725. levelSegs = rowStruct.segLevels[levelLimit - 1];
  9726. cellMatrix = rowStruct.cellMatrix;
  9727. limitedNodes = core.findChildren(rowStruct.tbodyEl).slice(levelLimit); // get level <tr> elements past the limit
  9728. limitedNodes.forEach(function (node) {
  9729. node.classList.add('fc-limited'); // hide elements and get a simple DOM-nodes array
  9730. });
  9731. // iterate though segments in the last allowable level
  9732. for (i = 0; i < levelSegs.length; i++) {
  9733. seg = levelSegs[i];
  9734. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  9735. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  9736. emptyCellsUntil(leftCol); // process empty cells before the segment
  9737. // determine *all* segments below `seg` that occupy the same columns
  9738. colSegsBelow = [];
  9739. totalSegsBelow = 0;
  9740. while (col <= rightCol) {
  9741. segsBelow = this.getCellSegs(row, col, levelLimit);
  9742. colSegsBelow.push(segsBelow);
  9743. totalSegsBelow += segsBelow.length;
  9744. col++;
  9745. }
  9746. if (totalSegsBelow) { // do we need to replace this segment with one or many "more" links?
  9747. td = cellMatrix[levelLimit - 1][leftCol]; // the segment's parent cell
  9748. rowSpan = td.rowSpan || 1;
  9749. segMoreNodes = [];
  9750. // make a replacement <td> for each column the segment occupies. will be one for each colspan
  9751. for (j = 0; j < colSegsBelow.length; j++) {
  9752. moreTd = core.createElement('td', { className: 'fc-more-cell', rowSpan: rowSpan });
  9753. segsBelow = colSegsBelow[j];
  9754. moreLink = this.renderMoreLink(row, leftCol + j, [seg].concat(segsBelow) // count seg as hidden too
  9755. );
  9756. moreWrap = core.createElement('div', null, moreLink);
  9757. moreTd.appendChild(moreWrap);
  9758. segMoreNodes.push(moreTd);
  9759. moreNodes.push(moreTd);
  9760. }
  9761. td.classList.add('fc-limited');
  9762. core.insertAfterElement(td, segMoreNodes);
  9763. limitedNodes.push(td);
  9764. }
  9765. }
  9766. emptyCellsUntil(this.colCnt); // finish off the level
  9767. rowStruct.moreEls = moreNodes; // for easy undoing later
  9768. rowStruct.limitedEls = limitedNodes; // for easy undoing later
  9769. }
  9770. };
  9771. // Reveals all levels and removes all "more"-related elements for a grid's row.
  9772. // `row` is a row number.
  9773. DayGrid.prototype.unlimitRow = function (row) {
  9774. var rowStruct = this.eventRenderer.rowStructs[row];
  9775. if (rowStruct.moreEls) {
  9776. rowStruct.moreEls.forEach(core.removeElement);
  9777. rowStruct.moreEls = null;
  9778. }
  9779. if (rowStruct.limitedEls) {
  9780. rowStruct.limitedEls.forEach(function (limitedEl) {
  9781. limitedEl.classList.remove('fc-limited');
  9782. });
  9783. rowStruct.limitedEls = null;
  9784. }
  9785. };
  9786. // Renders an <a> element that represents hidden event element for a cell.
  9787. // Responsible for attaching click handler as well.
  9788. DayGrid.prototype.renderMoreLink = function (row, col, hiddenSegs) {
  9789. var _this = this;
  9790. var _a = this.context, calendar = _a.calendar, view = _a.view, dateEnv = _a.dateEnv, options = _a.options, isRtl = _a.isRtl;
  9791. var a = core.createElement('a', { className: 'fc-more' });
  9792. a.innerText = this.getMoreLinkText(hiddenSegs.length);
  9793. a.addEventListener('click', function (ev) {
  9794. var clickOption = options.eventLimitClick;
  9795. var _col = isRtl ? _this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  9796. var date = _this.props.cells[row][_col].date;
  9797. var moreEl = ev.currentTarget;
  9798. var dayEl = _this.getCellEl(row, col);
  9799. var allSegs = _this.getCellSegs(row, col);
  9800. // rescope the segments to be within the cell's date
  9801. var reslicedAllSegs = _this.resliceDaySegs(allSegs, date);
  9802. var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date);
  9803. if (typeof clickOption === 'function') {
  9804. // the returned value can be an atomic option
  9805. clickOption = calendar.publiclyTrigger('eventLimitClick', [
  9806. {
  9807. date: dateEnv.toDate(date),
  9808. allDay: true,
  9809. dayEl: dayEl,
  9810. moreEl: moreEl,
  9811. segs: reslicedAllSegs,
  9812. hiddenSegs: reslicedHiddenSegs,
  9813. jsEvent: ev,
  9814. view: view
  9815. }
  9816. ]);
  9817. }
  9818. if (clickOption === 'popover') {
  9819. _this.showSegPopover(row, col, moreEl, reslicedAllSegs);
  9820. }
  9821. else if (typeof clickOption === 'string') { // a view name
  9822. calendar.zoomTo(date, clickOption);
  9823. }
  9824. });
  9825. return a;
  9826. };
  9827. // Reveals the popover that displays all events within a cell
  9828. DayGrid.prototype.showSegPopover = function (row, col, moreLink, segs) {
  9829. var _this = this;
  9830. var _a = this.context, calendar = _a.calendar, view = _a.view, theme = _a.theme, isRtl = _a.isRtl;
  9831. var _col = isRtl ? this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  9832. var moreWrap = moreLink.parentNode; // the <div> wrapper around the <a>
  9833. var topEl; // the element we want to match the top coordinate of
  9834. var options;
  9835. if (this.rowCnt === 1) {
  9836. topEl = view.el; // will cause the popover to cover any sort of header
  9837. }
  9838. else {
  9839. topEl = this.rowEls[row]; // will align with top of row
  9840. }
  9841. options = {
  9842. className: 'fc-more-popover ' + theme.getClass('popover'),
  9843. parentEl: view.el,
  9844. top: core.computeRect(topEl).top,
  9845. autoHide: true,
  9846. content: function (el) {
  9847. _this.segPopoverTile = new DayTile(el);
  9848. _this.updateSegPopoverTile(_this.props.cells[row][_col].date, segs);
  9849. },
  9850. hide: function () {
  9851. _this.segPopoverTile.destroy();
  9852. _this.segPopoverTile = null;
  9853. _this.segPopover.destroy();
  9854. _this.segPopover = null;
  9855. }
  9856. };
  9857. // Determine horizontal coordinate.
  9858. // We use the moreWrap instead of the <td> to avoid border confusion.
  9859. if (isRtl) {
  9860. options.right = core.computeRect(moreWrap).right + 1; // +1 to be over cell border
  9861. }
  9862. else {
  9863. options.left = core.computeRect(moreWrap).left - 1; // -1 to be over cell border
  9864. }
  9865. this.segPopover = new Popover(options);
  9866. this.segPopover.show();
  9867. calendar.releaseAfterSizingTriggers(); // hack for eventPositioned
  9868. };
  9869. // Given the events within an array of segment objects, reslice them to be in a single day
  9870. DayGrid.prototype.resliceDaySegs = function (segs, dayDate) {
  9871. var dayStart = dayDate;
  9872. var dayEnd = core.addDays(dayStart, 1);
  9873. var dayRange = { start: dayStart, end: dayEnd };
  9874. var newSegs = [];
  9875. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  9876. var seg = segs_1[_i];
  9877. var eventRange = seg.eventRange;
  9878. var origRange = eventRange.range;
  9879. var slicedRange = core.intersectRanges(origRange, dayRange);
  9880. if (slicedRange) {
  9881. newSegs.push(__assign({}, seg, { eventRange: {
  9882. def: eventRange.def,
  9883. ui: __assign({}, eventRange.ui, { durationEditable: false }),
  9884. instance: eventRange.instance,
  9885. range: slicedRange
  9886. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  9887. }
  9888. }
  9889. return newSegs;
  9890. };
  9891. // Generates the text that should be inside a "more" link, given the number of events it represents
  9892. DayGrid.prototype.getMoreLinkText = function (num) {
  9893. var opt = this.context.options.eventLimitText;
  9894. if (typeof opt === 'function') {
  9895. return opt(num);
  9896. }
  9897. else {
  9898. return '+' + num + ' ' + opt;
  9899. }
  9900. };
  9901. // Returns segments within a given cell.
  9902. // If `startLevel` is specified, returns only events including and below that level. Otherwise returns all segs.
  9903. DayGrid.prototype.getCellSegs = function (row, col, startLevel) {
  9904. var segMatrix = this.eventRenderer.rowStructs[row].segMatrix;
  9905. var level = startLevel || 0;
  9906. var segs = [];
  9907. var seg;
  9908. while (level < segMatrix.length) {
  9909. seg = segMatrix[level][col];
  9910. if (seg) {
  9911. segs.push(seg);
  9912. }
  9913. level++;
  9914. }
  9915. return segs;
  9916. };
  9917. return DayGrid;
  9918. }(core.DateComponent));
  9919. var WEEK_NUM_FORMAT$1 = core.createFormatter({ week: 'numeric' });
  9920. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  9921. ----------------------------------------------------------------------------------------------------------------------*/
  9922. // It is a manager for a DayGrid subcomponent, which does most of the heavy lifting.
  9923. // It is responsible for managing width/height.
  9924. var AbstractDayGridView = /** @class */ (function (_super) {
  9925. __extends(AbstractDayGridView, _super);
  9926. function AbstractDayGridView() {
  9927. var _this = _super !== null && _super.apply(this, arguments) || this;
  9928. _this.processOptions = core.memoize(_this._processOptions);
  9929. _this.renderSkeleton = core.memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  9930. /* Header Rendering
  9931. ------------------------------------------------------------------------------------------------------------------*/
  9932. // Generates the HTML that will go before the day-of week header cells
  9933. _this.renderHeadIntroHtml = function () {
  9934. var _a = _this.context, theme = _a.theme, options = _a.options;
  9935. if (_this.colWeekNumbersVisible) {
  9936. return '' +
  9937. '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.weekNumberStyleAttr() + '>' +
  9938. '<span>' + // needed for matchCellWidths
  9939. core.htmlEscape(options.weekLabel) +
  9940. '</span>' +
  9941. '</th>';
  9942. }
  9943. return '';
  9944. };
  9945. /* Day Grid Rendering
  9946. ------------------------------------------------------------------------------------------------------------------*/
  9947. // Generates the HTML that will go before content-skeleton cells that display the day/week numbers
  9948. _this.renderDayGridNumberIntroHtml = function (row, dayGrid) {
  9949. var _a = _this.context, options = _a.options, dateEnv = _a.dateEnv;
  9950. var weekStart = dayGrid.props.cells[row][0].date;
  9951. if (_this.colWeekNumbersVisible) {
  9952. return '' +
  9953. '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '>' +
  9954. core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths
  9955. options, dateEnv, { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 }, dateEnv.format(weekStart, WEEK_NUM_FORMAT$1) // inner HTML
  9956. ) +
  9957. '</td>';
  9958. }
  9959. return '';
  9960. };
  9961. // Generates the HTML that goes before the day bg cells for each day-row
  9962. _this.renderDayGridBgIntroHtml = function () {
  9963. var theme = _this.context.theme;
  9964. if (_this.colWeekNumbersVisible) {
  9965. return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '" ' + _this.weekNumberStyleAttr() + '></td>';
  9966. }
  9967. return '';
  9968. };
  9969. // Generates the HTML that goes before every other type of row generated by DayGrid.
  9970. // Affects mirror-skeleton and highlight-skeleton rows.
  9971. _this.renderDayGridIntroHtml = function () {
  9972. if (_this.colWeekNumbersVisible) {
  9973. return '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '></td>';
  9974. }
  9975. return '';
  9976. };
  9977. return _this;
  9978. }
  9979. AbstractDayGridView.prototype._processOptions = function (options) {
  9980. if (options.weekNumbers) {
  9981. if (options.weekNumbersWithinDays) {
  9982. this.cellWeekNumbersVisible = true;
  9983. this.colWeekNumbersVisible = false;
  9984. }
  9985. else {
  9986. this.cellWeekNumbersVisible = false;
  9987. this.colWeekNumbersVisible = true;
  9988. }
  9989. }
  9990. else {
  9991. this.colWeekNumbersVisible = false;
  9992. this.cellWeekNumbersVisible = false;
  9993. }
  9994. };
  9995. AbstractDayGridView.prototype.render = function (props, context) {
  9996. _super.prototype.render.call(this, props, context);
  9997. this.processOptions(context.options);
  9998. this.renderSkeleton(context);
  9999. };
  10000. AbstractDayGridView.prototype.destroy = function () {
  10001. _super.prototype.destroy.call(this);
  10002. this.renderSkeleton.unrender();
  10003. };
  10004. AbstractDayGridView.prototype._renderSkeleton = function (context) {
  10005. this.el.classList.add('fc-dayGrid-view');
  10006. this.el.innerHTML = this.renderSkeletonHtml();
  10007. this.scroller = new core.ScrollComponent('hidden', // overflow x
  10008. 'auto' // overflow y
  10009. );
  10010. var dayGridContainerEl = this.scroller.el;
  10011. this.el.querySelector('.fc-body > tr > td').appendChild(dayGridContainerEl);
  10012. dayGridContainerEl.classList.add('fc-day-grid-container');
  10013. var dayGridEl = core.createElement('div', { className: 'fc-day-grid' });
  10014. dayGridContainerEl.appendChild(dayGridEl);
  10015. this.dayGrid = new DayGrid(dayGridEl, {
  10016. renderNumberIntroHtml: this.renderDayGridNumberIntroHtml,
  10017. renderBgIntroHtml: this.renderDayGridBgIntroHtml,
  10018. renderIntroHtml: this.renderDayGridIntroHtml,
  10019. colWeekNumbersVisible: this.colWeekNumbersVisible,
  10020. cellWeekNumbersVisible: this.cellWeekNumbersVisible
  10021. });
  10022. };
  10023. AbstractDayGridView.prototype._unrenderSkeleton = function () {
  10024. this.el.classList.remove('fc-dayGrid-view');
  10025. this.dayGrid.destroy();
  10026. this.scroller.destroy();
  10027. };
  10028. // Builds the HTML skeleton for the view.
  10029. // The day-grid component will render inside of a container defined by this HTML.
  10030. AbstractDayGridView.prototype.renderSkeletonHtml = function () {
  10031. var _a = this.context, theme = _a.theme, options = _a.options;
  10032. return '' +
  10033. '<table class="' + theme.getClass('tableGrid') + '">' +
  10034. (options.columnHeader ?
  10035. '<thead class="fc-head">' +
  10036. '<tr>' +
  10037. '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
  10038. '</tr>' +
  10039. '</thead>' :
  10040. '') +
  10041. '<tbody class="fc-body">' +
  10042. '<tr>' +
  10043. '<td class="' + theme.getClass('widgetContent') + '"></td>' +
  10044. '</tr>' +
  10045. '</tbody>' +
  10046. '</table>';
  10047. };
  10048. // Generates an HTML attribute string for setting the width of the week number column, if it is known
  10049. AbstractDayGridView.prototype.weekNumberStyleAttr = function () {
  10050. if (this.weekNumberWidth != null) {
  10051. return 'style="width:' + this.weekNumberWidth + 'px"';
  10052. }
  10053. return '';
  10054. };
  10055. // Determines whether each row should have a constant height
  10056. AbstractDayGridView.prototype.hasRigidRows = function () {
  10057. var eventLimit = this.context.options.eventLimit;
  10058. return eventLimit && typeof eventLimit !== 'number';
  10059. };
  10060. /* Dimensions
  10061. ------------------------------------------------------------------------------------------------------------------*/
  10062. AbstractDayGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  10063. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
  10064. this.dayGrid.updateSize(isResize);
  10065. };
  10066. // Refreshes the horizontal dimensions of the view
  10067. AbstractDayGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  10068. var dayGrid = this.dayGrid;
  10069. var eventLimit = this.context.options.eventLimit;
  10070. var headRowEl = this.header ? this.header.el : null; // HACK
  10071. var scrollerHeight;
  10072. var scrollbarWidths;
  10073. // hack to give the view some height prior to dayGrid's columns being rendered
  10074. // TODO: separate setting height from scroller VS dayGrid.
  10075. if (!dayGrid.rowEls) {
  10076. if (!isAuto) {
  10077. scrollerHeight = this.computeScrollerHeight(viewHeight);
  10078. this.scroller.setHeight(scrollerHeight);
  10079. }
  10080. return;
  10081. }
  10082. if (this.colWeekNumbersVisible) {
  10083. // Make sure all week number cells running down the side have the same width.
  10084. this.weekNumberWidth = core.matchCellWidths(core.findElements(this.el, '.fc-week-number'));
  10085. }
  10086. // reset all heights to be natural
  10087. this.scroller.clear();
  10088. if (headRowEl) {
  10089. core.uncompensateScroll(headRowEl);
  10090. }
  10091. dayGrid.removeSegPopover(); // kill the "more" popover if displayed
  10092. // is the event limit a constant level number?
  10093. if (eventLimit && typeof eventLimit === 'number') {
  10094. dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after
  10095. }
  10096. // distribute the height to the rows
  10097. // (viewHeight is a "recommended" value if isAuto)
  10098. scrollerHeight = this.computeScrollerHeight(viewHeight);
  10099. this.setGridHeight(scrollerHeight, isAuto);
  10100. // is the event limit dynamically calculated?
  10101. if (eventLimit && typeof eventLimit !== 'number') {
  10102. dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set
  10103. }
  10104. if (!isAuto) { // should we force dimensions of the scroll container?
  10105. this.scroller.setHeight(scrollerHeight);
  10106. scrollbarWidths = this.scroller.getScrollbarWidths();
  10107. if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
  10108. if (headRowEl) {
  10109. core.compensateScroll(headRowEl, scrollbarWidths);
  10110. }
  10111. // doing the scrollbar compensation might have created text overflow which created more height. redo
  10112. scrollerHeight = this.computeScrollerHeight(viewHeight);
  10113. this.scroller.setHeight(scrollerHeight);
  10114. }
  10115. // guarantees the same scrollbar widths
  10116. this.scroller.lockOverflow(scrollbarWidths);
  10117. }
  10118. };
  10119. // given a desired total height of the view, returns what the height of the scroller should be
  10120. AbstractDayGridView.prototype.computeScrollerHeight = function (viewHeight) {
  10121. return viewHeight -
  10122. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  10123. };
  10124. // Sets the height of just the DayGrid component in this view
  10125. AbstractDayGridView.prototype.setGridHeight = function (height, isAuto) {
  10126. if (this.context.options.monthMode) {
  10127. // if auto, make the height of each row the height that it would be if there were 6 weeks
  10128. if (isAuto) {
  10129. height *= this.dayGrid.rowCnt / 6;
  10130. }
  10131. core.distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows
  10132. }
  10133. else {
  10134. if (isAuto) {
  10135. core.undistributeHeight(this.dayGrid.rowEls); // let the rows be their natural height with no expanding
  10136. }
  10137. else {
  10138. core.distributeHeight(this.dayGrid.rowEls, height, true); // true = compensate for height-hogging rows
  10139. }
  10140. }
  10141. };
  10142. /* Scroll
  10143. ------------------------------------------------------------------------------------------------------------------*/
  10144. AbstractDayGridView.prototype.computeDateScroll = function (duration) {
  10145. return { top: 0 };
  10146. };
  10147. AbstractDayGridView.prototype.queryDateScroll = function () {
  10148. return { top: this.scroller.getScrollTop() };
  10149. };
  10150. AbstractDayGridView.prototype.applyDateScroll = function (scroll) {
  10151. if (scroll.top !== undefined) {
  10152. this.scroller.setScrollTop(scroll.top);
  10153. }
  10154. };
  10155. return AbstractDayGridView;
  10156. }(core.View));
  10157. AbstractDayGridView.prototype.dateProfileGeneratorClass = DayGridDateProfileGenerator;
  10158. var SimpleDayGrid = /** @class */ (function (_super) {
  10159. __extends(SimpleDayGrid, _super);
  10160. function SimpleDayGrid(dayGrid) {
  10161. var _this = _super.call(this, dayGrid.el) || this;
  10162. _this.slicer = new DayGridSlicer();
  10163. _this.dayGrid = dayGrid;
  10164. return _this;
  10165. }
  10166. SimpleDayGrid.prototype.firstContext = function (context) {
  10167. context.calendar.registerInteractiveComponent(this, { el: this.dayGrid.el });
  10168. };
  10169. SimpleDayGrid.prototype.destroy = function () {
  10170. _super.prototype.destroy.call(this);
  10171. this.context.calendar.unregisterInteractiveComponent(this);
  10172. };
  10173. SimpleDayGrid.prototype.render = function (props, context) {
  10174. var dayGrid = this.dayGrid;
  10175. var dateProfile = props.dateProfile, dayTable = props.dayTable;
  10176. dayGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, context.calendar, dayGrid, dayTable), { dateProfile: dateProfile, cells: dayTable.cells, isRigid: props.isRigid }), context);
  10177. };
  10178. SimpleDayGrid.prototype.buildPositionCaches = function () {
  10179. this.dayGrid.buildPositionCaches();
  10180. };
  10181. SimpleDayGrid.prototype.queryHit = function (positionLeft, positionTop) {
  10182. var rawHit = this.dayGrid.positionToHit(positionLeft, positionTop);
  10183. if (rawHit) {
  10184. return {
  10185. component: this.dayGrid,
  10186. dateSpan: rawHit.dateSpan,
  10187. dayEl: rawHit.dayEl,
  10188. rect: {
  10189. left: rawHit.relativeRect.left,
  10190. right: rawHit.relativeRect.right,
  10191. top: rawHit.relativeRect.top,
  10192. bottom: rawHit.relativeRect.bottom
  10193. },
  10194. layer: 0
  10195. };
  10196. }
  10197. };
  10198. return SimpleDayGrid;
  10199. }(core.DateComponent));
  10200. var DayGridSlicer = /** @class */ (function (_super) {
  10201. __extends(DayGridSlicer, _super);
  10202. function DayGridSlicer() {
  10203. return _super !== null && _super.apply(this, arguments) || this;
  10204. }
  10205. DayGridSlicer.prototype.sliceRange = function (dateRange, dayTable) {
  10206. return dayTable.sliceRange(dateRange);
  10207. };
  10208. return DayGridSlicer;
  10209. }(core.Slicer));
  10210. var DayGridView = /** @class */ (function (_super) {
  10211. __extends(DayGridView, _super);
  10212. function DayGridView() {
  10213. var _this = _super !== null && _super.apply(this, arguments) || this;
  10214. _this.buildDayTable = core.memoize(buildDayTable);
  10215. return _this;
  10216. }
  10217. DayGridView.prototype.render = function (props, context) {
  10218. _super.prototype.render.call(this, props, context); // will call _renderSkeleton/_unrenderSkeleton
  10219. var dateProfile = this.props.dateProfile;
  10220. var dayTable = this.dayTable =
  10221. this.buildDayTable(dateProfile, props.dateProfileGenerator);
  10222. if (this.header) {
  10223. this.header.receiveProps({
  10224. dateProfile: dateProfile,
  10225. dates: dayTable.headerDates,
  10226. datesRepDistinctDays: dayTable.rowCnt === 1,
  10227. renderIntroHtml: this.renderHeadIntroHtml
  10228. }, context);
  10229. }
  10230. this.simpleDayGrid.receiveProps({
  10231. dateProfile: dateProfile,
  10232. dayTable: dayTable,
  10233. businessHours: props.businessHours,
  10234. dateSelection: props.dateSelection,
  10235. eventStore: props.eventStore,
  10236. eventUiBases: props.eventUiBases,
  10237. eventSelection: props.eventSelection,
  10238. eventDrag: props.eventDrag,
  10239. eventResize: props.eventResize,
  10240. isRigid: this.hasRigidRows(),
  10241. nextDayThreshold: this.context.nextDayThreshold
  10242. }, context);
  10243. };
  10244. DayGridView.prototype._renderSkeleton = function (context) {
  10245. _super.prototype._renderSkeleton.call(this, context);
  10246. if (context.options.columnHeader) {
  10247. this.header = new core.DayHeader(this.el.querySelector('.fc-head-container'));
  10248. }
  10249. this.simpleDayGrid = new SimpleDayGrid(this.dayGrid);
  10250. };
  10251. DayGridView.prototype._unrenderSkeleton = function () {
  10252. _super.prototype._unrenderSkeleton.call(this);
  10253. if (this.header) {
  10254. this.header.destroy();
  10255. }
  10256. this.simpleDayGrid.destroy();
  10257. };
  10258. return DayGridView;
  10259. }(AbstractDayGridView));
  10260. function buildDayTable(dateProfile, dateProfileGenerator) {
  10261. var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator);
  10262. return new core.DayTable(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  10263. }
  10264. var main = core.createPlugin({
  10265. defaultView: 'dayGridMonth',
  10266. views: {
  10267. dayGrid: DayGridView,
  10268. dayGridDay: {
  10269. type: 'dayGrid',
  10270. duration: { days: 1 }
  10271. },
  10272. dayGridWeek: {
  10273. type: 'dayGrid',
  10274. duration: { weeks: 1 }
  10275. },
  10276. dayGridMonth: {
  10277. type: 'dayGrid',
  10278. duration: { months: 1 },
  10279. monthMode: true,
  10280. fixedWeekCount: true
  10281. }
  10282. }
  10283. });
  10284. exports.AbstractDayGridView = AbstractDayGridView;
  10285. exports.DayBgRow = DayBgRow;
  10286. exports.DayGrid = DayGrid;
  10287. exports.DayGridSlicer = DayGridSlicer;
  10288. exports.DayGridView = DayGridView;
  10289. exports.SimpleDayGrid = SimpleDayGrid;
  10290. exports.buildBasicDayTable = buildDayTable;
  10291. exports.default = main;
  10292. Object.defineProperty(exports, '__esModule', { value: true });
  10293. }));
  10294. /*!
  10295. FullCalendar List View Plugin v4.4.0
  10296. Docs & License: https://fullcalendar.io/
  10297. (c) 2019 Adam Shaw
  10298. */
  10299. (function (global, factory) {
  10300. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  10301. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  10302. (global = global || self, factory(global.FullCalendarList = {}, global.FullCalendar));
  10303. }(this, function (exports, core) { 'use strict';
  10304. /*! *****************************************************************************
  10305. Copyright (c) Microsoft Corporation. All rights reserved.
  10306. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  10307. this file except in compliance with the License. You may obtain a copy of the
  10308. License at http://www.apache.org/licenses/LICENSE-2.0
  10309. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  10310. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  10311. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10312. MERCHANTABLITY OR NON-INFRINGEMENT.
  10313. See the Apache Version 2.0 License for specific language governing permissions
  10314. and limitations under the License.
  10315. ***************************************************************************** */
  10316. /* global Reflect, Promise */
  10317. var extendStatics = function(d, b) {
  10318. extendStatics = Object.setPrototypeOf ||
  10319. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10320. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10321. return extendStatics(d, b);
  10322. };
  10323. function __extends(d, b) {
  10324. extendStatics(d, b);
  10325. function __() { this.constructor = d; }
  10326. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10327. }
  10328. var ListEventRenderer = /** @class */ (function (_super) {
  10329. __extends(ListEventRenderer, _super);
  10330. function ListEventRenderer(listView) {
  10331. var _this = _super.call(this) || this;
  10332. _this.listView = listView;
  10333. return _this;
  10334. }
  10335. ListEventRenderer.prototype.attachSegs = function (segs) {
  10336. if (!segs.length) {
  10337. this.listView.renderEmptyMessage();
  10338. }
  10339. else {
  10340. this.listView.renderSegList(segs);
  10341. }
  10342. };
  10343. ListEventRenderer.prototype.detachSegs = function () {
  10344. };
  10345. // generates the HTML for a single event row
  10346. ListEventRenderer.prototype.renderSegHtml = function (seg) {
  10347. var _a = this.context, theme = _a.theme, options = _a.options;
  10348. var eventRange = seg.eventRange;
  10349. var eventDef = eventRange.def;
  10350. var eventInstance = eventRange.instance;
  10351. var eventUi = eventRange.ui;
  10352. var url = eventDef.url;
  10353. var classes = ['fc-list-item'].concat(eventUi.classNames);
  10354. var bgColor = eventUi.backgroundColor;
  10355. var timeHtml;
  10356. if (eventDef.allDay) {
  10357. timeHtml = core.getAllDayHtml(options);
  10358. }
  10359. else if (core.isMultiDayRange(eventRange.range)) {
  10360. if (seg.isStart) {
  10361. timeHtml = core.htmlEscape(this._getTimeText(eventInstance.range.start, seg.end, false // allDay
  10362. ));
  10363. }
  10364. else if (seg.isEnd) {
  10365. timeHtml = core.htmlEscape(this._getTimeText(seg.start, eventInstance.range.end, false // allDay
  10366. ));
  10367. }
  10368. else { // inner segment that lasts the whole day
  10369. timeHtml = core.getAllDayHtml(options);
  10370. }
  10371. }
  10372. else {
  10373. // Display the normal time text for the *event's* times
  10374. timeHtml = core.htmlEscape(this.getTimeText(eventRange));
  10375. }
  10376. if (url) {
  10377. classes.push('fc-has-url');
  10378. }
  10379. return '<tr class="' + classes.join(' ') + '">' +
  10380. (this.displayEventTime ?
  10381. '<td class="fc-list-item-time ' + theme.getClass('widgetContent') + '">' +
  10382. (timeHtml || '') +
  10383. '</td>' :
  10384. '') +
  10385. '<td class="fc-list-item-marker ' + theme.getClass('widgetContent') + '">' +
  10386. '<span class="fc-event-dot"' +
  10387. (bgColor ?
  10388. ' style="background-color:' + bgColor + '"' :
  10389. '') +
  10390. '></span>' +
  10391. '</td>' +
  10392. '<td class="fc-list-item-title ' + theme.getClass('widgetContent') + '">' +
  10393. '<a' + (url ? ' href="' + core.htmlEscape(url) + '"' : '') + '>' +
  10394. core.htmlEscape(eventDef.title || '') +
  10395. '</a>' +
  10396. '</td>' +
  10397. '</tr>';
  10398. };
  10399. // like "4:00am"
  10400. ListEventRenderer.prototype.computeEventTimeFormat = function () {
  10401. return {
  10402. hour: 'numeric',
  10403. minute: '2-digit',
  10404. meridiem: 'short'
  10405. };
  10406. };
  10407. return ListEventRenderer;
  10408. }(core.FgEventRenderer));
  10409. /*
  10410. Responsible for the scroller, and forwarding event-related actions into the "grid".
  10411. */
  10412. var ListView = /** @class */ (function (_super) {
  10413. __extends(ListView, _super);
  10414. function ListView(viewSpec, parentEl) {
  10415. var _this = _super.call(this, viewSpec, parentEl) || this;
  10416. _this.computeDateVars = core.memoize(computeDateVars);
  10417. _this.eventStoreToSegs = core.memoize(_this._eventStoreToSegs);
  10418. _this.renderSkeleton = core.memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  10419. var eventRenderer = _this.eventRenderer = new ListEventRenderer(_this);
  10420. _this.renderContent = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [_this.renderSkeleton]);
  10421. return _this;
  10422. }
  10423. ListView.prototype.firstContext = function (context) {
  10424. context.calendar.registerInteractiveComponent(this, {
  10425. el: this.el
  10426. // TODO: make aware that it doesn't do Hits
  10427. });
  10428. };
  10429. ListView.prototype.render = function (props, context) {
  10430. _super.prototype.render.call(this, props, context);
  10431. var _a = this.computeDateVars(props.dateProfile), dayDates = _a.dayDates, dayRanges = _a.dayRanges;
  10432. this.dayDates = dayDates;
  10433. this.renderSkeleton(context);
  10434. this.renderContent(context, this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges));
  10435. };
  10436. ListView.prototype.destroy = function () {
  10437. _super.prototype.destroy.call(this);
  10438. this.renderSkeleton.unrender();
  10439. this.renderContent.unrender();
  10440. this.context.calendar.unregisterInteractiveComponent(this);
  10441. };
  10442. ListView.prototype._renderSkeleton = function (context) {
  10443. var theme = context.theme;
  10444. this.el.classList.add('fc-list-view');
  10445. var listViewClassNames = (theme.getClass('listView') || '').split(' '); // wish we didn't have to do this
  10446. for (var _i = 0, listViewClassNames_1 = listViewClassNames; _i < listViewClassNames_1.length; _i++) {
  10447. var listViewClassName = listViewClassNames_1[_i];
  10448. if (listViewClassName) { // in case input was empty string
  10449. this.el.classList.add(listViewClassName);
  10450. }
  10451. }
  10452. this.scroller = new core.ScrollComponent('hidden', // overflow x
  10453. 'auto' // overflow y
  10454. );
  10455. this.el.appendChild(this.scroller.el);
  10456. this.contentEl = this.scroller.el; // shortcut
  10457. };
  10458. ListView.prototype._unrenderSkeleton = function () {
  10459. // TODO: remove classNames
  10460. this.scroller.destroy(); // will remove the Grid too
  10461. };
  10462. ListView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  10463. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto);
  10464. this.eventRenderer.computeSizes(isResize);
  10465. this.eventRenderer.assignSizes(isResize);
  10466. this.scroller.clear(); // sets height to 'auto' and clears overflow
  10467. if (!isAuto) {
  10468. this.scroller.setHeight(this.computeScrollerHeight(viewHeight));
  10469. }
  10470. };
  10471. ListView.prototype.computeScrollerHeight = function (viewHeight) {
  10472. return viewHeight -
  10473. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  10474. };
  10475. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  10476. return this.eventRangesToSegs(core.sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.nextDayThreshold).fg, dayRanges);
  10477. };
  10478. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  10479. var segs = [];
  10480. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  10481. var eventRange = eventRanges_1[_i];
  10482. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  10483. }
  10484. return segs;
  10485. };
  10486. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  10487. var _a = this.context, dateEnv = _a.dateEnv, nextDayThreshold = _a.nextDayThreshold;
  10488. var range = eventRange.range;
  10489. var allDay = eventRange.def.allDay;
  10490. var dayIndex;
  10491. var segRange;
  10492. var seg;
  10493. var segs = [];
  10494. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex++) {
  10495. segRange = core.intersectRanges(range, dayRanges[dayIndex]);
  10496. if (segRange) {
  10497. seg = {
  10498. component: this,
  10499. eventRange: eventRange,
  10500. start: segRange.start,
  10501. end: segRange.end,
  10502. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  10503. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  10504. dayIndex: dayIndex
  10505. };
  10506. segs.push(seg);
  10507. // detect when range won't go fully into the next day,
  10508. // and mutate the latest seg to the be the end.
  10509. if (!seg.isEnd && !allDay &&
  10510. dayIndex + 1 < dayRanges.length &&
  10511. range.end <
  10512. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  10513. seg.end = range.end;
  10514. seg.isEnd = true;
  10515. break;
  10516. }
  10517. }
  10518. }
  10519. return segs;
  10520. };
  10521. ListView.prototype.renderEmptyMessage = function () {
  10522. this.contentEl.innerHTML =
  10523. '<div class="fc-list-empty-wrap2">' + // TODO: try less wraps
  10524. '<div class="fc-list-empty-wrap1">' +
  10525. '<div class="fc-list-empty">' +
  10526. core.htmlEscape(this.context.options.noEventsMessage) +
  10527. '</div>' +
  10528. '</div>' +
  10529. '</div>';
  10530. };
  10531. // called by ListEventRenderer
  10532. ListView.prototype.renderSegList = function (allSegs) {
  10533. var theme = this.context.theme;
  10534. var segsByDay = this.groupSegsByDay(allSegs); // sparse array
  10535. var dayIndex;
  10536. var daySegs;
  10537. var i;
  10538. var tableEl = core.htmlToElement('<table class="fc-list-table ' + theme.getClass('tableList') + '"><tbody></tbody></table>');
  10539. var tbodyEl = tableEl.querySelector('tbody');
  10540. for (dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) {
  10541. daySegs = segsByDay[dayIndex];
  10542. if (daySegs) { // sparse array, so might be undefined
  10543. // append a day header
  10544. tbodyEl.appendChild(this.buildDayHeaderRow(this.dayDates[dayIndex]));
  10545. daySegs = this.eventRenderer.sortEventSegs(daySegs);
  10546. for (i = 0; i < daySegs.length; i++) {
  10547. tbodyEl.appendChild(daySegs[i].el); // append event row
  10548. }
  10549. }
  10550. }
  10551. this.contentEl.innerHTML = '';
  10552. this.contentEl.appendChild(tableEl);
  10553. };
  10554. // Returns a sparse array of arrays, segs grouped by their dayIndex
  10555. ListView.prototype.groupSegsByDay = function (segs) {
  10556. var segsByDay = []; // sparse array
  10557. var i;
  10558. var seg;
  10559. for (i = 0; i < segs.length; i++) {
  10560. seg = segs[i];
  10561. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  10562. .push(seg);
  10563. }
  10564. return segsByDay;
  10565. };
  10566. // generates the HTML for the day headers that live amongst the event rows
  10567. ListView.prototype.buildDayHeaderRow = function (dayDate) {
  10568. var _a = this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options;
  10569. var mainFormat = core.createFormatter(options.listDayFormat); // TODO: cache
  10570. var altFormat = core.createFormatter(options.listDayAltFormat); // TODO: cache
  10571. return core.createElement('tr', {
  10572. className: 'fc-list-heading',
  10573. 'data-date': dateEnv.formatIso(dayDate, { omitTime: true })
  10574. }, '<td class="' + (theme.getClass('tableListHeading') ||
  10575. theme.getClass('widgetHeader')) + '" colspan="3">' +
  10576. (mainFormat ?
  10577. core.buildGotoAnchorHtml(options, dateEnv, dayDate, { 'class': 'fc-list-heading-main' }, core.htmlEscape(dateEnv.format(dayDate, mainFormat)) // inner HTML
  10578. ) :
  10579. '') +
  10580. (altFormat ?
  10581. core.buildGotoAnchorHtml(options, dateEnv, dayDate, { 'class': 'fc-list-heading-alt' }, core.htmlEscape(dateEnv.format(dayDate, altFormat)) // inner HTML
  10582. ) :
  10583. '') +
  10584. '</td>');
  10585. };
  10586. return ListView;
  10587. }(core.View));
  10588. ListView.prototype.fgSegSelector = '.fc-list-item'; // which elements accept event actions
  10589. function computeDateVars(dateProfile) {
  10590. var dayStart = core.startOfDay(dateProfile.renderRange.start);
  10591. var viewEnd = dateProfile.renderRange.end;
  10592. var dayDates = [];
  10593. var dayRanges = [];
  10594. while (dayStart < viewEnd) {
  10595. dayDates.push(dayStart);
  10596. dayRanges.push({
  10597. start: dayStart,
  10598. end: core.addDays(dayStart, 1)
  10599. });
  10600. dayStart = core.addDays(dayStart, 1);
  10601. }
  10602. return { dayDates: dayDates, dayRanges: dayRanges };
  10603. }
  10604. var main = core.createPlugin({
  10605. views: {
  10606. list: {
  10607. class: ListView,
  10608. buttonTextKey: 'list',
  10609. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' } // like "January 1, 2016"
  10610. },
  10611. listDay: {
  10612. type: 'list',
  10613. duration: { days: 1 },
  10614. listDayFormat: { weekday: 'long' } // day-of-week is all we need. full date is probably in header
  10615. },
  10616. listWeek: {
  10617. type: 'list',
  10618. duration: { weeks: 1 },
  10619. listDayFormat: { weekday: 'long' },
  10620. listDayAltFormat: { month: 'long', day: 'numeric', year: 'numeric' }
  10621. },
  10622. listMonth: {
  10623. type: 'list',
  10624. duration: { month: 1 },
  10625. listDayAltFormat: { weekday: 'long' } // day-of-week is nice-to-have
  10626. },
  10627. listYear: {
  10628. type: 'list',
  10629. duration: { year: 1 },
  10630. listDayAltFormat: { weekday: 'long' } // day-of-week is nice-to-have
  10631. }
  10632. }
  10633. });
  10634. exports.ListView = ListView;
  10635. exports.default = main;
  10636. Object.defineProperty(exports, '__esModule', { value: true });
  10637. }));
  10638. /*!
  10639. FullCalendar Time Grid Plugin v4.4.0
  10640. Docs & License: https://fullcalendar.io/
  10641. (c) 2019 Adam Shaw
  10642. */
  10643. (function (global, factory) {
  10644. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core'), require('@fullcalendar/daygrid')) :
  10645. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core', '@fullcalendar/daygrid'], factory) :
  10646. (global = global || self, factory(global.FullCalendarTimeGrid = {}, global.FullCalendar, global.FullCalendarDayGrid));
  10647. }(this, function (exports, core, daygrid) { 'use strict';
  10648. /*! *****************************************************************************
  10649. Copyright (c) Microsoft Corporation. All rights reserved.
  10650. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  10651. this file except in compliance with the License. You may obtain a copy of the
  10652. License at http://www.apache.org/licenses/LICENSE-2.0
  10653. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  10654. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  10655. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10656. MERCHANTABLITY OR NON-INFRINGEMENT.
  10657. See the Apache Version 2.0 License for specific language governing permissions
  10658. and limitations under the License.
  10659. ***************************************************************************** */
  10660. /* global Reflect, Promise */
  10661. var extendStatics = function(d, b) {
  10662. extendStatics = Object.setPrototypeOf ||
  10663. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10664. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10665. return extendStatics(d, b);
  10666. };
  10667. function __extends(d, b) {
  10668. extendStatics(d, b);
  10669. function __() { this.constructor = d; }
  10670. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10671. }
  10672. var __assign = function() {
  10673. __assign = Object.assign || function __assign(t) {
  10674. for (var s, i = 1, n = arguments.length; i < n; i++) {
  10675. s = arguments[i];
  10676. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  10677. }
  10678. return t;
  10679. };
  10680. return __assign.apply(this, arguments);
  10681. };
  10682. /*
  10683. Only handles foreground segs.
  10684. Does not own rendering. Use for low-level util methods by TimeGrid.
  10685. */
  10686. var TimeGridEventRenderer = /** @class */ (function (_super) {
  10687. __extends(TimeGridEventRenderer, _super);
  10688. function TimeGridEventRenderer(timeGrid) {
  10689. var _this = _super.call(this) || this;
  10690. _this.timeGrid = timeGrid;
  10691. return _this;
  10692. }
  10693. TimeGridEventRenderer.prototype.renderSegs = function (context, segs, mirrorInfo) {
  10694. _super.prototype.renderSegs.call(this, context, segs, mirrorInfo);
  10695. // TODO: dont do every time. memoize
  10696. this.fullTimeFormat = core.createFormatter({
  10697. hour: 'numeric',
  10698. minute: '2-digit',
  10699. separator: this.context.options.defaultRangeSeparator
  10700. });
  10701. };
  10702. // Given an array of foreground segments, render a DOM element for each, computes position,
  10703. // and attaches to the column inner-container elements.
  10704. TimeGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  10705. var segsByCol = this.timeGrid.groupSegsByCol(segs);
  10706. // order the segs within each column
  10707. // TODO: have groupSegsByCol do this?
  10708. for (var col = 0; col < segsByCol.length; col++) {
  10709. segsByCol[col] = this.sortEventSegs(segsByCol[col]);
  10710. }
  10711. this.segsByCol = segsByCol;
  10712. this.timeGrid.attachSegsByCol(segsByCol, this.timeGrid.fgContainerEls);
  10713. };
  10714. TimeGridEventRenderer.prototype.detachSegs = function (segs) {
  10715. segs.forEach(function (seg) {
  10716. core.removeElement(seg.el);
  10717. });
  10718. this.segsByCol = null;
  10719. };
  10720. TimeGridEventRenderer.prototype.computeSegSizes = function (allSegs) {
  10721. var _a = this, timeGrid = _a.timeGrid, segsByCol = _a.segsByCol;
  10722. var colCnt = timeGrid.colCnt;
  10723. timeGrid.computeSegVerticals(allSegs); // horizontals relies on this
  10724. if (segsByCol) {
  10725. for (var col = 0; col < colCnt; col++) {
  10726. this.computeSegHorizontals(segsByCol[col]); // compute horizontal coordinates, z-index's, and reorder the array
  10727. }
  10728. }
  10729. };
  10730. TimeGridEventRenderer.prototype.assignSegSizes = function (allSegs) {
  10731. var _a = this, timeGrid = _a.timeGrid, segsByCol = _a.segsByCol;
  10732. var colCnt = timeGrid.colCnt;
  10733. timeGrid.assignSegVerticals(allSegs); // horizontals relies on this
  10734. if (segsByCol) {
  10735. for (var col = 0; col < colCnt; col++) {
  10736. this.assignSegCss(segsByCol[col]);
  10737. }
  10738. }
  10739. };
  10740. // Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
  10741. TimeGridEventRenderer.prototype.computeEventTimeFormat = function () {
  10742. return {
  10743. hour: 'numeric',
  10744. minute: '2-digit',
  10745. meridiem: false
  10746. };
  10747. };
  10748. // Computes a default `displayEventEnd` value if one is not expliclty defined
  10749. TimeGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  10750. return true;
  10751. };
  10752. // Renders the HTML for a single event segment's default rendering
  10753. TimeGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
  10754. var eventRange = seg.eventRange;
  10755. var eventDef = eventRange.def;
  10756. var eventUi = eventRange.ui;
  10757. var allDay = eventDef.allDay;
  10758. var isDraggable = core.computeEventDraggable(this.context, eventDef, eventUi);
  10759. var isResizableFromStart = seg.isStart && core.computeEventStartResizable(this.context, eventDef, eventUi);
  10760. var isResizableFromEnd = seg.isEnd && core.computeEventEndResizable(this.context, eventDef, eventUi);
  10761. var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
  10762. var skinCss = core.cssToStr(this.getSkinCss(eventUi));
  10763. var timeText;
  10764. var fullTimeText; // more verbose time text. for the print stylesheet
  10765. var startTimeText; // just the start time text
  10766. classes.unshift('fc-time-grid-event');
  10767. // if the event appears to span more than one day...
  10768. if (core.isMultiDayRange(eventRange.range)) {
  10769. // Don't display time text on segments that run entirely through a day.
  10770. // That would appear as midnight-midnight and would look dumb.
  10771. // Otherwise, display the time text for the *segment's* times (like 6pm-midnight or midnight-10am)
  10772. if (seg.isStart || seg.isEnd) {
  10773. var unzonedStart = seg.start;
  10774. var unzonedEnd = seg.end;
  10775. timeText = this._getTimeText(unzonedStart, unzonedEnd, allDay); // TODO: give the timezones
  10776. fullTimeText = this._getTimeText(unzonedStart, unzonedEnd, allDay, this.fullTimeFormat);
  10777. startTimeText = this._getTimeText(unzonedStart, unzonedEnd, allDay, null, false); // displayEnd=false
  10778. }
  10779. }
  10780. else {
  10781. // Display the normal time text for the *event's* times
  10782. timeText = this.getTimeText(eventRange);
  10783. fullTimeText = this.getTimeText(eventRange, this.fullTimeFormat);
  10784. startTimeText = this.getTimeText(eventRange, null, false); // displayEnd=false
  10785. }
  10786. return '<a class="' + classes.join(' ') + '"' +
  10787. (eventDef.url ?
  10788. ' href="' + core.htmlEscape(eventDef.url) + '"' :
  10789. '') +
  10790. (skinCss ?
  10791. ' style="' + skinCss + '"' :
  10792. '') +
  10793. '>' +
  10794. '<div class="fc-content">' +
  10795. (timeText ?
  10796. '<div class="fc-time"' +
  10797. ' data-start="' + core.htmlEscape(startTimeText) + '"' +
  10798. ' data-full="' + core.htmlEscape(fullTimeText) + '"' +
  10799. '>' +
  10800. '<span>' + core.htmlEscape(timeText) + '</span>' +
  10801. '</div>' :
  10802. '') +
  10803. (eventDef.title ?
  10804. '<div class="fc-title">' +
  10805. core.htmlEscape(eventDef.title) +
  10806. '</div>' :
  10807. '') +
  10808. '</div>' +
  10809. /* TODO: write CSS for this
  10810. (isResizableFromStart ?
  10811. '<div class="fc-resizer fc-start-resizer"></div>' :
  10812. ''
  10813. ) +
  10814. */
  10815. (isResizableFromEnd ?
  10816. '<div class="fc-resizer fc-end-resizer"></div>' :
  10817. '') +
  10818. '</a>';
  10819. };
  10820. // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
  10821. // Assumed the segs are already ordered.
  10822. // NOTE: Also reorders the given array by date!
  10823. TimeGridEventRenderer.prototype.computeSegHorizontals = function (segs) {
  10824. var levels;
  10825. var level0;
  10826. var i;
  10827. levels = buildSlotSegLevels(segs);
  10828. computeForwardSlotSegs(levels);
  10829. if ((level0 = levels[0])) {
  10830. for (i = 0; i < level0.length; i++) {
  10831. computeSlotSegPressures(level0[i]);
  10832. }
  10833. for (i = 0; i < level0.length; i++) {
  10834. this.computeSegForwardBack(level0[i], 0, 0);
  10835. }
  10836. }
  10837. };
  10838. // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
  10839. // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
  10840. // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
  10841. //
  10842. // The segment might be part of a "series", which means consecutive segments with the same pressure
  10843. // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
  10844. // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
  10845. // coordinate of the first segment in the series.
  10846. TimeGridEventRenderer.prototype.computeSegForwardBack = function (seg, seriesBackwardPressure, seriesBackwardCoord) {
  10847. var forwardSegs = seg.forwardSegs;
  10848. var i;
  10849. if (seg.forwardCoord === undefined) { // not already computed
  10850. if (!forwardSegs.length) {
  10851. // if there are no forward segments, this segment should butt up against the edge
  10852. seg.forwardCoord = 1;
  10853. }
  10854. else {
  10855. // sort highest pressure first
  10856. this.sortForwardSegs(forwardSegs);
  10857. // this segment's forwardCoord will be calculated from the backwardCoord of the
  10858. // highest-pressure forward segment.
  10859. this.computeSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
  10860. seg.forwardCoord = forwardSegs[0].backwardCoord;
  10861. }
  10862. // calculate the backwardCoord from the forwardCoord. consider the series
  10863. seg.backwardCoord = seg.forwardCoord -
  10864. (seg.forwardCoord - seriesBackwardCoord) / // available width for series
  10865. (seriesBackwardPressure + 1); // # of segments in the series
  10866. // use this segment's coordinates to computed the coordinates of the less-pressurized
  10867. // forward segments
  10868. for (i = 0; i < forwardSegs.length; i++) {
  10869. this.computeSegForwardBack(forwardSegs[i], 0, seg.forwardCoord);
  10870. }
  10871. }
  10872. };
  10873. TimeGridEventRenderer.prototype.sortForwardSegs = function (forwardSegs) {
  10874. var objs = forwardSegs.map(buildTimeGridSegCompareObj);
  10875. var specs = [
  10876. // put higher-pressure first
  10877. { field: 'forwardPressure', order: -1 },
  10878. // put segments that are closer to initial edge first (and favor ones with no coords yet)
  10879. { field: 'backwardCoord', order: 1 }
  10880. ].concat(this.context.eventOrderSpecs);
  10881. objs.sort(function (obj0, obj1) {
  10882. return core.compareByFieldSpecs(obj0, obj1, specs);
  10883. });
  10884. return objs.map(function (c) {
  10885. return c._seg;
  10886. });
  10887. };
  10888. // Given foreground event segments that have already had their position coordinates computed,
  10889. // assigns position-related CSS values to their elements.
  10890. TimeGridEventRenderer.prototype.assignSegCss = function (segs) {
  10891. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  10892. var seg = segs_1[_i];
  10893. core.applyStyle(seg.el, this.generateSegCss(seg));
  10894. if (seg.level > 0) {
  10895. seg.el.classList.add('fc-time-grid-event-inset');
  10896. }
  10897. // if the event is short that the title will be cut off,
  10898. // attach a className that condenses the title into the time area.
  10899. if (seg.eventRange.def.title && seg.bottom - seg.top < 30) {
  10900. seg.el.classList.add('fc-short'); // TODO: "condensed" is a better name
  10901. }
  10902. }
  10903. };
  10904. // Generates an object with CSS properties/values that should be applied to an event segment element.
  10905. // Contains important positioning-related properties that should be applied to any event element, customized or not.
  10906. TimeGridEventRenderer.prototype.generateSegCss = function (seg) {
  10907. var shouldOverlap = this.context.options.slotEventOverlap;
  10908. var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
  10909. var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
  10910. var props = this.timeGrid.generateSegVerticalCss(seg); // get top/bottom first
  10911. var isRtl = this.context.isRtl;
  10912. var left; // amount of space from left edge, a fraction of the total width
  10913. var right; // amount of space from right edge, a fraction of the total width
  10914. if (shouldOverlap) {
  10915. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  10916. forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
  10917. }
  10918. if (isRtl) {
  10919. left = 1 - forwardCoord;
  10920. right = backwardCoord;
  10921. }
  10922. else {
  10923. left = backwardCoord;
  10924. right = 1 - forwardCoord;
  10925. }
  10926. props.zIndex = seg.level + 1; // convert from 0-base to 1-based
  10927. props.left = left * 100 + '%';
  10928. props.right = right * 100 + '%';
  10929. if (shouldOverlap && seg.forwardPressure) {
  10930. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  10931. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  10932. }
  10933. return props;
  10934. };
  10935. return TimeGridEventRenderer;
  10936. }(core.FgEventRenderer));
  10937. // Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
  10938. // left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
  10939. function buildSlotSegLevels(segs) {
  10940. var levels = [];
  10941. var i;
  10942. var seg;
  10943. var j;
  10944. for (i = 0; i < segs.length; i++) {
  10945. seg = segs[i];
  10946. // go through all the levels and stop on the first level where there are no collisions
  10947. for (j = 0; j < levels.length; j++) {
  10948. if (!computeSlotSegCollisions(seg, levels[j]).length) {
  10949. break;
  10950. }
  10951. }
  10952. seg.level = j;
  10953. (levels[j] || (levels[j] = [])).push(seg);
  10954. }
  10955. return levels;
  10956. }
  10957. // For every segment, figure out the other segments that are in subsequent
  10958. // levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
  10959. function computeForwardSlotSegs(levels) {
  10960. var i;
  10961. var level;
  10962. var j;
  10963. var seg;
  10964. var k;
  10965. for (i = 0; i < levels.length; i++) {
  10966. level = levels[i];
  10967. for (j = 0; j < level.length; j++) {
  10968. seg = level[j];
  10969. seg.forwardSegs = [];
  10970. for (k = i + 1; k < levels.length; k++) {
  10971. computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
  10972. }
  10973. }
  10974. }
  10975. }
  10976. // Figure out which path forward (via seg.forwardSegs) results in the longest path until
  10977. // the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
  10978. function computeSlotSegPressures(seg) {
  10979. var forwardSegs = seg.forwardSegs;
  10980. var forwardPressure = 0;
  10981. var i;
  10982. var forwardSeg;
  10983. if (seg.forwardPressure === undefined) { // not already computed
  10984. for (i = 0; i < forwardSegs.length; i++) {
  10985. forwardSeg = forwardSegs[i];
  10986. // figure out the child's maximum forward path
  10987. computeSlotSegPressures(forwardSeg);
  10988. // either use the existing maximum, or use the child's forward pressure
  10989. // plus one (for the forwardSeg itself)
  10990. forwardPressure = Math.max(forwardPressure, 1 + forwardSeg.forwardPressure);
  10991. }
  10992. seg.forwardPressure = forwardPressure;
  10993. }
  10994. }
  10995. // Find all the segments in `otherSegs` that vertically collide with `seg`.
  10996. // Append into an optionally-supplied `results` array and return.
  10997. function computeSlotSegCollisions(seg, otherSegs, results) {
  10998. if (results === void 0) { results = []; }
  10999. for (var i = 0; i < otherSegs.length; i++) {
  11000. if (isSlotSegCollision(seg, otherSegs[i])) {
  11001. results.push(otherSegs[i]);
  11002. }
  11003. }
  11004. return results;
  11005. }
  11006. // Do these segments occupy the same vertical space?
  11007. function isSlotSegCollision(seg1, seg2) {
  11008. return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
  11009. }
  11010. function buildTimeGridSegCompareObj(seg) {
  11011. var obj = core.buildSegCompareObj(seg);
  11012. obj.forwardPressure = seg.forwardPressure;
  11013. obj.backwardCoord = seg.backwardCoord;
  11014. return obj;
  11015. }
  11016. var TimeGridMirrorRenderer = /** @class */ (function (_super) {
  11017. __extends(TimeGridMirrorRenderer, _super);
  11018. function TimeGridMirrorRenderer() {
  11019. return _super !== null && _super.apply(this, arguments) || this;
  11020. }
  11021. TimeGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  11022. this.segsByCol = this.timeGrid.groupSegsByCol(segs);
  11023. this.timeGrid.attachSegsByCol(this.segsByCol, this.timeGrid.mirrorContainerEls);
  11024. this.sourceSeg = mirrorInfo.sourceSeg;
  11025. };
  11026. TimeGridMirrorRenderer.prototype.generateSegCss = function (seg) {
  11027. var props = _super.prototype.generateSegCss.call(this, seg);
  11028. var sourceSeg = this.sourceSeg;
  11029. if (sourceSeg && sourceSeg.col === seg.col) {
  11030. var sourceSegProps = _super.prototype.generateSegCss.call(this, sourceSeg);
  11031. props.left = sourceSegProps.left;
  11032. props.right = sourceSegProps.right;
  11033. props.marginLeft = sourceSegProps.marginLeft;
  11034. props.marginRight = sourceSegProps.marginRight;
  11035. }
  11036. return props;
  11037. };
  11038. return TimeGridMirrorRenderer;
  11039. }(TimeGridEventRenderer));
  11040. var TimeGridFillRenderer = /** @class */ (function (_super) {
  11041. __extends(TimeGridFillRenderer, _super);
  11042. function TimeGridFillRenderer(timeGrid) {
  11043. var _this = _super.call(this) || this;
  11044. _this.timeGrid = timeGrid;
  11045. return _this;
  11046. }
  11047. TimeGridFillRenderer.prototype.attachSegs = function (type, segs) {
  11048. var timeGrid = this.timeGrid;
  11049. var containerEls;
  11050. // TODO: more efficient lookup
  11051. if (type === 'bgEvent') {
  11052. containerEls = timeGrid.bgContainerEls;
  11053. }
  11054. else if (type === 'businessHours') {
  11055. containerEls = timeGrid.businessContainerEls;
  11056. }
  11057. else if (type === 'highlight') {
  11058. containerEls = timeGrid.highlightContainerEls;
  11059. }
  11060. timeGrid.attachSegsByCol(timeGrid.groupSegsByCol(segs), containerEls);
  11061. return segs.map(function (seg) {
  11062. return seg.el;
  11063. });
  11064. };
  11065. TimeGridFillRenderer.prototype.computeSegSizes = function (segs) {
  11066. this.timeGrid.computeSegVerticals(segs);
  11067. };
  11068. TimeGridFillRenderer.prototype.assignSegSizes = function (segs) {
  11069. this.timeGrid.assignSegVerticals(segs);
  11070. };
  11071. return TimeGridFillRenderer;
  11072. }(core.FillRenderer));
  11073. /* A component that renders one or more columns of vertical time slots
  11074. ----------------------------------------------------------------------------------------------------------------------*/
  11075. // potential nice values for the slot-duration and interval-duration
  11076. // from largest to smallest
  11077. var AGENDA_STOCK_SUB_DURATIONS = [
  11078. { hours: 1 },
  11079. { minutes: 30 },
  11080. { minutes: 15 },
  11081. { seconds: 30 },
  11082. { seconds: 15 }
  11083. ];
  11084. var TimeGrid = /** @class */ (function (_super) {
  11085. __extends(TimeGrid, _super);
  11086. function TimeGrid(el, renderProps) {
  11087. var _this = _super.call(this, el) || this;
  11088. _this.isSlatSizesDirty = false;
  11089. _this.isColSizesDirty = false;
  11090. _this.processOptions = core.memoize(_this._processOptions);
  11091. _this.renderSkeleton = core.memoizeRendering(_this._renderSkeleton);
  11092. _this.renderSlats = core.memoizeRendering(_this._renderSlats, null, [_this.renderSkeleton]);
  11093. _this.renderColumns = core.memoizeRendering(_this._renderColumns, _this._unrenderColumns, [_this.renderSkeleton]);
  11094. _this.renderProps = renderProps;
  11095. var renderColumns = _this.renderColumns;
  11096. var eventRenderer = _this.eventRenderer = new TimeGridEventRenderer(_this);
  11097. var fillRenderer = _this.fillRenderer = new TimeGridFillRenderer(_this);
  11098. _this.mirrorRenderer = new TimeGridMirrorRenderer(_this);
  11099. _this.renderBusinessHours = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderColumns]);
  11100. _this.renderDateSelection = core.memoizeRendering(_this._renderDateSelection, _this._unrenderDateSelection, [renderColumns]);
  11101. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderColumns]);
  11102. _this.renderBgEvents = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderColumns]);
  11103. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  11104. _this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderColumns]);
  11105. _this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderColumns]);
  11106. return _this;
  11107. }
  11108. /* Options
  11109. ------------------------------------------------------------------------------------------------------------------*/
  11110. // Parses various options into properties of this object
  11111. // MUST have context already set
  11112. TimeGrid.prototype._processOptions = function (options) {
  11113. var slotDuration = options.slotDuration, snapDuration = options.snapDuration;
  11114. var snapsPerSlot;
  11115. var input;
  11116. slotDuration = core.createDuration(slotDuration);
  11117. snapDuration = snapDuration ? core.createDuration(snapDuration) : slotDuration;
  11118. snapsPerSlot = core.wholeDivideDurations(slotDuration, snapDuration);
  11119. if (snapsPerSlot === null) {
  11120. snapDuration = slotDuration;
  11121. snapsPerSlot = 1;
  11122. // TODO: say warning?
  11123. }
  11124. this.slotDuration = slotDuration;
  11125. this.snapDuration = snapDuration;
  11126. this.snapsPerSlot = snapsPerSlot;
  11127. // might be an array value (for TimelineView).
  11128. // if so, getting the most granular entry (the last one probably).
  11129. input = options.slotLabelFormat;
  11130. if (Array.isArray(input)) {
  11131. input = input[input.length - 1];
  11132. }
  11133. this.labelFormat = core.createFormatter(input || {
  11134. hour: 'numeric',
  11135. minute: '2-digit',
  11136. omitZeroMinute: true,
  11137. meridiem: 'short'
  11138. });
  11139. input = options.slotLabelInterval;
  11140. this.labelInterval = input ?
  11141. core.createDuration(input) :
  11142. this.computeLabelInterval(slotDuration);
  11143. };
  11144. // Computes an automatic value for slotLabelInterval
  11145. TimeGrid.prototype.computeLabelInterval = function (slotDuration) {
  11146. var i;
  11147. var labelInterval;
  11148. var slotsPerLabel;
  11149. // find the smallest stock label interval that results in more than one slots-per-label
  11150. for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
  11151. labelInterval = core.createDuration(AGENDA_STOCK_SUB_DURATIONS[i]);
  11152. slotsPerLabel = core.wholeDivideDurations(labelInterval, slotDuration);
  11153. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  11154. return labelInterval;
  11155. }
  11156. }
  11157. return slotDuration; // fall back
  11158. };
  11159. /* Rendering
  11160. ------------------------------------------------------------------------------------------------------------------*/
  11161. TimeGrid.prototype.render = function (props, context) {
  11162. this.processOptions(context.options);
  11163. var cells = props.cells;
  11164. this.colCnt = cells.length;
  11165. this.renderSkeleton(context.theme);
  11166. this.renderSlats(props.dateProfile);
  11167. this.renderColumns(props.cells, props.dateProfile);
  11168. this.renderBusinessHours(context, props.businessHourSegs);
  11169. this.renderDateSelection(props.dateSelectionSegs);
  11170. this.renderFgEvents(context, props.fgEventSegs);
  11171. this.renderBgEvents(context, props.bgEventSegs);
  11172. this.renderEventSelection(props.eventSelection);
  11173. this.renderEventDrag(props.eventDrag);
  11174. this.renderEventResize(props.eventResize);
  11175. };
  11176. TimeGrid.prototype.destroy = function () {
  11177. _super.prototype.destroy.call(this);
  11178. // should unrender everything else too
  11179. this.renderSlats.unrender();
  11180. this.renderColumns.unrender();
  11181. this.renderSkeleton.unrender();
  11182. };
  11183. TimeGrid.prototype.updateSize = function (isResize) {
  11184. var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
  11185. if (isResize || this.isSlatSizesDirty) {
  11186. this.buildSlatPositions();
  11187. this.isSlatSizesDirty = false;
  11188. }
  11189. if (isResize || this.isColSizesDirty) {
  11190. this.buildColPositions();
  11191. this.isColSizesDirty = false;
  11192. }
  11193. fillRenderer.computeSizes(isResize);
  11194. eventRenderer.computeSizes(isResize);
  11195. mirrorRenderer.computeSizes(isResize);
  11196. fillRenderer.assignSizes(isResize);
  11197. eventRenderer.assignSizes(isResize);
  11198. mirrorRenderer.assignSizes(isResize);
  11199. };
  11200. TimeGrid.prototype._renderSkeleton = function (theme) {
  11201. var el = this.el;
  11202. el.innerHTML =
  11203. '<div class="fc-bg"></div>' +
  11204. '<div class="fc-slats"></div>' +
  11205. '<hr class="fc-divider ' + theme.getClass('widgetHeader') + '" style="display:none" />';
  11206. this.rootBgContainerEl = el.querySelector('.fc-bg');
  11207. this.slatContainerEl = el.querySelector('.fc-slats');
  11208. this.bottomRuleEl = el.querySelector('.fc-divider');
  11209. };
  11210. TimeGrid.prototype._renderSlats = function (dateProfile) {
  11211. var theme = this.context.theme;
  11212. this.slatContainerEl.innerHTML =
  11213. '<table class="' + theme.getClass('tableGrid') + '">' +
  11214. this.renderSlatRowHtml(dateProfile) +
  11215. '</table>';
  11216. this.slatEls = core.findElements(this.slatContainerEl, 'tr');
  11217. this.slatPositions = new core.PositionCache(this.el, this.slatEls, false, true // vertical
  11218. );
  11219. this.isSlatSizesDirty = true;
  11220. };
  11221. // Generates the HTML for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  11222. TimeGrid.prototype.renderSlatRowHtml = function (dateProfile) {
  11223. var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, isRtl = _a.isRtl;
  11224. var html = '';
  11225. var dayStart = core.startOfDay(dateProfile.renderRange.start);
  11226. var slotTime = dateProfile.minTime;
  11227. var slotIterator = core.createDuration(0);
  11228. var slotDate; // will be on the view's first day, but we only care about its time
  11229. var isLabeled;
  11230. var axisHtml;
  11231. // Calculate the time for each slot
  11232. while (core.asRoughMs(slotTime) < core.asRoughMs(dateProfile.maxTime)) {
  11233. slotDate = dateEnv.add(dayStart, slotTime);
  11234. isLabeled = core.wholeDivideDurations(slotIterator, this.labelInterval) !== null;
  11235. axisHtml =
  11236. '<td class="fc-axis fc-time ' + theme.getClass('widgetContent') + '">' +
  11237. (isLabeled ?
  11238. '<span>' + // for matchCellWidths
  11239. core.htmlEscape(dateEnv.format(slotDate, this.labelFormat)) +
  11240. '</span>' :
  11241. '') +
  11242. '</td>';
  11243. html +=
  11244. '<tr data-time="' + core.formatIsoTimeString(slotDate) + '"' +
  11245. (isLabeled ? '' : ' class="fc-minor"') +
  11246. '>' +
  11247. (!isRtl ? axisHtml : '') +
  11248. '<td class="' + theme.getClass('widgetContent') + '"></td>' +
  11249. (isRtl ? axisHtml : '') +
  11250. '</tr>';
  11251. slotTime = core.addDurations(slotTime, this.slotDuration);
  11252. slotIterator = core.addDurations(slotIterator, this.slotDuration);
  11253. }
  11254. return html;
  11255. };
  11256. TimeGrid.prototype._renderColumns = function (cells, dateProfile) {
  11257. var _a = this.context, calendar = _a.calendar, view = _a.view, isRtl = _a.isRtl, theme = _a.theme, dateEnv = _a.dateEnv;
  11258. var bgRow = new daygrid.DayBgRow(this.context);
  11259. this.rootBgContainerEl.innerHTML =
  11260. '<table class="' + theme.getClass('tableGrid') + '">' +
  11261. bgRow.renderHtml({
  11262. cells: cells,
  11263. dateProfile: dateProfile,
  11264. renderIntroHtml: this.renderProps.renderBgIntroHtml
  11265. }) +
  11266. '</table>';
  11267. this.colEls = core.findElements(this.el, '.fc-day, .fc-disabled-day');
  11268. for (var col = 0; col < this.colCnt; col++) {
  11269. calendar.publiclyTrigger('dayRender', [
  11270. {
  11271. date: dateEnv.toDate(cells[col].date),
  11272. el: this.colEls[col],
  11273. view: view
  11274. }
  11275. ]);
  11276. }
  11277. if (isRtl) {
  11278. this.colEls.reverse();
  11279. }
  11280. this.colPositions = new core.PositionCache(this.el, this.colEls, true, // horizontal
  11281. false);
  11282. this.renderContentSkeleton();
  11283. this.isColSizesDirty = true;
  11284. };
  11285. TimeGrid.prototype._unrenderColumns = function () {
  11286. this.unrenderContentSkeleton();
  11287. };
  11288. /* Content Skeleton
  11289. ------------------------------------------------------------------------------------------------------------------*/
  11290. // Renders the DOM that the view's content will live in
  11291. TimeGrid.prototype.renderContentSkeleton = function () {
  11292. var isRtl = this.context.isRtl;
  11293. var parts = [];
  11294. var skeletonEl;
  11295. parts.push(this.renderProps.renderIntroHtml());
  11296. for (var i = 0; i < this.colCnt; i++) {
  11297. parts.push('<td>' +
  11298. '<div class="fc-content-col">' +
  11299. '<div class="fc-event-container fc-mirror-container"></div>' +
  11300. '<div class="fc-event-container"></div>' +
  11301. '<div class="fc-highlight-container"></div>' +
  11302. '<div class="fc-bgevent-container"></div>' +
  11303. '<div class="fc-business-container"></div>' +
  11304. '</div>' +
  11305. '</td>');
  11306. }
  11307. if (isRtl) {
  11308. parts.reverse();
  11309. }
  11310. skeletonEl = this.contentSkeletonEl = core.htmlToElement('<div class="fc-content-skeleton">' +
  11311. '<table>' +
  11312. '<tr>' + parts.join('') + '</tr>' +
  11313. '</table>' +
  11314. '</div>');
  11315. this.colContainerEls = core.findElements(skeletonEl, '.fc-content-col');
  11316. this.mirrorContainerEls = core.findElements(skeletonEl, '.fc-mirror-container');
  11317. this.fgContainerEls = core.findElements(skeletonEl, '.fc-event-container:not(.fc-mirror-container)');
  11318. this.bgContainerEls = core.findElements(skeletonEl, '.fc-bgevent-container');
  11319. this.highlightContainerEls = core.findElements(skeletonEl, '.fc-highlight-container');
  11320. this.businessContainerEls = core.findElements(skeletonEl, '.fc-business-container');
  11321. if (isRtl) {
  11322. this.colContainerEls.reverse();
  11323. this.mirrorContainerEls.reverse();
  11324. this.fgContainerEls.reverse();
  11325. this.bgContainerEls.reverse();
  11326. this.highlightContainerEls.reverse();
  11327. this.businessContainerEls.reverse();
  11328. }
  11329. this.el.appendChild(skeletonEl);
  11330. };
  11331. TimeGrid.prototype.unrenderContentSkeleton = function () {
  11332. core.removeElement(this.contentSkeletonEl);
  11333. };
  11334. // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's col
  11335. TimeGrid.prototype.groupSegsByCol = function (segs) {
  11336. var segsByCol = [];
  11337. var i;
  11338. for (i = 0; i < this.colCnt; i++) {
  11339. segsByCol.push([]);
  11340. }
  11341. for (i = 0; i < segs.length; i++) {
  11342. segsByCol[segs[i].col].push(segs[i]);
  11343. }
  11344. return segsByCol;
  11345. };
  11346. // Given segments grouped by column, insert the segments' elements into a parallel array of container
  11347. // elements, each living within a column.
  11348. TimeGrid.prototype.attachSegsByCol = function (segsByCol, containerEls) {
  11349. var col;
  11350. var segs;
  11351. var i;
  11352. for (col = 0; col < this.colCnt; col++) { // iterate each column grouping
  11353. segs = segsByCol[col];
  11354. for (i = 0; i < segs.length; i++) {
  11355. containerEls[col].appendChild(segs[i].el);
  11356. }
  11357. }
  11358. };
  11359. /* Now Indicator
  11360. ------------------------------------------------------------------------------------------------------------------*/
  11361. TimeGrid.prototype.getNowIndicatorUnit = function () {
  11362. return 'minute'; // will refresh on the minute
  11363. };
  11364. TimeGrid.prototype.renderNowIndicator = function (segs, date) {
  11365. // HACK: if date columns not ready for some reason (scheduler)
  11366. if (!this.colContainerEls) {
  11367. return;
  11368. }
  11369. var top = this.computeDateTop(date);
  11370. var nodes = [];
  11371. var i;
  11372. // render lines within the columns
  11373. for (i = 0; i < segs.length; i++) {
  11374. var lineEl = core.createElement('div', { className: 'fc-now-indicator fc-now-indicator-line' });
  11375. lineEl.style.top = top + 'px';
  11376. this.colContainerEls[segs[i].col].appendChild(lineEl);
  11377. nodes.push(lineEl);
  11378. }
  11379. // render an arrow over the axis
  11380. if (segs.length > 0) { // is the current time in view?
  11381. var arrowEl = core.createElement('div', { className: 'fc-now-indicator fc-now-indicator-arrow' });
  11382. arrowEl.style.top = top + 'px';
  11383. this.contentSkeletonEl.appendChild(arrowEl);
  11384. nodes.push(arrowEl);
  11385. }
  11386. this.nowIndicatorEls = nodes;
  11387. };
  11388. TimeGrid.prototype.unrenderNowIndicator = function () {
  11389. if (this.nowIndicatorEls) {
  11390. this.nowIndicatorEls.forEach(core.removeElement);
  11391. this.nowIndicatorEls = null;
  11392. }
  11393. };
  11394. /* Coordinates
  11395. ------------------------------------------------------------------------------------------------------------------*/
  11396. TimeGrid.prototype.getTotalSlatHeight = function () {
  11397. return this.slatContainerEl.getBoundingClientRect().height;
  11398. };
  11399. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  11400. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  11401. TimeGrid.prototype.computeDateTop = function (when, startOfDayDate) {
  11402. if (!startOfDayDate) {
  11403. startOfDayDate = core.startOfDay(when);
  11404. }
  11405. return this.computeTimeTop(core.createDuration(when.valueOf() - startOfDayDate.valueOf()));
  11406. };
  11407. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  11408. TimeGrid.prototype.computeTimeTop = function (duration) {
  11409. var len = this.slatEls.length;
  11410. var dateProfile = this.props.dateProfile;
  11411. var slatCoverage = (duration.milliseconds - core.asRoughMs(dateProfile.minTime)) / core.asRoughMs(this.slotDuration); // floating-point value of # of slots covered
  11412. var slatIndex;
  11413. var slatRemainder;
  11414. // compute a floating-point number for how many slats should be progressed through.
  11415. // from 0 to number of slats (inclusive)
  11416. // constrained because minTime/maxTime might be customized.
  11417. slatCoverage = Math.max(0, slatCoverage);
  11418. slatCoverage = Math.min(len, slatCoverage);
  11419. // an integer index of the furthest whole slat
  11420. // from 0 to number slats (*exclusive*, so len-1)
  11421. slatIndex = Math.floor(slatCoverage);
  11422. slatIndex = Math.min(slatIndex, len - 1);
  11423. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  11424. // could be 1.0 if slatCoverage is covering *all* the slots
  11425. slatRemainder = slatCoverage - slatIndex;
  11426. return this.slatPositions.tops[slatIndex] +
  11427. this.slatPositions.getHeight(slatIndex) * slatRemainder;
  11428. };
  11429. // For each segment in an array, computes and assigns its top and bottom properties
  11430. TimeGrid.prototype.computeSegVerticals = function (segs) {
  11431. var options = this.context.options;
  11432. var eventMinHeight = options.timeGridEventMinHeight;
  11433. var i;
  11434. var seg;
  11435. var dayDate;
  11436. for (i = 0; i < segs.length; i++) {
  11437. seg = segs[i];
  11438. dayDate = this.props.cells[seg.col].date;
  11439. seg.top = this.computeDateTop(seg.start, dayDate);
  11440. seg.bottom = Math.max(seg.top + eventMinHeight, this.computeDateTop(seg.end, dayDate));
  11441. }
  11442. };
  11443. // Given segments that already have their top/bottom properties computed, applies those values to
  11444. // the segments' elements.
  11445. TimeGrid.prototype.assignSegVerticals = function (segs) {
  11446. var i;
  11447. var seg;
  11448. for (i = 0; i < segs.length; i++) {
  11449. seg = segs[i];
  11450. core.applyStyle(seg.el, this.generateSegVerticalCss(seg));
  11451. }
  11452. };
  11453. // Generates an object with CSS properties for the top/bottom coordinates of a segment element
  11454. TimeGrid.prototype.generateSegVerticalCss = function (seg) {
  11455. return {
  11456. top: seg.top,
  11457. bottom: -seg.bottom // flipped because needs to be space beyond bottom edge of event container
  11458. };
  11459. };
  11460. /* Sizing
  11461. ------------------------------------------------------------------------------------------------------------------*/
  11462. TimeGrid.prototype.buildPositionCaches = function () {
  11463. this.buildColPositions();
  11464. this.buildSlatPositions();
  11465. };
  11466. TimeGrid.prototype.buildColPositions = function () {
  11467. this.colPositions.build();
  11468. };
  11469. TimeGrid.prototype.buildSlatPositions = function () {
  11470. this.slatPositions.build();
  11471. };
  11472. /* Hit System
  11473. ------------------------------------------------------------------------------------------------------------------*/
  11474. TimeGrid.prototype.positionToHit = function (positionLeft, positionTop) {
  11475. var dateEnv = this.context.dateEnv;
  11476. var _a = this, snapsPerSlot = _a.snapsPerSlot, slatPositions = _a.slatPositions, colPositions = _a.colPositions;
  11477. var colIndex = colPositions.leftToIndex(positionLeft);
  11478. var slatIndex = slatPositions.topToIndex(positionTop);
  11479. if (colIndex != null && slatIndex != null) {
  11480. var slatTop = slatPositions.tops[slatIndex];
  11481. var slatHeight = slatPositions.getHeight(slatIndex);
  11482. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  11483. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  11484. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  11485. var dayDate = this.props.cells[colIndex].date;
  11486. var time = core.addDurations(this.props.dateProfile.minTime, core.multiplyDuration(this.snapDuration, snapIndex));
  11487. var start = dateEnv.add(dayDate, time);
  11488. var end = dateEnv.add(start, this.snapDuration);
  11489. return {
  11490. col: colIndex,
  11491. dateSpan: {
  11492. range: { start: start, end: end },
  11493. allDay: false
  11494. },
  11495. dayEl: this.colEls[colIndex],
  11496. relativeRect: {
  11497. left: colPositions.lefts[colIndex],
  11498. right: colPositions.rights[colIndex],
  11499. top: slatTop,
  11500. bottom: slatTop + slatHeight
  11501. }
  11502. };
  11503. }
  11504. };
  11505. /* Event Drag Visualization
  11506. ------------------------------------------------------------------------------------------------------------------*/
  11507. TimeGrid.prototype._renderEventDrag = function (state) {
  11508. if (state) {
  11509. this.eventRenderer.hideByHash(state.affectedInstances);
  11510. if (state.isEvent) {
  11511. this.mirrorRenderer.renderSegs(this.context, state.segs, { isDragging: true, sourceSeg: state.sourceSeg });
  11512. }
  11513. else {
  11514. this.fillRenderer.renderSegs('highlight', this.context, state.segs);
  11515. }
  11516. }
  11517. };
  11518. TimeGrid.prototype._unrenderEventDrag = function (state) {
  11519. if (state) {
  11520. this.eventRenderer.showByHash(state.affectedInstances);
  11521. if (state.isEvent) {
  11522. this.mirrorRenderer.unrender(this.context, state.segs, { isDragging: true, sourceSeg: state.sourceSeg });
  11523. }
  11524. else {
  11525. this.fillRenderer.unrender('highlight', this.context);
  11526. }
  11527. }
  11528. };
  11529. /* Event Resize Visualization
  11530. ------------------------------------------------------------------------------------------------------------------*/
  11531. TimeGrid.prototype._renderEventResize = function (state) {
  11532. if (state) {
  11533. this.eventRenderer.hideByHash(state.affectedInstances);
  11534. this.mirrorRenderer.renderSegs(this.context, state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  11535. }
  11536. };
  11537. TimeGrid.prototype._unrenderEventResize = function (state) {
  11538. if (state) {
  11539. this.eventRenderer.showByHash(state.affectedInstances);
  11540. this.mirrorRenderer.unrender(this.context, state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  11541. }
  11542. };
  11543. /* Selection
  11544. ------------------------------------------------------------------------------------------------------------------*/
  11545. // Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight.
  11546. TimeGrid.prototype._renderDateSelection = function (segs) {
  11547. if (segs) {
  11548. if (this.context.options.selectMirror) {
  11549. this.mirrorRenderer.renderSegs(this.context, segs, { isSelecting: true });
  11550. }
  11551. else {
  11552. this.fillRenderer.renderSegs('highlight', this.context, segs);
  11553. }
  11554. }
  11555. };
  11556. TimeGrid.prototype._unrenderDateSelection = function (segs) {
  11557. if (segs) {
  11558. if (this.context.options.selectMirror) {
  11559. this.mirrorRenderer.unrender(this.context, segs, { isSelecting: true });
  11560. }
  11561. else {
  11562. this.fillRenderer.unrender('highlight', this.context);
  11563. }
  11564. }
  11565. };
  11566. return TimeGrid;
  11567. }(core.DateComponent));
  11568. var AllDaySplitter = /** @class */ (function (_super) {
  11569. __extends(AllDaySplitter, _super);
  11570. function AllDaySplitter() {
  11571. return _super !== null && _super.apply(this, arguments) || this;
  11572. }
  11573. AllDaySplitter.prototype.getKeyInfo = function () {
  11574. return {
  11575. allDay: {},
  11576. timed: {}
  11577. };
  11578. };
  11579. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  11580. if (dateSpan.allDay) {
  11581. return ['allDay'];
  11582. }
  11583. else {
  11584. return ['timed'];
  11585. }
  11586. };
  11587. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  11588. if (!eventDef.allDay) {
  11589. return ['timed'];
  11590. }
  11591. else if (core.hasBgRendering(eventDef)) {
  11592. return ['timed', 'allDay'];
  11593. }
  11594. else {
  11595. return ['allDay'];
  11596. }
  11597. };
  11598. return AllDaySplitter;
  11599. }(core.Splitter));
  11600. var TIMEGRID_ALL_DAY_EVENT_LIMIT = 5;
  11601. var WEEK_HEADER_FORMAT = core.createFormatter({ week: 'short' });
  11602. /* An abstract class for all timegrid-related views. Displays one more columns with time slots running vertically.
  11603. ----------------------------------------------------------------------------------------------------------------------*/
  11604. // Is a manager for the TimeGrid subcomponent and possibly the DayGrid subcomponent (if allDaySlot is on).
  11605. // Responsible for managing width/height.
  11606. var AbstractTimeGridView = /** @class */ (function (_super) {
  11607. __extends(AbstractTimeGridView, _super);
  11608. function AbstractTimeGridView() {
  11609. var _this = _super !== null && _super.apply(this, arguments) || this;
  11610. _this.splitter = new AllDaySplitter();
  11611. _this.renderSkeleton = core.memoizeRendering(_this._renderSkeleton, _this._unrenderSkeleton);
  11612. /* Header Render Methods
  11613. ------------------------------------------------------------------------------------------------------------------*/
  11614. // Generates the HTML that will go before the day-of week header cells
  11615. _this.renderHeadIntroHtml = function () {
  11616. var _a = _this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options;
  11617. var range = _this.props.dateProfile.renderRange;
  11618. var dayCnt = core.diffDays(range.start, range.end);
  11619. var weekText;
  11620. if (options.weekNumbers) {
  11621. weekText = dateEnv.format(range.start, WEEK_HEADER_FORMAT);
  11622. return '' +
  11623. '<th class="fc-axis fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.axisStyleAttr() + '>' +
  11624. core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths
  11625. options, dateEnv, { date: range.start, type: 'week', forceOff: dayCnt > 1 }, core.htmlEscape(weekText) // inner HTML
  11626. ) +
  11627. '</th>';
  11628. }
  11629. else {
  11630. return '<th class="fc-axis ' + theme.getClass('widgetHeader') + '" ' + _this.axisStyleAttr() + '></th>';
  11631. }
  11632. };
  11633. /* Time Grid Render Methods
  11634. ------------------------------------------------------------------------------------------------------------------*/
  11635. // Generates the HTML that goes before the bg of the TimeGrid slot area. Long vertical column.
  11636. _this.renderTimeGridBgIntroHtml = function () {
  11637. var theme = _this.context.theme;
  11638. return '<td class="fc-axis ' + theme.getClass('widgetContent') + '" ' + _this.axisStyleAttr() + '></td>';
  11639. };
  11640. // Generates the HTML that goes before all other types of cells.
  11641. // Affects content-skeleton, mirror-skeleton, highlight-skeleton for both the time-grid and day-grid.
  11642. _this.renderTimeGridIntroHtml = function () {
  11643. return '<td class="fc-axis" ' + _this.axisStyleAttr() + '></td>';
  11644. };
  11645. /* Day Grid Render Methods
  11646. ------------------------------------------------------------------------------------------------------------------*/
  11647. // Generates the HTML that goes before the all-day cells
  11648. _this.renderDayGridBgIntroHtml = function () {
  11649. var _a = _this.context, theme = _a.theme, options = _a.options;
  11650. return '' +
  11651. '<td class="fc-axis ' + theme.getClass('widgetContent') + '" ' + _this.axisStyleAttr() + '>' +
  11652. '<span>' + // needed for matchCellWidths
  11653. core.getAllDayHtml(options) +
  11654. '</span>' +
  11655. '</td>';
  11656. };
  11657. // Generates the HTML that goes before all other types of cells.
  11658. // Affects content-skeleton, mirror-skeleton, highlight-skeleton for both the time-grid and day-grid.
  11659. _this.renderDayGridIntroHtml = function () {
  11660. return '<td class="fc-axis" ' + _this.axisStyleAttr() + '></td>';
  11661. };
  11662. return _this;
  11663. }
  11664. AbstractTimeGridView.prototype.render = function (props, context) {
  11665. _super.prototype.render.call(this, props, context);
  11666. this.renderSkeleton(context);
  11667. };
  11668. AbstractTimeGridView.prototype.destroy = function () {
  11669. _super.prototype.destroy.call(this);
  11670. this.renderSkeleton.unrender();
  11671. };
  11672. AbstractTimeGridView.prototype._renderSkeleton = function (context) {
  11673. this.el.classList.add('fc-timeGrid-view');
  11674. this.el.innerHTML = this.renderSkeletonHtml();
  11675. this.scroller = new core.ScrollComponent('hidden', // overflow x
  11676. 'auto' // overflow y
  11677. );
  11678. var timeGridWrapEl = this.scroller.el;
  11679. this.el.querySelector('.fc-body > tr > td').appendChild(timeGridWrapEl);
  11680. timeGridWrapEl.classList.add('fc-time-grid-container');
  11681. var timeGridEl = core.createElement('div', { className: 'fc-time-grid' });
  11682. timeGridWrapEl.appendChild(timeGridEl);
  11683. this.timeGrid = new TimeGrid(timeGridEl, {
  11684. renderBgIntroHtml: this.renderTimeGridBgIntroHtml,
  11685. renderIntroHtml: this.renderTimeGridIntroHtml
  11686. });
  11687. if (context.options.allDaySlot) { // should we display the "all-day" area?
  11688. this.dayGrid = new daygrid.DayGrid(// the all-day subcomponent of this view
  11689. this.el.querySelector('.fc-day-grid'), {
  11690. renderNumberIntroHtml: this.renderDayGridIntroHtml,
  11691. renderBgIntroHtml: this.renderDayGridBgIntroHtml,
  11692. renderIntroHtml: this.renderDayGridIntroHtml,
  11693. colWeekNumbersVisible: false,
  11694. cellWeekNumbersVisible: false
  11695. });
  11696. // have the day-grid extend it's coordinate area over the <hr> dividing the two grids
  11697. var dividerEl = this.el.querySelector('.fc-divider');
  11698. this.dayGrid.bottomCoordPadding = dividerEl.getBoundingClientRect().height;
  11699. }
  11700. };
  11701. AbstractTimeGridView.prototype._unrenderSkeleton = function () {
  11702. this.el.classList.remove('fc-timeGrid-view');
  11703. this.timeGrid.destroy();
  11704. if (this.dayGrid) {
  11705. this.dayGrid.destroy();
  11706. }
  11707. this.scroller.destroy();
  11708. };
  11709. /* Rendering
  11710. ------------------------------------------------------------------------------------------------------------------*/
  11711. // Builds the HTML skeleton for the view.
  11712. // The day-grid and time-grid components will render inside containers defined by this HTML.
  11713. AbstractTimeGridView.prototype.renderSkeletonHtml = function () {
  11714. var _a = this.context, theme = _a.theme, options = _a.options;
  11715. return '' +
  11716. '<table class="' + theme.getClass('tableGrid') + '">' +
  11717. (options.columnHeader ?
  11718. '<thead class="fc-head">' +
  11719. '<tr>' +
  11720. '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
  11721. '</tr>' +
  11722. '</thead>' :
  11723. '') +
  11724. '<tbody class="fc-body">' +
  11725. '<tr>' +
  11726. '<td class="' + theme.getClass('widgetContent') + '">' +
  11727. (options.allDaySlot ?
  11728. '<div class="fc-day-grid"></div>' +
  11729. '<hr class="fc-divider ' + theme.getClass('widgetHeader') + '" />' :
  11730. '') +
  11731. '</td>' +
  11732. '</tr>' +
  11733. '</tbody>' +
  11734. '</table>';
  11735. };
  11736. /* Now Indicator
  11737. ------------------------------------------------------------------------------------------------------------------*/
  11738. AbstractTimeGridView.prototype.getNowIndicatorUnit = function () {
  11739. return this.timeGrid.getNowIndicatorUnit();
  11740. };
  11741. // subclasses should implement
  11742. // renderNowIndicator(date: DateMarker) {
  11743. // }
  11744. AbstractTimeGridView.prototype.unrenderNowIndicator = function () {
  11745. this.timeGrid.unrenderNowIndicator();
  11746. };
  11747. /* Dimensions
  11748. ------------------------------------------------------------------------------------------------------------------*/
  11749. AbstractTimeGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  11750. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
  11751. this.timeGrid.updateSize(isResize);
  11752. if (this.dayGrid) {
  11753. this.dayGrid.updateSize(isResize);
  11754. }
  11755. };
  11756. // Adjusts the vertical dimensions of the view to the specified values
  11757. AbstractTimeGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  11758. var _this = this;
  11759. var eventLimit;
  11760. var scrollerHeight;
  11761. var scrollbarWidths;
  11762. // make all axis cells line up
  11763. this.axisWidth = core.matchCellWidths(core.findElements(this.el, '.fc-axis'));
  11764. // hack to give the view some height prior to timeGrid's columns being rendered
  11765. // TODO: separate setting height from scroller VS timeGrid.
  11766. if (!this.timeGrid.colEls) {
  11767. if (!isAuto) {
  11768. scrollerHeight = this.computeScrollerHeight(viewHeight);
  11769. this.scroller.setHeight(scrollerHeight);
  11770. }
  11771. return;
  11772. }
  11773. // set of fake row elements that must compensate when scroller has scrollbars
  11774. var noScrollRowEls = core.findElements(this.el, '.fc-row').filter(function (node) {
  11775. return !_this.scroller.el.contains(node);
  11776. });
  11777. // reset all dimensions back to the original state
  11778. this.timeGrid.bottomRuleEl.style.display = 'none'; // will be shown later if this <hr> is necessary
  11779. this.scroller.clear(); // sets height to 'auto' and clears overflow
  11780. noScrollRowEls.forEach(core.uncompensateScroll);
  11781. // limit number of events in the all-day area
  11782. if (this.dayGrid) {
  11783. this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed
  11784. eventLimit = this.context.options.eventLimit;
  11785. if (eventLimit && typeof eventLimit !== 'number') {
  11786. eventLimit = TIMEGRID_ALL_DAY_EVENT_LIMIT; // make sure "auto" goes to a real number
  11787. }
  11788. if (eventLimit) {
  11789. this.dayGrid.limitRows(eventLimit);
  11790. }
  11791. }
  11792. if (!isAuto) { // should we force dimensions of the scroll container?
  11793. scrollerHeight = this.computeScrollerHeight(viewHeight);
  11794. this.scroller.setHeight(scrollerHeight);
  11795. scrollbarWidths = this.scroller.getScrollbarWidths();
  11796. if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
  11797. // make the all-day and header rows lines up
  11798. noScrollRowEls.forEach(function (rowEl) {
  11799. core.compensateScroll(rowEl, scrollbarWidths);
  11800. });
  11801. // the scrollbar compensation might have changed text flow, which might affect height, so recalculate
  11802. // and reapply the desired height to the scroller.
  11803. scrollerHeight = this.computeScrollerHeight(viewHeight);
  11804. this.scroller.setHeight(scrollerHeight);
  11805. }
  11806. // guarantees the same scrollbar widths
  11807. this.scroller.lockOverflow(scrollbarWidths);
  11808. // if there's any space below the slats, show the horizontal rule.
  11809. // this won't cause any new overflow, because lockOverflow already called.
  11810. if (this.timeGrid.getTotalSlatHeight() < scrollerHeight) {
  11811. this.timeGrid.bottomRuleEl.style.display = '';
  11812. }
  11813. }
  11814. };
  11815. // given a desired total height of the view, returns what the height of the scroller should be
  11816. AbstractTimeGridView.prototype.computeScrollerHeight = function (viewHeight) {
  11817. return viewHeight -
  11818. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  11819. };
  11820. /* Scroll
  11821. ------------------------------------------------------------------------------------------------------------------*/
  11822. // Computes the initial pre-configured scroll state prior to allowing the user to change it
  11823. AbstractTimeGridView.prototype.computeDateScroll = function (duration) {
  11824. var top = this.timeGrid.computeTimeTop(duration);
  11825. // zoom can give weird floating-point values. rather scroll a little bit further
  11826. top = Math.ceil(top);
  11827. if (top) {
  11828. top++; // to overcome top border that slots beyond the first have. looks better
  11829. }
  11830. return { top: top };
  11831. };
  11832. AbstractTimeGridView.prototype.queryDateScroll = function () {
  11833. return { top: this.scroller.getScrollTop() };
  11834. };
  11835. AbstractTimeGridView.prototype.applyDateScroll = function (scroll) {
  11836. if (scroll.top !== undefined) {
  11837. this.scroller.setScrollTop(scroll.top);
  11838. }
  11839. };
  11840. // Generates an HTML attribute string for setting the width of the axis, if it is known
  11841. AbstractTimeGridView.prototype.axisStyleAttr = function () {
  11842. if (this.axisWidth != null) {
  11843. return 'style="width:' + this.axisWidth + 'px"';
  11844. }
  11845. return '';
  11846. };
  11847. return AbstractTimeGridView;
  11848. }(core.View));
  11849. AbstractTimeGridView.prototype.usesMinMaxTime = true; // indicates that minTime/maxTime affects rendering
  11850. var SimpleTimeGrid = /** @class */ (function (_super) {
  11851. __extends(SimpleTimeGrid, _super);
  11852. function SimpleTimeGrid(timeGrid) {
  11853. var _this = _super.call(this, timeGrid.el) || this;
  11854. _this.buildDayRanges = core.memoize(buildDayRanges);
  11855. _this.slicer = new TimeGridSlicer();
  11856. _this.timeGrid = timeGrid;
  11857. return _this;
  11858. }
  11859. SimpleTimeGrid.prototype.firstContext = function (context) {
  11860. context.calendar.registerInteractiveComponent(this, {
  11861. el: this.timeGrid.el
  11862. });
  11863. };
  11864. SimpleTimeGrid.prototype.destroy = function () {
  11865. _super.prototype.destroy.call(this);
  11866. this.context.calendar.unregisterInteractiveComponent(this);
  11867. };
  11868. SimpleTimeGrid.prototype.render = function (props, context) {
  11869. var dateEnv = this.context.dateEnv;
  11870. var dateProfile = props.dateProfile, dayTable = props.dayTable;
  11871. var dayRanges = this.dayRanges = this.buildDayRanges(dayTable, dateProfile, dateEnv);
  11872. this.timeGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, null, context.calendar, this.timeGrid, dayRanges), { dateProfile: dateProfile, cells: dayTable.cells[0] }), context);
  11873. };
  11874. SimpleTimeGrid.prototype.renderNowIndicator = function (date) {
  11875. this.timeGrid.renderNowIndicator(this.slicer.sliceNowDate(date, this.timeGrid, this.dayRanges), date);
  11876. };
  11877. SimpleTimeGrid.prototype.buildPositionCaches = function () {
  11878. this.timeGrid.buildPositionCaches();
  11879. };
  11880. SimpleTimeGrid.prototype.queryHit = function (positionLeft, positionTop) {
  11881. var rawHit = this.timeGrid.positionToHit(positionLeft, positionTop);
  11882. if (rawHit) {
  11883. return {
  11884. component: this.timeGrid,
  11885. dateSpan: rawHit.dateSpan,
  11886. dayEl: rawHit.dayEl,
  11887. rect: {
  11888. left: rawHit.relativeRect.left,
  11889. right: rawHit.relativeRect.right,
  11890. top: rawHit.relativeRect.top,
  11891. bottom: rawHit.relativeRect.bottom
  11892. },
  11893. layer: 0
  11894. };
  11895. }
  11896. };
  11897. return SimpleTimeGrid;
  11898. }(core.DateComponent));
  11899. function buildDayRanges(dayTable, dateProfile, dateEnv) {
  11900. var ranges = [];
  11901. for (var _i = 0, _a = dayTable.headerDates; _i < _a.length; _i++) {
  11902. var date = _a[_i];
  11903. ranges.push({
  11904. start: dateEnv.add(date, dateProfile.minTime),
  11905. end: dateEnv.add(date, dateProfile.maxTime)
  11906. });
  11907. }
  11908. return ranges;
  11909. }
  11910. var TimeGridSlicer = /** @class */ (function (_super) {
  11911. __extends(TimeGridSlicer, _super);
  11912. function TimeGridSlicer() {
  11913. return _super !== null && _super.apply(this, arguments) || this;
  11914. }
  11915. TimeGridSlicer.prototype.sliceRange = function (range, dayRanges) {
  11916. var segs = [];
  11917. for (var col = 0; col < dayRanges.length; col++) {
  11918. var segRange = core.intersectRanges(range, dayRanges[col]);
  11919. if (segRange) {
  11920. segs.push({
  11921. start: segRange.start,
  11922. end: segRange.end,
  11923. isStart: segRange.start.valueOf() === range.start.valueOf(),
  11924. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  11925. col: col
  11926. });
  11927. }
  11928. }
  11929. return segs;
  11930. };
  11931. return TimeGridSlicer;
  11932. }(core.Slicer));
  11933. var TimeGridView = /** @class */ (function (_super) {
  11934. __extends(TimeGridView, _super);
  11935. function TimeGridView() {
  11936. var _this = _super !== null && _super.apply(this, arguments) || this;
  11937. _this.buildDayTable = core.memoize(buildDayTable);
  11938. return _this;
  11939. }
  11940. TimeGridView.prototype.render = function (props, context) {
  11941. _super.prototype.render.call(this, props, context); // for flags for updateSize. also _renderSkeleton/_unrenderSkeleton
  11942. var _a = this.props, dateProfile = _a.dateProfile, dateProfileGenerator = _a.dateProfileGenerator;
  11943. var nextDayThreshold = context.nextDayThreshold;
  11944. var dayTable = this.buildDayTable(dateProfile, dateProfileGenerator);
  11945. var splitProps = this.splitter.splitProps(props);
  11946. if (this.header) {
  11947. this.header.receiveProps({
  11948. dateProfile: dateProfile,
  11949. dates: dayTable.headerDates,
  11950. datesRepDistinctDays: true,
  11951. renderIntroHtml: this.renderHeadIntroHtml
  11952. }, context);
  11953. }
  11954. this.simpleTimeGrid.receiveProps(__assign({}, splitProps['timed'], { dateProfile: dateProfile,
  11955. dayTable: dayTable }), context);
  11956. if (this.simpleDayGrid) {
  11957. this.simpleDayGrid.receiveProps(__assign({}, splitProps['allDay'], { dateProfile: dateProfile,
  11958. dayTable: dayTable,
  11959. nextDayThreshold: nextDayThreshold, isRigid: false }), context);
  11960. }
  11961. this.startNowIndicator(dateProfile, dateProfileGenerator);
  11962. };
  11963. TimeGridView.prototype._renderSkeleton = function (context) {
  11964. _super.prototype._renderSkeleton.call(this, context);
  11965. if (context.options.columnHeader) {
  11966. this.header = new core.DayHeader(this.el.querySelector('.fc-head-container'));
  11967. }
  11968. this.simpleTimeGrid = new SimpleTimeGrid(this.timeGrid);
  11969. if (this.dayGrid) {
  11970. this.simpleDayGrid = new daygrid.SimpleDayGrid(this.dayGrid);
  11971. }
  11972. };
  11973. TimeGridView.prototype._unrenderSkeleton = function () {
  11974. _super.prototype._unrenderSkeleton.call(this);
  11975. if (this.header) {
  11976. this.header.destroy();
  11977. }
  11978. this.simpleTimeGrid.destroy();
  11979. if (this.simpleDayGrid) {
  11980. this.simpleDayGrid.destroy();
  11981. }
  11982. };
  11983. TimeGridView.prototype.renderNowIndicator = function (date) {
  11984. this.simpleTimeGrid.renderNowIndicator(date);
  11985. };
  11986. return TimeGridView;
  11987. }(AbstractTimeGridView));
  11988. function buildDayTable(dateProfile, dateProfileGenerator) {
  11989. var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator);
  11990. return new core.DayTable(daySeries, false);
  11991. }
  11992. var main = core.createPlugin({
  11993. defaultView: 'timeGridWeek',
  11994. views: {
  11995. timeGrid: {
  11996. class: TimeGridView,
  11997. allDaySlot: true,
  11998. slotDuration: '00:30:00',
  11999. slotEventOverlap: true // a bad name. confused with overlap/constraint system
  12000. },
  12001. timeGridDay: {
  12002. type: 'timeGrid',
  12003. duration: { days: 1 }
  12004. },
  12005. timeGridWeek: {
  12006. type: 'timeGrid',
  12007. duration: { weeks: 1 }
  12008. }
  12009. }
  12010. });
  12011. exports.AbstractTimeGridView = AbstractTimeGridView;
  12012. exports.TimeGrid = TimeGrid;
  12013. exports.TimeGridSlicer = TimeGridSlicer;
  12014. exports.TimeGridView = TimeGridView;
  12015. exports.buildDayRanges = buildDayRanges;
  12016. exports.buildDayTable = buildDayTable;
  12017. exports.default = main;
  12018. Object.defineProperty(exports, '__esModule', { value: true });
  12019. }));
  12020. /*!
  12021. FullCalendar Interaction Plugin v4.4.0
  12022. Docs & License: https://fullcalendar.io/
  12023. (c) 2019 Adam Shaw
  12024. */
  12025. (function (global, factory) {
  12026. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  12027. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  12028. (global = global || self, factory(global.FullCalendarInteraction = {}, global.FullCalendar));
  12029. }(this, function (exports, core) { 'use strict';
  12030. /*! *****************************************************************************
  12031. Copyright (c) Microsoft Corporation. All rights reserved.
  12032. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  12033. this file except in compliance with the License. You may obtain a copy of the
  12034. License at http://www.apache.org/licenses/LICENSE-2.0
  12035. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  12036. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  12037. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  12038. MERCHANTABLITY OR NON-INFRINGEMENT.
  12039. See the Apache Version 2.0 License for specific language governing permissions
  12040. and limitations under the License.
  12041. ***************************************************************************** */
  12042. /* global Reflect, Promise */
  12043. var extendStatics = function(d, b) {
  12044. extendStatics = Object.setPrototypeOf ||
  12045. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  12046. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  12047. return extendStatics(d, b);
  12048. };
  12049. function __extends(d, b) {
  12050. extendStatics(d, b);
  12051. function __() { this.constructor = d; }
  12052. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12053. }
  12054. var __assign = function() {
  12055. __assign = Object.assign || function __assign(t) {
  12056. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12057. s = arguments[i];
  12058. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  12059. }
  12060. return t;
  12061. };
  12062. return __assign.apply(this, arguments);
  12063. };
  12064. core.config.touchMouseIgnoreWait = 500;
  12065. var ignoreMouseDepth = 0;
  12066. var listenerCnt = 0;
  12067. var isWindowTouchMoveCancelled = false;
  12068. /*
  12069. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  12070. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  12071. Also, tracks if there was touch-scrolling.
  12072. Also, can prevent touch-scrolling from happening.
  12073. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  12074. emits:
  12075. - pointerdown
  12076. - pointermove
  12077. - pointerup
  12078. */
  12079. var PointerDragging = /** @class */ (function () {
  12080. function PointerDragging(containerEl) {
  12081. var _this = this;
  12082. this.subjectEl = null;
  12083. this.downEl = null;
  12084. // options that can be directly assigned by caller
  12085. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  12086. this.handleSelector = '';
  12087. this.shouldIgnoreMove = false;
  12088. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  12089. // internal states
  12090. this.isDragging = false;
  12091. this.isTouchDragging = false;
  12092. this.wasTouchScroll = false;
  12093. // Mouse
  12094. // ----------------------------------------------------------------------------------------------------
  12095. this.handleMouseDown = function (ev) {
  12096. if (!_this.shouldIgnoreMouse() &&
  12097. isPrimaryMouseButton(ev) &&
  12098. _this.tryStart(ev)) {
  12099. var pev = _this.createEventFromMouse(ev, true);
  12100. _this.emitter.trigger('pointerdown', pev);
  12101. _this.initScrollWatch(pev);
  12102. if (!_this.shouldIgnoreMove) {
  12103. document.addEventListener('mousemove', _this.handleMouseMove);
  12104. }
  12105. document.addEventListener('mouseup', _this.handleMouseUp);
  12106. }
  12107. };
  12108. this.handleMouseMove = function (ev) {
  12109. var pev = _this.createEventFromMouse(ev);
  12110. _this.recordCoords(pev);
  12111. _this.emitter.trigger('pointermove', pev);
  12112. };
  12113. this.handleMouseUp = function (ev) {
  12114. document.removeEventListener('mousemove', _this.handleMouseMove);
  12115. document.removeEventListener('mouseup', _this.handleMouseUp);
  12116. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  12117. _this.cleanup(); // call last so that pointerup has access to props
  12118. };
  12119. // Touch
  12120. // ----------------------------------------------------------------------------------------------------
  12121. this.handleTouchStart = function (ev) {
  12122. if (_this.tryStart(ev)) {
  12123. _this.isTouchDragging = true;
  12124. var pev = _this.createEventFromTouch(ev, true);
  12125. _this.emitter.trigger('pointerdown', pev);
  12126. _this.initScrollWatch(pev);
  12127. // unlike mouse, need to attach to target, not document
  12128. // https://stackoverflow.com/a/45760014
  12129. var target = ev.target;
  12130. if (!_this.shouldIgnoreMove) {
  12131. target.addEventListener('touchmove', _this.handleTouchMove);
  12132. }
  12133. target.addEventListener('touchend', _this.handleTouchEnd);
  12134. target.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  12135. // attach a handler to get called when ANY scroll action happens on the page.
  12136. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  12137. // http://stackoverflow.com/a/32954565/96342
  12138. window.addEventListener('scroll', _this.handleTouchScroll, true // useCapture
  12139. );
  12140. }
  12141. };
  12142. this.handleTouchMove = function (ev) {
  12143. var pev = _this.createEventFromTouch(ev);
  12144. _this.recordCoords(pev);
  12145. _this.emitter.trigger('pointermove', pev);
  12146. };
  12147. this.handleTouchEnd = function (ev) {
  12148. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  12149. var target = ev.target;
  12150. target.removeEventListener('touchmove', _this.handleTouchMove);
  12151. target.removeEventListener('touchend', _this.handleTouchEnd);
  12152. target.removeEventListener('touchcancel', _this.handleTouchEnd);
  12153. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  12154. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  12155. _this.cleanup(); // call last so that pointerup has access to props
  12156. _this.isTouchDragging = false;
  12157. startIgnoringMouse();
  12158. }
  12159. };
  12160. this.handleTouchScroll = function () {
  12161. _this.wasTouchScroll = true;
  12162. };
  12163. this.handleScroll = function (ev) {
  12164. if (!_this.shouldIgnoreMove) {
  12165. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  12166. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  12167. _this.emitter.trigger('pointermove', {
  12168. origEvent: ev,
  12169. isTouch: _this.isTouchDragging,
  12170. subjectEl: _this.subjectEl,
  12171. pageX: pageX,
  12172. pageY: pageY,
  12173. deltaX: pageX - _this.origPageX,
  12174. deltaY: pageY - _this.origPageY
  12175. });
  12176. }
  12177. };
  12178. this.containerEl = containerEl;
  12179. this.emitter = new core.EmitterMixin();
  12180. containerEl.addEventListener('mousedown', this.handleMouseDown);
  12181. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  12182. listenerCreated();
  12183. }
  12184. PointerDragging.prototype.destroy = function () {
  12185. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  12186. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  12187. listenerDestroyed();
  12188. };
  12189. PointerDragging.prototype.tryStart = function (ev) {
  12190. var subjectEl = this.querySubjectEl(ev);
  12191. var downEl = ev.target;
  12192. if (subjectEl &&
  12193. (!this.handleSelector || core.elementClosest(downEl, this.handleSelector))) {
  12194. this.subjectEl = subjectEl;
  12195. this.downEl = downEl;
  12196. this.isDragging = true; // do this first so cancelTouchScroll will work
  12197. this.wasTouchScroll = false;
  12198. return true;
  12199. }
  12200. return false;
  12201. };
  12202. PointerDragging.prototype.cleanup = function () {
  12203. isWindowTouchMoveCancelled = false;
  12204. this.isDragging = false;
  12205. this.subjectEl = null;
  12206. this.downEl = null;
  12207. // keep wasTouchScroll around for later access
  12208. this.destroyScrollWatch();
  12209. };
  12210. PointerDragging.prototype.querySubjectEl = function (ev) {
  12211. if (this.selector) {
  12212. return core.elementClosest(ev.target, this.selector);
  12213. }
  12214. else {
  12215. return this.containerEl;
  12216. }
  12217. };
  12218. PointerDragging.prototype.shouldIgnoreMouse = function () {
  12219. return ignoreMouseDepth || this.isTouchDragging;
  12220. };
  12221. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  12222. PointerDragging.prototype.cancelTouchScroll = function () {
  12223. if (this.isDragging) {
  12224. isWindowTouchMoveCancelled = true;
  12225. }
  12226. };
  12227. // Scrolling that simulates pointermoves
  12228. // ----------------------------------------------------------------------------------------------------
  12229. PointerDragging.prototype.initScrollWatch = function (ev) {
  12230. if (this.shouldWatchScroll) {
  12231. this.recordCoords(ev);
  12232. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  12233. }
  12234. };
  12235. PointerDragging.prototype.recordCoords = function (ev) {
  12236. if (this.shouldWatchScroll) {
  12237. this.prevPageX = ev.pageX;
  12238. this.prevPageY = ev.pageY;
  12239. this.prevScrollX = window.pageXOffset;
  12240. this.prevScrollY = window.pageYOffset;
  12241. }
  12242. };
  12243. PointerDragging.prototype.destroyScrollWatch = function () {
  12244. if (this.shouldWatchScroll) {
  12245. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  12246. }
  12247. };
  12248. // Event Normalization
  12249. // ----------------------------------------------------------------------------------------------------
  12250. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  12251. var deltaX = 0;
  12252. var deltaY = 0;
  12253. // TODO: repeat code
  12254. if (isFirst) {
  12255. this.origPageX = ev.pageX;
  12256. this.origPageY = ev.pageY;
  12257. }
  12258. else {
  12259. deltaX = ev.pageX - this.origPageX;
  12260. deltaY = ev.pageY - this.origPageY;
  12261. }
  12262. return {
  12263. origEvent: ev,
  12264. isTouch: false,
  12265. subjectEl: this.subjectEl,
  12266. pageX: ev.pageX,
  12267. pageY: ev.pageY,
  12268. deltaX: deltaX,
  12269. deltaY: deltaY
  12270. };
  12271. };
  12272. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  12273. var touches = ev.touches;
  12274. var pageX;
  12275. var pageY;
  12276. var deltaX = 0;
  12277. var deltaY = 0;
  12278. // if touch coords available, prefer,
  12279. // because FF would give bad ev.pageX ev.pageY
  12280. if (touches && touches.length) {
  12281. pageX = touches[0].pageX;
  12282. pageY = touches[0].pageY;
  12283. }
  12284. else {
  12285. pageX = ev.pageX;
  12286. pageY = ev.pageY;
  12287. }
  12288. // TODO: repeat code
  12289. if (isFirst) {
  12290. this.origPageX = pageX;
  12291. this.origPageY = pageY;
  12292. }
  12293. else {
  12294. deltaX = pageX - this.origPageX;
  12295. deltaY = pageY - this.origPageY;
  12296. }
  12297. return {
  12298. origEvent: ev,
  12299. isTouch: true,
  12300. subjectEl: this.subjectEl,
  12301. pageX: pageX,
  12302. pageY: pageY,
  12303. deltaX: deltaX,
  12304. deltaY: deltaY
  12305. };
  12306. };
  12307. return PointerDragging;
  12308. }());
  12309. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  12310. function isPrimaryMouseButton(ev) {
  12311. return ev.button === 0 && !ev.ctrlKey;
  12312. }
  12313. // Ignoring fake mouse events generated by touch
  12314. // ----------------------------------------------------------------------------------------------------
  12315. function startIgnoringMouse() {
  12316. ignoreMouseDepth++;
  12317. setTimeout(function () {
  12318. ignoreMouseDepth--;
  12319. }, core.config.touchMouseIgnoreWait);
  12320. }
  12321. // We want to attach touchmove as early as possible for Safari
  12322. // ----------------------------------------------------------------------------------------------------
  12323. function listenerCreated() {
  12324. if (!(listenerCnt++)) {
  12325. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  12326. }
  12327. }
  12328. function listenerDestroyed() {
  12329. if (!(--listenerCnt)) {
  12330. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  12331. }
  12332. }
  12333. function onWindowTouchMove(ev) {
  12334. if (isWindowTouchMoveCancelled) {
  12335. ev.preventDefault();
  12336. }
  12337. }
  12338. /*
  12339. An effect in which an element follows the movement of a pointer across the screen.
  12340. The moving element is a clone of some other element.
  12341. Must call start + handleMove + stop.
  12342. */
  12343. var ElementMirror = /** @class */ (function () {
  12344. function ElementMirror() {
  12345. this.isVisible = false; // must be explicitly enabled
  12346. this.sourceEl = null;
  12347. this.mirrorEl = null;
  12348. this.sourceElRect = null; // screen coords relative to viewport
  12349. // options that can be set directly by caller
  12350. this.parentNode = document.body;
  12351. this.zIndex = 9999;
  12352. this.revertDuration = 0;
  12353. }
  12354. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  12355. this.sourceEl = sourceEl;
  12356. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  12357. this.origScreenX = pageX - window.pageXOffset;
  12358. this.origScreenY = pageY - window.pageYOffset;
  12359. this.deltaX = 0;
  12360. this.deltaY = 0;
  12361. this.updateElPosition();
  12362. };
  12363. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  12364. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  12365. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  12366. this.updateElPosition();
  12367. };
  12368. // can be called before start
  12369. ElementMirror.prototype.setIsVisible = function (bool) {
  12370. if (bool) {
  12371. if (!this.isVisible) {
  12372. if (this.mirrorEl) {
  12373. this.mirrorEl.style.display = '';
  12374. }
  12375. this.isVisible = bool; // needs to happen before updateElPosition
  12376. this.updateElPosition(); // because was not updating the position while invisible
  12377. }
  12378. }
  12379. else {
  12380. if (this.isVisible) {
  12381. if (this.mirrorEl) {
  12382. this.mirrorEl.style.display = 'none';
  12383. }
  12384. this.isVisible = bool;
  12385. }
  12386. }
  12387. };
  12388. // always async
  12389. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  12390. var _this = this;
  12391. var done = function () {
  12392. _this.cleanup();
  12393. callback();
  12394. };
  12395. if (needsRevertAnimation &&
  12396. this.mirrorEl &&
  12397. this.isVisible &&
  12398. this.revertDuration && // if 0, transition won't work
  12399. (this.deltaX || this.deltaY) // if same coords, transition won't work
  12400. ) {
  12401. this.doRevertAnimation(done, this.revertDuration);
  12402. }
  12403. else {
  12404. setTimeout(done, 0);
  12405. }
  12406. };
  12407. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  12408. var mirrorEl = this.mirrorEl;
  12409. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  12410. mirrorEl.style.transition =
  12411. 'top ' + revertDuration + 'ms,' +
  12412. 'left ' + revertDuration + 'ms';
  12413. core.applyStyle(mirrorEl, {
  12414. left: finalSourceElRect.left,
  12415. top: finalSourceElRect.top
  12416. });
  12417. core.whenTransitionDone(mirrorEl, function () {
  12418. mirrorEl.style.transition = '';
  12419. callback();
  12420. });
  12421. };
  12422. ElementMirror.prototype.cleanup = function () {
  12423. if (this.mirrorEl) {
  12424. core.removeElement(this.mirrorEl);
  12425. this.mirrorEl = null;
  12426. }
  12427. this.sourceEl = null;
  12428. };
  12429. ElementMirror.prototype.updateElPosition = function () {
  12430. if (this.sourceEl && this.isVisible) {
  12431. core.applyStyle(this.getMirrorEl(), {
  12432. left: this.sourceElRect.left + this.deltaX,
  12433. top: this.sourceElRect.top + this.deltaY
  12434. });
  12435. }
  12436. };
  12437. ElementMirror.prototype.getMirrorEl = function () {
  12438. var sourceElRect = this.sourceElRect;
  12439. var mirrorEl = this.mirrorEl;
  12440. if (!mirrorEl) {
  12441. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  12442. // we don't want long taps or any mouse interaction causing selection/menus.
  12443. // would use preventSelection(), but that prevents selectstart, causing problems.
  12444. mirrorEl.classList.add('fc-unselectable');
  12445. mirrorEl.classList.add('fc-dragging');
  12446. core.applyStyle(mirrorEl, {
  12447. position: 'fixed',
  12448. zIndex: this.zIndex,
  12449. visibility: '',
  12450. boxSizing: 'border-box',
  12451. width: sourceElRect.right - sourceElRect.left,
  12452. height: sourceElRect.bottom - sourceElRect.top,
  12453. right: 'auto',
  12454. bottom: 'auto',
  12455. margin: 0
  12456. });
  12457. this.parentNode.appendChild(mirrorEl);
  12458. }
  12459. return mirrorEl;
  12460. };
  12461. return ElementMirror;
  12462. }());
  12463. /*
  12464. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  12465. in addition the "client rectangle" of the element.. the area within the scrollbars.
  12466. The cache can be in one of two modes:
  12467. - doesListening:false - ignores when the container is scrolled by someone else
  12468. - doesListening:true - watch for scrolling and update the cache
  12469. */
  12470. var ScrollGeomCache = /** @class */ (function (_super) {
  12471. __extends(ScrollGeomCache, _super);
  12472. function ScrollGeomCache(scrollController, doesListening) {
  12473. var _this = _super.call(this) || this;
  12474. _this.handleScroll = function () {
  12475. _this.scrollTop = _this.scrollController.getScrollTop();
  12476. _this.scrollLeft = _this.scrollController.getScrollLeft();
  12477. _this.handleScrollChange();
  12478. };
  12479. _this.scrollController = scrollController;
  12480. _this.doesListening = doesListening;
  12481. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  12482. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  12483. _this.scrollWidth = scrollController.getScrollWidth();
  12484. _this.scrollHeight = scrollController.getScrollHeight();
  12485. _this.clientWidth = scrollController.getClientWidth();
  12486. _this.clientHeight = scrollController.getClientHeight();
  12487. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  12488. if (_this.doesListening) {
  12489. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  12490. }
  12491. return _this;
  12492. }
  12493. ScrollGeomCache.prototype.destroy = function () {
  12494. if (this.doesListening) {
  12495. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  12496. }
  12497. };
  12498. ScrollGeomCache.prototype.getScrollTop = function () {
  12499. return this.scrollTop;
  12500. };
  12501. ScrollGeomCache.prototype.getScrollLeft = function () {
  12502. return this.scrollLeft;
  12503. };
  12504. ScrollGeomCache.prototype.setScrollTop = function (top) {
  12505. this.scrollController.setScrollTop(top);
  12506. if (!this.doesListening) {
  12507. // we are not relying on the element to normalize out-of-bounds scroll values
  12508. // so we need to sanitize ourselves
  12509. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  12510. this.handleScrollChange();
  12511. }
  12512. };
  12513. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  12514. this.scrollController.setScrollLeft(top);
  12515. if (!this.doesListening) {
  12516. // we are not relying on the element to normalize out-of-bounds scroll values
  12517. // so we need to sanitize ourselves
  12518. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  12519. this.handleScrollChange();
  12520. }
  12521. };
  12522. ScrollGeomCache.prototype.getClientWidth = function () {
  12523. return this.clientWidth;
  12524. };
  12525. ScrollGeomCache.prototype.getClientHeight = function () {
  12526. return this.clientHeight;
  12527. };
  12528. ScrollGeomCache.prototype.getScrollWidth = function () {
  12529. return this.scrollWidth;
  12530. };
  12531. ScrollGeomCache.prototype.getScrollHeight = function () {
  12532. return this.scrollHeight;
  12533. };
  12534. ScrollGeomCache.prototype.handleScrollChange = function () {
  12535. };
  12536. return ScrollGeomCache;
  12537. }(core.ScrollController));
  12538. var ElementScrollGeomCache = /** @class */ (function (_super) {
  12539. __extends(ElementScrollGeomCache, _super);
  12540. function ElementScrollGeomCache(el, doesListening) {
  12541. return _super.call(this, new core.ElementScrollController(el), doesListening) || this;
  12542. }
  12543. ElementScrollGeomCache.prototype.getEventTarget = function () {
  12544. return this.scrollController.el;
  12545. };
  12546. ElementScrollGeomCache.prototype.computeClientRect = function () {
  12547. return core.computeInnerRect(this.scrollController.el);
  12548. };
  12549. return ElementScrollGeomCache;
  12550. }(ScrollGeomCache));
  12551. var WindowScrollGeomCache = /** @class */ (function (_super) {
  12552. __extends(WindowScrollGeomCache, _super);
  12553. function WindowScrollGeomCache(doesListening) {
  12554. return _super.call(this, new core.WindowScrollController(), doesListening) || this;
  12555. }
  12556. WindowScrollGeomCache.prototype.getEventTarget = function () {
  12557. return window;
  12558. };
  12559. WindowScrollGeomCache.prototype.computeClientRect = function () {
  12560. return {
  12561. left: this.scrollLeft,
  12562. right: this.scrollLeft + this.clientWidth,
  12563. top: this.scrollTop,
  12564. bottom: this.scrollTop + this.clientHeight
  12565. };
  12566. };
  12567. // the window is the only scroll object that changes it's rectangle relative
  12568. // to the document's topleft as it scrolls
  12569. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  12570. this.clientRect = this.computeClientRect();
  12571. };
  12572. return WindowScrollGeomCache;
  12573. }(ScrollGeomCache));
  12574. // If available we are using native "performance" API instead of "Date"
  12575. // Read more about it on MDN:
  12576. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  12577. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  12578. /*
  12579. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  12580. approaches the edge.
  12581. The caller must call start + handleMove + stop.
  12582. */
  12583. var AutoScroller = /** @class */ (function () {
  12584. function AutoScroller() {
  12585. var _this = this;
  12586. // options that can be set by caller
  12587. this.isEnabled = true;
  12588. this.scrollQuery = [window, '.fc-scroller'];
  12589. this.edgeThreshold = 50; // pixels
  12590. this.maxVelocity = 300; // pixels per second
  12591. // internal state
  12592. this.pointerScreenX = null;
  12593. this.pointerScreenY = null;
  12594. this.isAnimating = false;
  12595. this.scrollCaches = null;
  12596. // protect against the initial pointerdown being too close to an edge and starting the scroll
  12597. this.everMovedUp = false;
  12598. this.everMovedDown = false;
  12599. this.everMovedLeft = false;
  12600. this.everMovedRight = false;
  12601. this.animate = function () {
  12602. if (_this.isAnimating) { // wasn't cancelled between animation calls
  12603. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  12604. if (edge) {
  12605. var now = getTime();
  12606. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  12607. _this.requestAnimation(now);
  12608. }
  12609. else {
  12610. _this.isAnimating = false; // will stop animation
  12611. }
  12612. }
  12613. };
  12614. }
  12615. AutoScroller.prototype.start = function (pageX, pageY) {
  12616. if (this.isEnabled) {
  12617. this.scrollCaches = this.buildCaches();
  12618. this.pointerScreenX = null;
  12619. this.pointerScreenY = null;
  12620. this.everMovedUp = false;
  12621. this.everMovedDown = false;
  12622. this.everMovedLeft = false;
  12623. this.everMovedRight = false;
  12624. this.handleMove(pageX, pageY);
  12625. }
  12626. };
  12627. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  12628. if (this.isEnabled) {
  12629. var pointerScreenX = pageX - window.pageXOffset;
  12630. var pointerScreenY = pageY - window.pageYOffset;
  12631. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  12632. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  12633. if (yDelta < 0) {
  12634. this.everMovedUp = true;
  12635. }
  12636. else if (yDelta > 0) {
  12637. this.everMovedDown = true;
  12638. }
  12639. if (xDelta < 0) {
  12640. this.everMovedLeft = true;
  12641. }
  12642. else if (xDelta > 0) {
  12643. this.everMovedRight = true;
  12644. }
  12645. this.pointerScreenX = pointerScreenX;
  12646. this.pointerScreenY = pointerScreenY;
  12647. if (!this.isAnimating) {
  12648. this.isAnimating = true;
  12649. this.requestAnimation(getTime());
  12650. }
  12651. }
  12652. };
  12653. AutoScroller.prototype.stop = function () {
  12654. if (this.isEnabled) {
  12655. this.isAnimating = false; // will stop animation
  12656. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12657. var scrollCache = _a[_i];
  12658. scrollCache.destroy();
  12659. }
  12660. this.scrollCaches = null;
  12661. }
  12662. };
  12663. AutoScroller.prototype.requestAnimation = function (now) {
  12664. this.msSinceRequest = now;
  12665. requestAnimationFrame(this.animate);
  12666. };
  12667. AutoScroller.prototype.handleSide = function (edge, seconds) {
  12668. var scrollCache = edge.scrollCache;
  12669. var edgeThreshold = this.edgeThreshold;
  12670. var invDistance = edgeThreshold - edge.distance;
  12671. var velocity = // the closer to the edge, the faster we scroll
  12672. (invDistance * invDistance) / (edgeThreshold * edgeThreshold) * // quadratic
  12673. this.maxVelocity * seconds;
  12674. var sign = 1;
  12675. switch (edge.name) {
  12676. case 'left':
  12677. sign = -1;
  12678. // falls through
  12679. case 'right':
  12680. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  12681. break;
  12682. case 'top':
  12683. sign = -1;
  12684. // falls through
  12685. case 'bottom':
  12686. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  12687. break;
  12688. }
  12689. };
  12690. // left/top are relative to document topleft
  12691. AutoScroller.prototype.computeBestEdge = function (left, top) {
  12692. var edgeThreshold = this.edgeThreshold;
  12693. var bestSide = null;
  12694. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12695. var scrollCache = _a[_i];
  12696. var rect = scrollCache.clientRect;
  12697. var leftDist = left - rect.left;
  12698. var rightDist = rect.right - left;
  12699. var topDist = top - rect.top;
  12700. var bottomDist = rect.bottom - top;
  12701. // completely within the rect?
  12702. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  12703. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  12704. (!bestSide || bestSide.distance > topDist)) {
  12705. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  12706. }
  12707. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  12708. (!bestSide || bestSide.distance > bottomDist)) {
  12709. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  12710. }
  12711. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  12712. (!bestSide || bestSide.distance > leftDist)) {
  12713. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  12714. }
  12715. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  12716. (!bestSide || bestSide.distance > rightDist)) {
  12717. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  12718. }
  12719. }
  12720. }
  12721. return bestSide;
  12722. };
  12723. AutoScroller.prototype.buildCaches = function () {
  12724. return this.queryScrollEls().map(function (el) {
  12725. if (el === window) {
  12726. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  12727. }
  12728. else {
  12729. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  12730. }
  12731. });
  12732. };
  12733. AutoScroller.prototype.queryScrollEls = function () {
  12734. var els = [];
  12735. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  12736. var query = _a[_i];
  12737. if (typeof query === 'object') {
  12738. els.push(query);
  12739. }
  12740. else {
  12741. els.push.apply(els, Array.prototype.slice.call(document.querySelectorAll(query)));
  12742. }
  12743. }
  12744. return els;
  12745. };
  12746. return AutoScroller;
  12747. }());
  12748. /*
  12749. Monitors dragging on an element. Has a number of high-level features:
  12750. - minimum distance required before dragging
  12751. - minimum wait time ("delay") before dragging
  12752. - a mirror element that follows the pointer
  12753. */
  12754. var FeaturefulElementDragging = /** @class */ (function (_super) {
  12755. __extends(FeaturefulElementDragging, _super);
  12756. function FeaturefulElementDragging(containerEl) {
  12757. var _this = _super.call(this, containerEl) || this;
  12758. // options that can be directly set by caller
  12759. // the caller can also set the PointerDragging's options as well
  12760. _this.delay = null;
  12761. _this.minDistance = 0;
  12762. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  12763. _this.mirrorNeedsRevert = false;
  12764. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  12765. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  12766. _this.isDelayEnded = false;
  12767. _this.isDistanceSurpassed = false;
  12768. _this.delayTimeoutId = null;
  12769. _this.onPointerDown = function (ev) {
  12770. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  12771. _this.isInteracting = true;
  12772. _this.isDelayEnded = false;
  12773. _this.isDistanceSurpassed = false;
  12774. core.preventSelection(document.body);
  12775. core.preventContextMenu(document.body);
  12776. // prevent links from being visited if there's an eventual drag.
  12777. // also prevents selection in older browsers (maybe?).
  12778. // not necessary for touch, besides, browser would complain about passiveness.
  12779. if (!ev.isTouch) {
  12780. ev.origEvent.preventDefault();
  12781. }
  12782. _this.emitter.trigger('pointerdown', ev);
  12783. if (!_this.pointer.shouldIgnoreMove) {
  12784. // actions related to initiating dragstart+dragmove+dragend...
  12785. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  12786. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  12787. _this.startDelay(ev);
  12788. if (!_this.minDistance) {
  12789. _this.handleDistanceSurpassed(ev);
  12790. }
  12791. }
  12792. }
  12793. };
  12794. _this.onPointerMove = function (ev) {
  12795. if (_this.isInteracting) { // if false, still waiting for previous drag's revert
  12796. _this.emitter.trigger('pointermove', ev);
  12797. if (!_this.isDistanceSurpassed) {
  12798. var minDistance = _this.minDistance;
  12799. var distanceSq = void 0; // current distance from the origin, squared
  12800. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  12801. distanceSq = deltaX * deltaX + deltaY * deltaY;
  12802. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  12803. _this.handleDistanceSurpassed(ev);
  12804. }
  12805. }
  12806. if (_this.isDragging) {
  12807. // a real pointer move? (not one simulated by scrolling)
  12808. if (ev.origEvent.type !== 'scroll') {
  12809. _this.mirror.handleMove(ev.pageX, ev.pageY);
  12810. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  12811. }
  12812. _this.emitter.trigger('dragmove', ev);
  12813. }
  12814. }
  12815. };
  12816. _this.onPointerUp = function (ev) {
  12817. if (_this.isInteracting) { // if false, still waiting for previous drag's revert
  12818. _this.isInteracting = false;
  12819. core.allowSelection(document.body);
  12820. core.allowContextMenu(document.body);
  12821. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  12822. if (_this.isDragging) {
  12823. _this.autoScroller.stop();
  12824. _this.tryStopDrag(ev); // which will stop the mirror
  12825. }
  12826. if (_this.delayTimeoutId) {
  12827. clearTimeout(_this.delayTimeoutId);
  12828. _this.delayTimeoutId = null;
  12829. }
  12830. }
  12831. };
  12832. var pointer = _this.pointer = new PointerDragging(containerEl);
  12833. pointer.emitter.on('pointerdown', _this.onPointerDown);
  12834. pointer.emitter.on('pointermove', _this.onPointerMove);
  12835. pointer.emitter.on('pointerup', _this.onPointerUp);
  12836. _this.mirror = new ElementMirror();
  12837. _this.autoScroller = new AutoScroller();
  12838. return _this;
  12839. }
  12840. FeaturefulElementDragging.prototype.destroy = function () {
  12841. this.pointer.destroy();
  12842. };
  12843. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  12844. var _this = this;
  12845. if (typeof this.delay === 'number') {
  12846. this.delayTimeoutId = setTimeout(function () {
  12847. _this.delayTimeoutId = null;
  12848. _this.handleDelayEnd(ev);
  12849. }, this.delay); // not assignable to number!
  12850. }
  12851. else {
  12852. this.handleDelayEnd(ev);
  12853. }
  12854. };
  12855. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  12856. this.isDelayEnded = true;
  12857. this.tryStartDrag(ev);
  12858. };
  12859. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  12860. this.isDistanceSurpassed = true;
  12861. this.tryStartDrag(ev);
  12862. };
  12863. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  12864. if (this.isDelayEnded && this.isDistanceSurpassed) {
  12865. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  12866. this.isDragging = true;
  12867. this.mirrorNeedsRevert = false;
  12868. this.autoScroller.start(ev.pageX, ev.pageY);
  12869. this.emitter.trigger('dragstart', ev);
  12870. if (this.touchScrollAllowed === false) {
  12871. this.pointer.cancelTouchScroll();
  12872. }
  12873. }
  12874. }
  12875. };
  12876. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  12877. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  12878. // that come from the document to fire beforehand. much more convenient this way.
  12879. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev) // bound with args
  12880. );
  12881. };
  12882. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  12883. this.isDragging = false;
  12884. this.emitter.trigger('dragend', ev);
  12885. };
  12886. // fill in the implementations...
  12887. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  12888. this.pointer.shouldIgnoreMove = bool;
  12889. };
  12890. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  12891. this.mirror.setIsVisible(bool);
  12892. };
  12893. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  12894. this.mirrorNeedsRevert = bool;
  12895. };
  12896. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  12897. this.autoScroller.isEnabled = bool;
  12898. };
  12899. return FeaturefulElementDragging;
  12900. }(core.ElementDragging));
  12901. /*
  12902. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  12903. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  12904. Does not access the DOM after instantiation, so highly performant.
  12905. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  12906. and an determine if a given point is inside the combined clipping rectangle.
  12907. */
  12908. var OffsetTracker = /** @class */ (function () {
  12909. function OffsetTracker(el) {
  12910. this.origRect = core.computeRect(el);
  12911. // will work fine for divs that have overflow:hidden
  12912. this.scrollCaches = core.getClippingParents(el).map(function (el) {
  12913. return new ElementScrollGeomCache(el, true); // listen=true
  12914. });
  12915. }
  12916. OffsetTracker.prototype.destroy = function () {
  12917. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12918. var scrollCache = _a[_i];
  12919. scrollCache.destroy();
  12920. }
  12921. };
  12922. OffsetTracker.prototype.computeLeft = function () {
  12923. var left = this.origRect.left;
  12924. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12925. var scrollCache = _a[_i];
  12926. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  12927. }
  12928. return left;
  12929. };
  12930. OffsetTracker.prototype.computeTop = function () {
  12931. var top = this.origRect.top;
  12932. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12933. var scrollCache = _a[_i];
  12934. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  12935. }
  12936. return top;
  12937. };
  12938. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  12939. var point = { left: pageX, top: pageY };
  12940. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12941. var scrollCache = _a[_i];
  12942. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  12943. !core.pointInsideRect(point, scrollCache.clientRect)) {
  12944. return false;
  12945. }
  12946. }
  12947. return true;
  12948. };
  12949. return OffsetTracker;
  12950. }());
  12951. // certain clipping containers should never constrain interactions, like <html> and <body>
  12952. // https://github.com/fullcalendar/fullcalendar/issues/3615
  12953. function isIgnoredClipping(node) {
  12954. var tagName = node.tagName;
  12955. return tagName === 'HTML' || tagName === 'BODY';
  12956. }
  12957. /*
  12958. Tracks movement over multiple droppable areas (aka "hits")
  12959. that exist in one or more DateComponents.
  12960. Relies on an existing draggable.
  12961. emits:
  12962. - pointerdown
  12963. - dragstart
  12964. - hitchange - fires initially, even if not over a hit
  12965. - pointerup
  12966. - (hitchange - again, to null, if ended over a hit)
  12967. - dragend
  12968. */
  12969. var HitDragging = /** @class */ (function () {
  12970. function HitDragging(dragging, droppableStore) {
  12971. var _this = this;
  12972. // options that can be set by caller
  12973. this.useSubjectCenter = false;
  12974. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  12975. this.initialHit = null;
  12976. this.movingHit = null;
  12977. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  12978. this.handlePointerDown = function (ev) {
  12979. var dragging = _this.dragging;
  12980. _this.initialHit = null;
  12981. _this.movingHit = null;
  12982. _this.finalHit = null;
  12983. _this.prepareHits();
  12984. _this.processFirstCoord(ev);
  12985. if (_this.initialHit || !_this.requireInitial) {
  12986. dragging.setIgnoreMove(false);
  12987. _this.emitter.trigger('pointerdown', ev); // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  12988. }
  12989. else {
  12990. dragging.setIgnoreMove(true);
  12991. }
  12992. };
  12993. this.handleDragStart = function (ev) {
  12994. _this.emitter.trigger('dragstart', ev);
  12995. _this.handleMove(ev, true); // force = fire even if initially null
  12996. };
  12997. this.handleDragMove = function (ev) {
  12998. _this.emitter.trigger('dragmove', ev);
  12999. _this.handleMove(ev);
  13000. };
  13001. this.handlePointerUp = function (ev) {
  13002. _this.releaseHits();
  13003. _this.emitter.trigger('pointerup', ev);
  13004. };
  13005. this.handleDragEnd = function (ev) {
  13006. if (_this.movingHit) {
  13007. _this.emitter.trigger('hitupdate', null, true, ev);
  13008. }
  13009. _this.finalHit = _this.movingHit;
  13010. _this.movingHit = null;
  13011. _this.emitter.trigger('dragend', ev);
  13012. };
  13013. this.droppableStore = droppableStore;
  13014. dragging.emitter.on('pointerdown', this.handlePointerDown);
  13015. dragging.emitter.on('dragstart', this.handleDragStart);
  13016. dragging.emitter.on('dragmove', this.handleDragMove);
  13017. dragging.emitter.on('pointerup', this.handlePointerUp);
  13018. dragging.emitter.on('dragend', this.handleDragEnd);
  13019. this.dragging = dragging;
  13020. this.emitter = new core.EmitterMixin();
  13021. }
  13022. // sets initialHit
  13023. // sets coordAdjust
  13024. HitDragging.prototype.processFirstCoord = function (ev) {
  13025. var origPoint = { left: ev.pageX, top: ev.pageY };
  13026. var adjustedPoint = origPoint;
  13027. var subjectEl = ev.subjectEl;
  13028. var subjectRect;
  13029. if (subjectEl !== document) {
  13030. subjectRect = core.computeRect(subjectEl);
  13031. adjustedPoint = core.constrainPoint(adjustedPoint, subjectRect);
  13032. }
  13033. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  13034. if (initialHit) {
  13035. if (this.useSubjectCenter && subjectRect) {
  13036. var slicedSubjectRect = core.intersectRects(subjectRect, initialHit.rect);
  13037. if (slicedSubjectRect) {
  13038. adjustedPoint = core.getRectCenter(slicedSubjectRect);
  13039. }
  13040. }
  13041. this.coordAdjust = core.diffPoints(adjustedPoint, origPoint);
  13042. }
  13043. else {
  13044. this.coordAdjust = { left: 0, top: 0 };
  13045. }
  13046. };
  13047. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  13048. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  13049. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  13050. this.movingHit = hit;
  13051. this.emitter.trigger('hitupdate', hit, false, ev);
  13052. }
  13053. };
  13054. HitDragging.prototype.prepareHits = function () {
  13055. this.offsetTrackers = core.mapHash(this.droppableStore, function (interactionSettings) {
  13056. interactionSettings.component.buildPositionCaches();
  13057. return new OffsetTracker(interactionSettings.el);
  13058. });
  13059. };
  13060. HitDragging.prototype.releaseHits = function () {
  13061. var offsetTrackers = this.offsetTrackers;
  13062. for (var id in offsetTrackers) {
  13063. offsetTrackers[id].destroy();
  13064. }
  13065. this.offsetTrackers = {};
  13066. };
  13067. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  13068. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  13069. var bestHit = null;
  13070. for (var id in droppableStore) {
  13071. var component = droppableStore[id].component;
  13072. var offsetTracker = offsetTrackers[id];
  13073. if (offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  13074. var originLeft = offsetTracker.computeLeft();
  13075. var originTop = offsetTracker.computeTop();
  13076. var positionLeft = offsetLeft - originLeft;
  13077. var positionTop = offsetTop - originTop;
  13078. var origRect = offsetTracker.origRect;
  13079. var width = origRect.right - origRect.left;
  13080. var height = origRect.bottom - origRect.top;
  13081. if (
  13082. // must be within the element's bounds
  13083. positionLeft >= 0 && positionLeft < width &&
  13084. positionTop >= 0 && positionTop < height) {
  13085. var hit = component.queryHit(positionLeft, positionTop, width, height);
  13086. if (hit &&
  13087. (
  13088. // make sure the hit is within activeRange, meaning it's not a deal cell
  13089. !component.props.dateProfile || // hack for DayTile
  13090. core.rangeContainsRange(component.props.dateProfile.activeRange, hit.dateSpan.range)) &&
  13091. (!bestHit || hit.layer > bestHit.layer)) {
  13092. // TODO: better way to re-orient rectangle
  13093. hit.rect.left += originLeft;
  13094. hit.rect.right += originLeft;
  13095. hit.rect.top += originTop;
  13096. hit.rect.bottom += originTop;
  13097. bestHit = hit;
  13098. }
  13099. }
  13100. }
  13101. }
  13102. return bestHit;
  13103. };
  13104. return HitDragging;
  13105. }());
  13106. function isHitsEqual(hit0, hit1) {
  13107. if (!hit0 && !hit1) {
  13108. return true;
  13109. }
  13110. if (Boolean(hit0) !== Boolean(hit1)) {
  13111. return false;
  13112. }
  13113. return core.isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  13114. }
  13115. /*
  13116. Monitors when the user clicks on a specific date/time of a component.
  13117. A pointerdown+pointerup on the same "hit" constitutes a click.
  13118. */
  13119. var DateClicking = /** @class */ (function (_super) {
  13120. __extends(DateClicking, _super);
  13121. function DateClicking(settings) {
  13122. var _this = _super.call(this, settings) || this;
  13123. _this.handlePointerDown = function (ev) {
  13124. var dragging = _this.dragging;
  13125. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  13126. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(dragging.pointer.downEl));
  13127. };
  13128. // won't even fire if moving was ignored
  13129. _this.handleDragEnd = function (ev) {
  13130. var component = _this.component;
  13131. var _a = component.context, calendar = _a.calendar, view = _a.view;
  13132. var pointer = _this.dragging.pointer;
  13133. if (!pointer.wasTouchScroll) {
  13134. var _b = _this.hitDragging, initialHit = _b.initialHit, finalHit = _b.finalHit;
  13135. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  13136. calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, view, ev.origEvent);
  13137. }
  13138. }
  13139. };
  13140. var component = settings.component;
  13141. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  13142. _this.dragging = new FeaturefulElementDragging(component.el);
  13143. _this.dragging.autoScroller.isEnabled = false;
  13144. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
  13145. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13146. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  13147. return _this;
  13148. }
  13149. DateClicking.prototype.destroy = function () {
  13150. this.dragging.destroy();
  13151. };
  13152. return DateClicking;
  13153. }(core.Interaction));
  13154. /*
  13155. Tracks when the user selects a portion of time of a component,
  13156. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  13157. */
  13158. var DateSelecting = /** @class */ (function (_super) {
  13159. __extends(DateSelecting, _super);
  13160. function DateSelecting(settings) {
  13161. var _this = _super.call(this, settings) || this;
  13162. _this.dragSelection = null;
  13163. _this.handlePointerDown = function (ev) {
  13164. var _a = _this, component = _a.component, dragging = _a.dragging;
  13165. var options = component.context.options;
  13166. var canSelect = options.selectable &&
  13167. component.isValidDateDownEl(ev.origEvent.target);
  13168. // don't bother to watch expensive moves if component won't do selection
  13169. dragging.setIgnoreMove(!canSelect);
  13170. // if touch, require user to hold down
  13171. dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
  13172. };
  13173. _this.handleDragStart = function (ev) {
  13174. _this.component.context.calendar.unselect(ev); // unselect previous selections
  13175. };
  13176. _this.handleHitUpdate = function (hit, isFinal) {
  13177. var calendar = _this.component.context.calendar;
  13178. var dragSelection = null;
  13179. var isInvalid = false;
  13180. if (hit) {
  13181. dragSelection = joinHitsIntoSelection(_this.hitDragging.initialHit, hit, calendar.pluginSystem.hooks.dateSelectionTransformers);
  13182. if (!dragSelection || !_this.component.isDateSelectionValid(dragSelection)) {
  13183. isInvalid = true;
  13184. dragSelection = null;
  13185. }
  13186. }
  13187. if (dragSelection) {
  13188. calendar.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  13189. }
  13190. else if (!isFinal) { // only unselect if moved away while dragging
  13191. calendar.dispatch({ type: 'UNSELECT_DATES' });
  13192. }
  13193. if (!isInvalid) {
  13194. core.enableCursor();
  13195. }
  13196. else {
  13197. core.disableCursor();
  13198. }
  13199. if (!isFinal) {
  13200. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  13201. }
  13202. };
  13203. _this.handlePointerUp = function (pev) {
  13204. if (_this.dragSelection) {
  13205. // selection is already rendered, so just need to report selection
  13206. _this.component.context.calendar.triggerDateSelect(_this.dragSelection, pev);
  13207. _this.dragSelection = null;
  13208. }
  13209. };
  13210. var component = settings.component;
  13211. var options = component.context.options;
  13212. var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
  13213. dragging.touchScrollAllowed = false;
  13214. dragging.minDistance = options.selectMinDistance || 0;
  13215. dragging.autoScroller.isEnabled = options.dragScroll;
  13216. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
  13217. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13218. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  13219. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  13220. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  13221. return _this;
  13222. }
  13223. DateSelecting.prototype.destroy = function () {
  13224. this.dragging.destroy();
  13225. };
  13226. return DateSelecting;
  13227. }(core.Interaction));
  13228. function getComponentTouchDelay(component) {
  13229. var options = component.context.options;
  13230. var delay = options.selectLongPressDelay;
  13231. if (delay == null) {
  13232. delay = options.longPressDelay;
  13233. }
  13234. return delay;
  13235. }
  13236. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  13237. var dateSpan0 = hit0.dateSpan;
  13238. var dateSpan1 = hit1.dateSpan;
  13239. var ms = [
  13240. dateSpan0.range.start,
  13241. dateSpan0.range.end,
  13242. dateSpan1.range.start,
  13243. dateSpan1.range.end
  13244. ];
  13245. ms.sort(core.compareNumbers);
  13246. var props = {};
  13247. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  13248. var transformer = dateSelectionTransformers_1[_i];
  13249. var res = transformer(hit0, hit1);
  13250. if (res === false) {
  13251. return null;
  13252. }
  13253. else if (res) {
  13254. __assign(props, res);
  13255. }
  13256. }
  13257. props.range = { start: ms[0], end: ms[3] };
  13258. props.allDay = dateSpan0.allDay;
  13259. return props;
  13260. }
  13261. var EventDragging = /** @class */ (function (_super) {
  13262. __extends(EventDragging, _super);
  13263. function EventDragging(settings) {
  13264. var _this = _super.call(this, settings) || this;
  13265. // internal state
  13266. _this.subjectSeg = null; // the seg being selected/dragged
  13267. _this.isDragging = false;
  13268. _this.eventRange = null;
  13269. _this.relevantEvents = null; // the events being dragged
  13270. _this.receivingCalendar = null;
  13271. _this.validMutation = null;
  13272. _this.mutatedRelevantEvents = null;
  13273. _this.handlePointerDown = function (ev) {
  13274. var origTarget = ev.origEvent.target;
  13275. var _a = _this, component = _a.component, dragging = _a.dragging;
  13276. var mirror = dragging.mirror;
  13277. var options = component.context.options;
  13278. var initialCalendar = component.context.calendar;
  13279. var subjectSeg = _this.subjectSeg = core.getElSeg(ev.subjectEl);
  13280. var eventRange = _this.eventRange = subjectSeg.eventRange;
  13281. var eventInstanceId = eventRange.instance.instanceId;
  13282. _this.relevantEvents = core.getRelevantEvents(initialCalendar.state.eventStore, eventInstanceId);
  13283. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  13284. dragging.delay =
  13285. // only do a touch delay if touch and this event hasn't been selected yet
  13286. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  13287. getComponentTouchDelay$1(component) :
  13288. null;
  13289. mirror.parentNode = initialCalendar.el;
  13290. mirror.revertDuration = options.dragRevertDuration;
  13291. var isValid = component.isValidSegDownEl(origTarget) &&
  13292. !core.elementClosest(origTarget, '.fc-resizer'); // NOT on a resizer
  13293. dragging.setIgnoreMove(!isValid);
  13294. // disable dragging for elements that are resizable (ie, selectable)
  13295. // but are not draggable
  13296. _this.isDragging = isValid &&
  13297. ev.subjectEl.classList.contains('fc-draggable');
  13298. };
  13299. _this.handleDragStart = function (ev) {
  13300. var context = _this.component.context;
  13301. var initialCalendar = context.calendar;
  13302. var eventRange = _this.eventRange;
  13303. var eventInstanceId = eventRange.instance.instanceId;
  13304. if (ev.isTouch) {
  13305. // need to select a different event?
  13306. if (eventInstanceId !== _this.component.props.eventSelection) {
  13307. initialCalendar.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  13308. }
  13309. }
  13310. else {
  13311. // if now using mouse, but was previous touch interaction, clear selected event
  13312. initialCalendar.dispatch({ type: 'UNSELECT_EVENT' });
  13313. }
  13314. if (_this.isDragging) {
  13315. initialCalendar.unselect(ev); // unselect *date* selection
  13316. initialCalendar.publiclyTrigger('eventDragStart', [
  13317. {
  13318. el: _this.subjectSeg.el,
  13319. event: new core.EventApi(initialCalendar, eventRange.def, eventRange.instance),
  13320. jsEvent: ev.origEvent,
  13321. view: context.view
  13322. }
  13323. ]);
  13324. }
  13325. };
  13326. _this.handleHitUpdate = function (hit, isFinal) {
  13327. if (!_this.isDragging) {
  13328. return;
  13329. }
  13330. var relevantEvents = _this.relevantEvents;
  13331. var initialHit = _this.hitDragging.initialHit;
  13332. var initialCalendar = _this.component.context.calendar;
  13333. // states based on new hit
  13334. var receivingCalendar = null;
  13335. var mutation = null;
  13336. var mutatedRelevantEvents = null;
  13337. var isInvalid = false;
  13338. var interaction = {
  13339. affectedEvents: relevantEvents,
  13340. mutatedEvents: core.createEmptyEventStore(),
  13341. isEvent: true,
  13342. origSeg: _this.subjectSeg
  13343. };
  13344. if (hit) {
  13345. var receivingComponent = hit.component;
  13346. receivingCalendar = receivingComponent.context.calendar;
  13347. var receivingOptions = receivingComponent.context.options;
  13348. if (initialCalendar === receivingCalendar ||
  13349. receivingOptions.editable && receivingOptions.droppable) {
  13350. mutation = computeEventMutation(initialHit, hit, receivingCalendar.pluginSystem.hooks.eventDragMutationMassagers);
  13351. if (mutation) {
  13352. mutatedRelevantEvents = core.applyMutationToEventStore(relevantEvents, receivingCalendar.eventUiBases, mutation, receivingCalendar);
  13353. interaction.mutatedEvents = mutatedRelevantEvents;
  13354. if (!receivingComponent.isInteractionValid(interaction)) {
  13355. isInvalid = true;
  13356. mutation = null;
  13357. mutatedRelevantEvents = null;
  13358. interaction.mutatedEvents = core.createEmptyEventStore();
  13359. }
  13360. }
  13361. }
  13362. else {
  13363. receivingCalendar = null;
  13364. }
  13365. }
  13366. _this.displayDrag(receivingCalendar, interaction);
  13367. if (!isInvalid) {
  13368. core.enableCursor();
  13369. }
  13370. else {
  13371. core.disableCursor();
  13372. }
  13373. if (!isFinal) {
  13374. if (initialCalendar === receivingCalendar && // TODO: write test for this
  13375. isHitsEqual(initialHit, hit)) {
  13376. mutation = null;
  13377. }
  13378. _this.dragging.setMirrorNeedsRevert(!mutation);
  13379. // render the mirror if no already-rendered mirror
  13380. // TODO: wish we could somehow wait for dispatch to guarantee render
  13381. _this.dragging.setMirrorIsVisible(!hit || !document.querySelector('.fc-mirror'));
  13382. // assign states based on new hit
  13383. _this.receivingCalendar = receivingCalendar;
  13384. _this.validMutation = mutation;
  13385. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  13386. }
  13387. };
  13388. _this.handlePointerUp = function () {
  13389. if (!_this.isDragging) {
  13390. _this.cleanup(); // because handleDragEnd won't fire
  13391. }
  13392. };
  13393. _this.handleDragEnd = function (ev) {
  13394. if (_this.isDragging) {
  13395. var context = _this.component.context;
  13396. var initialCalendar_1 = context.calendar;
  13397. var initialView = context.view;
  13398. var _a = _this, receivingCalendar = _a.receivingCalendar, validMutation = _a.validMutation;
  13399. var eventDef = _this.eventRange.def;
  13400. var eventInstance = _this.eventRange.instance;
  13401. var eventApi = new core.EventApi(initialCalendar_1, eventDef, eventInstance);
  13402. var relevantEvents_1 = _this.relevantEvents;
  13403. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  13404. var finalHit = _this.hitDragging.finalHit;
  13405. _this.clearDrag(); // must happen after revert animation
  13406. initialCalendar_1.publiclyTrigger('eventDragStop', [
  13407. {
  13408. el: _this.subjectSeg.el,
  13409. event: eventApi,
  13410. jsEvent: ev.origEvent,
  13411. view: initialView
  13412. }
  13413. ]);
  13414. if (validMutation) {
  13415. // dropped within same calendar
  13416. if (receivingCalendar === initialCalendar_1) {
  13417. initialCalendar_1.dispatch({
  13418. type: 'MERGE_EVENTS',
  13419. eventStore: mutatedRelevantEvents
  13420. });
  13421. var transformed = {};
  13422. for (var _i = 0, _b = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _b.length; _i++) {
  13423. var transformer = _b[_i];
  13424. __assign(transformed, transformer(validMutation, initialCalendar_1));
  13425. }
  13426. var eventDropArg = __assign({}, transformed, { el: ev.subjectEl, delta: validMutation.datesDelta, oldEvent: eventApi, event: new core.EventApi(// the data AFTER the mutation
  13427. initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null), revert: function () {
  13428. initialCalendar_1.dispatch({
  13429. type: 'MERGE_EVENTS',
  13430. eventStore: relevantEvents_1
  13431. });
  13432. }, jsEvent: ev.origEvent, view: initialView });
  13433. initialCalendar_1.publiclyTrigger('eventDrop', [eventDropArg]);
  13434. // dropped in different calendar
  13435. }
  13436. else if (receivingCalendar) {
  13437. initialCalendar_1.publiclyTrigger('eventLeave', [
  13438. {
  13439. draggedEl: ev.subjectEl,
  13440. event: eventApi,
  13441. view: initialView
  13442. }
  13443. ]);
  13444. initialCalendar_1.dispatch({
  13445. type: 'REMOVE_EVENT_INSTANCES',
  13446. instances: _this.mutatedRelevantEvents.instances
  13447. });
  13448. receivingCalendar.dispatch({
  13449. type: 'MERGE_EVENTS',
  13450. eventStore: _this.mutatedRelevantEvents
  13451. });
  13452. if (ev.isTouch) {
  13453. receivingCalendar.dispatch({
  13454. type: 'SELECT_EVENT',
  13455. eventInstanceId: eventInstance.instanceId
  13456. });
  13457. }
  13458. var dropArg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component // should this be finalHit.component.view? See #4644
  13459. });
  13460. receivingCalendar.publiclyTrigger('drop', [dropArg]);
  13461. receivingCalendar.publiclyTrigger('eventReceive', [
  13462. {
  13463. draggedEl: ev.subjectEl,
  13464. event: new core.EventApi(// the data AFTER the mutation
  13465. receivingCalendar, mutatedRelevantEvents.defs[eventDef.defId], mutatedRelevantEvents.instances[eventInstance.instanceId]),
  13466. view: finalHit.component // should this be finalHit.component.view? See #4644
  13467. }
  13468. ]);
  13469. }
  13470. }
  13471. else {
  13472. initialCalendar_1.publiclyTrigger('_noEventDrop');
  13473. }
  13474. }
  13475. _this.cleanup();
  13476. };
  13477. var component = _this.component;
  13478. var options = component.context.options;
  13479. var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
  13480. dragging.pointer.selector = EventDragging.SELECTOR;
  13481. dragging.touchScrollAllowed = false;
  13482. dragging.autoScroller.isEnabled = options.dragScroll;
  13483. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsStore);
  13484. hitDragging.useSubjectCenter = settings.useEventCenter;
  13485. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13486. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  13487. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  13488. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  13489. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  13490. return _this;
  13491. }
  13492. EventDragging.prototype.destroy = function () {
  13493. this.dragging.destroy();
  13494. };
  13495. // render a drag state on the next receivingCalendar
  13496. EventDragging.prototype.displayDrag = function (nextCalendar, state) {
  13497. var initialCalendar = this.component.context.calendar;
  13498. var prevCalendar = this.receivingCalendar;
  13499. // does the previous calendar need to be cleared?
  13500. if (prevCalendar && prevCalendar !== nextCalendar) {
  13501. // does the initial calendar need to be cleared?
  13502. // if so, don't clear all the way. we still need to to hide the affectedEvents
  13503. if (prevCalendar === initialCalendar) {
  13504. prevCalendar.dispatch({
  13505. type: 'SET_EVENT_DRAG',
  13506. state: {
  13507. affectedEvents: state.affectedEvents,
  13508. mutatedEvents: core.createEmptyEventStore(),
  13509. isEvent: true,
  13510. origSeg: state.origSeg
  13511. }
  13512. });
  13513. // completely clear the old calendar if it wasn't the initial
  13514. }
  13515. else {
  13516. prevCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13517. }
  13518. }
  13519. if (nextCalendar) {
  13520. nextCalendar.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  13521. }
  13522. };
  13523. EventDragging.prototype.clearDrag = function () {
  13524. var initialCalendar = this.component.context.calendar;
  13525. var receivingCalendar = this.receivingCalendar;
  13526. if (receivingCalendar) {
  13527. receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13528. }
  13529. // the initial calendar might have an dummy drag state from displayDrag
  13530. if (initialCalendar !== receivingCalendar) {
  13531. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13532. }
  13533. };
  13534. EventDragging.prototype.cleanup = function () {
  13535. this.subjectSeg = null;
  13536. this.isDragging = false;
  13537. this.eventRange = null;
  13538. this.relevantEvents = null;
  13539. this.receivingCalendar = null;
  13540. this.validMutation = null;
  13541. this.mutatedRelevantEvents = null;
  13542. };
  13543. EventDragging.SELECTOR = '.fc-draggable, .fc-resizable'; // TODO: test this in IE11
  13544. return EventDragging;
  13545. }(core.Interaction));
  13546. function computeEventMutation(hit0, hit1, massagers) {
  13547. var dateSpan0 = hit0.dateSpan;
  13548. var dateSpan1 = hit1.dateSpan;
  13549. var date0 = dateSpan0.range.start;
  13550. var date1 = dateSpan1.range.start;
  13551. var standardProps = {};
  13552. if (dateSpan0.allDay !== dateSpan1.allDay) {
  13553. standardProps.allDay = dateSpan1.allDay;
  13554. standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
  13555. if (dateSpan1.allDay) {
  13556. // means date1 is already start-of-day,
  13557. // but date0 needs to be converted
  13558. date0 = core.startOfDay(date0);
  13559. }
  13560. }
  13561. var delta = core.diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
  13562. hit0.component.largeUnit :
  13563. null);
  13564. if (delta.milliseconds) { // has hours/minutes/seconds
  13565. standardProps.allDay = false;
  13566. }
  13567. var mutation = {
  13568. datesDelta: delta,
  13569. standardProps: standardProps
  13570. };
  13571. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  13572. var massager = massagers_1[_i];
  13573. massager(mutation, hit0, hit1);
  13574. }
  13575. return mutation;
  13576. }
  13577. function getComponentTouchDelay$1(component) {
  13578. var options = component.context.options;
  13579. var delay = options.eventLongPressDelay;
  13580. if (delay == null) {
  13581. delay = options.longPressDelay;
  13582. }
  13583. return delay;
  13584. }
  13585. var EventDragging$1 = /** @class */ (function (_super) {
  13586. __extends(EventDragging, _super);
  13587. function EventDragging(settings) {
  13588. var _this = _super.call(this, settings) || this;
  13589. // internal state
  13590. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  13591. _this.eventRange = null;
  13592. _this.relevantEvents = null;
  13593. _this.validMutation = null;
  13594. _this.mutatedRelevantEvents = null;
  13595. _this.handlePointerDown = function (ev) {
  13596. var component = _this.component;
  13597. var seg = _this.querySeg(ev);
  13598. var eventRange = _this.eventRange = seg.eventRange;
  13599. _this.dragging.minDistance = component.context.options.eventDragMinDistance;
  13600. // if touch, need to be working with a selected event
  13601. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  13602. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  13603. };
  13604. _this.handleDragStart = function (ev) {
  13605. var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
  13606. var eventRange = _this.eventRange;
  13607. _this.relevantEvents = core.getRelevantEvents(calendar.state.eventStore, _this.eventRange.instance.instanceId);
  13608. _this.draggingSeg = _this.querySeg(ev);
  13609. calendar.unselect();
  13610. calendar.publiclyTrigger('eventResizeStart', [
  13611. {
  13612. el: _this.draggingSeg.el,
  13613. event: new core.EventApi(calendar, eventRange.def, eventRange.instance),
  13614. jsEvent: ev.origEvent,
  13615. view: view
  13616. }
  13617. ]);
  13618. };
  13619. _this.handleHitUpdate = function (hit, isFinal, ev) {
  13620. var calendar = _this.component.context.calendar;
  13621. var relevantEvents = _this.relevantEvents;
  13622. var initialHit = _this.hitDragging.initialHit;
  13623. var eventInstance = _this.eventRange.instance;
  13624. var mutation = null;
  13625. var mutatedRelevantEvents = null;
  13626. var isInvalid = false;
  13627. var interaction = {
  13628. affectedEvents: relevantEvents,
  13629. mutatedEvents: core.createEmptyEventStore(),
  13630. isEvent: true,
  13631. origSeg: _this.draggingSeg
  13632. };
  13633. if (hit) {
  13634. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-start-resizer'), eventInstance.range, calendar.pluginSystem.hooks.eventResizeJoinTransforms);
  13635. }
  13636. if (mutation) {
  13637. mutatedRelevantEvents = core.applyMutationToEventStore(relevantEvents, calendar.eventUiBases, mutation, calendar);
  13638. interaction.mutatedEvents = mutatedRelevantEvents;
  13639. if (!_this.component.isInteractionValid(interaction)) {
  13640. isInvalid = true;
  13641. mutation = null;
  13642. mutatedRelevantEvents = null;
  13643. interaction.mutatedEvents = null;
  13644. }
  13645. }
  13646. if (mutatedRelevantEvents) {
  13647. calendar.dispatch({
  13648. type: 'SET_EVENT_RESIZE',
  13649. state: interaction
  13650. });
  13651. }
  13652. else {
  13653. calendar.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  13654. }
  13655. if (!isInvalid) {
  13656. core.enableCursor();
  13657. }
  13658. else {
  13659. core.disableCursor();
  13660. }
  13661. if (!isFinal) {
  13662. if (mutation && isHitsEqual(initialHit, hit)) {
  13663. mutation = null;
  13664. }
  13665. _this.validMutation = mutation;
  13666. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  13667. }
  13668. };
  13669. _this.handleDragEnd = function (ev) {
  13670. var _a = _this.component.context, calendar = _a.calendar, view = _a.view;
  13671. var eventDef = _this.eventRange.def;
  13672. var eventInstance = _this.eventRange.instance;
  13673. var eventApi = new core.EventApi(calendar, eventDef, eventInstance);
  13674. var relevantEvents = _this.relevantEvents;
  13675. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  13676. calendar.publiclyTrigger('eventResizeStop', [
  13677. {
  13678. el: _this.draggingSeg.el,
  13679. event: eventApi,
  13680. jsEvent: ev.origEvent,
  13681. view: view
  13682. }
  13683. ]);
  13684. if (_this.validMutation) {
  13685. calendar.dispatch({
  13686. type: 'MERGE_EVENTS',
  13687. eventStore: mutatedRelevantEvents
  13688. });
  13689. calendar.publiclyTrigger('eventResize', [
  13690. {
  13691. el: _this.draggingSeg.el,
  13692. startDelta: _this.validMutation.startDelta || core.createDuration(0),
  13693. endDelta: _this.validMutation.endDelta || core.createDuration(0),
  13694. prevEvent: eventApi,
  13695. event: new core.EventApi(// the data AFTER the mutation
  13696. calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
  13697. revert: function () {
  13698. calendar.dispatch({
  13699. type: 'MERGE_EVENTS',
  13700. eventStore: relevantEvents
  13701. });
  13702. },
  13703. jsEvent: ev.origEvent,
  13704. view: view
  13705. }
  13706. ]);
  13707. }
  13708. else {
  13709. calendar.publiclyTrigger('_noEventResize');
  13710. }
  13711. // reset all internal state
  13712. _this.draggingSeg = null;
  13713. _this.relevantEvents = null;
  13714. _this.validMutation = null;
  13715. // okay to keep eventInstance around. useful to set it in handlePointerDown
  13716. };
  13717. var component = settings.component;
  13718. var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
  13719. dragging.pointer.selector = '.fc-resizer';
  13720. dragging.touchScrollAllowed = false;
  13721. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  13722. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
  13723. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13724. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  13725. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  13726. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  13727. return _this;
  13728. }
  13729. EventDragging.prototype.destroy = function () {
  13730. this.dragging.destroy();
  13731. };
  13732. EventDragging.prototype.querySeg = function (ev) {
  13733. return core.getElSeg(core.elementClosest(ev.subjectEl, this.component.fgSegSelector));
  13734. };
  13735. return EventDragging;
  13736. }(core.Interaction));
  13737. function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
  13738. var dateEnv = hit0.component.context.dateEnv;
  13739. var date0 = hit0.dateSpan.range.start;
  13740. var date1 = hit1.dateSpan.range.start;
  13741. var delta = core.diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
  13742. var props = {};
  13743. for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
  13744. var transform = transforms_1[_i];
  13745. var res = transform(hit0, hit1);
  13746. if (res === false) {
  13747. return null;
  13748. }
  13749. else if (res) {
  13750. __assign(props, res);
  13751. }
  13752. }
  13753. if (isFromStart) {
  13754. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  13755. props.startDelta = delta;
  13756. return props;
  13757. }
  13758. }
  13759. else {
  13760. if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  13761. props.endDelta = delta;
  13762. return props;
  13763. }
  13764. }
  13765. return null;
  13766. }
  13767. var UnselectAuto = /** @class */ (function () {
  13768. function UnselectAuto(calendar) {
  13769. var _this = this;
  13770. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  13771. this.onSelect = function (selectInfo) {
  13772. if (selectInfo.jsEvent) {
  13773. _this.isRecentPointerDateSelect = true;
  13774. }
  13775. };
  13776. this.onDocumentPointerUp = function (pev) {
  13777. var _a = _this, calendar = _a.calendar, documentPointer = _a.documentPointer;
  13778. var state = calendar.state;
  13779. // touch-scrolling should never unfocus any type of selection
  13780. if (!documentPointer.wasTouchScroll) {
  13781. if (state.dateSelection && // an existing date selection?
  13782. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  13783. ) {
  13784. var unselectAuto = calendar.viewOpt('unselectAuto');
  13785. var unselectCancel = calendar.viewOpt('unselectCancel');
  13786. if (unselectAuto && (!unselectAuto || !core.elementClosest(documentPointer.downEl, unselectCancel))) {
  13787. calendar.unselect(pev);
  13788. }
  13789. }
  13790. if (state.eventSelection && // an existing event selected?
  13791. !core.elementClosest(documentPointer.downEl, EventDragging.SELECTOR) // interaction DIDN'T start on an event
  13792. ) {
  13793. calendar.dispatch({ type: 'UNSELECT_EVENT' });
  13794. }
  13795. }
  13796. _this.isRecentPointerDateSelect = false;
  13797. };
  13798. this.calendar = calendar;
  13799. var documentPointer = this.documentPointer = new PointerDragging(document);
  13800. documentPointer.shouldIgnoreMove = true;
  13801. documentPointer.shouldWatchScroll = false;
  13802. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  13803. /*
  13804. TODO: better way to know about whether there was a selection with the pointer
  13805. */
  13806. calendar.on('select', this.onSelect);
  13807. }
  13808. UnselectAuto.prototype.destroy = function () {
  13809. this.calendar.off('select', this.onSelect);
  13810. this.documentPointer.destroy();
  13811. };
  13812. return UnselectAuto;
  13813. }());
  13814. /*
  13815. Given an already instantiated draggable object for one-or-more elements,
  13816. Interprets any dragging as an attempt to drag an events that lives outside
  13817. of a calendar onto a calendar.
  13818. */
  13819. var ExternalElementDragging = /** @class */ (function () {
  13820. function ExternalElementDragging(dragging, suppliedDragMeta) {
  13821. var _this = this;
  13822. this.receivingCalendar = null;
  13823. this.droppableEvent = null; // will exist for all drags, even if create:false
  13824. this.suppliedDragMeta = null;
  13825. this.dragMeta = null;
  13826. this.handleDragStart = function (ev) {
  13827. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  13828. };
  13829. this.handleHitUpdate = function (hit, isFinal, ev) {
  13830. var dragging = _this.hitDragging.dragging;
  13831. var receivingCalendar = null;
  13832. var droppableEvent = null;
  13833. var isInvalid = false;
  13834. var interaction = {
  13835. affectedEvents: core.createEmptyEventStore(),
  13836. mutatedEvents: core.createEmptyEventStore(),
  13837. isEvent: _this.dragMeta.create,
  13838. origSeg: null
  13839. };
  13840. if (hit) {
  13841. receivingCalendar = hit.component.context.calendar;
  13842. if (_this.canDropElOnCalendar(ev.subjectEl, receivingCalendar)) {
  13843. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingCalendar);
  13844. interaction.mutatedEvents = core.eventTupleToStore(droppableEvent);
  13845. isInvalid = !core.isInteractionValid(interaction, receivingCalendar);
  13846. if (isInvalid) {
  13847. interaction.mutatedEvents = core.createEmptyEventStore();
  13848. droppableEvent = null;
  13849. }
  13850. }
  13851. }
  13852. _this.displayDrag(receivingCalendar, interaction);
  13853. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  13854. // TODO: wish we could somehow wait for dispatch to guarantee render
  13855. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-mirror'));
  13856. if (!isInvalid) {
  13857. core.enableCursor();
  13858. }
  13859. else {
  13860. core.disableCursor();
  13861. }
  13862. if (!isFinal) {
  13863. dragging.setMirrorNeedsRevert(!droppableEvent);
  13864. _this.receivingCalendar = receivingCalendar;
  13865. _this.droppableEvent = droppableEvent;
  13866. }
  13867. };
  13868. this.handleDragEnd = function (pev) {
  13869. var _a = _this, receivingCalendar = _a.receivingCalendar, droppableEvent = _a.droppableEvent;
  13870. _this.clearDrag();
  13871. if (receivingCalendar && droppableEvent) {
  13872. var finalHit = _this.hitDragging.finalHit;
  13873. var finalView = finalHit.component.context.view;
  13874. var dragMeta = _this.dragMeta;
  13875. var arg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView });
  13876. receivingCalendar.publiclyTrigger('drop', [arg]);
  13877. if (dragMeta.create) {
  13878. receivingCalendar.dispatch({
  13879. type: 'MERGE_EVENTS',
  13880. eventStore: core.eventTupleToStore(droppableEvent)
  13881. });
  13882. if (pev.isTouch) {
  13883. receivingCalendar.dispatch({
  13884. type: 'SELECT_EVENT',
  13885. eventInstanceId: droppableEvent.instance.instanceId
  13886. });
  13887. }
  13888. // signal that an external event landed
  13889. receivingCalendar.publiclyTrigger('eventReceive', [
  13890. {
  13891. draggedEl: pev.subjectEl,
  13892. event: new core.EventApi(receivingCalendar, droppableEvent.def, droppableEvent.instance),
  13893. view: finalView
  13894. }
  13895. ]);
  13896. }
  13897. }
  13898. _this.receivingCalendar = null;
  13899. _this.droppableEvent = null;
  13900. };
  13901. var hitDragging = this.hitDragging = new HitDragging(dragging, core.interactionSettingsStore);
  13902. hitDragging.requireInitial = false; // will start outside of a component
  13903. hitDragging.emitter.on('dragstart', this.handleDragStart);
  13904. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  13905. hitDragging.emitter.on('dragend', this.handleDragEnd);
  13906. this.suppliedDragMeta = suppliedDragMeta;
  13907. }
  13908. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  13909. if (typeof this.suppliedDragMeta === 'object') {
  13910. return core.parseDragMeta(this.suppliedDragMeta);
  13911. }
  13912. else if (typeof this.suppliedDragMeta === 'function') {
  13913. return core.parseDragMeta(this.suppliedDragMeta(subjectEl));
  13914. }
  13915. else {
  13916. return getDragMetaFromEl(subjectEl);
  13917. }
  13918. };
  13919. ExternalElementDragging.prototype.displayDrag = function (nextCalendar, state) {
  13920. var prevCalendar = this.receivingCalendar;
  13921. if (prevCalendar && prevCalendar !== nextCalendar) {
  13922. prevCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13923. }
  13924. if (nextCalendar) {
  13925. nextCalendar.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  13926. }
  13927. };
  13928. ExternalElementDragging.prototype.clearDrag = function () {
  13929. if (this.receivingCalendar) {
  13930. this.receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13931. }
  13932. };
  13933. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingCalendar) {
  13934. var dropAccept = receivingCalendar.opt('dropAccept');
  13935. if (typeof dropAccept === 'function') {
  13936. return dropAccept(el);
  13937. }
  13938. else if (typeof dropAccept === 'string' && dropAccept) {
  13939. return Boolean(core.elementMatches(el, dropAccept));
  13940. }
  13941. return true;
  13942. };
  13943. return ExternalElementDragging;
  13944. }());
  13945. // Utils for computing event store from the DragMeta
  13946. // ----------------------------------------------------------------------------------------------------
  13947. function computeEventForDateSpan(dateSpan, dragMeta, calendar) {
  13948. var defProps = __assign({}, dragMeta.leftoverProps);
  13949. for (var _i = 0, _a = calendar.pluginSystem.hooks.externalDefTransforms; _i < _a.length; _i++) {
  13950. var transform = _a[_i];
  13951. __assign(defProps, transform(dateSpan, dragMeta));
  13952. }
  13953. var def = core.parseEventDef(defProps, dragMeta.sourceId, dateSpan.allDay, calendar.opt('forceEventDuration') || Boolean(dragMeta.duration), // hasEnd
  13954. calendar);
  13955. var start = dateSpan.range.start;
  13956. // only rely on time info if drop zone is all-day,
  13957. // otherwise, we already know the time
  13958. if (dateSpan.allDay && dragMeta.startTime) {
  13959. start = calendar.dateEnv.add(start, dragMeta.startTime);
  13960. }
  13961. var end = dragMeta.duration ?
  13962. calendar.dateEnv.add(start, dragMeta.duration) :
  13963. calendar.getDefaultEventEnd(dateSpan.allDay, start);
  13964. var instance = core.createEventInstance(def.defId, { start: start, end: end });
  13965. return { def: def, instance: instance };
  13966. }
  13967. // Utils for extracting data from element
  13968. // ----------------------------------------------------------------------------------------------------
  13969. function getDragMetaFromEl(el) {
  13970. var str = getEmbeddedElData(el, 'event');
  13971. var obj = str ?
  13972. JSON.parse(str) :
  13973. { create: false }; // if no embedded data, assume no event creation
  13974. return core.parseDragMeta(obj);
  13975. }
  13976. core.config.dataAttrPrefix = '';
  13977. function getEmbeddedElData(el, name) {
  13978. var prefix = core.config.dataAttrPrefix;
  13979. var prefixedName = (prefix ? prefix + '-' : '') + name;
  13980. return el.getAttribute('data-' + prefixedName) || '';
  13981. }
  13982. /*
  13983. Makes an element (that is *external* to any calendar) draggable.
  13984. Can pass in data that determines how an event will be created when dropped onto a calendar.
  13985. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  13986. */
  13987. var ExternalDraggable = /** @class */ (function () {
  13988. function ExternalDraggable(el, settings) {
  13989. var _this = this;
  13990. if (settings === void 0) { settings = {}; }
  13991. this.handlePointerDown = function (ev) {
  13992. var dragging = _this.dragging;
  13993. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  13994. dragging.minDistance =
  13995. minDistance != null ?
  13996. minDistance :
  13997. (ev.isTouch ? 0 : core.globalDefaults.eventDragMinDistance);
  13998. dragging.delay =
  13999. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  14000. (longPressDelay != null ? longPressDelay : core.globalDefaults.longPressDelay) :
  14001. 0;
  14002. };
  14003. this.handleDragStart = function (ev) {
  14004. if (ev.isTouch &&
  14005. _this.dragging.delay &&
  14006. ev.subjectEl.classList.contains('fc-event')) {
  14007. _this.dragging.mirror.getMirrorEl().classList.add('fc-selected');
  14008. }
  14009. };
  14010. this.settings = settings;
  14011. var dragging = this.dragging = new FeaturefulElementDragging(el);
  14012. dragging.touchScrollAllowed = false;
  14013. if (settings.itemSelector != null) {
  14014. dragging.pointer.selector = settings.itemSelector;
  14015. }
  14016. if (settings.appendTo != null) {
  14017. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  14018. }
  14019. dragging.emitter.on('pointerdown', this.handlePointerDown);
  14020. dragging.emitter.on('dragstart', this.handleDragStart);
  14021. new ExternalElementDragging(dragging, settings.eventData);
  14022. }
  14023. ExternalDraggable.prototype.destroy = function () {
  14024. this.dragging.destroy();
  14025. };
  14026. return ExternalDraggable;
  14027. }());
  14028. /*
  14029. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  14030. The third-party system is responsible for drawing the visuals effects of the drag.
  14031. This class simply monitors for pointer movements and fires events.
  14032. It also has the ability to hide the moving element (the "mirror") during the drag.
  14033. */
  14034. var InferredElementDragging = /** @class */ (function (_super) {
  14035. __extends(InferredElementDragging, _super);
  14036. function InferredElementDragging(containerEl) {
  14037. var _this = _super.call(this, containerEl) || this;
  14038. _this.shouldIgnoreMove = false;
  14039. _this.mirrorSelector = '';
  14040. _this.currentMirrorEl = null;
  14041. _this.handlePointerDown = function (ev) {
  14042. _this.emitter.trigger('pointerdown', ev);
  14043. if (!_this.shouldIgnoreMove) {
  14044. // fire dragstart right away. does not support delay or min-distance
  14045. _this.emitter.trigger('dragstart', ev);
  14046. }
  14047. };
  14048. _this.handlePointerMove = function (ev) {
  14049. if (!_this.shouldIgnoreMove) {
  14050. _this.emitter.trigger('dragmove', ev);
  14051. }
  14052. };
  14053. _this.handlePointerUp = function (ev) {
  14054. _this.emitter.trigger('pointerup', ev);
  14055. if (!_this.shouldIgnoreMove) {
  14056. // fire dragend right away. does not support a revert animation
  14057. _this.emitter.trigger('dragend', ev);
  14058. }
  14059. };
  14060. var pointer = _this.pointer = new PointerDragging(containerEl);
  14061. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  14062. pointer.emitter.on('pointermove', _this.handlePointerMove);
  14063. pointer.emitter.on('pointerup', _this.handlePointerUp);
  14064. return _this;
  14065. }
  14066. InferredElementDragging.prototype.destroy = function () {
  14067. this.pointer.destroy();
  14068. };
  14069. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  14070. this.shouldIgnoreMove = bool;
  14071. };
  14072. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  14073. if (bool) {
  14074. // restore a previously hidden element.
  14075. // use the reference in case the selector class has already been removed.
  14076. if (this.currentMirrorEl) {
  14077. this.currentMirrorEl.style.visibility = '';
  14078. this.currentMirrorEl = null;
  14079. }
  14080. }
  14081. else {
  14082. var mirrorEl = this.mirrorSelector ?
  14083. document.querySelector(this.mirrorSelector) :
  14084. null;
  14085. if (mirrorEl) {
  14086. this.currentMirrorEl = mirrorEl;
  14087. mirrorEl.style.visibility = 'hidden';
  14088. }
  14089. }
  14090. };
  14091. return InferredElementDragging;
  14092. }(core.ElementDragging));
  14093. /*
  14094. Bridges third-party drag-n-drop systems with FullCalendar.
  14095. Must be instantiated and destroyed by caller.
  14096. */
  14097. var ThirdPartyDraggable = /** @class */ (function () {
  14098. function ThirdPartyDraggable(containerOrSettings, settings) {
  14099. var containerEl = document;
  14100. if (
  14101. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  14102. containerOrSettings === document ||
  14103. containerOrSettings instanceof Element) {
  14104. containerEl = containerOrSettings;
  14105. settings = settings || {};
  14106. }
  14107. else {
  14108. settings = (containerOrSettings || {});
  14109. }
  14110. var dragging = this.dragging = new InferredElementDragging(containerEl);
  14111. if (typeof settings.itemSelector === 'string') {
  14112. dragging.pointer.selector = settings.itemSelector;
  14113. }
  14114. else if (containerEl === document) {
  14115. dragging.pointer.selector = '[data-event]';
  14116. }
  14117. if (typeof settings.mirrorSelector === 'string') {
  14118. dragging.mirrorSelector = settings.mirrorSelector;
  14119. }
  14120. new ExternalElementDragging(dragging, settings.eventData);
  14121. }
  14122. ThirdPartyDraggable.prototype.destroy = function () {
  14123. this.dragging.destroy();
  14124. };
  14125. return ThirdPartyDraggable;
  14126. }());
  14127. var main = core.createPlugin({
  14128. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventDragging$1],
  14129. calendarInteractions: [UnselectAuto],
  14130. elementDraggingImpl: FeaturefulElementDragging
  14131. });
  14132. exports.Draggable = ExternalDraggable;
  14133. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  14134. exports.PointerDragging = PointerDragging;
  14135. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  14136. exports.default = main;
  14137. Object.defineProperty(exports, '__esModule', { value: true });
  14138. }));
  14139. /*!
  14140. FullCalendar Bootstrap Plugin v4.1.0
  14141. Docs & License: https://fullcalendar.io/
  14142. (c) 2019 Adam Shaw
  14143. */
  14144. (function (global, factory) {
  14145. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  14146. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  14147. (global = global || self, factory(global.FullCalendarBootstrap = {}, global.FullCalendar));
  14148. }(this, function (exports, core) { 'use strict';
  14149. /*! *****************************************************************************
  14150. Copyright (c) Microsoft Corporation. All rights reserved.
  14151. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14152. this file except in compliance with the License. You may obtain a copy of the
  14153. License at http://www.apache.org/licenses/LICENSE-2.0
  14154. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14155. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  14156. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  14157. MERCHANTABLITY OR NON-INFRINGEMENT.
  14158. See the Apache Version 2.0 License for specific language governing permissions
  14159. and limitations under the License.
  14160. ***************************************************************************** */
  14161. /* global Reflect, Promise */
  14162. var extendStatics = function(d, b) {
  14163. extendStatics = Object.setPrototypeOf ||
  14164. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14165. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14166. return extendStatics(d, b);
  14167. };
  14168. function __extends(d, b) {
  14169. extendStatics(d, b);
  14170. function __() { this.constructor = d; }
  14171. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14172. }
  14173. var BootstrapTheme = /** @class */ (function (_super) {
  14174. __extends(BootstrapTheme, _super);
  14175. function BootstrapTheme() {
  14176. return _super !== null && _super.apply(this, arguments) || this;
  14177. }
  14178. return BootstrapTheme;
  14179. }(core.Theme));
  14180. BootstrapTheme.prototype.classes = {
  14181. widget: 'fc-bootstrap',
  14182. tableGrid: 'table-bordered',
  14183. tableList: 'table',
  14184. tableListHeading: 'table-active',
  14185. buttonGroup: 'btn-group',
  14186. button: 'btn btn-default',
  14187. buttonActive: 'active',
  14188. today: 'alert alert-info',
  14189. popover: 'card card-primary',
  14190. popoverHeader: 'card-header',
  14191. popoverContent: 'card-body',
  14192. // day grid
  14193. // for left/right border color when border is inset from edges (all-day in timeGrid view)
  14194. // avoid `table` class b/c don't want margins/padding/structure. only border color.
  14195. headerRow: 'table-bordered',
  14196. dayRow: 'table-bordered',
  14197. // list view
  14198. listView: 'card card-primary'
  14199. };
  14200. BootstrapTheme.prototype.baseIconClass = 'fal';
  14201. BootstrapTheme.prototype.iconClasses = {
  14202. close: 'fa-times',
  14203. prev: 'fa-chevron-left',
  14204. next: 'fa-chevron-right',
  14205. prevYear: 'fa-angle-double-left',
  14206. nextYear: 'fa-angle-double-right'
  14207. };
  14208. BootstrapTheme.prototype.iconOverrideOption = 'bootstrapFontAwesome';
  14209. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  14210. BootstrapTheme.prototype.iconOverridePrefix = 'fa-';
  14211. var main = core.createPlugin({
  14212. themeClasses: {
  14213. bootstrap: BootstrapTheme
  14214. }
  14215. });
  14216. exports.BootstrapTheme = BootstrapTheme;
  14217. exports.default = main;
  14218. Object.defineProperty(exports, '__esModule', { value: true });
  14219. }));