main.js 660 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322
  1. /*!
  2. FullCalendar v5.5.0
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2020 Adam Shaw
  5. */
  6. var FullCalendar = (function (exports) {
  7. 'use strict';
  8. /*! *****************************************************************************
  9. Copyright (c) Microsoft Corporation.
  10. Permission to use, copy, modify, and/or distribute this software for any
  11. purpose with or without fee is hereby granted.
  12. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  13. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  14. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  15. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  16. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  17. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  18. PERFORMANCE OF THIS SOFTWARE.
  19. ***************************************************************************** */
  20. /* global Reflect, Promise */
  21. var extendStatics = function(d, b) {
  22. extendStatics = Object.setPrototypeOf ||
  23. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  24. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  25. return extendStatics(d, b);
  26. };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. var __assign = function() {
  33. __assign = Object.assign || function __assign(t) {
  34. for (var s, i = 1, n = arguments.length; i < n; i++) {
  35. s = arguments[i];
  36. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  37. }
  38. return t;
  39. };
  40. return __assign.apply(this, arguments);
  41. };
  42. function __spreadArrays() {
  43. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  44. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  45. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  46. r[k] = a[j];
  47. return r;
  48. }
  49. var n,u,i,t,o,r,f={},e=[],c=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function s(n,l){for(var u in l)n[u]=l[u];return n}function a(n){var l=n.parentNode;l&&l.removeChild(n);}function v(n,l,u){var i,t,o,r=arguments,f={};for(o in l)"key"==o?i=l[o]:"ref"==o?t=l[o]:f[o]=l[o];if(arguments.length>3)for(u=[u],o=3;o<arguments.length;o++)u.push(r[o]);if(null!=u&&(f.children=u),"function"==typeof n&&null!=n.defaultProps)for(o in n.defaultProps)void 0===f[o]&&(f[o]=n.defaultProps[o]);return h(n,f,i,t,null)}function h(l,u,i,t,o){var r={type:l,props:u,key:i,ref:t,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:null==o?++n.__v:o};return null!=n.vnode&&n.vnode(r),r}function y(){return {current:null}}function p(n){return n.children}function d(n,l){this.props=n,this.context=l;}function _(n,l){if(null==l)return n.__?_(n.__,n.__.__k.indexOf(n)+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?_(n):null}function w(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return w(n)}}function k(l){(!l.__d&&(l.__d=!0)&&u.push(l)&&!g.__r++||t!==n.debounceRendering)&&((t=n.debounceRendering)||i)(g);}function g(){for(var n;g.__r=u.length;)n=u.sort(function(n,l){return n.__v.__b-l.__v.__b}),u=[],n.some(function(n){var l,u,i,t,o,r,f;n.__d&&(r=(o=(l=n).__v).__e,(f=l.__P)&&(u=[],(i=s({},o)).__v=o.__v+1,t=$(f,o,i,l.__n,void 0!==f.ownerSVGElement,null!=o.__h?[r]:null,u,null==r?_(o):r,o.__h),j(u,o),t!=r&&w(o)));});}function m(n,l,u,i,t,o,r,c,s,v){var y,d,w,k,g,m,b,A=i&&i.__k||e,P=A.length;for(s==f&&(s=null!=r?r[0]:P?_(i,0):null),u.__k=[],y=0;y<l.length;y++)if(null!=(k=u.__k[y]=null==(k=l[y])||"boolean"==typeof k?null:"string"==typeof k||"number"==typeof k?h(null,k,null,null,k):Array.isArray(k)?h(p,{children:k},null,null,null):null!=k.__e||null!=k.__c?h(k.type,k.props,k.key,null,k.__v):k)){if(k.__=u,k.__b=u.__b+1,null===(w=A[y])||w&&k.key==w.key&&k.type===w.type)A[y]=void 0;else for(d=0;d<P;d++){if((w=A[d])&&k.key==w.key&&k.type===w.type){A[d]=void 0;break}w=null;}g=$(n,k,w=w||f,t,o,r,c,s,v),(d=k.ref)&&w.ref!=d&&(b||(b=[]),w.ref&&b.push(w.ref,null,k),b.push(d,k.__c||g,k)),null!=g?(null==m&&(m=g),s=x(n,k,w,A,r,g,s),v||"option"!=u.type?"function"==typeof u.type&&(u.__d=s):n.value=""):s&&w.__e==s&&s.parentNode!=n&&(s=_(w));}if(u.__e=m,null!=r&&"function"!=typeof u.type)for(y=r.length;y--;)null!=r[y]&&a(r[y]);for(y=P;y--;)null!=A[y]&&L(A[y],A[y]);if(b)for(y=0;y<b.length;y++)I(b[y],b[++y],b[++y]);}function x(n,l,u,i,t,o,r){var f,e,c;if(void 0!==l.__d)f=l.__d,l.__d=void 0;else if(t==u||o!=r||null==o.parentNode)n:if(null==r||r.parentNode!==n)n.appendChild(o),f=null;else {for(e=r,c=0;(e=e.nextSibling)&&c<i.length;c+=2)if(e==o)break n;n.insertBefore(o,r),f=r;}return void 0!==f?f:o.nextSibling}function A(n,l,u,i,t){var o;for(o in u)"children"===o||"key"===o||o in l||C(n,o,null,u[o],i);for(o in l)t&&"function"!=typeof l[o]||"children"===o||"key"===o||"value"===o||"checked"===o||u[o]===l[o]||C(n,o,l[o],u[o],i);}function P(n,l,u){"-"===l[0]?n.setProperty(l,u):n[l]=null==u?"":"number"!=typeof u||c.test(l)?u:u+"px";}function C(n,l,u,i,t){var o,r,f;if(t&&"className"==l&&(l="class"),"style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof i&&(n.style.cssText=i=""),i)for(l in i)u&&l in u||P(n.style,l,"");if(u)for(l in u)i&&u[l]===i[l]||P(n.style,l,u[l]);}else "o"===l[0]&&"n"===l[1]?(o=l!==(l=l.replace(/Capture$/,"")),(r=l.toLowerCase())in n&&(l=r),l=l.slice(2),n.l||(n.l={}),n.l[l+o]=u,f=o?N:z,u?i||n.addEventListener(l,f,o):n.removeEventListener(l,f,o)):"list"!==l&&"tagName"!==l&&"form"!==l&&"type"!==l&&"size"!==l&&"download"!==l&&"href"!==l&&!t&&l in n?n[l]=null==u?"":u:"function"!=typeof u&&"dangerouslySetInnerHTML"!==l&&(l!==(l=l.replace(/xlink:?/,""))?null==u||!1===u?n.removeAttributeNS("http://www.w3.org/1999/xlink",l.toLowerCase()):n.setAttributeNS("http://www.w3.org/1999/xlink",l.toLowerCase(),u):null==u||!1===u&&!/^ar/.test(l)?n.removeAttribute(l):n.setAttribute(l,u));}function z(l){this.l[l.type+!1](n.event?n.event(l):l);}function N(l){this.l[l.type+!0](n.event?n.event(l):l);}function T(n,l,u){var i,t;for(i=0;i<n.__k.length;i++)(t=n.__k[i])&&(t.__=n,t.__e&&("function"==typeof t.type&&t.__k.length>1&&T(t,l,u),l=x(u,t,t,n.__k,null,t.__e,l),"function"==typeof n.type&&(n.__d=l)));}function $(l,u,i,t,o,r,f,e,c){var a,v,h,y,_,w,k,g,b,x,A,P=u.type;if(void 0!==u.constructor)return null;null!=i.__h&&(c=i.__h,e=u.__e=i.__e,u.__h=null,r=[e]),(a=n.__b)&&a(u);try{n:if("function"==typeof P){if(g=u.props,b=(a=P.contextType)&&t[a.__c],x=a?b?b.props.value:a.__:t,i.__c?k=(v=u.__c=i.__c).__=v.__E:("prototype"in P&&P.prototype.render?u.__c=v=new P(g,x):(u.__c=v=new d(g,x),v.constructor=P,v.render=M),b&&b.sub(v),v.props=g,v.state||(v.state={}),v.context=x,v.__n=t,h=v.__d=!0,v.__h=[]),null==v.__s&&(v.__s=v.state),null!=P.getDerivedStateFromProps&&(v.__s==v.state&&(v.__s=s({},v.__s)),s(v.__s,P.getDerivedStateFromProps(g,v.__s))),y=v.props,_=v.state,h)null==P.getDerivedStateFromProps&&null!=v.componentWillMount&&v.componentWillMount(),null!=v.componentDidMount&&v.__h.push(v.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==y&&null!=v.componentWillReceiveProps&&v.componentWillReceiveProps(g,x),!v.__e&&null!=v.shouldComponentUpdate&&!1===v.shouldComponentUpdate(g,v.__s,x)||u.__v===i.__v){v.props=g,v.state=v.__s,u.__v!==i.__v&&(v.__d=!1),v.__v=u,u.__e=i.__e,u.__k=i.__k,v.__h.length&&f.push(v),T(u,e,l);break n}null!=v.componentWillUpdate&&v.componentWillUpdate(g,v.__s,x),null!=v.componentDidUpdate&&v.__h.push(function(){v.componentDidUpdate(y,_,w);});}v.context=x,v.props=g,v.state=v.__s,(a=n.__r)&&a(u),v.__d=!1,v.__v=u,v.__P=l,a=v.render(v.props,v.state,v.context),v.state=v.__s,null!=v.getChildContext&&(t=s(s({},t),v.getChildContext())),h||null==v.getSnapshotBeforeUpdate||(w=v.getSnapshotBeforeUpdate(y,_)),A=null!=a&&a.type==p&&null==a.key?a.props.children:a,m(l,Array.isArray(A)?A:[A],u,i,t,o,r,f,e,c),v.base=u.__e,u.__h=null,v.__h.length&&f.push(v),k&&(v.__E=v.__=null),v.__e=!1;}else null==r&&u.__v===i.__v?(u.__k=i.__k,u.__e=i.__e):u.__e=H(i.__e,u,i,t,o,r,f,c);(a=n.diffed)&&a(u);}catch(l){u.__v=null,(c||null!=r)&&(u.__e=e,u.__h=!!c,r[r.indexOf(e)]=null),n.__e(l,u,i);}return u.__e}function j(l,u){n.__c&&n.__c(u,l),l.some(function(u){try{l=u.__h,u.__h=[],l.some(function(n){n.call(u);});}catch(l){n.__e(l,u.__v);}});}function H(n,l,u,i,t,o,r,c){var s,a,v,h,y,p=u.props,d=l.props;if(t="svg"===l.type||t,null!=o)for(s=0;s<o.length;s++)if(null!=(a=o[s])&&((null===l.type?3===a.nodeType:a.localName===l.type)||n==a)){n=a,o[s]=null;break}if(null==n){if(null===l.type)return document.createTextNode(d);n=t?document.createElementNS("http://www.w3.org/2000/svg",l.type):document.createElement(l.type,d.is&&{is:d.is}),o=null,c=!1;}if(null===l.type)p===d||c&&n.data===d||(n.data=d);else {if(null!=o&&(o=e.slice.call(n.childNodes)),v=(p=u.props||f).dangerouslySetInnerHTML,h=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(h||v)&&(h&&(v&&h.__html==v.__html||h.__html===n.innerHTML)||(n.innerHTML=h&&h.__html||""));}A(n,d,p,t,c),h?l.__k=[]:(s=l.props.children,m(n,Array.isArray(s)?s:[s],l,u,i,"foreignObject"!==l.type&&t,o,r,f,c)),c||("value"in d&&void 0!==(s=d.value)&&(s!==n.value||"progress"===l.type&&!s)&&C(n,"value",s,p.value,!1),"checked"in d&&void 0!==(s=d.checked)&&s!==n.checked&&C(n,"checked",s,p.checked,!1));}return n}function I(l,u,i){try{"function"==typeof l?l(u):l.current=u;}catch(l){n.__e(l,i);}}function L(l,u,i){var t,o,r;if(n.unmount&&n.unmount(l),(t=l.ref)&&(t.current&&t.current!==l.__e||I(t,null,u)),i||"function"==typeof l.type||(i=null!=(o=l.__e)),l.__e=l.__d=void 0,null!=(t=l.__c)){if(t.componentWillUnmount)try{t.componentWillUnmount();}catch(l){n.__e(l,u);}t.base=t.__P=null;}if(t=l.__k)for(r=0;r<t.length;r++)t[r]&&L(t[r],u,i);null!=o&&a(o);}function M(n,l,u){return this.constructor(n,u)}function O(l,u,i){var t,r,c;n.__&&n.__(l,u),r=(t=i===o)?null:i&&i.__k||u.__k,l=v(p,null,[l]),c=[],$(u,(t?u:i||u).__k=l,r||f,f,void 0!==u.ownerSVGElement,i&&!t?[i]:r?null:u.childNodes.length?e.slice.call(u.childNodes):null,c,i||f,t),j(c,l);}function B(n,l){var u={__c:l="__cC"+r++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n,u,i){return this.getChildContext||(u=[],(i={})[l]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.some(k);},this.sub=function(n){u.push(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u.splice(u.indexOf(n),1),l&&l.call(n);};}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n={__e:function(n,l){for(var u,i,t,o=l.__h;l=l.__;)if((u=l.__c)&&!u.__)try{if((i=u.constructor)&&null!=i.getDerivedStateFromError&&(u.setState(i.getDerivedStateFromError(n)),t=u.__d),null!=u.componentDidCatch&&(u.componentDidCatch(n),t=u.__d),t)return l.__h=o,u.__E=u}catch(l){n=l;}throw n},__v:0},d.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=s({},this.state),"function"==typeof n&&(n=n(s({},u),this.props)),n&&s(u,n),null!=n&&this.__v&&(l&&this.__h.push(l),k(this));},d.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),k(this));},d.prototype.render=p,u=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,g.__r=0,o=f,r=0;
  50. var globalObj = typeof globalThis !== 'undefined' ? globalThis : window; // // TODO: streamline when killing IE11 support
  51. if (globalObj.FullCalendarVDom) {
  52. console.warn('FullCalendar VDOM already loaded');
  53. }
  54. else {
  55. globalObj.FullCalendarVDom = {
  56. Component: d,
  57. createElement: v,
  58. render: O,
  59. createRef: y,
  60. Fragment: p,
  61. createContext: createContext,
  62. flushToDom: flushToDom,
  63. unmountComponentAtNode: unmountComponentAtNode,
  64. };
  65. }
  66. // HACKS...
  67. // TODO: lock version
  68. // TODO: link gh issues
  69. function flushToDom() {
  70. var oldDebounceRendering = n.debounceRendering; // orig
  71. var callbackQ = [];
  72. function execCallbackSync(callback) {
  73. callbackQ.push(callback);
  74. }
  75. n.debounceRendering = execCallbackSync;
  76. O(v(FakeComponent, {}), document.createElement('div'));
  77. while (callbackQ.length) {
  78. callbackQ.shift()();
  79. }
  80. n.debounceRendering = oldDebounceRendering;
  81. }
  82. var FakeComponent = /** @class */ (function (_super) {
  83. __extends(FakeComponent, _super);
  84. function FakeComponent() {
  85. return _super !== null && _super.apply(this, arguments) || this;
  86. }
  87. FakeComponent.prototype.render = function () { return v('div', {}); };
  88. FakeComponent.prototype.componentDidMount = function () { this.setState({}); };
  89. return FakeComponent;
  90. }(d));
  91. function createContext(defaultValue) {
  92. var ContextType = B(defaultValue);
  93. var origProvider = ContextType.Provider;
  94. ContextType.Provider = function () {
  95. var _this = this;
  96. var isNew = !this.getChildContext;
  97. var children = origProvider.apply(this, arguments); // eslint-disable-line prefer-rest-params
  98. if (isNew) {
  99. var subs_1 = [];
  100. this.shouldComponentUpdate = function (_props) {
  101. if (_this.props.value !== _props.value) {
  102. subs_1.forEach(function (c) {
  103. c.context = _props.value;
  104. c.forceUpdate();
  105. });
  106. }
  107. };
  108. this.sub = function (c) {
  109. subs_1.push(c);
  110. var old = c.componentWillUnmount;
  111. c.componentWillUnmount = function () {
  112. subs_1.splice(subs_1.indexOf(c), 1);
  113. old && old.call(c);
  114. };
  115. };
  116. }
  117. return children;
  118. };
  119. return ContextType;
  120. }
  121. function unmountComponentAtNode(node) {
  122. O(null, node);
  123. }
  124. // no public types yet. when there are, export from:
  125. // import {} from './api-type-deps'
  126. var EventSourceApi = /** @class */ (function () {
  127. function EventSourceApi(context, internalEventSource) {
  128. this.context = context;
  129. this.internalEventSource = internalEventSource;
  130. }
  131. EventSourceApi.prototype.remove = function () {
  132. this.context.dispatch({
  133. type: 'REMOVE_EVENT_SOURCE',
  134. sourceId: this.internalEventSource.sourceId,
  135. });
  136. };
  137. EventSourceApi.prototype.refetch = function () {
  138. this.context.dispatch({
  139. type: 'FETCH_EVENT_SOURCES',
  140. sourceIds: [this.internalEventSource.sourceId],
  141. });
  142. };
  143. Object.defineProperty(EventSourceApi.prototype, "id", {
  144. get: function () {
  145. return this.internalEventSource.publicId;
  146. },
  147. enumerable: false,
  148. configurable: true
  149. });
  150. Object.defineProperty(EventSourceApi.prototype, "url", {
  151. get: function () {
  152. return this.internalEventSource.meta.url;
  153. },
  154. enumerable: false,
  155. configurable: true
  156. });
  157. Object.defineProperty(EventSourceApi.prototype, "format", {
  158. get: function () {
  159. return this.internalEventSource.meta.format; // TODO: bad. not guaranteed
  160. },
  161. enumerable: false,
  162. configurable: true
  163. });
  164. return EventSourceApi;
  165. }());
  166. function removeElement(el) {
  167. if (el.parentNode) {
  168. el.parentNode.removeChild(el);
  169. }
  170. }
  171. // Querying
  172. // ----------------------------------------------------------------------------------------------------------------
  173. function elementClosest(el, selector) {
  174. if (el.closest) {
  175. return el.closest(selector);
  176. // really bad fallback for IE
  177. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  178. }
  179. if (!document.documentElement.contains(el)) {
  180. return null;
  181. }
  182. do {
  183. if (elementMatches(el, selector)) {
  184. return el;
  185. }
  186. el = (el.parentElement || el.parentNode);
  187. } while (el !== null && el.nodeType === 1);
  188. return null;
  189. }
  190. function elementMatches(el, selector) {
  191. var method = el.matches || el.matchesSelector || el.msMatchesSelector;
  192. return method.call(el, selector);
  193. }
  194. // accepts multiple subject els
  195. // returns a real array. good for methods like forEach
  196. // TODO: accept the document
  197. function findElements(container, selector) {
  198. var containers = container instanceof HTMLElement ? [container] : container;
  199. var allMatches = [];
  200. for (var i = 0; i < containers.length; i += 1) {
  201. var matches = containers[i].querySelectorAll(selector);
  202. for (var j = 0; j < matches.length; j += 1) {
  203. allMatches.push(matches[j]);
  204. }
  205. }
  206. return allMatches;
  207. }
  208. // accepts multiple subject els
  209. // only queries direct child elements // TODO: rename to findDirectChildren!
  210. function findDirectChildren(parent, selector) {
  211. var parents = parent instanceof HTMLElement ? [parent] : parent;
  212. var allMatches = [];
  213. for (var i = 0; i < parents.length; i += 1) {
  214. var childNodes = parents[i].children; // only ever elements
  215. for (var j = 0; j < childNodes.length; j += 1) {
  216. var childNode = childNodes[j];
  217. if (!selector || elementMatches(childNode, selector)) {
  218. allMatches.push(childNode);
  219. }
  220. }
  221. }
  222. return allMatches;
  223. }
  224. // Style
  225. // ----------------------------------------------------------------------------------------------------------------
  226. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  227. function applyStyle(el, props) {
  228. for (var propName in props) {
  229. applyStyleProp(el, propName, props[propName]);
  230. }
  231. }
  232. function applyStyleProp(el, name, val) {
  233. if (val == null) {
  234. el.style[name] = '';
  235. }
  236. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  237. el.style[name] = val + "px";
  238. }
  239. else {
  240. el.style[name] = val;
  241. }
  242. }
  243. // Stops a mouse/touch event from doing it's native browser action
  244. function preventDefault(ev) {
  245. ev.preventDefault();
  246. }
  247. // Event Delegation
  248. // ----------------------------------------------------------------------------------------------------------------
  249. function buildDelegationHandler(selector, handler) {
  250. return function (ev) {
  251. var matchedChild = elementClosest(ev.target, selector);
  252. if (matchedChild) {
  253. handler.call(matchedChild, ev, matchedChild);
  254. }
  255. };
  256. }
  257. function listenBySelector(container, eventType, selector, handler) {
  258. var attachedHandler = buildDelegationHandler(selector, handler);
  259. container.addEventListener(eventType, attachedHandler);
  260. return function () {
  261. container.removeEventListener(eventType, attachedHandler);
  262. };
  263. }
  264. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  265. var currentMatchedChild;
  266. return listenBySelector(container, 'mouseover', selector, function (mouseOverEv, matchedChild) {
  267. if (matchedChild !== currentMatchedChild) {
  268. currentMatchedChild = matchedChild;
  269. onMouseEnter(mouseOverEv, matchedChild);
  270. var realOnMouseLeave_1 = function (mouseLeaveEv) {
  271. currentMatchedChild = null;
  272. onMouseLeave(mouseLeaveEv, matchedChild);
  273. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  274. };
  275. // listen to the next mouseleave, and then unattach
  276. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  277. }
  278. });
  279. }
  280. // Animation
  281. // ----------------------------------------------------------------------------------------------------------------
  282. var transitionEventNames = [
  283. 'webkitTransitionEnd',
  284. 'otransitionend',
  285. 'oTransitionEnd',
  286. 'msTransitionEnd',
  287. 'transitionend',
  288. ];
  289. // triggered only when the next single subsequent transition finishes
  290. function whenTransitionDone(el, callback) {
  291. var realCallback = function (ev) {
  292. callback(ev);
  293. transitionEventNames.forEach(function (eventName) {
  294. el.removeEventListener(eventName, realCallback);
  295. });
  296. };
  297. transitionEventNames.forEach(function (eventName) {
  298. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  299. });
  300. }
  301. var guidNumber = 0;
  302. function guid() {
  303. guidNumber += 1;
  304. return String(guidNumber);
  305. }
  306. /* FullCalendar-specific DOM Utilities
  307. ----------------------------------------------------------------------------------------------------------------------*/
  308. // Make the mouse cursor express that an event is not allowed in the current area
  309. function disableCursor() {
  310. document.body.classList.add('fc-not-allowed');
  311. }
  312. // Returns the mouse cursor to its original look
  313. function enableCursor() {
  314. document.body.classList.remove('fc-not-allowed');
  315. }
  316. /* Selection
  317. ----------------------------------------------------------------------------------------------------------------------*/
  318. function preventSelection(el) {
  319. el.classList.add('fc-unselectable');
  320. el.addEventListener('selectstart', preventDefault);
  321. }
  322. function allowSelection(el) {
  323. el.classList.remove('fc-unselectable');
  324. el.removeEventListener('selectstart', preventDefault);
  325. }
  326. /* Context Menu
  327. ----------------------------------------------------------------------------------------------------------------------*/
  328. function preventContextMenu(el) {
  329. el.addEventListener('contextmenu', preventDefault);
  330. }
  331. function allowContextMenu(el) {
  332. el.removeEventListener('contextmenu', preventDefault);
  333. }
  334. function parseFieldSpecs(input) {
  335. var specs = [];
  336. var tokens = [];
  337. var i;
  338. var token;
  339. if (typeof input === 'string') {
  340. tokens = input.split(/\s*,\s*/);
  341. }
  342. else if (typeof input === 'function') {
  343. tokens = [input];
  344. }
  345. else if (Array.isArray(input)) {
  346. tokens = input;
  347. }
  348. for (i = 0; i < tokens.length; i += 1) {
  349. token = tokens[i];
  350. if (typeof token === 'string') {
  351. specs.push(token.charAt(0) === '-' ?
  352. { field: token.substring(1), order: -1 } :
  353. { field: token, order: 1 });
  354. }
  355. else if (typeof token === 'function') {
  356. specs.push({ func: token });
  357. }
  358. }
  359. return specs;
  360. }
  361. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  362. var i;
  363. var cmp;
  364. for (i = 0; i < fieldSpecs.length; i += 1) {
  365. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  366. if (cmp) {
  367. return cmp;
  368. }
  369. }
  370. return 0;
  371. }
  372. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  373. if (fieldSpec.func) {
  374. return fieldSpec.func(obj0, obj1);
  375. }
  376. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  377. * (fieldSpec.order || 1);
  378. }
  379. function flexibleCompare(a, b) {
  380. if (!a && !b) {
  381. return 0;
  382. }
  383. if (b == null) {
  384. return -1;
  385. }
  386. if (a == null) {
  387. return 1;
  388. }
  389. if (typeof a === 'string' || typeof b === 'string') {
  390. return String(a).localeCompare(String(b));
  391. }
  392. return a - b;
  393. }
  394. /* String Utilities
  395. ----------------------------------------------------------------------------------------------------------------------*/
  396. function padStart(val, len) {
  397. var s = String(val);
  398. return '000'.substr(0, len - s.length) + s;
  399. }
  400. /* Number Utilities
  401. ----------------------------------------------------------------------------------------------------------------------*/
  402. function compareNumbers(a, b) {
  403. return a - b;
  404. }
  405. function isInt(n) {
  406. return n % 1 === 0;
  407. }
  408. /* FC-specific DOM dimension stuff
  409. ----------------------------------------------------------------------------------------------------------------------*/
  410. function computeSmallestCellWidth(cellEl) {
  411. var allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
  412. var contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
  413. if (!allWidthEl) {
  414. throw new Error('needs fc-scrollgrid-shrink-frame className'); // TODO: use const
  415. }
  416. if (!contentWidthEl) {
  417. throw new Error('needs fc-scrollgrid-shrink-cushion className');
  418. }
  419. return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + // the cell padding+border
  420. contentWidthEl.getBoundingClientRect().width;
  421. }
  422. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  423. // Adding
  424. function addWeeks(m, n) {
  425. var a = dateToUtcArray(m);
  426. a[2] += n * 7;
  427. return arrayToUtcDate(a);
  428. }
  429. function addDays(m, n) {
  430. var a = dateToUtcArray(m);
  431. a[2] += n;
  432. return arrayToUtcDate(a);
  433. }
  434. function addMs(m, n) {
  435. var a = dateToUtcArray(m);
  436. a[6] += n;
  437. return arrayToUtcDate(a);
  438. }
  439. // Diffing (all return floats)
  440. // TODO: why not use ranges?
  441. function diffWeeks(m0, m1) {
  442. return diffDays(m0, m1) / 7;
  443. }
  444. function diffDays(m0, m1) {
  445. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  446. }
  447. function diffHours(m0, m1) {
  448. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  449. }
  450. function diffMinutes(m0, m1) {
  451. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  452. }
  453. function diffSeconds(m0, m1) {
  454. return (m1.valueOf() - m0.valueOf()) / 1000;
  455. }
  456. function diffDayAndTime(m0, m1) {
  457. var m0day = startOfDay(m0);
  458. var m1day = startOfDay(m1);
  459. return {
  460. years: 0,
  461. months: 0,
  462. days: Math.round(diffDays(m0day, m1day)),
  463. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf()),
  464. };
  465. }
  466. // Diffing Whole Units
  467. function diffWholeWeeks(m0, m1) {
  468. var d = diffWholeDays(m0, m1);
  469. if (d !== null && d % 7 === 0) {
  470. return d / 7;
  471. }
  472. return null;
  473. }
  474. function diffWholeDays(m0, m1) {
  475. if (timeAsMs(m0) === timeAsMs(m1)) {
  476. return Math.round(diffDays(m0, m1));
  477. }
  478. return null;
  479. }
  480. // Start-Of
  481. function startOfDay(m) {
  482. return arrayToUtcDate([
  483. m.getUTCFullYear(),
  484. m.getUTCMonth(),
  485. m.getUTCDate(),
  486. ]);
  487. }
  488. function startOfHour(m) {
  489. return arrayToUtcDate([
  490. m.getUTCFullYear(),
  491. m.getUTCMonth(),
  492. m.getUTCDate(),
  493. m.getUTCHours(),
  494. ]);
  495. }
  496. function startOfMinute(m) {
  497. return arrayToUtcDate([
  498. m.getUTCFullYear(),
  499. m.getUTCMonth(),
  500. m.getUTCDate(),
  501. m.getUTCHours(),
  502. m.getUTCMinutes(),
  503. ]);
  504. }
  505. function startOfSecond(m) {
  506. return arrayToUtcDate([
  507. m.getUTCFullYear(),
  508. m.getUTCMonth(),
  509. m.getUTCDate(),
  510. m.getUTCHours(),
  511. m.getUTCMinutes(),
  512. m.getUTCSeconds(),
  513. ]);
  514. }
  515. // Week Computation
  516. function weekOfYear(marker, dow, doy) {
  517. var y = marker.getUTCFullYear();
  518. var w = weekOfGivenYear(marker, y, dow, doy);
  519. if (w < 1) {
  520. return weekOfGivenYear(marker, y - 1, dow, doy);
  521. }
  522. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  523. if (nextW >= 1) {
  524. return Math.min(w, nextW);
  525. }
  526. return w;
  527. }
  528. function weekOfGivenYear(marker, year, dow, doy) {
  529. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  530. var dayStart = startOfDay(marker);
  531. var days = Math.round(diffDays(firstWeekStart, dayStart));
  532. return Math.floor(days / 7) + 1; // zero-indexed
  533. }
  534. // start-of-first-week - start-of-year
  535. function firstWeekOffset(year, dow, doy) {
  536. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  537. var fwd = 7 + dow - doy;
  538. // first-week day local weekday -- which local weekday is fwd
  539. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  540. return -fwdlw + fwd - 1;
  541. }
  542. // Array Conversion
  543. function dateToLocalArray(date) {
  544. return [
  545. date.getFullYear(),
  546. date.getMonth(),
  547. date.getDate(),
  548. date.getHours(),
  549. date.getMinutes(),
  550. date.getSeconds(),
  551. date.getMilliseconds(),
  552. ];
  553. }
  554. function arrayToLocalDate(a) {
  555. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  556. a[3] || 0, a[4] || 0, a[5] || 0);
  557. }
  558. function dateToUtcArray(date) {
  559. return [
  560. date.getUTCFullYear(),
  561. date.getUTCMonth(),
  562. date.getUTCDate(),
  563. date.getUTCHours(),
  564. date.getUTCMinutes(),
  565. date.getUTCSeconds(),
  566. date.getUTCMilliseconds(),
  567. ];
  568. }
  569. function arrayToUtcDate(a) {
  570. // according to web standards (and Safari), a month index is required.
  571. // massage if only given a year.
  572. if (a.length === 1) {
  573. a = a.concat([0]);
  574. }
  575. return new Date(Date.UTC.apply(Date, a));
  576. }
  577. // Other Utils
  578. function isValidDate(m) {
  579. return !isNaN(m.valueOf());
  580. }
  581. function timeAsMs(m) {
  582. return m.getUTCHours() * 1000 * 60 * 60 +
  583. m.getUTCMinutes() * 1000 * 60 +
  584. m.getUTCSeconds() * 1000 +
  585. m.getUTCMilliseconds();
  586. }
  587. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  588. return {
  589. instanceId: guid(),
  590. defId: defId,
  591. range: range,
  592. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  593. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo,
  594. };
  595. }
  596. var hasOwnProperty = Object.prototype.hasOwnProperty;
  597. // Merges an array of objects into a single object.
  598. // The second argument allows for an array of property names who's object values will be merged together.
  599. function mergeProps(propObjs, complexPropsMap) {
  600. var dest = {};
  601. if (complexPropsMap) {
  602. for (var name_1 in complexPropsMap) {
  603. var complexObjs = [];
  604. // collect the trailing object values, stopping when a non-object is discovered
  605. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  606. var val = propObjs[i][name_1];
  607. if (typeof val === 'object' && val) { // non-null object
  608. complexObjs.unshift(val);
  609. }
  610. else if (val !== undefined) {
  611. dest[name_1] = val; // if there were no objects, this value will be used
  612. break;
  613. }
  614. }
  615. // if the trailing values were objects, use the merged value
  616. if (complexObjs.length) {
  617. dest[name_1] = mergeProps(complexObjs);
  618. }
  619. }
  620. }
  621. // copy values into the destination, going from last to first
  622. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  623. var props = propObjs[i];
  624. for (var name_2 in props) {
  625. if (!(name_2 in dest)) { // if already assigned by previous props or complex props, don't reassign
  626. dest[name_2] = props[name_2];
  627. }
  628. }
  629. }
  630. return dest;
  631. }
  632. function filterHash(hash, func) {
  633. var filtered = {};
  634. for (var key in hash) {
  635. if (func(hash[key], key)) {
  636. filtered[key] = hash[key];
  637. }
  638. }
  639. return filtered;
  640. }
  641. function mapHash(hash, func) {
  642. var newHash = {};
  643. for (var key in hash) {
  644. newHash[key] = func(hash[key], key);
  645. }
  646. return newHash;
  647. }
  648. function arrayToHash(a) {
  649. var hash = {};
  650. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  651. var item = a_1[_i];
  652. hash[item] = true;
  653. }
  654. return hash;
  655. }
  656. function buildHashFromArray(a, func) {
  657. var hash = {};
  658. for (var i = 0; i < a.length; i += 1) {
  659. var tuple = func(a[i], i);
  660. hash[tuple[0]] = tuple[1];
  661. }
  662. return hash;
  663. }
  664. function hashValuesToArray(obj) {
  665. var a = [];
  666. for (var key in obj) {
  667. a.push(obj[key]);
  668. }
  669. return a;
  670. }
  671. function isPropsEqual(obj0, obj1) {
  672. if (obj0 === obj1) {
  673. return true;
  674. }
  675. for (var key in obj0) {
  676. if (hasOwnProperty.call(obj0, key)) {
  677. if (!(key in obj1)) {
  678. return false;
  679. }
  680. }
  681. }
  682. for (var key in obj1) {
  683. if (hasOwnProperty.call(obj1, key)) {
  684. if (obj0[key] !== obj1[key]) {
  685. return false;
  686. }
  687. }
  688. }
  689. return true;
  690. }
  691. function getUnequalProps(obj0, obj1) {
  692. var keys = [];
  693. for (var key in obj0) {
  694. if (hasOwnProperty.call(obj0, key)) {
  695. if (!(key in obj1)) {
  696. keys.push(key);
  697. }
  698. }
  699. }
  700. for (var key in obj1) {
  701. if (hasOwnProperty.call(obj1, key)) {
  702. if (obj0[key] !== obj1[key]) {
  703. keys.push(key);
  704. }
  705. }
  706. }
  707. return keys;
  708. }
  709. function compareObjs(oldProps, newProps, equalityFuncs) {
  710. if (equalityFuncs === void 0) { equalityFuncs = {}; }
  711. if (oldProps === newProps) {
  712. return true;
  713. }
  714. for (var key in newProps) {
  715. if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
  716. else {
  717. return false;
  718. }
  719. }
  720. // check for props that were omitted in the new
  721. for (var key in oldProps) {
  722. if (!(key in newProps)) {
  723. return false;
  724. }
  725. }
  726. return true;
  727. }
  728. /*
  729. assumed "true" equality for handler names like "onReceiveSomething"
  730. */
  731. function isObjValsEqual(val0, val1, comparator) {
  732. if (val0 === val1 || comparator === true) {
  733. return true;
  734. }
  735. if (comparator) {
  736. return comparator(val0, val1);
  737. }
  738. return false;
  739. }
  740. function collectFromHash(hash, startIndex, endIndex, step) {
  741. if (startIndex === void 0) { startIndex = 0; }
  742. if (step === void 0) { step = 1; }
  743. var res = [];
  744. if (endIndex == null) {
  745. endIndex = Object.keys(hash).length;
  746. }
  747. for (var i = startIndex; i < endIndex; i += step) {
  748. var val = hash[i];
  749. if (val !== undefined) { // will disregard undefined for sparse arrays
  750. res.push(val);
  751. }
  752. }
  753. return res;
  754. }
  755. function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
  756. for (var i = 0; i < recurringTypes.length; i += 1) {
  757. var parsed = recurringTypes[i].parse(refined, dateEnv);
  758. if (parsed) {
  759. var allDay = refined.allDay;
  760. if (allDay == null) {
  761. allDay = defaultAllDay;
  762. if (allDay == null) {
  763. allDay = parsed.allDayGuess;
  764. if (allDay == null) {
  765. allDay = false;
  766. }
  767. }
  768. }
  769. return {
  770. allDay: allDay,
  771. duration: parsed.duration,
  772. typeData: parsed.typeData,
  773. typeId: i,
  774. };
  775. }
  776. }
  777. return null;
  778. }
  779. function expandRecurring(eventStore, framingRange, context) {
  780. var dateEnv = context.dateEnv, pluginHooks = context.pluginHooks, options = context.options;
  781. var defs = eventStore.defs, instances = eventStore.instances;
  782. // remove existing recurring instances
  783. // TODO: bad. always expand events as a second step
  784. instances = filterHash(instances, function (instance) { return !defs[instance.defId].recurringDef; });
  785. for (var defId in defs) {
  786. var def = defs[defId];
  787. if (def.recurringDef) {
  788. var duration = def.recurringDef.duration;
  789. if (!duration) {
  790. duration = def.allDay ?
  791. options.defaultAllDayEventDuration :
  792. options.defaultTimedEventDuration;
  793. }
  794. var starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
  795. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  796. var start = starts_1[_i];
  797. var instance = createEventInstance(defId, {
  798. start: start,
  799. end: dateEnv.add(start, duration),
  800. });
  801. instances[instance.instanceId] = instance;
  802. }
  803. }
  804. }
  805. return { defs: defs, instances: instances };
  806. }
  807. /*
  808. Event MUST have a recurringDef
  809. */
  810. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  811. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  812. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  813. start: dateEnv.subtract(framingRange.start, duration),
  814. end: framingRange.end,
  815. }, dateEnv);
  816. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  817. if (eventDef.allDay) {
  818. markers = markers.map(startOfDay);
  819. }
  820. return markers;
  821. }
  822. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  823. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  824. // Parsing and Creation
  825. function createDuration(input, unit) {
  826. var _a;
  827. if (typeof input === 'string') {
  828. return parseString(input);
  829. }
  830. if (typeof input === 'object' && input) { // non-null object
  831. return parseObject(input);
  832. }
  833. if (typeof input === 'number') {
  834. return parseObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  835. }
  836. return null;
  837. }
  838. function parseString(s) {
  839. var m = PARSE_RE.exec(s);
  840. if (m) {
  841. var sign = m[1] ? -1 : 1;
  842. return {
  843. years: 0,
  844. months: 0,
  845. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  846. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  847. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  848. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  849. (m[6] ? parseInt(m[6], 10) : 0) // ms
  850. ),
  851. };
  852. }
  853. return null;
  854. }
  855. function parseObject(obj) {
  856. var duration = {
  857. years: obj.years || obj.year || 0,
  858. months: obj.months || obj.month || 0,
  859. days: obj.days || obj.day || 0,
  860. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  861. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  862. (obj.seconds || obj.second || 0) * 1000 + // seconds
  863. (obj.milliseconds || obj.millisecond || obj.ms || 0),
  864. };
  865. var weeks = obj.weeks || obj.week;
  866. if (weeks) {
  867. duration.days += weeks * 7;
  868. duration.specifiedWeeks = true;
  869. }
  870. return duration;
  871. }
  872. // Equality
  873. function durationsEqual(d0, d1) {
  874. return d0.years === d1.years &&
  875. d0.months === d1.months &&
  876. d0.days === d1.days &&
  877. d0.milliseconds === d1.milliseconds;
  878. }
  879. function asCleanDays(dur) {
  880. if (!dur.years && !dur.months && !dur.milliseconds) {
  881. return dur.days;
  882. }
  883. return 0;
  884. }
  885. // Simple Math
  886. function addDurations(d0, d1) {
  887. return {
  888. years: d0.years + d1.years,
  889. months: d0.months + d1.months,
  890. days: d0.days + d1.days,
  891. milliseconds: d0.milliseconds + d1.milliseconds,
  892. };
  893. }
  894. function subtractDurations(d1, d0) {
  895. return {
  896. years: d1.years - d0.years,
  897. months: d1.months - d0.months,
  898. days: d1.days - d0.days,
  899. milliseconds: d1.milliseconds - d0.milliseconds,
  900. };
  901. }
  902. function multiplyDuration(d, n) {
  903. return {
  904. years: d.years * n,
  905. months: d.months * n,
  906. days: d.days * n,
  907. milliseconds: d.milliseconds * n,
  908. };
  909. }
  910. // Conversions
  911. // "Rough" because they are based on average-case Gregorian months/years
  912. function asRoughYears(dur) {
  913. return asRoughDays(dur) / 365;
  914. }
  915. function asRoughMonths(dur) {
  916. return asRoughDays(dur) / 30;
  917. }
  918. function asRoughDays(dur) {
  919. return asRoughMs(dur) / 864e5;
  920. }
  921. function asRoughMinutes(dur) {
  922. return asRoughMs(dur) / (1000 * 60);
  923. }
  924. function asRoughSeconds(dur) {
  925. return asRoughMs(dur) / 1000;
  926. }
  927. function asRoughMs(dur) {
  928. return dur.years * (365 * 864e5) +
  929. dur.months * (30 * 864e5) +
  930. dur.days * 864e5 +
  931. dur.milliseconds;
  932. }
  933. // Advanced Math
  934. function wholeDivideDurations(numerator, denominator) {
  935. var res = null;
  936. for (var i = 0; i < INTERNAL_UNITS.length; i += 1) {
  937. var unit = INTERNAL_UNITS[i];
  938. if (denominator[unit]) {
  939. var localRes = numerator[unit] / denominator[unit];
  940. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  941. return null;
  942. }
  943. res = localRes;
  944. }
  945. else if (numerator[unit]) {
  946. // needs to divide by something but can't!
  947. return null;
  948. }
  949. }
  950. return res;
  951. }
  952. function greatestDurationDenominator(dur) {
  953. var ms = dur.milliseconds;
  954. if (ms) {
  955. if (ms % 1000 !== 0) {
  956. return { unit: 'millisecond', value: ms };
  957. }
  958. if (ms % (1000 * 60) !== 0) {
  959. return { unit: 'second', value: ms / 1000 };
  960. }
  961. if (ms % (1000 * 60 * 60) !== 0) {
  962. return { unit: 'minute', value: ms / (1000 * 60) };
  963. }
  964. if (ms) {
  965. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  966. }
  967. }
  968. if (dur.days) {
  969. if (dur.specifiedWeeks && dur.days % 7 === 0) {
  970. return { unit: 'week', value: dur.days / 7 };
  971. }
  972. return { unit: 'day', value: dur.days };
  973. }
  974. if (dur.months) {
  975. return { unit: 'month', value: dur.months };
  976. }
  977. if (dur.years) {
  978. return { unit: 'year', value: dur.years };
  979. }
  980. return { unit: 'millisecond', value: 0 };
  981. }
  982. // timeZoneOffset is in minutes
  983. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  984. if (stripZeroTime === void 0) { stripZeroTime = false; }
  985. var s = marker.toISOString();
  986. s = s.replace('.000', '');
  987. if (stripZeroTime) {
  988. s = s.replace('T00:00:00Z', '');
  989. }
  990. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  991. if (timeZoneOffset == null) {
  992. s = s.replace('Z', '');
  993. }
  994. else if (timeZoneOffset !== 0) {
  995. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  996. }
  997. // otherwise, its UTC-0 and we want to keep the Z
  998. }
  999. return s;
  1000. }
  1001. // formats the date, but with no time part
  1002. // TODO: somehow merge with buildIsoString and stripZeroTime
  1003. // TODO: rename. omit "string"
  1004. function formatDayString(marker) {
  1005. return marker.toISOString().replace(/T.*$/, '');
  1006. }
  1007. // TODO: use Date::toISOString and use everything after the T?
  1008. function formatIsoTimeString(marker) {
  1009. return padStart(marker.getUTCHours(), 2) + ':' +
  1010. padStart(marker.getUTCMinutes(), 2) + ':' +
  1011. padStart(marker.getUTCSeconds(), 2);
  1012. }
  1013. function formatTimeZoneOffset(minutes, doIso) {
  1014. if (doIso === void 0) { doIso = false; }
  1015. var sign = minutes < 0 ? '-' : '+';
  1016. var abs = Math.abs(minutes);
  1017. var hours = Math.floor(abs / 60);
  1018. var mins = Math.round(abs % 60);
  1019. if (doIso) {
  1020. return sign + padStart(hours, 2) + ":" + padStart(mins, 2);
  1021. }
  1022. return "GMT" + sign + hours + (mins ? ":" + padStart(mins, 2) : '');
  1023. }
  1024. // TODO: new util arrayify?
  1025. function removeExact(array, exactVal) {
  1026. var removeCnt = 0;
  1027. var i = 0;
  1028. while (i < array.length) {
  1029. if (array[i] === exactVal) {
  1030. array.splice(i, 1);
  1031. removeCnt += 1;
  1032. }
  1033. else {
  1034. i += 1;
  1035. }
  1036. }
  1037. return removeCnt;
  1038. }
  1039. function isArraysEqual(a0, a1, equalityFunc) {
  1040. if (a0 === a1) {
  1041. return true;
  1042. }
  1043. var len = a0.length;
  1044. var i;
  1045. if (len !== a1.length) { // not array? or not same length?
  1046. return false;
  1047. }
  1048. for (i = 0; i < len; i += 1) {
  1049. if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
  1050. return false;
  1051. }
  1052. }
  1053. return true;
  1054. }
  1055. function memoize(workerFunc, resEquality, teardownFunc) {
  1056. var currentArgs;
  1057. var currentRes;
  1058. return function () {
  1059. var newArgs = [];
  1060. for (var _i = 0; _i < arguments.length; _i++) {
  1061. newArgs[_i] = arguments[_i];
  1062. }
  1063. if (!currentArgs) {
  1064. currentRes = workerFunc.apply(this, newArgs);
  1065. }
  1066. else if (!isArraysEqual(currentArgs, newArgs)) {
  1067. if (teardownFunc) {
  1068. teardownFunc(currentRes);
  1069. }
  1070. var res = workerFunc.apply(this, newArgs);
  1071. if (!resEquality || !resEquality(res, currentRes)) {
  1072. currentRes = res;
  1073. }
  1074. }
  1075. currentArgs = newArgs;
  1076. return currentRes;
  1077. };
  1078. }
  1079. function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
  1080. var _this = this;
  1081. var currentArg;
  1082. var currentRes;
  1083. return function (newArg) {
  1084. if (!currentArg) {
  1085. currentRes = workerFunc.call(_this, newArg);
  1086. }
  1087. else if (!isPropsEqual(currentArg, newArg)) {
  1088. if (teardownFunc) {
  1089. teardownFunc(currentRes);
  1090. }
  1091. var res = workerFunc.call(_this, newArg);
  1092. if (!resEquality || !resEquality(res, currentRes)) {
  1093. currentRes = res;
  1094. }
  1095. }
  1096. currentArg = newArg;
  1097. return currentRes;
  1098. };
  1099. }
  1100. function memoizeArraylike(// used at all?
  1101. workerFunc, resEquality, teardownFunc) {
  1102. var _this = this;
  1103. var currentArgSets = [];
  1104. var currentResults = [];
  1105. return function (newArgSets) {
  1106. var currentLen = currentArgSets.length;
  1107. var newLen = newArgSets.length;
  1108. var i = 0;
  1109. for (; i < currentLen; i += 1) {
  1110. if (!newArgSets[i]) { // one of the old sets no longer exists
  1111. if (teardownFunc) {
  1112. teardownFunc(currentResults[i]);
  1113. }
  1114. }
  1115. else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
  1116. if (teardownFunc) {
  1117. teardownFunc(currentResults[i]);
  1118. }
  1119. var res = workerFunc.apply(_this, newArgSets[i]);
  1120. if (!resEquality || !resEquality(res, currentResults[i])) {
  1121. currentResults[i] = res;
  1122. }
  1123. }
  1124. }
  1125. for (; i < newLen; i += 1) {
  1126. currentResults[i] = workerFunc.apply(_this, newArgSets[i]);
  1127. }
  1128. currentArgSets = newArgSets;
  1129. currentResults.splice(newLen); // remove excess
  1130. return currentResults;
  1131. };
  1132. }
  1133. function memoizeHashlike(// used?
  1134. workerFunc, resEquality, teardownFunc) {
  1135. var _this = this;
  1136. var currentArgHash = {};
  1137. var currentResHash = {};
  1138. return function (newArgHash) {
  1139. var newResHash = {};
  1140. for (var key in newArgHash) {
  1141. if (!currentResHash[key]) {
  1142. newResHash[key] = workerFunc.apply(_this, newArgHash[key]);
  1143. }
  1144. else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
  1145. if (teardownFunc) {
  1146. teardownFunc(currentResHash[key]);
  1147. }
  1148. var res = workerFunc.apply(_this, newArgHash[key]);
  1149. newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
  1150. ? currentResHash[key]
  1151. : res;
  1152. }
  1153. else {
  1154. newResHash[key] = currentResHash[key];
  1155. }
  1156. }
  1157. currentArgHash = newArgHash;
  1158. currentResHash = newResHash;
  1159. return newResHash;
  1160. };
  1161. }
  1162. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1163. week: 3,
  1164. separator: 0,
  1165. omitZeroMinute: 0,
  1166. meridiem: 0,
  1167. omitCommas: 0,
  1168. };
  1169. var STANDARD_DATE_PROP_SEVERITIES = {
  1170. timeZoneName: 7,
  1171. era: 6,
  1172. year: 5,
  1173. month: 4,
  1174. day: 2,
  1175. weekday: 2,
  1176. hour: 1,
  1177. minute: 1,
  1178. second: 1,
  1179. };
  1180. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1181. var COMMA_RE = /,/g; // we need re for globalness
  1182. var MULTI_SPACE_RE = /\s+/g;
  1183. var LTR_RE = /\u200e/g; // control character
  1184. var UTC_RE = /UTC|GMT/;
  1185. var NativeFormatter = /** @class */ (function () {
  1186. function NativeFormatter(formatSettings) {
  1187. var standardDateProps = {};
  1188. var extendedSettings = {};
  1189. var severity = 0;
  1190. for (var name_1 in formatSettings) {
  1191. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1192. extendedSettings[name_1] = formatSettings[name_1];
  1193. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1194. }
  1195. else {
  1196. standardDateProps[name_1] = formatSettings[name_1];
  1197. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
  1198. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1199. }
  1200. }
  1201. }
  1202. this.standardDateProps = standardDateProps;
  1203. this.extendedSettings = extendedSettings;
  1204. this.severity = severity;
  1205. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1206. }
  1207. NativeFormatter.prototype.format = function (date, context) {
  1208. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1209. };
  1210. NativeFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1211. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1212. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1213. if (!diffSeverity) {
  1214. return this.format(start, context);
  1215. }
  1216. var biggestUnitForPartial = diffSeverity;
  1217. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1218. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1219. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1220. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1221. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1222. }
  1223. var full0 = this.format(start, context);
  1224. var full1 = this.format(end, context);
  1225. if (full0 === full1) {
  1226. return full0;
  1227. }
  1228. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1229. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1230. var partial0 = partialFormattingFunc(start);
  1231. var partial1 = partialFormattingFunc(end);
  1232. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1233. var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
  1234. if (insertion) {
  1235. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1236. }
  1237. return full0 + separator + full1;
  1238. };
  1239. NativeFormatter.prototype.getLargestUnit = function () {
  1240. switch (this.severity) {
  1241. case 7:
  1242. case 6:
  1243. case 5:
  1244. return 'year';
  1245. case 4:
  1246. return 'month';
  1247. case 3:
  1248. return 'week';
  1249. case 2:
  1250. return 'day';
  1251. default:
  1252. return 'time'; // really?
  1253. }
  1254. };
  1255. return NativeFormatter;
  1256. }());
  1257. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1258. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1259. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1260. return function (date) { return (formatTimeZoneOffset(date.timeZoneOffset)); };
  1261. }
  1262. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1263. return function (date) { return (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.locale, extendedSettings.week)); };
  1264. }
  1265. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1266. }
  1267. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1268. standardDateProps = __assign({}, standardDateProps); // copy
  1269. extendedSettings = __assign({}, extendedSettings); // copy
  1270. sanitizeSettings(standardDateProps, extendedSettings);
  1271. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1272. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1273. var zeroFormat; // needed?
  1274. if (extendedSettings.omitZeroMinute) {
  1275. var zeroProps = __assign({}, standardDateProps);
  1276. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1277. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1278. }
  1279. return function (date) {
  1280. var marker = date.marker;
  1281. var format;
  1282. if (zeroFormat && !marker.getUTCMinutes()) {
  1283. format = zeroFormat;
  1284. }
  1285. else {
  1286. format = normalFormat;
  1287. }
  1288. var s = format.format(marker);
  1289. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1290. };
  1291. }
  1292. function sanitizeSettings(standardDateProps, extendedSettings) {
  1293. // deal with a browser inconsistency where formatting the timezone
  1294. // requires that the hour/minute be present.
  1295. if (standardDateProps.timeZoneName) {
  1296. if (!standardDateProps.hour) {
  1297. standardDateProps.hour = '2-digit';
  1298. }
  1299. if (!standardDateProps.minute) {
  1300. standardDateProps.minute = '2-digit';
  1301. }
  1302. }
  1303. // only support short timezone names
  1304. if (standardDateProps.timeZoneName === 'long') {
  1305. standardDateProps.timeZoneName = 'short';
  1306. }
  1307. // if requesting to display seconds, MUST display minutes
  1308. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1309. delete extendedSettings.omitZeroMinute;
  1310. }
  1311. }
  1312. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1313. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1314. if (standardDateProps.timeZoneName === 'short') {
  1315. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1316. 'UTC' : // important to normalize for IE, which does "GMT"
  1317. formatTimeZoneOffset(date.timeZoneOffset));
  1318. }
  1319. if (extendedSettings.omitCommas) {
  1320. s = s.replace(COMMA_RE, '').trim();
  1321. }
  1322. if (extendedSettings.omitZeroMinute) {
  1323. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1324. }
  1325. // ^ do anything that might create adjacent spaces before this point,
  1326. // because MERIDIEM_RE likes to eat up loading spaces
  1327. if (extendedSettings.meridiem === false) {
  1328. s = s.replace(MERIDIEM_RE, '').trim();
  1329. }
  1330. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1331. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase(); });
  1332. }
  1333. else if (extendedSettings.meridiem === 'short') { // am/pm
  1334. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase() + "m"; });
  1335. }
  1336. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1337. s = s.replace(MERIDIEM_RE, function (m0) { return m0.toLocaleLowerCase(); });
  1338. }
  1339. s = s.replace(MULTI_SPACE_RE, ' ');
  1340. s = s.trim();
  1341. return s;
  1342. }
  1343. function injectTzoStr(s, tzoStr) {
  1344. var replaced = false;
  1345. s = s.replace(UTC_RE, function () {
  1346. replaced = true;
  1347. return tzoStr;
  1348. });
  1349. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1350. if (!replaced) {
  1351. s += " " + tzoStr;
  1352. }
  1353. return s;
  1354. }
  1355. function formatWeekNumber(num, weekText, locale, display) {
  1356. var parts = [];
  1357. if (display === 'narrow') {
  1358. parts.push(weekText);
  1359. }
  1360. else if (display === 'short') {
  1361. parts.push(weekText, ' ');
  1362. }
  1363. // otherwise, considered 'numeric'
  1364. parts.push(locale.simpleNumberFormat.format(num));
  1365. if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
  1366. parts.reverse();
  1367. }
  1368. return parts.join('');
  1369. }
  1370. // Range Formatting Utils
  1371. // 0 = exactly the same
  1372. // 1 = different by time
  1373. // and bigger
  1374. function computeMarkerDiffSeverity(d0, d1, ca) {
  1375. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1376. return 5;
  1377. }
  1378. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1379. return 4;
  1380. }
  1381. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1382. return 2;
  1383. }
  1384. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1385. return 1;
  1386. }
  1387. return 0;
  1388. }
  1389. function computePartialFormattingOptions(options, biggestUnit) {
  1390. var partialOptions = {};
  1391. for (var name_2 in options) {
  1392. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1393. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1394. partialOptions[name_2] = options[name_2];
  1395. }
  1396. }
  1397. return partialOptions;
  1398. }
  1399. function findCommonInsertion(full0, partial0, full1, partial1) {
  1400. var i0 = 0;
  1401. while (i0 < full0.length) {
  1402. var found0 = full0.indexOf(partial0, i0);
  1403. if (found0 === -1) {
  1404. break;
  1405. }
  1406. var before0 = full0.substr(0, found0);
  1407. i0 = found0 + partial0.length;
  1408. var after0 = full0.substr(i0);
  1409. var i1 = 0;
  1410. while (i1 < full1.length) {
  1411. var found1 = full1.indexOf(partial1, i1);
  1412. if (found1 === -1) {
  1413. break;
  1414. }
  1415. var before1 = full1.substr(0, found1);
  1416. i1 = found1 + partial1.length;
  1417. var after1 = full1.substr(i1);
  1418. if (before0 === before1 && after0 === after1) {
  1419. return {
  1420. before: before0,
  1421. after: after0,
  1422. };
  1423. }
  1424. }
  1425. }
  1426. return null;
  1427. }
  1428. function expandZonedMarker(dateInfo, calendarSystem) {
  1429. var a = calendarSystem.markerToArray(dateInfo.marker);
  1430. return {
  1431. marker: dateInfo.marker,
  1432. timeZoneOffset: dateInfo.timeZoneOffset,
  1433. array: a,
  1434. year: a[0],
  1435. month: a[1],
  1436. day: a[2],
  1437. hour: a[3],
  1438. minute: a[4],
  1439. second: a[5],
  1440. millisecond: a[6],
  1441. };
  1442. }
  1443. function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
  1444. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1445. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1446. return {
  1447. date: startInfo,
  1448. start: startInfo,
  1449. end: endInfo,
  1450. timeZone: context.timeZone,
  1451. localeCodes: context.locale.codes,
  1452. defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
  1453. };
  1454. }
  1455. /*
  1456. TODO: fix the terminology of "formatter" vs "formatting func"
  1457. */
  1458. /*
  1459. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1460. It receives this at the time of formatting, as a setting.
  1461. */
  1462. var CmdFormatter = /** @class */ (function () {
  1463. function CmdFormatter(cmdStr) {
  1464. this.cmdStr = cmdStr;
  1465. }
  1466. CmdFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1467. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1468. };
  1469. CmdFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1470. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1471. };
  1472. return CmdFormatter;
  1473. }());
  1474. var FuncFormatter = /** @class */ (function () {
  1475. function FuncFormatter(func) {
  1476. this.func = func;
  1477. }
  1478. FuncFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1479. return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1480. };
  1481. FuncFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1482. return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1483. };
  1484. return FuncFormatter;
  1485. }());
  1486. function createFormatter(input) {
  1487. if (typeof input === 'object' && input) { // non-null object
  1488. return new NativeFormatter(input);
  1489. }
  1490. if (typeof input === 'string') {
  1491. return new CmdFormatter(input);
  1492. }
  1493. if (typeof input === 'function') {
  1494. return new FuncFormatter(input);
  1495. }
  1496. return null;
  1497. }
  1498. // base options
  1499. // ------------
  1500. var BASE_OPTION_REFINERS = {
  1501. navLinkDayClick: identity,
  1502. navLinkWeekClick: identity,
  1503. duration: createDuration,
  1504. bootstrapFontAwesome: identity,
  1505. buttonIcons: identity,
  1506. customButtons: identity,
  1507. defaultAllDayEventDuration: createDuration,
  1508. defaultTimedEventDuration: createDuration,
  1509. nextDayThreshold: createDuration,
  1510. scrollTime: createDuration,
  1511. slotMinTime: createDuration,
  1512. slotMaxTime: createDuration,
  1513. dayPopoverFormat: createFormatter,
  1514. slotDuration: createDuration,
  1515. snapDuration: createDuration,
  1516. headerToolbar: identity,
  1517. footerToolbar: identity,
  1518. defaultRangeSeparator: String,
  1519. titleRangeSeparator: String,
  1520. forceEventDuration: Boolean,
  1521. dayHeaders: Boolean,
  1522. dayHeaderFormat: createFormatter,
  1523. dayHeaderClassNames: identity,
  1524. dayHeaderContent: identity,
  1525. dayHeaderDidMount: identity,
  1526. dayHeaderWillUnmount: identity,
  1527. dayCellClassNames: identity,
  1528. dayCellContent: identity,
  1529. dayCellDidMount: identity,
  1530. dayCellWillUnmount: identity,
  1531. initialView: String,
  1532. aspectRatio: Number,
  1533. weekends: Boolean,
  1534. weekNumberCalculation: identity,
  1535. weekNumbers: Boolean,
  1536. weekNumberClassNames: identity,
  1537. weekNumberContent: identity,
  1538. weekNumberDidMount: identity,
  1539. weekNumberWillUnmount: identity,
  1540. editable: Boolean,
  1541. viewClassNames: identity,
  1542. viewDidMount: identity,
  1543. viewWillUnmount: identity,
  1544. nowIndicator: Boolean,
  1545. nowIndicatorClassNames: identity,
  1546. nowIndicatorContent: identity,
  1547. nowIndicatorDidMount: identity,
  1548. nowIndicatorWillUnmount: identity,
  1549. showNonCurrentDates: Boolean,
  1550. lazyFetching: Boolean,
  1551. startParam: String,
  1552. endParam: String,
  1553. timeZoneParam: String,
  1554. timeZone: String,
  1555. locales: identity,
  1556. locale: identity,
  1557. themeSystem: String,
  1558. dragRevertDuration: Number,
  1559. dragScroll: Boolean,
  1560. allDayMaintainDuration: Boolean,
  1561. unselectAuto: Boolean,
  1562. dropAccept: identity,
  1563. eventOrder: parseFieldSpecs,
  1564. handleWindowResize: Boolean,
  1565. windowResizeDelay: Number,
  1566. longPressDelay: Number,
  1567. eventDragMinDistance: Number,
  1568. expandRows: Boolean,
  1569. height: identity,
  1570. contentHeight: identity,
  1571. direction: String,
  1572. weekNumberFormat: createFormatter,
  1573. eventResizableFromStart: Boolean,
  1574. displayEventTime: Boolean,
  1575. displayEventEnd: Boolean,
  1576. weekText: String,
  1577. progressiveEventRendering: Boolean,
  1578. businessHours: identity,
  1579. initialDate: identity,
  1580. now: identity,
  1581. eventDataTransform: identity,
  1582. stickyHeaderDates: identity,
  1583. stickyFooterScrollbar: identity,
  1584. viewHeight: identity,
  1585. defaultAllDay: Boolean,
  1586. eventSourceFailure: identity,
  1587. eventSourceSuccess: identity,
  1588. eventDisplay: String,
  1589. eventStartEditable: Boolean,
  1590. eventDurationEditable: Boolean,
  1591. eventOverlap: identity,
  1592. eventConstraint: identity,
  1593. eventAllow: identity,
  1594. eventBackgroundColor: String,
  1595. eventBorderColor: String,
  1596. eventTextColor: String,
  1597. eventColor: String,
  1598. eventClassNames: identity,
  1599. eventContent: identity,
  1600. eventDidMount: identity,
  1601. eventWillUnmount: identity,
  1602. selectConstraint: identity,
  1603. selectOverlap: identity,
  1604. selectAllow: identity,
  1605. droppable: Boolean,
  1606. unselectCancel: String,
  1607. slotLabelFormat: identity,
  1608. slotLaneClassNames: identity,
  1609. slotLaneContent: identity,
  1610. slotLaneDidMount: identity,
  1611. slotLaneWillUnmount: identity,
  1612. slotLabelClassNames: identity,
  1613. slotLabelContent: identity,
  1614. slotLabelDidMount: identity,
  1615. slotLabelWillUnmount: identity,
  1616. dayMaxEvents: identity,
  1617. dayMaxEventRows: identity,
  1618. dayMinWidth: Number,
  1619. slotLabelInterval: createDuration,
  1620. allDayText: String,
  1621. allDayClassNames: identity,
  1622. allDayContent: identity,
  1623. allDayDidMount: identity,
  1624. allDayWillUnmount: identity,
  1625. slotMinWidth: Number,
  1626. navLinks: Boolean,
  1627. eventTimeFormat: createFormatter,
  1628. rerenderDelay: Number,
  1629. moreLinkText: identity,
  1630. selectMinDistance: Number,
  1631. selectable: Boolean,
  1632. selectLongPressDelay: Number,
  1633. eventLongPressDelay: Number,
  1634. selectMirror: Boolean,
  1635. eventMinHeight: Number,
  1636. slotEventOverlap: Boolean,
  1637. plugins: identity,
  1638. firstDay: Number,
  1639. dayCount: Number,
  1640. dateAlignment: String,
  1641. dateIncrement: createDuration,
  1642. hiddenDays: identity,
  1643. monthMode: Boolean,
  1644. fixedWeekCount: Boolean,
  1645. validRange: identity,
  1646. visibleRange: identity,
  1647. titleFormat: identity,
  1648. // only used by list-view, but languages define the value, so we need it in base options
  1649. noEventsText: String,
  1650. };
  1651. // do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
  1652. // raw values.
  1653. var BASE_OPTION_DEFAULTS = {
  1654. eventDisplay: 'auto',
  1655. defaultRangeSeparator: ' - ',
  1656. titleRangeSeparator: ' \u2013 ',
  1657. defaultTimedEventDuration: '01:00:00',
  1658. defaultAllDayEventDuration: { day: 1 },
  1659. forceEventDuration: false,
  1660. nextDayThreshold: '00:00:00',
  1661. dayHeaders: true,
  1662. initialView: '',
  1663. aspectRatio: 1.35,
  1664. headerToolbar: {
  1665. start: 'title',
  1666. center: '',
  1667. end: 'today prev,next',
  1668. },
  1669. weekends: true,
  1670. weekNumbers: false,
  1671. weekNumberCalculation: 'local',
  1672. editable: false,
  1673. nowIndicator: false,
  1674. scrollTime: '06:00:00',
  1675. slotMinTime: '00:00:00',
  1676. slotMaxTime: '24:00:00',
  1677. showNonCurrentDates: true,
  1678. lazyFetching: true,
  1679. startParam: 'start',
  1680. endParam: 'end',
  1681. timeZoneParam: 'timeZone',
  1682. timeZone: 'local',
  1683. locales: [],
  1684. locale: '',
  1685. themeSystem: 'standard',
  1686. dragRevertDuration: 500,
  1687. dragScroll: true,
  1688. allDayMaintainDuration: false,
  1689. unselectAuto: true,
  1690. dropAccept: '*',
  1691. eventOrder: 'start,-duration,allDay,title',
  1692. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  1693. handleWindowResize: true,
  1694. windowResizeDelay: 100,
  1695. longPressDelay: 1000,
  1696. eventDragMinDistance: 5,
  1697. expandRows: false,
  1698. navLinks: false,
  1699. selectable: false,
  1700. };
  1701. // calendar listeners
  1702. // ------------------
  1703. var CALENDAR_LISTENER_REFINERS = {
  1704. datesSet: identity,
  1705. eventsSet: identity,
  1706. eventAdd: identity,
  1707. eventChange: identity,
  1708. eventRemove: identity,
  1709. windowResize: identity,
  1710. eventClick: identity,
  1711. eventMouseEnter: identity,
  1712. eventMouseLeave: identity,
  1713. select: identity,
  1714. unselect: identity,
  1715. loading: identity,
  1716. // internal
  1717. _unmount: identity,
  1718. _beforeprint: identity,
  1719. _afterprint: identity,
  1720. _noEventDrop: identity,
  1721. _noEventResize: identity,
  1722. _resize: identity,
  1723. _scrollRequest: identity,
  1724. };
  1725. // calendar-specific options
  1726. // -------------------------
  1727. var CALENDAR_OPTION_REFINERS = {
  1728. buttonText: identity,
  1729. views: identity,
  1730. plugins: identity,
  1731. initialEvents: identity,
  1732. events: identity,
  1733. eventSources: identity,
  1734. };
  1735. var COMPLEX_OPTION_COMPARATORS = {
  1736. headerToolbar: isBoolComplexEqual,
  1737. footerToolbar: isBoolComplexEqual,
  1738. buttonText: isBoolComplexEqual,
  1739. buttonIcons: isBoolComplexEqual,
  1740. };
  1741. function isBoolComplexEqual(a, b) {
  1742. if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
  1743. return isPropsEqual(a, b);
  1744. }
  1745. return a === b;
  1746. }
  1747. // view-specific options
  1748. // ---------------------
  1749. var VIEW_OPTION_REFINERS = {
  1750. type: String,
  1751. component: identity,
  1752. buttonText: String,
  1753. buttonTextKey: String,
  1754. dateProfileGeneratorClass: identity,
  1755. usesMinMaxTime: Boolean,
  1756. classNames: identity,
  1757. content: identity,
  1758. didMount: identity,
  1759. willUnmount: identity,
  1760. };
  1761. // util funcs
  1762. // ----------------------------------------------------------------------------------------------------
  1763. function mergeRawOptions(optionSets) {
  1764. return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
  1765. }
  1766. function refineProps(input, refiners) {
  1767. var refined = {};
  1768. var extra = {};
  1769. for (var propName in refiners) {
  1770. if (propName in input) {
  1771. refined[propName] = refiners[propName](input[propName]);
  1772. }
  1773. }
  1774. for (var propName in input) {
  1775. if (!(propName in refiners)) {
  1776. extra[propName] = input[propName];
  1777. }
  1778. }
  1779. return { refined: refined, extra: extra };
  1780. }
  1781. function identity(raw) {
  1782. return raw;
  1783. }
  1784. function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
  1785. var eventStore = createEmptyEventStore();
  1786. var eventRefiners = buildEventRefiners(context);
  1787. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1788. var rawEvent = rawEvents_1[_i];
  1789. var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
  1790. if (tuple) {
  1791. eventTupleToStore(tuple, eventStore);
  1792. }
  1793. }
  1794. return eventStore;
  1795. }
  1796. function eventTupleToStore(tuple, eventStore) {
  1797. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1798. eventStore.defs[tuple.def.defId] = tuple.def;
  1799. if (tuple.instance) {
  1800. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1801. }
  1802. return eventStore;
  1803. }
  1804. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1805. // or they are the same as the instance.
  1806. // why might instanceId not be in the store? an event from another calendar?
  1807. function getRelevantEvents(eventStore, instanceId) {
  1808. var instance = eventStore.instances[instanceId];
  1809. if (instance) {
  1810. var def_1 = eventStore.defs[instance.defId];
  1811. // get events/instances with same group
  1812. var newStore = filterEventStoreDefs(eventStore, function (lookDef) { return isEventDefsGrouped(def_1, lookDef); });
  1813. // add the original
  1814. // TODO: wish we could use eventTupleToStore or something like it
  1815. newStore.defs[def_1.defId] = def_1;
  1816. newStore.instances[instance.instanceId] = instance;
  1817. return newStore;
  1818. }
  1819. return createEmptyEventStore();
  1820. }
  1821. function isEventDefsGrouped(def0, def1) {
  1822. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1823. }
  1824. function createEmptyEventStore() {
  1825. return { defs: {}, instances: {} };
  1826. }
  1827. function mergeEventStores(store0, store1) {
  1828. return {
  1829. defs: __assign(__assign({}, store0.defs), store1.defs),
  1830. instances: __assign(__assign({}, store0.instances), store1.instances),
  1831. };
  1832. }
  1833. function filterEventStoreDefs(eventStore, filterFunc) {
  1834. var defs = filterHash(eventStore.defs, filterFunc);
  1835. var instances = filterHash(eventStore.instances, function (instance) { return (defs[instance.defId] // still exists?
  1836. ); });
  1837. return { defs: defs, instances: instances };
  1838. }
  1839. function excludeSubEventStore(master, sub) {
  1840. var defs = master.defs, instances = master.instances;
  1841. var filteredDefs = {};
  1842. var filteredInstances = {};
  1843. for (var defId in defs) {
  1844. if (!sub.defs[defId]) { // not explicitly excluded
  1845. filteredDefs[defId] = defs[defId];
  1846. }
  1847. }
  1848. for (var instanceId in instances) {
  1849. if (!sub.instances[instanceId] && // not explicitly excluded
  1850. filteredDefs[instances[instanceId].defId] // def wasn't filtered away
  1851. ) {
  1852. filteredInstances[instanceId] = instances[instanceId];
  1853. }
  1854. }
  1855. return {
  1856. defs: filteredDefs,
  1857. instances: filteredInstances,
  1858. };
  1859. }
  1860. function normalizeConstraint(input, context) {
  1861. if (Array.isArray(input)) {
  1862. return parseEvents(input, null, context, true); // allowOpenRange=true
  1863. }
  1864. if (typeof input === 'object' && input) { // non-null object
  1865. return parseEvents([input], null, context, true); // allowOpenRange=true
  1866. }
  1867. if (input != null) {
  1868. return String(input);
  1869. }
  1870. return null;
  1871. }
  1872. function parseClassNames(raw) {
  1873. if (Array.isArray(raw)) {
  1874. return raw;
  1875. }
  1876. if (typeof raw === 'string') {
  1877. return raw.split(/\s+/);
  1878. }
  1879. return [];
  1880. }
  1881. // TODO: better called "EventSettings" or "EventConfig"
  1882. // TODO: move this file into structs
  1883. // TODO: separate constraint/overlap/allow, because selection uses only that, not other props
  1884. var EVENT_UI_REFINERS = {
  1885. display: String,
  1886. editable: Boolean,
  1887. startEditable: Boolean,
  1888. durationEditable: Boolean,
  1889. constraint: identity,
  1890. overlap: identity,
  1891. allow: identity,
  1892. className: parseClassNames,
  1893. classNames: parseClassNames,
  1894. color: String,
  1895. backgroundColor: String,
  1896. borderColor: String,
  1897. textColor: String,
  1898. };
  1899. var EMPTY_EVENT_UI = {
  1900. display: null,
  1901. startEditable: null,
  1902. durationEditable: null,
  1903. constraints: [],
  1904. overlap: null,
  1905. allows: [],
  1906. backgroundColor: '',
  1907. borderColor: '',
  1908. textColor: '',
  1909. classNames: [],
  1910. };
  1911. function createEventUi(refined, context) {
  1912. var constraint = normalizeConstraint(refined.constraint, context);
  1913. return {
  1914. display: refined.display || null,
  1915. startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
  1916. durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
  1917. constraints: constraint != null ? [constraint] : [],
  1918. overlap: refined.overlap != null ? refined.overlap : null,
  1919. allows: refined.allow != null ? [refined.allow] : [],
  1920. backgroundColor: refined.backgroundColor || refined.color || '',
  1921. borderColor: refined.borderColor || refined.color || '',
  1922. textColor: refined.textColor || '',
  1923. classNames: (refined.className || []).concat(refined.classNames || []),
  1924. };
  1925. }
  1926. // TODO: prevent against problems with <2 args!
  1927. function combineEventUis(uis) {
  1928. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  1929. }
  1930. function combineTwoEventUis(item0, item1) {
  1931. return {
  1932. display: item1.display != null ? item1.display : item0.display,
  1933. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  1934. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  1935. constraints: item0.constraints.concat(item1.constraints),
  1936. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  1937. allows: item0.allows.concat(item1.allows),
  1938. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  1939. borderColor: item1.borderColor || item0.borderColor,
  1940. textColor: item1.textColor || item0.textColor,
  1941. classNames: item0.classNames.concat(item1.classNames),
  1942. };
  1943. }
  1944. var EVENT_NON_DATE_REFINERS = {
  1945. id: String,
  1946. groupId: String,
  1947. title: String,
  1948. url: String,
  1949. };
  1950. var EVENT_DATE_REFINERS = {
  1951. start: identity,
  1952. end: identity,
  1953. date: identity,
  1954. allDay: Boolean,
  1955. };
  1956. var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
  1957. function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
  1958. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  1959. var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
  1960. var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
  1961. var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
  1962. if (recurringRes) {
  1963. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context);
  1964. def.recurringDef = {
  1965. typeId: recurringRes.typeId,
  1966. typeData: recurringRes.typeData,
  1967. duration: recurringRes.duration,
  1968. };
  1969. return { def: def, instance: null };
  1970. }
  1971. var singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
  1972. if (singleRes) {
  1973. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context);
  1974. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  1975. return { def: def, instance: instance };
  1976. }
  1977. return null;
  1978. }
  1979. function refineEventDef(raw, context, refiners) {
  1980. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  1981. return refineProps(raw, refiners);
  1982. }
  1983. function buildEventRefiners(context) {
  1984. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
  1985. }
  1986. /*
  1987. Will NOT populate extendedProps with the leftover properties.
  1988. Will NOT populate date-related props.
  1989. */
  1990. function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context) {
  1991. var def = {
  1992. title: refined.title || '',
  1993. groupId: refined.groupId || '',
  1994. publicId: refined.id || '',
  1995. url: refined.url || '',
  1996. recurringDef: null,
  1997. defId: guid(),
  1998. sourceId: sourceId,
  1999. allDay: allDay,
  2000. hasEnd: hasEnd,
  2001. ui: createEventUi(refined, context),
  2002. extendedProps: __assign(__assign({}, (refined.extendedProps || {})), extra),
  2003. };
  2004. for (var _i = 0, _a = context.pluginHooks.eventDefMemberAdders; _i < _a.length; _i++) {
  2005. var memberAdder = _a[_i];
  2006. __assign(def, memberAdder(refined));
  2007. }
  2008. // help out EventApi from having user modify props
  2009. Object.freeze(def.ui.classNames);
  2010. Object.freeze(def.extendedProps);
  2011. return def;
  2012. }
  2013. function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
  2014. var allDay = refined.allDay;
  2015. var startMeta;
  2016. var startMarker = null;
  2017. var hasEnd = false;
  2018. var endMeta;
  2019. var endMarker = null;
  2020. var startInput = refined.start != null ? refined.start : refined.date;
  2021. startMeta = context.dateEnv.createMarkerMeta(startInput);
  2022. if (startMeta) {
  2023. startMarker = startMeta.marker;
  2024. }
  2025. else if (!allowOpenRange) {
  2026. return null;
  2027. }
  2028. if (refined.end != null) {
  2029. endMeta = context.dateEnv.createMarkerMeta(refined.end);
  2030. }
  2031. if (allDay == null) {
  2032. if (defaultAllDay != null) {
  2033. allDay = defaultAllDay;
  2034. }
  2035. else {
  2036. // fall back to the date props LAST
  2037. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  2038. (!endMeta || endMeta.isTimeUnspecified);
  2039. }
  2040. }
  2041. if (allDay && startMarker) {
  2042. startMarker = startOfDay(startMarker);
  2043. }
  2044. if (endMeta) {
  2045. endMarker = endMeta.marker;
  2046. if (allDay) {
  2047. endMarker = startOfDay(endMarker);
  2048. }
  2049. if (startMarker && endMarker <= startMarker) {
  2050. endMarker = null;
  2051. }
  2052. }
  2053. if (endMarker) {
  2054. hasEnd = true;
  2055. }
  2056. else if (!allowOpenRange) {
  2057. hasEnd = context.options.forceEventDuration || false;
  2058. endMarker = context.dateEnv.add(startMarker, allDay ?
  2059. context.options.defaultAllDayEventDuration :
  2060. context.options.defaultTimedEventDuration);
  2061. }
  2062. return {
  2063. allDay: allDay,
  2064. hasEnd: hasEnd,
  2065. range: { start: startMarker, end: endMarker },
  2066. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  2067. forcedEndTzo: endMeta ? endMeta.forcedTzo : null,
  2068. };
  2069. }
  2070. function computeIsDefaultAllDay(eventSource, context) {
  2071. var res = null;
  2072. if (eventSource) {
  2073. res = eventSource.defaultAllDay;
  2074. }
  2075. if (res == null) {
  2076. res = context.options.defaultAllDay;
  2077. }
  2078. return res;
  2079. }
  2080. /* Date stuff that doesn't belong in datelib core
  2081. ----------------------------------------------------------------------------------------------------------------------*/
  2082. // given a timed range, computes an all-day range that has the same exact duration,
  2083. // but whose start time is aligned with the start of the day.
  2084. function computeAlignedDayRange(timedRange) {
  2085. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  2086. var start = startOfDay(timedRange.start);
  2087. var end = addDays(start, dayCnt);
  2088. return { start: start, end: end };
  2089. }
  2090. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  2091. // TODO: give nextDayThreshold a default arg
  2092. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  2093. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  2094. var startDay = null;
  2095. var endDay = null;
  2096. if (timedRange.end) {
  2097. endDay = startOfDay(timedRange.end);
  2098. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  2099. // If the end time is actually inclusively part of the next day and is equal to or
  2100. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  2101. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  2102. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  2103. endDay = addDays(endDay, 1);
  2104. }
  2105. }
  2106. if (timedRange.start) {
  2107. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  2108. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  2109. if (endDay && endDay <= startDay) {
  2110. endDay = addDays(startDay, 1);
  2111. }
  2112. }
  2113. return { start: startDay, end: endDay };
  2114. }
  2115. // spans from one day into another?
  2116. function isMultiDayRange(range) {
  2117. var visibleRange = computeVisibleDayRange(range);
  2118. return diffDays(visibleRange.start, visibleRange.end) > 1;
  2119. }
  2120. function diffDates(date0, date1, dateEnv, largeUnit) {
  2121. if (largeUnit === 'year') {
  2122. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  2123. }
  2124. if (largeUnit === 'month') {
  2125. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  2126. }
  2127. return diffDayAndTime(date0, date1); // returns a duration
  2128. }
  2129. function parseRange(input, dateEnv) {
  2130. var start = null;
  2131. var end = null;
  2132. if (input.start) {
  2133. start = dateEnv.createMarker(input.start);
  2134. }
  2135. if (input.end) {
  2136. end = dateEnv.createMarker(input.end);
  2137. }
  2138. if (!start && !end) {
  2139. return null;
  2140. }
  2141. if (start && end && end < start) {
  2142. return null;
  2143. }
  2144. return { start: start, end: end };
  2145. }
  2146. // SIDE-EFFECT: will mutate ranges.
  2147. // Will return a new array result.
  2148. function invertRanges(ranges, constraintRange) {
  2149. var invertedRanges = [];
  2150. var start = constraintRange.start; // the end of the previous range. the start of the new range
  2151. var i;
  2152. var dateRange;
  2153. // ranges need to be in order. required for our date-walking algorithm
  2154. ranges.sort(compareRanges);
  2155. for (i = 0; i < ranges.length; i += 1) {
  2156. dateRange = ranges[i];
  2157. // add the span of time before the event (if there is any)
  2158. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  2159. invertedRanges.push({ start: start, end: dateRange.start });
  2160. }
  2161. if (dateRange.end > start) {
  2162. start = dateRange.end;
  2163. }
  2164. }
  2165. // add the span of time after the last event (if there is any)
  2166. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  2167. invertedRanges.push({ start: start, end: constraintRange.end });
  2168. }
  2169. return invertedRanges;
  2170. }
  2171. function compareRanges(range0, range1) {
  2172. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  2173. }
  2174. function intersectRanges(range0, range1) {
  2175. var start = range0.start, end = range0.end;
  2176. var newRange = null;
  2177. if (range1.start !== null) {
  2178. if (start === null) {
  2179. start = range1.start;
  2180. }
  2181. else {
  2182. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  2183. }
  2184. }
  2185. if (range1.end != null) {
  2186. if (end === null) {
  2187. end = range1.end;
  2188. }
  2189. else {
  2190. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  2191. }
  2192. }
  2193. if (start === null || end === null || start < end) {
  2194. newRange = { start: start, end: end };
  2195. }
  2196. return newRange;
  2197. }
  2198. function rangesEqual(range0, range1) {
  2199. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  2200. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  2201. }
  2202. function rangesIntersect(range0, range1) {
  2203. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  2204. (range0.start === null || range1.end === null || range0.start < range1.end);
  2205. }
  2206. function rangeContainsRange(outerRange, innerRange) {
  2207. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  2208. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  2209. }
  2210. function rangeContainsMarker(range, date) {
  2211. return (range.start === null || date >= range.start) &&
  2212. (range.end === null || date < range.end);
  2213. }
  2214. // If the given date is not within the given range, move it inside.
  2215. // (If it's past the end, make it one millisecond before the end).
  2216. function constrainMarkerToRange(date, range) {
  2217. if (range.start != null && date < range.start) {
  2218. return range.start;
  2219. }
  2220. if (range.end != null && date >= range.end) {
  2221. return new Date(range.end.valueOf() - 1);
  2222. }
  2223. return date;
  2224. }
  2225. /*
  2226. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2227. */
  2228. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2229. var inverseBgByGroupId = {};
  2230. var inverseBgByDefId = {};
  2231. var defByGroupId = {};
  2232. var bgRanges = [];
  2233. var fgRanges = [];
  2234. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2235. for (var defId in eventStore.defs) {
  2236. var def = eventStore.defs[defId];
  2237. var ui = eventUis[def.defId];
  2238. if (ui.display === 'inverse-background') {
  2239. if (def.groupId) {
  2240. inverseBgByGroupId[def.groupId] = [];
  2241. if (!defByGroupId[def.groupId]) {
  2242. defByGroupId[def.groupId] = def;
  2243. }
  2244. }
  2245. else {
  2246. inverseBgByDefId[defId] = [];
  2247. }
  2248. }
  2249. }
  2250. for (var instanceId in eventStore.instances) {
  2251. var instance = eventStore.instances[instanceId];
  2252. var def = eventStore.defs[instance.defId];
  2253. var ui = eventUis[def.defId];
  2254. var origRange = instance.range;
  2255. var normalRange = (!def.allDay && nextDayThreshold) ?
  2256. computeVisibleDayRange(origRange, nextDayThreshold) :
  2257. origRange;
  2258. var slicedRange = intersectRanges(normalRange, framingRange);
  2259. if (slicedRange) {
  2260. if (ui.display === 'inverse-background') {
  2261. if (def.groupId) {
  2262. inverseBgByGroupId[def.groupId].push(slicedRange);
  2263. }
  2264. else {
  2265. inverseBgByDefId[instance.defId].push(slicedRange);
  2266. }
  2267. }
  2268. else if (ui.display !== 'none') {
  2269. (ui.display === 'background' ? bgRanges : fgRanges).push({
  2270. def: def,
  2271. ui: ui,
  2272. instance: instance,
  2273. range: slicedRange,
  2274. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2275. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf(),
  2276. });
  2277. }
  2278. }
  2279. }
  2280. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2281. var ranges = inverseBgByGroupId[groupId];
  2282. var invertedRanges = invertRanges(ranges, framingRange);
  2283. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2284. var invertedRange = invertedRanges_1[_i];
  2285. var def = defByGroupId[groupId];
  2286. var ui = eventUis[def.defId];
  2287. bgRanges.push({
  2288. def: def,
  2289. ui: ui,
  2290. instance: null,
  2291. range: invertedRange,
  2292. isStart: false,
  2293. isEnd: false,
  2294. });
  2295. }
  2296. }
  2297. for (var defId in inverseBgByDefId) {
  2298. var ranges = inverseBgByDefId[defId];
  2299. var invertedRanges = invertRanges(ranges, framingRange);
  2300. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2301. var invertedRange = invertedRanges_2[_a];
  2302. bgRanges.push({
  2303. def: eventStore.defs[defId],
  2304. ui: eventUis[defId],
  2305. instance: null,
  2306. range: invertedRange,
  2307. isStart: false,
  2308. isEnd: false,
  2309. });
  2310. }
  2311. }
  2312. return { bg: bgRanges, fg: fgRanges };
  2313. }
  2314. function hasBgRendering(def) {
  2315. return def.ui.display === 'background' || def.ui.display === 'inverse-background';
  2316. }
  2317. function setElSeg(el, seg) {
  2318. el.fcSeg = seg;
  2319. }
  2320. function getElSeg(el) {
  2321. return el.fcSeg ||
  2322. el.parentNode.fcSeg || // for the harness
  2323. null;
  2324. }
  2325. // event ui computation
  2326. function compileEventUis(eventDefs, eventUiBases) {
  2327. return mapHash(eventDefs, function (eventDef) { return compileEventUi(eventDef, eventUiBases); });
  2328. }
  2329. function compileEventUi(eventDef, eventUiBases) {
  2330. var uis = [];
  2331. if (eventUiBases['']) {
  2332. uis.push(eventUiBases['']);
  2333. }
  2334. if (eventUiBases[eventDef.defId]) {
  2335. uis.push(eventUiBases[eventDef.defId]);
  2336. }
  2337. uis.push(eventDef.ui);
  2338. return combineEventUis(uis);
  2339. }
  2340. function sortEventSegs(segs, eventOrderSpecs) {
  2341. var objs = segs.map(buildSegCompareObj);
  2342. objs.sort(function (obj0, obj1) { return compareByFieldSpecs(obj0, obj1, eventOrderSpecs); });
  2343. return objs.map(function (c) { return c._seg; });
  2344. }
  2345. // returns a object with all primitive props that can be compared
  2346. function buildSegCompareObj(seg) {
  2347. var eventRange = seg.eventRange;
  2348. var eventDef = eventRange.def;
  2349. var range = eventRange.instance ? eventRange.instance.range : eventRange.range;
  2350. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  2351. var end = range.end ? range.end.valueOf() : 0; // "
  2352. return __assign(__assign(__assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start: start,
  2353. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg });
  2354. }
  2355. function computeSegDraggable(seg, context) {
  2356. var pluginHooks = context.pluginHooks;
  2357. var transformers = pluginHooks.isDraggableTransformers;
  2358. var _a = seg.eventRange, def = _a.def, ui = _a.ui;
  2359. var val = ui.startEditable;
  2360. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  2361. var transformer = transformers_1[_i];
  2362. val = transformer(val, def, ui, context);
  2363. }
  2364. return val;
  2365. }
  2366. function computeSegStartResizable(seg, context) {
  2367. return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
  2368. }
  2369. function computeSegEndResizable(seg, context) {
  2370. return seg.isEnd && seg.eventRange.ui.durationEditable;
  2371. }
  2372. function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, // defaults to true
  2373. defaultDisplayEventEnd, // defaults to true
  2374. startOverride, endOverride) {
  2375. var dateEnv = context.dateEnv, options = context.options;
  2376. var displayEventTime = options.displayEventTime, displayEventEnd = options.displayEventEnd;
  2377. var eventDef = seg.eventRange.def;
  2378. var eventInstance = seg.eventRange.instance;
  2379. if (displayEventTime == null) {
  2380. displayEventTime = defaultDisplayEventTime !== false;
  2381. }
  2382. if (displayEventEnd == null) {
  2383. displayEventEnd = defaultDisplayEventEnd !== false;
  2384. }
  2385. if (displayEventTime && !eventDef.allDay && (seg.isStart || seg.isEnd)) {
  2386. var segStart = startOverride || (seg.isStart ? eventInstance.range.start : (seg.start || seg.eventRange.range.start));
  2387. var segEnd = endOverride || (seg.isEnd ? eventInstance.range.end : (seg.end || seg.eventRange.range.end));
  2388. if (displayEventEnd && eventDef.hasEnd) {
  2389. return dateEnv.formatRange(segStart, segEnd, timeFormat, {
  2390. forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2391. forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo,
  2392. });
  2393. }
  2394. return dateEnv.format(segStart, timeFormat, {
  2395. forcedTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2396. });
  2397. }
  2398. return '';
  2399. }
  2400. function getSegMeta(seg, todayRange, nowDate) {
  2401. var segRange = seg.eventRange.range;
  2402. return {
  2403. isPast: segRange.end < (nowDate || todayRange.start),
  2404. isFuture: segRange.start >= (nowDate || todayRange.end),
  2405. isToday: todayRange && rangeContainsMarker(todayRange, segRange.start),
  2406. };
  2407. }
  2408. function getEventClassNames(props) {
  2409. var classNames = ['fc-event'];
  2410. if (props.isMirror) {
  2411. classNames.push('fc-event-mirror');
  2412. }
  2413. if (props.isDraggable) {
  2414. classNames.push('fc-event-draggable');
  2415. }
  2416. if (props.isStartResizable || props.isEndResizable) {
  2417. classNames.push('fc-event-resizable');
  2418. }
  2419. if (props.isDragging) {
  2420. classNames.push('fc-event-dragging');
  2421. }
  2422. if (props.isResizing) {
  2423. classNames.push('fc-event-resizing');
  2424. }
  2425. if (props.isSelected) {
  2426. classNames.push('fc-event-selected');
  2427. }
  2428. if (props.isStart) {
  2429. classNames.push('fc-event-start');
  2430. }
  2431. if (props.isEnd) {
  2432. classNames.push('fc-event-end');
  2433. }
  2434. if (props.isPast) {
  2435. classNames.push('fc-event-past');
  2436. }
  2437. if (props.isToday) {
  2438. classNames.push('fc-event-today');
  2439. }
  2440. if (props.isFuture) {
  2441. classNames.push('fc-event-future');
  2442. }
  2443. return classNames;
  2444. }
  2445. function buildEventRangeKey(eventRange) {
  2446. return eventRange.instance
  2447. ? eventRange.instance.instanceId
  2448. : eventRange.def.defId + ":" + eventRange.range.start.toISOString();
  2449. // inverse-background events don't have specific instances. TODO: better solution
  2450. }
  2451. var STANDARD_PROPS = {
  2452. start: identity,
  2453. end: identity,
  2454. allDay: Boolean,
  2455. };
  2456. function parseDateSpan(raw, dateEnv, defaultDuration) {
  2457. var span = parseOpenDateSpan(raw, dateEnv);
  2458. var range = span.range;
  2459. if (!range.start) {
  2460. return null;
  2461. }
  2462. if (!range.end) {
  2463. if (defaultDuration == null) {
  2464. return null;
  2465. }
  2466. range.end = dateEnv.add(range.start, defaultDuration);
  2467. }
  2468. return span;
  2469. }
  2470. /*
  2471. TODO: somehow combine with parseRange?
  2472. Will return null if the start/end props were present but parsed invalidly.
  2473. */
  2474. function parseOpenDateSpan(raw, dateEnv) {
  2475. var _a = refineProps(raw, STANDARD_PROPS), standardProps = _a.refined, extra = _a.extra;
  2476. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  2477. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  2478. var allDay = standardProps.allDay;
  2479. if (allDay == null) {
  2480. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  2481. (!endMeta || endMeta.isTimeUnspecified);
  2482. }
  2483. return __assign({ range: {
  2484. start: startMeta ? startMeta.marker : null,
  2485. end: endMeta ? endMeta.marker : null,
  2486. }, allDay: allDay }, extra);
  2487. }
  2488. function isDateSpansEqual(span0, span1) {
  2489. return rangesEqual(span0.range, span1.range) &&
  2490. span0.allDay === span1.allDay &&
  2491. isSpanPropsEqual(span0, span1);
  2492. }
  2493. // the NON-DATE-RELATED props
  2494. function isSpanPropsEqual(span0, span1) {
  2495. for (var propName in span1) {
  2496. if (propName !== 'range' && propName !== 'allDay') {
  2497. if (span0[propName] !== span1[propName]) {
  2498. return false;
  2499. }
  2500. }
  2501. }
  2502. // are there any props that span0 has that span1 DOESN'T have?
  2503. // both have range/allDay, so no need to special-case.
  2504. for (var propName in span0) {
  2505. if (!(propName in span1)) {
  2506. return false;
  2507. }
  2508. }
  2509. return true;
  2510. }
  2511. function buildDateSpanApi(span, dateEnv) {
  2512. return __assign(__assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
  2513. }
  2514. function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
  2515. return __assign(__assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
  2516. }
  2517. function buildRangeApi(range, dateEnv, omitTime) {
  2518. return {
  2519. start: dateEnv.toDate(range.start),
  2520. end: dateEnv.toDate(range.end),
  2521. startStr: dateEnv.formatIso(range.start, { omitTime: omitTime }),
  2522. endStr: dateEnv.formatIso(range.end, { omitTime: omitTime }),
  2523. };
  2524. }
  2525. function fabricateEventRange(dateSpan, eventUiBases, context) {
  2526. var res = refineEventDef({ editable: false }, context);
  2527. var def = parseEventDef(res.refined, res.extra, '', // sourceId
  2528. dateSpan.allDay, true, // hasEnd
  2529. context);
  2530. return {
  2531. def: def,
  2532. ui: compileEventUi(def, eventUiBases),
  2533. instance: createEventInstance(def.defId, dateSpan.range),
  2534. range: dateSpan.range,
  2535. isStart: true,
  2536. isEnd: true,
  2537. };
  2538. }
  2539. function triggerDateSelect(selection, pev, context) {
  2540. context.emitter.trigger('select', __assign(__assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
  2541. }
  2542. function triggerDateUnselect(pev, context) {
  2543. context.emitter.trigger('unselect', {
  2544. jsEvent: pev ? pev.origEvent : null,
  2545. view: context.viewApi || context.calendarApi.view,
  2546. });
  2547. }
  2548. function buildDateSpanApiWithContext(dateSpan, context) {
  2549. var props = {};
  2550. for (var _i = 0, _a = context.pluginHooks.dateSpanTransforms; _i < _a.length; _i++) {
  2551. var transform = _a[_i];
  2552. __assign(props, transform(dateSpan, context));
  2553. }
  2554. __assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
  2555. return props;
  2556. }
  2557. // Given an event's allDay status and start date, return what its fallback end date should be.
  2558. // TODO: rename to computeDefaultEventEnd
  2559. function getDefaultEventEnd(allDay, marker, context) {
  2560. var dateEnv = context.dateEnv, options = context.options;
  2561. var end = marker;
  2562. if (allDay) {
  2563. end = startOfDay(end);
  2564. end = dateEnv.add(end, options.defaultAllDayEventDuration);
  2565. }
  2566. else {
  2567. end = dateEnv.add(end, options.defaultTimedEventDuration);
  2568. }
  2569. return end;
  2570. }
  2571. // applies the mutation to ALL defs/instances within the event store
  2572. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
  2573. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2574. var dest = createEmptyEventStore();
  2575. for (var defId in eventStore.defs) {
  2576. var def = eventStore.defs[defId];
  2577. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
  2578. }
  2579. for (var instanceId in eventStore.instances) {
  2580. var instance = eventStore.instances[instanceId];
  2581. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2582. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
  2583. }
  2584. return dest;
  2585. }
  2586. function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
  2587. var standardProps = mutation.standardProps || {};
  2588. // if hasEnd has not been specified, guess a good value based on deltas.
  2589. // if duration will change, there's no way the default duration will persist,
  2590. // and thus, we need to mark the event as having a real end
  2591. if (standardProps.hasEnd == null &&
  2592. eventConfig.durationEditable &&
  2593. (mutation.startDelta || mutation.endDelta)) {
  2594. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2595. }
  2596. var copy = __assign(__assign(__assign({}, eventDef), standardProps), { ui: __assign(__assign({}, eventDef.ui), standardProps.ui) });
  2597. if (mutation.extendedProps) {
  2598. copy.extendedProps = __assign(__assign({}, copy.extendedProps), mutation.extendedProps);
  2599. }
  2600. for (var _i = 0, _a = context.pluginHooks.eventDefMutationAppliers; _i < _a.length; _i++) {
  2601. var applier = _a[_i];
  2602. applier(copy, mutation, context);
  2603. }
  2604. if (!copy.hasEnd && context.options.forceEventDuration) {
  2605. copy.hasEnd = true;
  2606. }
  2607. return copy;
  2608. }
  2609. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2610. eventConfig, mutation, context) {
  2611. var dateEnv = context.dateEnv;
  2612. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2613. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2614. var copy = __assign({}, eventInstance);
  2615. if (forceAllDay) {
  2616. copy.range = computeAlignedDayRange(copy.range);
  2617. }
  2618. if (mutation.datesDelta && eventConfig.startEditable) {
  2619. copy.range = {
  2620. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2621. end: dateEnv.add(copy.range.end, mutation.datesDelta),
  2622. };
  2623. }
  2624. if (mutation.startDelta && eventConfig.durationEditable) {
  2625. copy.range = {
  2626. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2627. end: copy.range.end,
  2628. };
  2629. }
  2630. if (mutation.endDelta && eventConfig.durationEditable) {
  2631. copy.range = {
  2632. start: copy.range.start,
  2633. end: dateEnv.add(copy.range.end, mutation.endDelta),
  2634. };
  2635. }
  2636. if (clearEnd) {
  2637. copy.range = {
  2638. start: copy.range.start,
  2639. end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context),
  2640. };
  2641. }
  2642. // in case event was all-day but the supplied deltas were not
  2643. // better util for this?
  2644. if (eventDef.allDay) {
  2645. copy.range = {
  2646. start: startOfDay(copy.range.start),
  2647. end: startOfDay(copy.range.end),
  2648. };
  2649. }
  2650. // handle invalid durations
  2651. if (copy.range.end < copy.range.start) {
  2652. copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
  2653. }
  2654. return copy;
  2655. }
  2656. // no public types yet. when there are, export from:
  2657. // import {} from './api-type-deps'
  2658. var ViewApi = /** @class */ (function () {
  2659. function ViewApi(type, getCurrentData, dateEnv) {
  2660. this.type = type;
  2661. this.getCurrentData = getCurrentData;
  2662. this.dateEnv = dateEnv;
  2663. }
  2664. Object.defineProperty(ViewApi.prototype, "calendar", {
  2665. get: function () {
  2666. return this.getCurrentData().calendarApi;
  2667. },
  2668. enumerable: false,
  2669. configurable: true
  2670. });
  2671. Object.defineProperty(ViewApi.prototype, "title", {
  2672. get: function () {
  2673. return this.getCurrentData().viewTitle;
  2674. },
  2675. enumerable: false,
  2676. configurable: true
  2677. });
  2678. Object.defineProperty(ViewApi.prototype, "activeStart", {
  2679. get: function () {
  2680. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  2681. },
  2682. enumerable: false,
  2683. configurable: true
  2684. });
  2685. Object.defineProperty(ViewApi.prototype, "activeEnd", {
  2686. get: function () {
  2687. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  2688. },
  2689. enumerable: false,
  2690. configurable: true
  2691. });
  2692. Object.defineProperty(ViewApi.prototype, "currentStart", {
  2693. get: function () {
  2694. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  2695. },
  2696. enumerable: false,
  2697. configurable: true
  2698. });
  2699. Object.defineProperty(ViewApi.prototype, "currentEnd", {
  2700. get: function () {
  2701. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  2702. },
  2703. enumerable: false,
  2704. configurable: true
  2705. });
  2706. ViewApi.prototype.getOption = function (name) {
  2707. return this.getCurrentData().options[name]; // are the view-specific options
  2708. };
  2709. return ViewApi;
  2710. }());
  2711. var EVENT_SOURCE_REFINERS = {
  2712. id: String,
  2713. defaultAllDay: Boolean,
  2714. url: String,
  2715. format: String,
  2716. events: identity,
  2717. eventDataTransform: identity,
  2718. // for any network-related sources
  2719. success: identity,
  2720. failure: identity,
  2721. };
  2722. function parseEventSource(raw, context, refiners) {
  2723. if (refiners === void 0) { refiners = buildEventSourceRefiners(context); }
  2724. var rawObj;
  2725. if (typeof raw === 'string') {
  2726. rawObj = { url: raw };
  2727. }
  2728. else if (typeof raw === 'function' || Array.isArray(raw)) {
  2729. rawObj = { events: raw };
  2730. }
  2731. else if (typeof raw === 'object' && raw) { // not null
  2732. rawObj = raw;
  2733. }
  2734. if (rawObj) {
  2735. var _a = refineProps(rawObj, refiners), refined = _a.refined, extra = _a.extra;
  2736. var metaRes = buildEventSourceMeta(refined, context);
  2737. if (metaRes) {
  2738. return {
  2739. _raw: raw,
  2740. isFetching: false,
  2741. latestFetchId: '',
  2742. fetchRange: null,
  2743. defaultAllDay: refined.defaultAllDay,
  2744. eventDataTransform: refined.eventDataTransform,
  2745. success: refined.success,
  2746. failure: refined.failure,
  2747. publicId: refined.id || '',
  2748. sourceId: guid(),
  2749. sourceDefId: metaRes.sourceDefId,
  2750. meta: metaRes.meta,
  2751. ui: createEventUi(refined, context),
  2752. extendedProps: extra,
  2753. };
  2754. }
  2755. }
  2756. return null;
  2757. }
  2758. function buildEventSourceRefiners(context) {
  2759. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS), context.pluginHooks.eventSourceRefiners);
  2760. }
  2761. function buildEventSourceMeta(raw, context) {
  2762. var defs = context.pluginHooks.eventSourceDefs;
  2763. for (var i = defs.length - 1; i >= 0; i -= 1) { // later-added plugins take precedence
  2764. var def = defs[i];
  2765. var meta = def.parseMeta(raw);
  2766. if (meta) {
  2767. return { sourceDefId: i, meta: meta };
  2768. }
  2769. }
  2770. return null;
  2771. }
  2772. function reduceCurrentDate(currentDate, action) {
  2773. switch (action.type) {
  2774. case 'CHANGE_DATE':
  2775. return action.dateMarker;
  2776. default:
  2777. return currentDate;
  2778. }
  2779. }
  2780. function getInitialDate(options, dateEnv) {
  2781. var initialDateInput = options.initialDate;
  2782. // compute the initial ambig-timezone date
  2783. if (initialDateInput != null) {
  2784. return dateEnv.createMarker(initialDateInput);
  2785. }
  2786. return getNow(options.now, dateEnv); // getNow already returns unzoned
  2787. }
  2788. function getNow(nowInput, dateEnv) {
  2789. if (typeof nowInput === 'function') {
  2790. nowInput = nowInput();
  2791. }
  2792. if (nowInput == null) {
  2793. return dateEnv.createNowMarker();
  2794. }
  2795. return dateEnv.createMarker(nowInput);
  2796. }
  2797. var CalendarApi = /** @class */ (function () {
  2798. function CalendarApi() {
  2799. }
  2800. CalendarApi.prototype.getCurrentData = function () {
  2801. return this.currentDataManager.getCurrentData();
  2802. };
  2803. CalendarApi.prototype.dispatch = function (action) {
  2804. return this.currentDataManager.dispatch(action);
  2805. };
  2806. Object.defineProperty(CalendarApi.prototype, "view", {
  2807. get: function () { return this.getCurrentData().viewApi; } // for public API
  2808. ,
  2809. enumerable: false,
  2810. configurable: true
  2811. });
  2812. CalendarApi.prototype.batchRendering = function (callback) {
  2813. callback();
  2814. };
  2815. CalendarApi.prototype.updateSize = function () {
  2816. this.trigger('_resize', true);
  2817. };
  2818. // Options
  2819. // -----------------------------------------------------------------------------------------------------------------
  2820. CalendarApi.prototype.setOption = function (name, val) {
  2821. this.dispatch({
  2822. type: 'SET_OPTION',
  2823. optionName: name,
  2824. rawOptionValue: val,
  2825. });
  2826. };
  2827. CalendarApi.prototype.getOption = function (name) {
  2828. return this.currentDataManager.currentCalendarOptionsInput[name];
  2829. };
  2830. CalendarApi.prototype.getAvailableLocaleCodes = function () {
  2831. return Object.keys(this.getCurrentData().availableRawLocales);
  2832. };
  2833. // Trigger
  2834. // -----------------------------------------------------------------------------------------------------------------
  2835. CalendarApi.prototype.on = function (handlerName, handler) {
  2836. var currentDataManager = this.currentDataManager;
  2837. if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
  2838. currentDataManager.emitter.on(handlerName, handler);
  2839. }
  2840. else {
  2841. console.warn("Unknown listener name '" + handlerName + "'");
  2842. }
  2843. };
  2844. CalendarApi.prototype.off = function (handlerName, handler) {
  2845. this.currentDataManager.emitter.off(handlerName, handler);
  2846. };
  2847. // not meant for public use
  2848. CalendarApi.prototype.trigger = function (handlerName) {
  2849. var _a;
  2850. var args = [];
  2851. for (var _i = 1; _i < arguments.length; _i++) {
  2852. args[_i - 1] = arguments[_i];
  2853. }
  2854. (_a = this.currentDataManager.emitter).trigger.apply(_a, __spreadArrays([handlerName], args));
  2855. };
  2856. // View
  2857. // -----------------------------------------------------------------------------------------------------------------
  2858. CalendarApi.prototype.changeView = function (viewType, dateOrRange) {
  2859. var _this = this;
  2860. this.batchRendering(function () {
  2861. _this.unselect();
  2862. if (dateOrRange) {
  2863. if (dateOrRange.start && dateOrRange.end) { // a range
  2864. _this.dispatch({
  2865. type: 'CHANGE_VIEW_TYPE',
  2866. viewType: viewType,
  2867. });
  2868. _this.dispatch({
  2869. type: 'SET_OPTION',
  2870. optionName: 'visibleRange',
  2871. rawOptionValue: dateOrRange,
  2872. });
  2873. }
  2874. else {
  2875. var dateEnv = _this.getCurrentData().dateEnv;
  2876. _this.dispatch({
  2877. type: 'CHANGE_VIEW_TYPE',
  2878. viewType: viewType,
  2879. dateMarker: dateEnv.createMarker(dateOrRange),
  2880. });
  2881. }
  2882. }
  2883. else {
  2884. _this.dispatch({
  2885. type: 'CHANGE_VIEW_TYPE',
  2886. viewType: viewType,
  2887. });
  2888. }
  2889. });
  2890. };
  2891. // Forces navigation to a view for the given date.
  2892. // `viewType` can be a specific view name or a generic one like "week" or "day".
  2893. // needs to change
  2894. CalendarApi.prototype.zoomTo = function (dateMarker, viewType) {
  2895. var state = this.getCurrentData();
  2896. var spec;
  2897. viewType = viewType || 'day'; // day is default zoom
  2898. spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
  2899. this.unselect();
  2900. if (spec) {
  2901. this.dispatch({
  2902. type: 'CHANGE_VIEW_TYPE',
  2903. viewType: spec.type,
  2904. dateMarker: dateMarker,
  2905. });
  2906. }
  2907. else {
  2908. this.dispatch({
  2909. type: 'CHANGE_DATE',
  2910. dateMarker: dateMarker,
  2911. });
  2912. }
  2913. };
  2914. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  2915. // Preference is given to views that have corresponding buttons.
  2916. CalendarApi.prototype.getUnitViewSpec = function (unit) {
  2917. var _a = this.getCurrentData(), viewSpecs = _a.viewSpecs, toolbarConfig = _a.toolbarConfig;
  2918. var viewTypes = [].concat(toolbarConfig.viewsWithButtons);
  2919. var i;
  2920. var spec;
  2921. for (var viewType in viewSpecs) {
  2922. viewTypes.push(viewType);
  2923. }
  2924. for (i = 0; i < viewTypes.length; i += 1) {
  2925. spec = viewSpecs[viewTypes[i]];
  2926. if (spec) {
  2927. if (spec.singleUnit === unit) {
  2928. return spec;
  2929. }
  2930. }
  2931. }
  2932. return null;
  2933. };
  2934. // Current Date
  2935. // -----------------------------------------------------------------------------------------------------------------
  2936. CalendarApi.prototype.prev = function () {
  2937. this.unselect();
  2938. this.dispatch({ type: 'PREV' });
  2939. };
  2940. CalendarApi.prototype.next = function () {
  2941. this.unselect();
  2942. this.dispatch({ type: 'NEXT' });
  2943. };
  2944. CalendarApi.prototype.prevYear = function () {
  2945. var state = this.getCurrentData();
  2946. this.unselect();
  2947. this.dispatch({
  2948. type: 'CHANGE_DATE',
  2949. dateMarker: state.dateEnv.addYears(state.currentDate, -1),
  2950. });
  2951. };
  2952. CalendarApi.prototype.nextYear = function () {
  2953. var state = this.getCurrentData();
  2954. this.unselect();
  2955. this.dispatch({
  2956. type: 'CHANGE_DATE',
  2957. dateMarker: state.dateEnv.addYears(state.currentDate, 1),
  2958. });
  2959. };
  2960. CalendarApi.prototype.today = function () {
  2961. var state = this.getCurrentData();
  2962. this.unselect();
  2963. this.dispatch({
  2964. type: 'CHANGE_DATE',
  2965. dateMarker: getNow(state.calendarOptions.now, state.dateEnv),
  2966. });
  2967. };
  2968. CalendarApi.prototype.gotoDate = function (zonedDateInput) {
  2969. var state = this.getCurrentData();
  2970. this.unselect();
  2971. this.dispatch({
  2972. type: 'CHANGE_DATE',
  2973. dateMarker: state.dateEnv.createMarker(zonedDateInput),
  2974. });
  2975. };
  2976. CalendarApi.prototype.incrementDate = function (deltaInput) {
  2977. var state = this.getCurrentData();
  2978. var delta = createDuration(deltaInput);
  2979. if (delta) { // else, warn about invalid input?
  2980. this.unselect();
  2981. this.dispatch({
  2982. type: 'CHANGE_DATE',
  2983. dateMarker: state.dateEnv.add(state.currentDate, delta),
  2984. });
  2985. }
  2986. };
  2987. // for external API
  2988. CalendarApi.prototype.getDate = function () {
  2989. var state = this.getCurrentData();
  2990. return state.dateEnv.toDate(state.currentDate);
  2991. };
  2992. // Date Formatting Utils
  2993. // -----------------------------------------------------------------------------------------------------------------
  2994. CalendarApi.prototype.formatDate = function (d, formatter) {
  2995. var dateEnv = this.getCurrentData().dateEnv;
  2996. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  2997. };
  2998. // `settings` is for formatter AND isEndExclusive
  2999. CalendarApi.prototype.formatRange = function (d0, d1, settings) {
  3000. var dateEnv = this.getCurrentData().dateEnv;
  3001. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
  3002. };
  3003. CalendarApi.prototype.formatIso = function (d, omitTime) {
  3004. var dateEnv = this.getCurrentData().dateEnv;
  3005. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  3006. };
  3007. // Date Selection / Event Selection / DayClick
  3008. // -----------------------------------------------------------------------------------------------------------------
  3009. // this public method receives start/end dates in any format, with any timezone
  3010. // NOTE: args were changed from v3
  3011. CalendarApi.prototype.select = function (dateOrObj, endDate) {
  3012. var selectionInput;
  3013. if (endDate == null) {
  3014. if (dateOrObj.start != null) {
  3015. selectionInput = dateOrObj;
  3016. }
  3017. else {
  3018. selectionInput = {
  3019. start: dateOrObj,
  3020. end: null,
  3021. };
  3022. }
  3023. }
  3024. else {
  3025. selectionInput = {
  3026. start: dateOrObj,
  3027. end: endDate,
  3028. };
  3029. }
  3030. var state = this.getCurrentData();
  3031. var selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
  3032. if (selection) { // throw parse error otherwise?
  3033. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  3034. triggerDateSelect(selection, null, state);
  3035. }
  3036. };
  3037. // public method
  3038. CalendarApi.prototype.unselect = function (pev) {
  3039. var state = this.getCurrentData();
  3040. if (state.dateSelection) {
  3041. this.dispatch({ type: 'UNSELECT_DATES' });
  3042. triggerDateUnselect(pev, state);
  3043. }
  3044. };
  3045. // Public Events API
  3046. // -----------------------------------------------------------------------------------------------------------------
  3047. CalendarApi.prototype.addEvent = function (eventInput, sourceInput) {
  3048. if (eventInput instanceof EventApi) {
  3049. var def = eventInput._def;
  3050. var instance = eventInput._instance;
  3051. var currentData = this.getCurrentData();
  3052. // not already present? don't want to add an old snapshot
  3053. if (!currentData.eventStore.defs[def.defId]) {
  3054. this.dispatch({
  3055. type: 'ADD_EVENTS',
  3056. eventStore: eventTupleToStore({ def: def, instance: instance }),
  3057. });
  3058. this.triggerEventAdd(eventInput);
  3059. }
  3060. return eventInput;
  3061. }
  3062. var state = this.getCurrentData();
  3063. var eventSource;
  3064. if (sourceInput instanceof EventSourceApi) {
  3065. eventSource = sourceInput.internalEventSource;
  3066. }
  3067. else if (typeof sourceInput === 'boolean') {
  3068. if (sourceInput) { // true. part of the first event source
  3069. eventSource = hashValuesToArray(state.eventSources)[0];
  3070. }
  3071. }
  3072. else if (sourceInput != null) { // an ID. accepts a number too
  3073. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  3074. if (!sourceApi) {
  3075. console.warn("Could not find an event source with ID \"" + sourceInput + "\""); // TODO: test
  3076. return null;
  3077. }
  3078. eventSource = sourceApi.internalEventSource;
  3079. }
  3080. var tuple = parseEvent(eventInput, eventSource, state, false);
  3081. if (tuple) {
  3082. var newEventApi = new EventApi(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  3083. this.dispatch({
  3084. type: 'ADD_EVENTS',
  3085. eventStore: eventTupleToStore(tuple),
  3086. });
  3087. this.triggerEventAdd(newEventApi);
  3088. return newEventApi;
  3089. }
  3090. return null;
  3091. };
  3092. CalendarApi.prototype.triggerEventAdd = function (eventApi) {
  3093. var _this = this;
  3094. var emitter = this.getCurrentData().emitter;
  3095. emitter.trigger('eventAdd', {
  3096. event: eventApi,
  3097. relatedEvents: [],
  3098. revert: function () {
  3099. _this.dispatch({
  3100. type: 'REMOVE_EVENTS',
  3101. eventStore: eventApiToStore(eventApi),
  3102. });
  3103. },
  3104. });
  3105. };
  3106. // TODO: optimize
  3107. CalendarApi.prototype.getEventById = function (id) {
  3108. var state = this.getCurrentData();
  3109. var _a = state.eventStore, defs = _a.defs, instances = _a.instances;
  3110. id = String(id);
  3111. for (var defId in defs) {
  3112. var def = defs[defId];
  3113. if (def.publicId === id) {
  3114. if (def.recurringDef) {
  3115. return new EventApi(state, def, null);
  3116. }
  3117. for (var instanceId in instances) {
  3118. var instance = instances[instanceId];
  3119. if (instance.defId === def.defId) {
  3120. return new EventApi(state, def, instance);
  3121. }
  3122. }
  3123. }
  3124. }
  3125. return null;
  3126. };
  3127. CalendarApi.prototype.getEvents = function () {
  3128. var currentData = this.getCurrentData();
  3129. return buildEventApis(currentData.eventStore, currentData);
  3130. };
  3131. CalendarApi.prototype.removeAllEvents = function () {
  3132. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  3133. };
  3134. // Public Event Sources API
  3135. // -----------------------------------------------------------------------------------------------------------------
  3136. CalendarApi.prototype.getEventSources = function () {
  3137. var state = this.getCurrentData();
  3138. var sourceHash = state.eventSources;
  3139. var sourceApis = [];
  3140. for (var internalId in sourceHash) {
  3141. sourceApis.push(new EventSourceApi(state, sourceHash[internalId]));
  3142. }
  3143. return sourceApis;
  3144. };
  3145. CalendarApi.prototype.getEventSourceById = function (id) {
  3146. var state = this.getCurrentData();
  3147. var sourceHash = state.eventSources;
  3148. id = String(id);
  3149. for (var sourceId in sourceHash) {
  3150. if (sourceHash[sourceId].publicId === id) {
  3151. return new EventSourceApi(state, sourceHash[sourceId]);
  3152. }
  3153. }
  3154. return null;
  3155. };
  3156. CalendarApi.prototype.addEventSource = function (sourceInput) {
  3157. var state = this.getCurrentData();
  3158. if (sourceInput instanceof EventSourceApi) {
  3159. // not already present? don't want to add an old snapshot
  3160. if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
  3161. this.dispatch({
  3162. type: 'ADD_EVENT_SOURCES',
  3163. sources: [sourceInput.internalEventSource],
  3164. });
  3165. }
  3166. return sourceInput;
  3167. }
  3168. var eventSource = parseEventSource(sourceInput, state);
  3169. if (eventSource) { // TODO: error otherwise?
  3170. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  3171. return new EventSourceApi(state, eventSource);
  3172. }
  3173. return null;
  3174. };
  3175. CalendarApi.prototype.removeAllEventSources = function () {
  3176. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  3177. };
  3178. CalendarApi.prototype.refetchEvents = function () {
  3179. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  3180. };
  3181. // Scroll
  3182. // -----------------------------------------------------------------------------------------------------------------
  3183. CalendarApi.prototype.scrollToTime = function (timeInput) {
  3184. var time = createDuration(timeInput);
  3185. if (time) {
  3186. this.trigger('_scrollRequest', { time: time });
  3187. }
  3188. };
  3189. return CalendarApi;
  3190. }());
  3191. var EventApi = /** @class */ (function () {
  3192. // instance will be null if expressing a recurring event that has no current instances,
  3193. // OR if trying to validate an incoming external event that has no dates assigned
  3194. function EventApi(context, def, instance) {
  3195. this._context = context;
  3196. this._def = def;
  3197. this._instance = instance || null;
  3198. }
  3199. /*
  3200. TODO: make event struct more responsible for this
  3201. */
  3202. EventApi.prototype.setProp = function (name, val) {
  3203. var _a, _b;
  3204. if (name in EVENT_DATE_REFINERS) {
  3205. console.warn('Could not set date-related prop \'name\'. Use one of the date-related methods instead.');
  3206. }
  3207. else if (name in EVENT_NON_DATE_REFINERS) {
  3208. val = EVENT_NON_DATE_REFINERS[name](val);
  3209. this.mutate({
  3210. standardProps: (_a = {}, _a[name] = val, _a),
  3211. });
  3212. }
  3213. else if (name in EVENT_UI_REFINERS) {
  3214. var ui = EVENT_UI_REFINERS[name](val);
  3215. if (name === 'color') {
  3216. ui = { backgroundColor: val, borderColor: val };
  3217. }
  3218. else if (name === 'editable') {
  3219. ui = { startEditable: val, durationEditable: val };
  3220. }
  3221. else {
  3222. ui = (_b = {}, _b[name] = val, _b);
  3223. }
  3224. this.mutate({
  3225. standardProps: { ui: ui },
  3226. });
  3227. }
  3228. else {
  3229. console.warn("Could not set prop '" + name + "'. Use setExtendedProp instead.");
  3230. }
  3231. };
  3232. EventApi.prototype.setExtendedProp = function (name, val) {
  3233. var _a;
  3234. this.mutate({
  3235. extendedProps: (_a = {}, _a[name] = val, _a),
  3236. });
  3237. };
  3238. EventApi.prototype.setStart = function (startInput, options) {
  3239. if (options === void 0) { options = {}; }
  3240. var dateEnv = this._context.dateEnv;
  3241. var start = dateEnv.createMarker(startInput);
  3242. if (start && this._instance) { // TODO: warning if parsed bad
  3243. var instanceRange = this._instance.range;
  3244. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  3245. if (options.maintainDuration) {
  3246. this.mutate({ datesDelta: startDelta });
  3247. }
  3248. else {
  3249. this.mutate({ startDelta: startDelta });
  3250. }
  3251. }
  3252. };
  3253. EventApi.prototype.setEnd = function (endInput, options) {
  3254. if (options === void 0) { options = {}; }
  3255. var dateEnv = this._context.dateEnv;
  3256. var end;
  3257. if (endInput != null) {
  3258. end = dateEnv.createMarker(endInput);
  3259. if (!end) {
  3260. return; // TODO: warning if parsed bad
  3261. }
  3262. }
  3263. if (this._instance) {
  3264. if (end) {
  3265. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  3266. this.mutate({ endDelta: endDelta });
  3267. }
  3268. else {
  3269. this.mutate({ standardProps: { hasEnd: false } });
  3270. }
  3271. }
  3272. };
  3273. EventApi.prototype.setDates = function (startInput, endInput, options) {
  3274. if (options === void 0) { options = {}; }
  3275. var dateEnv = this._context.dateEnv;
  3276. var standardProps = { allDay: options.allDay };
  3277. var start = dateEnv.createMarker(startInput);
  3278. var end;
  3279. if (!start) {
  3280. return; // TODO: warning if parsed bad
  3281. }
  3282. if (endInput != null) {
  3283. end = dateEnv.createMarker(endInput);
  3284. if (!end) { // TODO: warning if parsed bad
  3285. return;
  3286. }
  3287. }
  3288. if (this._instance) {
  3289. var instanceRange = this._instance.range;
  3290. // when computing the diff for an event being converted to all-day,
  3291. // compute diff off of the all-day values the way event-mutation does.
  3292. if (options.allDay === true) {
  3293. instanceRange = computeAlignedDayRange(instanceRange);
  3294. }
  3295. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  3296. if (end) {
  3297. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  3298. if (durationsEqual(startDelta, endDelta)) {
  3299. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3300. }
  3301. else {
  3302. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  3303. }
  3304. }
  3305. else { // means "clear the end"
  3306. standardProps.hasEnd = false;
  3307. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3308. }
  3309. }
  3310. };
  3311. EventApi.prototype.moveStart = function (deltaInput) {
  3312. var delta = createDuration(deltaInput);
  3313. if (delta) { // TODO: warning if parsed bad
  3314. this.mutate({ startDelta: delta });
  3315. }
  3316. };
  3317. EventApi.prototype.moveEnd = function (deltaInput) {
  3318. var delta = createDuration(deltaInput);
  3319. if (delta) { // TODO: warning if parsed bad
  3320. this.mutate({ endDelta: delta });
  3321. }
  3322. };
  3323. EventApi.prototype.moveDates = function (deltaInput) {
  3324. var delta = createDuration(deltaInput);
  3325. if (delta) { // TODO: warning if parsed bad
  3326. this.mutate({ datesDelta: delta });
  3327. }
  3328. };
  3329. EventApi.prototype.setAllDay = function (allDay, options) {
  3330. if (options === void 0) { options = {}; }
  3331. var standardProps = { allDay: allDay };
  3332. var maintainDuration = options.maintainDuration;
  3333. if (maintainDuration == null) {
  3334. maintainDuration = this._context.options.allDayMaintainDuration;
  3335. }
  3336. if (this._def.allDay !== allDay) {
  3337. standardProps.hasEnd = maintainDuration;
  3338. }
  3339. this.mutate({ standardProps: standardProps });
  3340. };
  3341. EventApi.prototype.formatRange = function (formatInput) {
  3342. var dateEnv = this._context.dateEnv;
  3343. var instance = this._instance;
  3344. var formatter = createFormatter(formatInput);
  3345. if (this._def.hasEnd) {
  3346. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  3347. forcedStartTzo: instance.forcedStartTzo,
  3348. forcedEndTzo: instance.forcedEndTzo,
  3349. });
  3350. }
  3351. return dateEnv.format(instance.range.start, formatter, {
  3352. forcedTzo: instance.forcedStartTzo,
  3353. });
  3354. };
  3355. EventApi.prototype.mutate = function (mutation) {
  3356. var instance = this._instance;
  3357. if (instance) {
  3358. var def = this._def;
  3359. var context_1 = this._context;
  3360. var eventStore_1 = context_1.getCurrentData().eventStore;
  3361. var relevantEvents = getRelevantEvents(eventStore_1, instance.instanceId);
  3362. var eventConfigBase = {
  3363. '': {
  3364. display: '',
  3365. startEditable: true,
  3366. durationEditable: true,
  3367. constraints: [],
  3368. overlap: null,
  3369. allows: [],
  3370. backgroundColor: '',
  3371. borderColor: '',
  3372. textColor: '',
  3373. classNames: [],
  3374. },
  3375. };
  3376. relevantEvents = applyMutationToEventStore(relevantEvents, eventConfigBase, mutation, context_1);
  3377. var oldEvent = new EventApi(context_1, def, instance); // snapshot
  3378. this._def = relevantEvents.defs[def.defId];
  3379. this._instance = relevantEvents.instances[instance.instanceId];
  3380. context_1.dispatch({
  3381. type: 'MERGE_EVENTS',
  3382. eventStore: relevantEvents,
  3383. });
  3384. context_1.emitter.trigger('eventChange', {
  3385. oldEvent: oldEvent,
  3386. event: this,
  3387. relatedEvents: buildEventApis(relevantEvents, context_1, instance),
  3388. revert: function () {
  3389. context_1.dispatch({
  3390. type: 'RESET_EVENTS',
  3391. eventStore: eventStore_1,
  3392. });
  3393. },
  3394. });
  3395. }
  3396. };
  3397. EventApi.prototype.remove = function () {
  3398. var context = this._context;
  3399. var asStore = eventApiToStore(this);
  3400. context.dispatch({
  3401. type: 'REMOVE_EVENTS',
  3402. eventStore: asStore,
  3403. });
  3404. context.emitter.trigger('eventRemove', {
  3405. event: this,
  3406. relatedEvents: [],
  3407. revert: function () {
  3408. context.dispatch({
  3409. type: 'MERGE_EVENTS',
  3410. eventStore: asStore,
  3411. });
  3412. },
  3413. });
  3414. };
  3415. Object.defineProperty(EventApi.prototype, "source", {
  3416. get: function () {
  3417. var sourceId = this._def.sourceId;
  3418. if (sourceId) {
  3419. return new EventSourceApi(this._context, this._context.getCurrentData().eventSources[sourceId]);
  3420. }
  3421. return null;
  3422. },
  3423. enumerable: false,
  3424. configurable: true
  3425. });
  3426. Object.defineProperty(EventApi.prototype, "start", {
  3427. get: function () {
  3428. return this._instance ?
  3429. this._context.dateEnv.toDate(this._instance.range.start) :
  3430. null;
  3431. },
  3432. enumerable: false,
  3433. configurable: true
  3434. });
  3435. Object.defineProperty(EventApi.prototype, "end", {
  3436. get: function () {
  3437. return (this._instance && this._def.hasEnd) ?
  3438. this._context.dateEnv.toDate(this._instance.range.end) :
  3439. null;
  3440. },
  3441. enumerable: false,
  3442. configurable: true
  3443. });
  3444. Object.defineProperty(EventApi.prototype, "startStr", {
  3445. get: function () {
  3446. var instance = this._instance;
  3447. if (instance) {
  3448. return this._context.dateEnv.formatIso(instance.range.start, {
  3449. omitTime: this._def.allDay,
  3450. forcedTzo: instance.forcedStartTzo,
  3451. });
  3452. }
  3453. return '';
  3454. },
  3455. enumerable: false,
  3456. configurable: true
  3457. });
  3458. Object.defineProperty(EventApi.prototype, "endStr", {
  3459. get: function () {
  3460. var instance = this._instance;
  3461. if (instance && this._def.hasEnd) {
  3462. return this._context.dateEnv.formatIso(instance.range.end, {
  3463. omitTime: this._def.allDay,
  3464. forcedTzo: instance.forcedEndTzo,
  3465. });
  3466. }
  3467. return '';
  3468. },
  3469. enumerable: false,
  3470. configurable: true
  3471. });
  3472. Object.defineProperty(EventApi.prototype, "id", {
  3473. // computable props that all access the def
  3474. // TODO: find a TypeScript-compatible way to do this at scale
  3475. get: function () { return this._def.publicId; },
  3476. enumerable: false,
  3477. configurable: true
  3478. });
  3479. Object.defineProperty(EventApi.prototype, "groupId", {
  3480. get: function () { return this._def.groupId; },
  3481. enumerable: false,
  3482. configurable: true
  3483. });
  3484. Object.defineProperty(EventApi.prototype, "allDay", {
  3485. get: function () { return this._def.allDay; },
  3486. enumerable: false,
  3487. configurable: true
  3488. });
  3489. Object.defineProperty(EventApi.prototype, "title", {
  3490. get: function () { return this._def.title; },
  3491. enumerable: false,
  3492. configurable: true
  3493. });
  3494. Object.defineProperty(EventApi.prototype, "url", {
  3495. get: function () { return this._def.url; },
  3496. enumerable: false,
  3497. configurable: true
  3498. });
  3499. Object.defineProperty(EventApi.prototype, "display", {
  3500. get: function () { return this._def.ui.display || 'auto'; } // bad. just normalize the type earlier
  3501. ,
  3502. enumerable: false,
  3503. configurable: true
  3504. });
  3505. Object.defineProperty(EventApi.prototype, "startEditable", {
  3506. get: function () { return this._def.ui.startEditable; },
  3507. enumerable: false,
  3508. configurable: true
  3509. });
  3510. Object.defineProperty(EventApi.prototype, "durationEditable", {
  3511. get: function () { return this._def.ui.durationEditable; },
  3512. enumerable: false,
  3513. configurable: true
  3514. });
  3515. Object.defineProperty(EventApi.prototype, "constraint", {
  3516. get: function () { return this._def.ui.constraints[0] || null; },
  3517. enumerable: false,
  3518. configurable: true
  3519. });
  3520. Object.defineProperty(EventApi.prototype, "overlap", {
  3521. get: function () { return this._def.ui.overlap; },
  3522. enumerable: false,
  3523. configurable: true
  3524. });
  3525. Object.defineProperty(EventApi.prototype, "allow", {
  3526. get: function () { return this._def.ui.allows[0] || null; },
  3527. enumerable: false,
  3528. configurable: true
  3529. });
  3530. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  3531. get: function () { return this._def.ui.backgroundColor; },
  3532. enumerable: false,
  3533. configurable: true
  3534. });
  3535. Object.defineProperty(EventApi.prototype, "borderColor", {
  3536. get: function () { return this._def.ui.borderColor; },
  3537. enumerable: false,
  3538. configurable: true
  3539. });
  3540. Object.defineProperty(EventApi.prototype, "textColor", {
  3541. get: function () { return this._def.ui.textColor; },
  3542. enumerable: false,
  3543. configurable: true
  3544. });
  3545. Object.defineProperty(EventApi.prototype, "classNames", {
  3546. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  3547. get: function () { return this._def.ui.classNames; },
  3548. enumerable: false,
  3549. configurable: true
  3550. });
  3551. Object.defineProperty(EventApi.prototype, "extendedProps", {
  3552. get: function () { return this._def.extendedProps; },
  3553. enumerable: false,
  3554. configurable: true
  3555. });
  3556. EventApi.prototype.toPlainObject = function (settings) {
  3557. if (settings === void 0) { settings = {}; }
  3558. var def = this._def;
  3559. var ui = def.ui;
  3560. var _a = this, startStr = _a.startStr, endStr = _a.endStr;
  3561. var res = {};
  3562. if (def.title) {
  3563. res.title = def.title;
  3564. }
  3565. if (startStr) {
  3566. res.start = startStr;
  3567. }
  3568. if (endStr) {
  3569. res.end = endStr;
  3570. }
  3571. if (def.publicId) {
  3572. res.id = def.publicId;
  3573. }
  3574. if (def.groupId) {
  3575. res.groupId = def.groupId;
  3576. }
  3577. if (def.url) {
  3578. res.url = def.url;
  3579. }
  3580. if (ui.display && ui.display !== 'auto') {
  3581. res.display = ui.display;
  3582. }
  3583. // TODO: what about recurring-event properties???
  3584. // TODO: include startEditable/durationEditable/constraint/overlap/allow
  3585. if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
  3586. res.color = ui.backgroundColor;
  3587. }
  3588. else {
  3589. if (ui.backgroundColor) {
  3590. res.backgroundColor = ui.backgroundColor;
  3591. }
  3592. if (ui.borderColor) {
  3593. res.borderColor = ui.borderColor;
  3594. }
  3595. }
  3596. if (ui.textColor) {
  3597. res.textColor = ui.textColor;
  3598. }
  3599. if (ui.classNames.length) {
  3600. res.classNames = ui.classNames;
  3601. }
  3602. if (Object.keys(def.extendedProps).length) {
  3603. if (settings.collapseExtendedProps) {
  3604. __assign(res, def.extendedProps);
  3605. }
  3606. else {
  3607. res.extendedProps = def.extendedProps;
  3608. }
  3609. }
  3610. return res;
  3611. };
  3612. EventApi.prototype.toJSON = function () {
  3613. return this.toPlainObject();
  3614. };
  3615. return EventApi;
  3616. }());
  3617. function eventApiToStore(eventApi) {
  3618. var _a, _b;
  3619. var def = eventApi._def;
  3620. var instance = eventApi._instance;
  3621. return {
  3622. defs: (_a = {}, _a[def.defId] = def, _a),
  3623. instances: instance
  3624. ? (_b = {}, _b[instance.instanceId] = instance, _b) : {},
  3625. };
  3626. }
  3627. function buildEventApis(eventStore, context, excludeInstance) {
  3628. var defs = eventStore.defs, instances = eventStore.instances;
  3629. var eventApis = [];
  3630. var excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
  3631. for (var id in instances) {
  3632. var instance = instances[id];
  3633. var def = defs[instance.defId];
  3634. if (instance.instanceId !== excludeInstanceId) {
  3635. eventApis.push(new EventApi(context, def, instance));
  3636. }
  3637. }
  3638. return eventApis;
  3639. }
  3640. var calendarSystemClassMap = {};
  3641. function registerCalendarSystem(name, theClass) {
  3642. calendarSystemClassMap[name] = theClass;
  3643. }
  3644. function createCalendarSystem(name) {
  3645. return new calendarSystemClassMap[name]();
  3646. }
  3647. var GregorianCalendarSystem = /** @class */ (function () {
  3648. function GregorianCalendarSystem() {
  3649. }
  3650. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  3651. return d.getUTCFullYear();
  3652. };
  3653. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  3654. return d.getUTCMonth();
  3655. };
  3656. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  3657. return d.getUTCDate();
  3658. };
  3659. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  3660. return arrayToUtcDate(arr);
  3661. };
  3662. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  3663. return dateToUtcArray(marker);
  3664. };
  3665. return GregorianCalendarSystem;
  3666. }());
  3667. registerCalendarSystem('gregory', GregorianCalendarSystem);
  3668. var ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  3669. function parse(str) {
  3670. var m = ISO_RE.exec(str);
  3671. if (m) {
  3672. 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));
  3673. if (isValidDate(marker)) {
  3674. var timeZoneOffset = null;
  3675. if (m[13]) {
  3676. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  3677. Number(m[18] || 0));
  3678. }
  3679. return {
  3680. marker: marker,
  3681. isTimeUnspecified: !m[6],
  3682. timeZoneOffset: timeZoneOffset,
  3683. };
  3684. }
  3685. }
  3686. return null;
  3687. }
  3688. var DateEnv = /** @class */ (function () {
  3689. function DateEnv(settings) {
  3690. var timeZone = this.timeZone = settings.timeZone;
  3691. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  3692. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  3693. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  3694. }
  3695. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  3696. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  3697. this.locale = settings.locale;
  3698. this.weekDow = settings.locale.week.dow;
  3699. this.weekDoy = settings.locale.week.doy;
  3700. if (settings.weekNumberCalculation === 'ISO') {
  3701. this.weekDow = 1;
  3702. this.weekDoy = 4;
  3703. }
  3704. if (typeof settings.firstDay === 'number') {
  3705. this.weekDow = settings.firstDay;
  3706. }
  3707. if (typeof settings.weekNumberCalculation === 'function') {
  3708. this.weekNumberFunc = settings.weekNumberCalculation;
  3709. }
  3710. this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
  3711. this.cmdFormatter = settings.cmdFormatter;
  3712. this.defaultSeparator = settings.defaultSeparator;
  3713. }
  3714. // Creating / Parsing
  3715. DateEnv.prototype.createMarker = function (input) {
  3716. var meta = this.createMarkerMeta(input);
  3717. if (meta === null) {
  3718. return null;
  3719. }
  3720. return meta.marker;
  3721. };
  3722. DateEnv.prototype.createNowMarker = function () {
  3723. if (this.canComputeOffset) {
  3724. return this.timestampToMarker(new Date().valueOf());
  3725. }
  3726. // if we can't compute the current date val for a timezone,
  3727. // better to give the current local date vals than UTC
  3728. return arrayToUtcDate(dateToLocalArray(new Date()));
  3729. };
  3730. DateEnv.prototype.createMarkerMeta = function (input) {
  3731. if (typeof input === 'string') {
  3732. return this.parse(input);
  3733. }
  3734. var marker = null;
  3735. if (typeof input === 'number') {
  3736. marker = this.timestampToMarker(input);
  3737. }
  3738. else if (input instanceof Date) {
  3739. input = input.valueOf();
  3740. if (!isNaN(input)) {
  3741. marker = this.timestampToMarker(input);
  3742. }
  3743. }
  3744. else if (Array.isArray(input)) {
  3745. marker = arrayToUtcDate(input);
  3746. }
  3747. if (marker === null || !isValidDate(marker)) {
  3748. return null;
  3749. }
  3750. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  3751. };
  3752. DateEnv.prototype.parse = function (s) {
  3753. var parts = parse(s);
  3754. if (parts === null) {
  3755. return null;
  3756. }
  3757. var marker = parts.marker;
  3758. var forcedTzo = null;
  3759. if (parts.timeZoneOffset !== null) {
  3760. if (this.canComputeOffset) {
  3761. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  3762. }
  3763. else {
  3764. forcedTzo = parts.timeZoneOffset;
  3765. }
  3766. }
  3767. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  3768. };
  3769. // Accessors
  3770. DateEnv.prototype.getYear = function (marker) {
  3771. return this.calendarSystem.getMarkerYear(marker);
  3772. };
  3773. DateEnv.prototype.getMonth = function (marker) {
  3774. return this.calendarSystem.getMarkerMonth(marker);
  3775. };
  3776. // Adding / Subtracting
  3777. DateEnv.prototype.add = function (marker, dur) {
  3778. var a = this.calendarSystem.markerToArray(marker);
  3779. a[0] += dur.years;
  3780. a[1] += dur.months;
  3781. a[2] += dur.days;
  3782. a[6] += dur.milliseconds;
  3783. return this.calendarSystem.arrayToMarker(a);
  3784. };
  3785. DateEnv.prototype.subtract = function (marker, dur) {
  3786. var a = this.calendarSystem.markerToArray(marker);
  3787. a[0] -= dur.years;
  3788. a[1] -= dur.months;
  3789. a[2] -= dur.days;
  3790. a[6] -= dur.milliseconds;
  3791. return this.calendarSystem.arrayToMarker(a);
  3792. };
  3793. DateEnv.prototype.addYears = function (marker, n) {
  3794. var a = this.calendarSystem.markerToArray(marker);
  3795. a[0] += n;
  3796. return this.calendarSystem.arrayToMarker(a);
  3797. };
  3798. DateEnv.prototype.addMonths = function (marker, n) {
  3799. var a = this.calendarSystem.markerToArray(marker);
  3800. a[1] += n;
  3801. return this.calendarSystem.arrayToMarker(a);
  3802. };
  3803. // Diffing Whole Units
  3804. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  3805. var calendarSystem = this.calendarSystem;
  3806. if (timeAsMs(m0) === timeAsMs(m1) &&
  3807. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  3808. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  3809. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  3810. }
  3811. return null;
  3812. };
  3813. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  3814. var calendarSystem = this.calendarSystem;
  3815. if (timeAsMs(m0) === timeAsMs(m1) &&
  3816. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  3817. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  3818. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  3819. }
  3820. return null;
  3821. };
  3822. // Range / Duration
  3823. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  3824. var n = this.diffWholeYears(m0, m1);
  3825. if (n !== null) {
  3826. return { unit: 'year', value: n };
  3827. }
  3828. n = this.diffWholeMonths(m0, m1);
  3829. if (n !== null) {
  3830. return { unit: 'month', value: n };
  3831. }
  3832. n = diffWholeWeeks(m0, m1);
  3833. if (n !== null) {
  3834. return { unit: 'week', value: n };
  3835. }
  3836. n = diffWholeDays(m0, m1);
  3837. if (n !== null) {
  3838. return { unit: 'day', value: n };
  3839. }
  3840. n = diffHours(m0, m1);
  3841. if (isInt(n)) {
  3842. return { unit: 'hour', value: n };
  3843. }
  3844. n = diffMinutes(m0, m1);
  3845. if (isInt(n)) {
  3846. return { unit: 'minute', value: n };
  3847. }
  3848. n = diffSeconds(m0, m1);
  3849. if (isInt(n)) {
  3850. return { unit: 'second', value: n };
  3851. }
  3852. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  3853. };
  3854. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  3855. // TODO: can use greatestWholeUnit
  3856. var diff;
  3857. if (d.years) {
  3858. diff = this.diffWholeYears(m0, m1);
  3859. if (diff !== null) {
  3860. return diff / asRoughYears(d);
  3861. }
  3862. }
  3863. if (d.months) {
  3864. diff = this.diffWholeMonths(m0, m1);
  3865. if (diff !== null) {
  3866. return diff / asRoughMonths(d);
  3867. }
  3868. }
  3869. if (d.days) {
  3870. diff = diffWholeDays(m0, m1);
  3871. if (diff !== null) {
  3872. return diff / asRoughDays(d);
  3873. }
  3874. }
  3875. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  3876. };
  3877. // Start-Of
  3878. // these DON'T return zoned-dates. only UTC start-of dates
  3879. DateEnv.prototype.startOf = function (m, unit) {
  3880. if (unit === 'year') {
  3881. return this.startOfYear(m);
  3882. }
  3883. if (unit === 'month') {
  3884. return this.startOfMonth(m);
  3885. }
  3886. if (unit === 'week') {
  3887. return this.startOfWeek(m);
  3888. }
  3889. if (unit === 'day') {
  3890. return startOfDay(m);
  3891. }
  3892. if (unit === 'hour') {
  3893. return startOfHour(m);
  3894. }
  3895. if (unit === 'minute') {
  3896. return startOfMinute(m);
  3897. }
  3898. if (unit === 'second') {
  3899. return startOfSecond(m);
  3900. }
  3901. return null;
  3902. };
  3903. DateEnv.prototype.startOfYear = function (m) {
  3904. return this.calendarSystem.arrayToMarker([
  3905. this.calendarSystem.getMarkerYear(m),
  3906. ]);
  3907. };
  3908. DateEnv.prototype.startOfMonth = function (m) {
  3909. return this.calendarSystem.arrayToMarker([
  3910. this.calendarSystem.getMarkerYear(m),
  3911. this.calendarSystem.getMarkerMonth(m),
  3912. ]);
  3913. };
  3914. DateEnv.prototype.startOfWeek = function (m) {
  3915. return this.calendarSystem.arrayToMarker([
  3916. this.calendarSystem.getMarkerYear(m),
  3917. this.calendarSystem.getMarkerMonth(m),
  3918. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7),
  3919. ]);
  3920. };
  3921. // Week Number
  3922. DateEnv.prototype.computeWeekNumber = function (marker) {
  3923. if (this.weekNumberFunc) {
  3924. return this.weekNumberFunc(this.toDate(marker));
  3925. }
  3926. return weekOfYear(marker, this.weekDow, this.weekDoy);
  3927. };
  3928. // TODO: choke on timeZoneName: long
  3929. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  3930. if (dateOptions === void 0) { dateOptions = {}; }
  3931. return formatter.format({
  3932. marker: marker,
  3933. timeZoneOffset: dateOptions.forcedTzo != null ?
  3934. dateOptions.forcedTzo :
  3935. this.offsetForMarker(marker),
  3936. }, this);
  3937. };
  3938. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  3939. if (dateOptions === void 0) { dateOptions = {}; }
  3940. if (dateOptions.isEndExclusive) {
  3941. end = addMs(end, -1);
  3942. }
  3943. return formatter.formatRange({
  3944. marker: start,
  3945. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  3946. dateOptions.forcedStartTzo :
  3947. this.offsetForMarker(start),
  3948. }, {
  3949. marker: end,
  3950. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  3951. dateOptions.forcedEndTzo :
  3952. this.offsetForMarker(end),
  3953. }, this, dateOptions.defaultSeparator);
  3954. };
  3955. /*
  3956. DUMB: the omitTime arg is dumb. if we omit the time, we want to omit the timezone offset. and if we do that,
  3957. might as well use buildIsoString or some other util directly
  3958. */
  3959. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  3960. if (extraOptions === void 0) { extraOptions = {}; }
  3961. var timeZoneOffset = null;
  3962. if (!extraOptions.omitTimeZoneOffset) {
  3963. if (extraOptions.forcedTzo != null) {
  3964. timeZoneOffset = extraOptions.forcedTzo;
  3965. }
  3966. else {
  3967. timeZoneOffset = this.offsetForMarker(marker);
  3968. }
  3969. }
  3970. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  3971. };
  3972. // TimeZone
  3973. DateEnv.prototype.timestampToMarker = function (ms) {
  3974. if (this.timeZone === 'local') {
  3975. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  3976. }
  3977. if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  3978. return new Date(ms);
  3979. }
  3980. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  3981. };
  3982. DateEnv.prototype.offsetForMarker = function (m) {
  3983. if (this.timeZone === 'local') {
  3984. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  3985. }
  3986. if (this.timeZone === 'UTC') {
  3987. return 0;
  3988. }
  3989. if (this.namedTimeZoneImpl) {
  3990. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  3991. }
  3992. return null;
  3993. };
  3994. // Conversion
  3995. DateEnv.prototype.toDate = function (m, forcedTzo) {
  3996. if (this.timeZone === 'local') {
  3997. return arrayToLocalDate(dateToUtcArray(m));
  3998. }
  3999. if (this.timeZone === 'UTC') {
  4000. return new Date(m.valueOf()); // make sure it's a copy
  4001. }
  4002. if (!this.namedTimeZoneImpl) {
  4003. return new Date(m.valueOf() - (forcedTzo || 0));
  4004. }
  4005. return new Date(m.valueOf() -
  4006. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60);
  4007. };
  4008. return DateEnv;
  4009. }());
  4010. var globalLocales = [];
  4011. var RAW_EN_LOCALE = {
  4012. code: 'en',
  4013. week: {
  4014. dow: 0,
  4015. doy: 4,
  4016. },
  4017. direction: 'ltr',
  4018. buttonText: {
  4019. prev: 'prev',
  4020. next: 'next',
  4021. prevYear: 'prev year',
  4022. nextYear: 'next year',
  4023. year: 'year',
  4024. today: 'today',
  4025. month: 'month',
  4026. week: 'week',
  4027. day: 'day',
  4028. list: 'list',
  4029. },
  4030. weekText: 'W',
  4031. allDayText: 'all-day',
  4032. moreLinkText: 'more',
  4033. noEventsText: 'No events to display',
  4034. };
  4035. function organizeRawLocales(explicitRawLocales) {
  4036. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4037. var allRawLocales = globalLocales.concat(explicitRawLocales);
  4038. var rawLocaleMap = {
  4039. en: RAW_EN_LOCALE,
  4040. };
  4041. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4042. var rawLocale = allRawLocales_1[_i];
  4043. rawLocaleMap[rawLocale.code] = rawLocale;
  4044. }
  4045. return {
  4046. map: rawLocaleMap,
  4047. defaultCode: defaultCode,
  4048. };
  4049. }
  4050. function buildLocale(inputSingular, available) {
  4051. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4052. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4053. }
  4054. return queryLocale(inputSingular, available);
  4055. }
  4056. function queryLocale(codeArg, available) {
  4057. var codes = [].concat(codeArg || []); // will convert to array
  4058. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4059. return parseLocale(codeArg, codes, raw);
  4060. }
  4061. function queryRawLocale(codes, available) {
  4062. for (var i = 0; i < codes.length; i += 1) {
  4063. var parts = codes[i].toLocaleLowerCase().split('-');
  4064. for (var j = parts.length; j > 0; j -= 1) {
  4065. var simpleId = parts.slice(0, j).join('-');
  4066. if (available[simpleId]) {
  4067. return available[simpleId];
  4068. }
  4069. }
  4070. }
  4071. return null;
  4072. }
  4073. function parseLocale(codeArg, codes, raw) {
  4074. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4075. delete merged.code; // don't want this part of the options
  4076. var week = merged.week;
  4077. delete merged.week;
  4078. return {
  4079. codeArg: codeArg,
  4080. codes: codes,
  4081. week: week,
  4082. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4083. options: merged,
  4084. };
  4085. }
  4086. function formatDate(dateInput, options) {
  4087. if (options === void 0) { options = {}; }
  4088. var dateEnv = buildDateEnv(options);
  4089. var formatter = createFormatter(options);
  4090. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  4091. if (!dateMeta) { // TODO: warning?
  4092. return '';
  4093. }
  4094. return dateEnv.format(dateMeta.marker, formatter, {
  4095. forcedTzo: dateMeta.forcedTzo,
  4096. });
  4097. }
  4098. function formatRange(startInput, endInput, options) {
  4099. var dateEnv = buildDateEnv(typeof options === 'object' && options ? options : {}); // pass in if non-null object
  4100. var formatter = createFormatter(options);
  4101. var startMeta = dateEnv.createMarkerMeta(startInput);
  4102. var endMeta = dateEnv.createMarkerMeta(endInput);
  4103. if (!startMeta || !endMeta) { // TODO: warning?
  4104. return '';
  4105. }
  4106. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  4107. forcedStartTzo: startMeta.forcedTzo,
  4108. forcedEndTzo: endMeta.forcedTzo,
  4109. isEndExclusive: options.isEndExclusive,
  4110. defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator,
  4111. });
  4112. }
  4113. // TODO: more DRY and optimized
  4114. function buildDateEnv(settings) {
  4115. var locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  4116. return new DateEnv(__assign(__assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale: locale }));
  4117. }
  4118. var DEF_DEFAULTS = {
  4119. startTime: '09:00',
  4120. endTime: '17:00',
  4121. daysOfWeek: [1, 2, 3, 4, 5],
  4122. display: 'inverse-background',
  4123. classNames: 'fc-non-business',
  4124. groupId: '_businessHours',
  4125. };
  4126. /*
  4127. TODO: pass around as EventDefHash!!!
  4128. */
  4129. function parseBusinessHours(input, context) {
  4130. return parseEvents(refineInputs(input), null, context);
  4131. }
  4132. function refineInputs(input) {
  4133. var rawDefs;
  4134. if (input === true) {
  4135. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  4136. }
  4137. else if (Array.isArray(input)) {
  4138. // if specifying an array, every sub-definition NEEDS a day-of-week
  4139. rawDefs = input.filter(function (rawDef) { return rawDef.daysOfWeek; });
  4140. }
  4141. else if (typeof input === 'object' && input) { // non-null object
  4142. rawDefs = [input];
  4143. }
  4144. else { // is probably false
  4145. rawDefs = [];
  4146. }
  4147. rawDefs = rawDefs.map(function (rawDef) { return (__assign(__assign({}, DEF_DEFAULTS), rawDef)); });
  4148. return rawDefs;
  4149. }
  4150. function pointInsideRect(point, rect) {
  4151. return point.left >= rect.left &&
  4152. point.left < rect.right &&
  4153. point.top >= rect.top &&
  4154. point.top < rect.bottom;
  4155. }
  4156. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  4157. function intersectRects(rect1, rect2) {
  4158. var res = {
  4159. left: Math.max(rect1.left, rect2.left),
  4160. right: Math.min(rect1.right, rect2.right),
  4161. top: Math.max(rect1.top, rect2.top),
  4162. bottom: Math.min(rect1.bottom, rect2.bottom),
  4163. };
  4164. if (res.left < res.right && res.top < res.bottom) {
  4165. return res;
  4166. }
  4167. return false;
  4168. }
  4169. function translateRect(rect, deltaX, deltaY) {
  4170. return {
  4171. left: rect.left + deltaX,
  4172. right: rect.right + deltaX,
  4173. top: rect.top + deltaY,
  4174. bottom: rect.bottom + deltaY,
  4175. };
  4176. }
  4177. // Returns a new point that will have been moved to reside within the given rectangle
  4178. function constrainPoint(point, rect) {
  4179. return {
  4180. left: Math.min(Math.max(point.left, rect.left), rect.right),
  4181. top: Math.min(Math.max(point.top, rect.top), rect.bottom),
  4182. };
  4183. }
  4184. // Returns a point that is the center of the given rectangle
  4185. function getRectCenter(rect) {
  4186. return {
  4187. left: (rect.left + rect.right) / 2,
  4188. top: (rect.top + rect.bottom) / 2,
  4189. };
  4190. }
  4191. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  4192. function diffPoints(point1, point2) {
  4193. return {
  4194. left: point1.left - point2.left,
  4195. top: point1.top - point2.top,
  4196. };
  4197. }
  4198. var canVGrowWithinCell;
  4199. function getCanVGrowWithinCell() {
  4200. if (canVGrowWithinCell == null) {
  4201. canVGrowWithinCell = computeCanVGrowWithinCell();
  4202. }
  4203. return canVGrowWithinCell;
  4204. }
  4205. function computeCanVGrowWithinCell() {
  4206. // for SSR, because this function is call immediately at top-level
  4207. // TODO: just make this logic execute top-level, immediately, instead of doing lazily
  4208. if (typeof document === 'undefined') {
  4209. return true;
  4210. }
  4211. var el = document.createElement('div');
  4212. el.style.position = 'absolute';
  4213. el.style.top = '0px';
  4214. el.style.left = '0px';
  4215. el.innerHTML = '<table><tr><td><div></div></td></tr></table>';
  4216. el.querySelector('table').style.height = '100px';
  4217. el.querySelector('div').style.height = '100%';
  4218. document.body.appendChild(el);
  4219. var div = el.querySelector('div');
  4220. var possible = div.offsetHeight > 0;
  4221. document.body.removeChild(el);
  4222. return possible;
  4223. }
  4224. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  4225. var Splitter = /** @class */ (function () {
  4226. function Splitter() {
  4227. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  4228. this.splitDateSelection = memoize(this._splitDateSpan);
  4229. this.splitEventStore = memoize(this._splitEventStore);
  4230. this.splitIndividualUi = memoize(this._splitIndividualUi);
  4231. this.splitEventDrag = memoize(this._splitInteraction);
  4232. this.splitEventResize = memoize(this._splitInteraction);
  4233. this.eventUiBuilders = {}; // TODO: typescript protection
  4234. }
  4235. Splitter.prototype.splitProps = function (props) {
  4236. var _this = this;
  4237. var keyInfos = this.getKeyInfo(props);
  4238. var defKeys = this.getKeysForEventDefs(props.eventStore);
  4239. var dateSelections = this.splitDateSelection(props.dateSelection);
  4240. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  4241. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  4242. var eventDrags = this.splitEventDrag(props.eventDrag);
  4243. var eventResizes = this.splitEventResize(props.eventResize);
  4244. var splitProps = {};
  4245. this.eventUiBuilders = mapHash(keyInfos, function (info, key) { return _this.eventUiBuilders[key] || memoize(buildEventUiForKey); });
  4246. for (var key in keyInfos) {
  4247. var keyInfo = keyInfos[key];
  4248. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  4249. var buildEventUi = this.eventUiBuilders[key];
  4250. splitProps[key] = {
  4251. businessHours: keyInfo.businessHours || props.businessHours,
  4252. dateSelection: dateSelections[key] || null,
  4253. eventStore: eventStore,
  4254. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  4255. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  4256. eventDrag: eventDrags[key] || null,
  4257. eventResize: eventResizes[key] || null,
  4258. };
  4259. }
  4260. return splitProps;
  4261. };
  4262. Splitter.prototype._splitDateSpan = function (dateSpan) {
  4263. var dateSpans = {};
  4264. if (dateSpan) {
  4265. var keys = this.getKeysForDateSpan(dateSpan);
  4266. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  4267. var key = keys_1[_i];
  4268. dateSpans[key] = dateSpan;
  4269. }
  4270. }
  4271. return dateSpans;
  4272. };
  4273. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  4274. var _this = this;
  4275. return mapHash(eventStore.defs, function (eventDef) { return _this.getKeysForEventDef(eventDef); });
  4276. };
  4277. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  4278. var defs = eventStore.defs, instances = eventStore.instances;
  4279. var splitStores = {};
  4280. for (var defId in defs) {
  4281. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4282. var key = _a[_i];
  4283. if (!splitStores[key]) {
  4284. splitStores[key] = createEmptyEventStore();
  4285. }
  4286. splitStores[key].defs[defId] = defs[defId];
  4287. }
  4288. }
  4289. for (var instanceId in instances) {
  4290. var instance = instances[instanceId];
  4291. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  4292. var key = _c[_b];
  4293. if (splitStores[key]) { // must have already been created
  4294. splitStores[key].instances[instanceId] = instance;
  4295. }
  4296. }
  4297. }
  4298. return splitStores;
  4299. };
  4300. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  4301. var splitHashes = {};
  4302. for (var defId in eventUiBases) {
  4303. if (defId) { // not the '' key
  4304. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4305. var key = _a[_i];
  4306. if (!splitHashes[key]) {
  4307. splitHashes[key] = {};
  4308. }
  4309. splitHashes[key][defId] = eventUiBases[defId];
  4310. }
  4311. }
  4312. }
  4313. return splitHashes;
  4314. };
  4315. Splitter.prototype._splitInteraction = function (interaction) {
  4316. var splitStates = {};
  4317. if (interaction) {
  4318. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
  4319. // can't rely on defKeys because event data is mutated
  4320. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  4321. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  4322. var populate = function (key) {
  4323. if (!splitStates[key]) {
  4324. splitStates[key] = {
  4325. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  4326. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  4327. isEvent: interaction.isEvent,
  4328. };
  4329. }
  4330. };
  4331. for (var key in affectedStores_1) {
  4332. populate(key);
  4333. }
  4334. for (var key in mutatedStores_1) {
  4335. populate(key);
  4336. }
  4337. }
  4338. return splitStates;
  4339. };
  4340. return Splitter;
  4341. }());
  4342. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  4343. var baseParts = [];
  4344. if (allUi) {
  4345. baseParts.push(allUi);
  4346. }
  4347. if (eventUiForKey) {
  4348. baseParts.push(eventUiForKey);
  4349. }
  4350. var stuff = {
  4351. '': combineEventUis(baseParts),
  4352. };
  4353. if (individualUi) {
  4354. __assign(stuff, individualUi);
  4355. }
  4356. return stuff;
  4357. }
  4358. function getDateMeta(date, todayRange, nowDate, dateProfile) {
  4359. return {
  4360. dow: date.getUTCDay(),
  4361. isDisabled: Boolean(dateProfile && !rangeContainsMarker(dateProfile.activeRange, date)),
  4362. isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
  4363. isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
  4364. isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
  4365. isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false),
  4366. };
  4367. }
  4368. function getDayClassNames(meta, theme) {
  4369. var classNames = [
  4370. 'fc-day',
  4371. "fc-day-" + DAY_IDS[meta.dow],
  4372. ];
  4373. if (meta.isDisabled) {
  4374. classNames.push('fc-day-disabled');
  4375. }
  4376. else {
  4377. if (meta.isToday) {
  4378. classNames.push('fc-day-today');
  4379. classNames.push(theme.getClass('today'));
  4380. }
  4381. if (meta.isPast) {
  4382. classNames.push('fc-day-past');
  4383. }
  4384. if (meta.isFuture) {
  4385. classNames.push('fc-day-future');
  4386. }
  4387. if (meta.isOther) {
  4388. classNames.push('fc-day-other');
  4389. }
  4390. }
  4391. return classNames;
  4392. }
  4393. function getSlotClassNames(meta, theme) {
  4394. var classNames = [
  4395. 'fc-slot',
  4396. "fc-slot-" + DAY_IDS[meta.dow],
  4397. ];
  4398. if (meta.isDisabled) {
  4399. classNames.push('fc-slot-disabled');
  4400. }
  4401. else {
  4402. if (meta.isToday) {
  4403. classNames.push('fc-slot-today');
  4404. classNames.push(theme.getClass('today'));
  4405. }
  4406. if (meta.isPast) {
  4407. classNames.push('fc-slot-past');
  4408. }
  4409. if (meta.isFuture) {
  4410. classNames.push('fc-slot-future');
  4411. }
  4412. }
  4413. return classNames;
  4414. }
  4415. function buildNavLinkData(date, type) {
  4416. if (type === void 0) { type = 'day'; }
  4417. return JSON.stringify({
  4418. date: formatDayString(date),
  4419. type: type,
  4420. });
  4421. }
  4422. var _isRtlScrollbarOnLeft = null;
  4423. function getIsRtlScrollbarOnLeft() {
  4424. if (_isRtlScrollbarOnLeft === null) {
  4425. _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  4426. }
  4427. return _isRtlScrollbarOnLeft;
  4428. }
  4429. function computeIsRtlScrollbarOnLeft() {
  4430. var outerEl = document.createElement('div');
  4431. applyStyle(outerEl, {
  4432. position: 'absolute',
  4433. top: -1000,
  4434. left: 0,
  4435. border: 0,
  4436. padding: 0,
  4437. overflow: 'scroll',
  4438. direction: 'rtl',
  4439. });
  4440. outerEl.innerHTML = '<div></div>';
  4441. document.body.appendChild(outerEl);
  4442. var innerEl = outerEl.firstChild;
  4443. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  4444. removeElement(outerEl);
  4445. return res;
  4446. }
  4447. var _scrollbarWidths;
  4448. function getScrollbarWidths() {
  4449. if (!_scrollbarWidths) {
  4450. _scrollbarWidths = computeScrollbarWidths();
  4451. }
  4452. return _scrollbarWidths;
  4453. }
  4454. function computeScrollbarWidths() {
  4455. var el = document.createElement('div');
  4456. el.style.overflow = 'scroll';
  4457. el.style.position = 'absolute';
  4458. el.style.top = '-9999px';
  4459. el.style.left = '-9999px';
  4460. document.body.appendChild(el);
  4461. var res = computeScrollbarWidthsForEl(el);
  4462. document.body.removeChild(el);
  4463. return res;
  4464. }
  4465. // WARNING: will include border
  4466. function computeScrollbarWidthsForEl(el) {
  4467. return {
  4468. x: el.offsetHeight - el.clientHeight,
  4469. y: el.offsetWidth - el.clientWidth,
  4470. };
  4471. }
  4472. function computeEdges(el, getPadding) {
  4473. if (getPadding === void 0) { getPadding = false; }
  4474. var computedStyle = window.getComputedStyle(el);
  4475. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  4476. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  4477. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  4478. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  4479. var badScrollbarWidths = computeScrollbarWidthsForEl(el); // includes border!
  4480. var scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
  4481. var scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
  4482. var res = {
  4483. borderLeft: borderLeft,
  4484. borderRight: borderRight,
  4485. borderTop: borderTop,
  4486. borderBottom: borderBottom,
  4487. scrollbarBottom: scrollbarBottom,
  4488. scrollbarLeft: 0,
  4489. scrollbarRight: 0,
  4490. };
  4491. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  4492. res.scrollbarLeft = scrollbarLeftRight;
  4493. }
  4494. else {
  4495. res.scrollbarRight = scrollbarLeftRight;
  4496. }
  4497. if (getPadding) {
  4498. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  4499. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  4500. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  4501. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  4502. }
  4503. return res;
  4504. }
  4505. function computeInnerRect(el, goWithinPadding, doFromWindowViewport) {
  4506. if (goWithinPadding === void 0) { goWithinPadding = false; }
  4507. var outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
  4508. var edges = computeEdges(el, goWithinPadding);
  4509. var res = {
  4510. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  4511. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  4512. top: outerRect.top + edges.borderTop,
  4513. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom,
  4514. };
  4515. if (goWithinPadding) {
  4516. res.left += edges.paddingLeft;
  4517. res.right -= edges.paddingRight;
  4518. res.top += edges.paddingTop;
  4519. res.bottom -= edges.paddingBottom;
  4520. }
  4521. return res;
  4522. }
  4523. function computeRect(el) {
  4524. var rect = el.getBoundingClientRect();
  4525. return {
  4526. left: rect.left + window.pageXOffset,
  4527. top: rect.top + window.pageYOffset,
  4528. right: rect.right + window.pageXOffset,
  4529. bottom: rect.bottom + window.pageYOffset,
  4530. };
  4531. }
  4532. function computeHeightAndMargins(el) {
  4533. return el.getBoundingClientRect().height + computeVMargins(el);
  4534. }
  4535. function computeVMargins(el) {
  4536. var computed = window.getComputedStyle(el);
  4537. return parseInt(computed.marginTop, 10) +
  4538. parseInt(computed.marginBottom, 10);
  4539. }
  4540. // does not return window
  4541. function getClippingParents(el) {
  4542. var parents = [];
  4543. while (el instanceof HTMLElement) { // will stop when gets to document or null
  4544. var computedStyle = window.getComputedStyle(el);
  4545. if (computedStyle.position === 'fixed') {
  4546. break;
  4547. }
  4548. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  4549. parents.push(el);
  4550. }
  4551. el = el.parentNode;
  4552. }
  4553. return parents;
  4554. }
  4555. // given a function that resolves a result asynchronously.
  4556. // the function can either call passed-in success and failure callbacks,
  4557. // or it can return a promise.
  4558. // if you need to pass additional params to func, bind them first.
  4559. function unpromisify(func, success, failure) {
  4560. // guard against success/failure callbacks being called more than once
  4561. // and guard against a promise AND callback being used together.
  4562. var isResolved = false;
  4563. var wrappedSuccess = function () {
  4564. if (!isResolved) {
  4565. isResolved = true;
  4566. success.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4567. }
  4568. };
  4569. var wrappedFailure = function () {
  4570. if (!isResolved) {
  4571. isResolved = true;
  4572. if (failure) {
  4573. failure.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4574. }
  4575. }
  4576. };
  4577. var res = func(wrappedSuccess, wrappedFailure);
  4578. if (res && typeof res.then === 'function') {
  4579. res.then(wrappedSuccess, wrappedFailure);
  4580. }
  4581. }
  4582. var Emitter = /** @class */ (function () {
  4583. function Emitter() {
  4584. this.handlers = {};
  4585. this.thisContext = null;
  4586. }
  4587. Emitter.prototype.setThisContext = function (thisContext) {
  4588. this.thisContext = thisContext;
  4589. };
  4590. Emitter.prototype.setOptions = function (options) {
  4591. this.options = options;
  4592. };
  4593. Emitter.prototype.on = function (type, handler) {
  4594. addToHash(this.handlers, type, handler);
  4595. };
  4596. Emitter.prototype.off = function (type, handler) {
  4597. removeFromHash(this.handlers, type, handler);
  4598. };
  4599. Emitter.prototype.trigger = function (type) {
  4600. var args = [];
  4601. for (var _i = 1; _i < arguments.length; _i++) {
  4602. args[_i - 1] = arguments[_i];
  4603. }
  4604. var attachedHandlers = this.handlers[type] || [];
  4605. var optionHandler = this.options && this.options[type];
  4606. var handlers = [].concat(optionHandler || [], attachedHandlers);
  4607. for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
  4608. var handler = handlers_1[_a];
  4609. handler.apply(this.thisContext, args);
  4610. }
  4611. };
  4612. Emitter.prototype.hasHandlers = function (type) {
  4613. return (this.handlers[type] && this.handlers[type].length) ||
  4614. (this.options && this.options[type]);
  4615. };
  4616. return Emitter;
  4617. }());
  4618. function addToHash(hash, type, handler) {
  4619. (hash[type] || (hash[type] = []))
  4620. .push(handler);
  4621. }
  4622. function removeFromHash(hash, type, handler) {
  4623. if (handler) {
  4624. if (hash[type]) {
  4625. hash[type] = hash[type].filter(function (func) { return func !== handler; });
  4626. }
  4627. }
  4628. else {
  4629. delete hash[type]; // remove all handler funcs for this type
  4630. }
  4631. }
  4632. /*
  4633. Records offset information for a set of elements, relative to an origin element.
  4634. Can record the left/right OR the top/bottom OR both.
  4635. Provides methods for querying the cache by position.
  4636. */
  4637. var PositionCache = /** @class */ (function () {
  4638. function PositionCache(originEl, els, isHorizontal, isVertical) {
  4639. this.els = els;
  4640. var originClientRect = this.originClientRect = originEl.getBoundingClientRect(); // relative to viewport top-left
  4641. if (isHorizontal) {
  4642. this.buildElHorizontals(originClientRect.left);
  4643. }
  4644. if (isVertical) {
  4645. this.buildElVerticals(originClientRect.top);
  4646. }
  4647. }
  4648. // Populates the left/right internal coordinate arrays
  4649. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  4650. var lefts = [];
  4651. var rights = [];
  4652. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4653. var el = _a[_i];
  4654. var rect = el.getBoundingClientRect();
  4655. lefts.push(rect.left - originClientLeft);
  4656. rights.push(rect.right - originClientLeft);
  4657. }
  4658. this.lefts = lefts;
  4659. this.rights = rights;
  4660. };
  4661. // Populates the top/bottom internal coordinate arrays
  4662. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  4663. var tops = [];
  4664. var bottoms = [];
  4665. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4666. var el = _a[_i];
  4667. var rect = el.getBoundingClientRect();
  4668. tops.push(rect.top - originClientTop);
  4669. bottoms.push(rect.bottom - originClientTop);
  4670. }
  4671. this.tops = tops;
  4672. this.bottoms = bottoms;
  4673. };
  4674. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  4675. // If no intersection is made, returns undefined.
  4676. PositionCache.prototype.leftToIndex = function (leftPosition) {
  4677. var _a = this, lefts = _a.lefts, rights = _a.rights;
  4678. var len = lefts.length;
  4679. var i;
  4680. for (i = 0; i < len; i += 1) {
  4681. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  4682. return i;
  4683. }
  4684. }
  4685. return undefined; // TODO: better
  4686. };
  4687. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  4688. // If no intersection is made, returns undefined.
  4689. PositionCache.prototype.topToIndex = function (topPosition) {
  4690. var _a = this, tops = _a.tops, bottoms = _a.bottoms;
  4691. var len = tops.length;
  4692. var i;
  4693. for (i = 0; i < len; i += 1) {
  4694. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  4695. return i;
  4696. }
  4697. }
  4698. return undefined; // TODO: better
  4699. };
  4700. // Gets the width of the element at the given index
  4701. PositionCache.prototype.getWidth = function (leftIndex) {
  4702. return this.rights[leftIndex] - this.lefts[leftIndex];
  4703. };
  4704. // Gets the height of the element at the given index
  4705. PositionCache.prototype.getHeight = function (topIndex) {
  4706. return this.bottoms[topIndex] - this.tops[topIndex];
  4707. };
  4708. return PositionCache;
  4709. }());
  4710. /* eslint max-classes-per-file: "off" */
  4711. /*
  4712. An object for getting/setting scroll-related information for an element.
  4713. Internally, this is done very differently for window versus DOM element,
  4714. so this object serves as a common interface.
  4715. */
  4716. var ScrollController = /** @class */ (function () {
  4717. function ScrollController() {
  4718. }
  4719. ScrollController.prototype.getMaxScrollTop = function () {
  4720. return this.getScrollHeight() - this.getClientHeight();
  4721. };
  4722. ScrollController.prototype.getMaxScrollLeft = function () {
  4723. return this.getScrollWidth() - this.getClientWidth();
  4724. };
  4725. ScrollController.prototype.canScrollVertically = function () {
  4726. return this.getMaxScrollTop() > 0;
  4727. };
  4728. ScrollController.prototype.canScrollHorizontally = function () {
  4729. return this.getMaxScrollLeft() > 0;
  4730. };
  4731. ScrollController.prototype.canScrollUp = function () {
  4732. return this.getScrollTop() > 0;
  4733. };
  4734. ScrollController.prototype.canScrollDown = function () {
  4735. return this.getScrollTop() < this.getMaxScrollTop();
  4736. };
  4737. ScrollController.prototype.canScrollLeft = function () {
  4738. return this.getScrollLeft() > 0;
  4739. };
  4740. ScrollController.prototype.canScrollRight = function () {
  4741. return this.getScrollLeft() < this.getMaxScrollLeft();
  4742. };
  4743. return ScrollController;
  4744. }());
  4745. var ElementScrollController = /** @class */ (function (_super) {
  4746. __extends(ElementScrollController, _super);
  4747. function ElementScrollController(el) {
  4748. var _this = _super.call(this) || this;
  4749. _this.el = el;
  4750. return _this;
  4751. }
  4752. ElementScrollController.prototype.getScrollTop = function () {
  4753. return this.el.scrollTop;
  4754. };
  4755. ElementScrollController.prototype.getScrollLeft = function () {
  4756. return this.el.scrollLeft;
  4757. };
  4758. ElementScrollController.prototype.setScrollTop = function (top) {
  4759. this.el.scrollTop = top;
  4760. };
  4761. ElementScrollController.prototype.setScrollLeft = function (left) {
  4762. this.el.scrollLeft = left;
  4763. };
  4764. ElementScrollController.prototype.getScrollWidth = function () {
  4765. return this.el.scrollWidth;
  4766. };
  4767. ElementScrollController.prototype.getScrollHeight = function () {
  4768. return this.el.scrollHeight;
  4769. };
  4770. ElementScrollController.prototype.getClientHeight = function () {
  4771. return this.el.clientHeight;
  4772. };
  4773. ElementScrollController.prototype.getClientWidth = function () {
  4774. return this.el.clientWidth;
  4775. };
  4776. return ElementScrollController;
  4777. }(ScrollController));
  4778. var WindowScrollController = /** @class */ (function (_super) {
  4779. __extends(WindowScrollController, _super);
  4780. function WindowScrollController() {
  4781. return _super !== null && _super.apply(this, arguments) || this;
  4782. }
  4783. WindowScrollController.prototype.getScrollTop = function () {
  4784. return window.pageYOffset;
  4785. };
  4786. WindowScrollController.prototype.getScrollLeft = function () {
  4787. return window.pageXOffset;
  4788. };
  4789. WindowScrollController.prototype.setScrollTop = function (n) {
  4790. window.scroll(window.pageXOffset, n);
  4791. };
  4792. WindowScrollController.prototype.setScrollLeft = function (n) {
  4793. window.scroll(n, window.pageYOffset);
  4794. };
  4795. WindowScrollController.prototype.getScrollWidth = function () {
  4796. return document.documentElement.scrollWidth;
  4797. };
  4798. WindowScrollController.prototype.getScrollHeight = function () {
  4799. return document.documentElement.scrollHeight;
  4800. };
  4801. WindowScrollController.prototype.getClientHeight = function () {
  4802. return document.documentElement.clientHeight;
  4803. };
  4804. WindowScrollController.prototype.getClientWidth = function () {
  4805. return document.documentElement.clientWidth;
  4806. };
  4807. return WindowScrollController;
  4808. }(ScrollController));
  4809. var Theme = /** @class */ (function () {
  4810. function Theme(calendarOptions) {
  4811. if (this.iconOverrideOption) {
  4812. this.setIconOverride(calendarOptions[this.iconOverrideOption]);
  4813. }
  4814. }
  4815. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  4816. var iconClassesCopy;
  4817. var buttonName;
  4818. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  4819. iconClassesCopy = __assign({}, this.iconClasses);
  4820. for (buttonName in iconOverrideHash) {
  4821. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  4822. }
  4823. this.iconClasses = iconClassesCopy;
  4824. }
  4825. else if (iconOverrideHash === false) {
  4826. this.iconClasses = {};
  4827. }
  4828. };
  4829. Theme.prototype.applyIconOverridePrefix = function (className) {
  4830. var prefix = this.iconOverridePrefix;
  4831. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  4832. className = prefix + className;
  4833. }
  4834. return className;
  4835. };
  4836. Theme.prototype.getClass = function (key) {
  4837. return this.classes[key] || '';
  4838. };
  4839. Theme.prototype.getIconClass = function (buttonName, isRtl) {
  4840. var className;
  4841. if (isRtl && this.rtlIconClasses) {
  4842. className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
  4843. }
  4844. else {
  4845. className = this.iconClasses[buttonName];
  4846. }
  4847. if (className) {
  4848. return this.baseIconClass + " " + className;
  4849. }
  4850. return '';
  4851. };
  4852. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  4853. var className;
  4854. if (this.iconOverrideCustomButtonOption) {
  4855. className = customButtonProps[this.iconOverrideCustomButtonOption];
  4856. if (className) {
  4857. return this.baseIconClass + " " + this.applyIconOverridePrefix(className);
  4858. }
  4859. }
  4860. return '';
  4861. };
  4862. return Theme;
  4863. }());
  4864. Theme.prototype.classes = {};
  4865. Theme.prototype.iconClasses = {};
  4866. Theme.prototype.baseIconClass = '';
  4867. Theme.prototype.iconOverridePrefix = '';
  4868. /// <reference types="@fullcalendar/core-preact" />
  4869. if (typeof FullCalendarVDom === 'undefined') {
  4870. throw new Error('Please import the top-level fullcalendar lib before attempting to import a plugin.');
  4871. }
  4872. var Component = FullCalendarVDom.Component;
  4873. var createElement = FullCalendarVDom.createElement;
  4874. var render = FullCalendarVDom.render;
  4875. var createRef = FullCalendarVDom.createRef;
  4876. var Fragment = FullCalendarVDom.Fragment;
  4877. var createContext$1 = FullCalendarVDom.createContext;
  4878. var flushToDom$1 = FullCalendarVDom.flushToDom;
  4879. var unmountComponentAtNode$1 = FullCalendarVDom.unmountComponentAtNode;
  4880. var ScrollResponder = /** @class */ (function () {
  4881. function ScrollResponder(execFunc, emitter, scrollTime) {
  4882. var _this = this;
  4883. this.execFunc = execFunc;
  4884. this.emitter = emitter;
  4885. this.scrollTime = scrollTime;
  4886. this.handleScrollRequest = function (request) {
  4887. _this.queuedRequest = __assign({}, _this.queuedRequest || {}, request);
  4888. _this.drain();
  4889. };
  4890. emitter.on('_scrollRequest', this.handleScrollRequest);
  4891. this.fireInitialScroll();
  4892. }
  4893. ScrollResponder.prototype.detach = function () {
  4894. this.emitter.off('_scrollRequest', this.handleScrollRequest);
  4895. };
  4896. ScrollResponder.prototype.update = function (isDatesNew) {
  4897. if (isDatesNew) {
  4898. this.fireInitialScroll(); // will drain
  4899. }
  4900. else {
  4901. this.drain();
  4902. }
  4903. };
  4904. ScrollResponder.prototype.fireInitialScroll = function () {
  4905. this.handleScrollRequest({
  4906. time: this.scrollTime,
  4907. });
  4908. };
  4909. ScrollResponder.prototype.drain = function () {
  4910. if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
  4911. this.queuedRequest = null;
  4912. }
  4913. };
  4914. return ScrollResponder;
  4915. }());
  4916. var ViewContextType = createContext$1({}); // for Components
  4917. function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
  4918. return {
  4919. dateEnv: dateEnv,
  4920. options: viewOptions,
  4921. pluginHooks: pluginHooks,
  4922. emitter: emitter,
  4923. dispatch: dispatch,
  4924. getCurrentData: getCurrentData,
  4925. calendarApi: calendarApi,
  4926. viewSpec: viewSpec,
  4927. viewApi: viewApi,
  4928. dateProfileGenerator: dateProfileGenerator,
  4929. theme: theme,
  4930. isRtl: viewOptions.direction === 'rtl',
  4931. addResizeHandler: function (handler) {
  4932. emitter.on('_resize', handler);
  4933. },
  4934. removeResizeHandler: function (handler) {
  4935. emitter.off('_resize', handler);
  4936. },
  4937. createScrollResponder: function (execFunc) {
  4938. return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime));
  4939. },
  4940. registerInteractiveComponent: registerInteractiveComponent,
  4941. unregisterInteractiveComponent: unregisterInteractiveComponent,
  4942. };
  4943. }
  4944. /* eslint max-classes-per-file: off */
  4945. var PureComponent = /** @class */ (function (_super) {
  4946. __extends(PureComponent, _super);
  4947. function PureComponent() {
  4948. return _super !== null && _super.apply(this, arguments) || this;
  4949. }
  4950. PureComponent.prototype.shouldComponentUpdate = function (nextProps, nextState) {
  4951. if (this.debug) {
  4952. // eslint-disable-next-line no-console
  4953. console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
  4954. }
  4955. return !compareObjs(this.props, nextProps, this.propEquality) ||
  4956. !compareObjs(this.state, nextState, this.stateEquality);
  4957. };
  4958. PureComponent.addPropsEquality = addPropsEquality;
  4959. PureComponent.addStateEquality = addStateEquality;
  4960. PureComponent.contextType = ViewContextType;
  4961. return PureComponent;
  4962. }(Component));
  4963. PureComponent.prototype.propEquality = {};
  4964. PureComponent.prototype.stateEquality = {};
  4965. var BaseComponent = /** @class */ (function (_super) {
  4966. __extends(BaseComponent, _super);
  4967. function BaseComponent() {
  4968. return _super !== null && _super.apply(this, arguments) || this;
  4969. }
  4970. BaseComponent.contextType = ViewContextType;
  4971. return BaseComponent;
  4972. }(PureComponent));
  4973. function addPropsEquality(propEquality) {
  4974. var hash = Object.create(this.prototype.propEquality);
  4975. __assign(hash, propEquality);
  4976. this.prototype.propEquality = hash;
  4977. }
  4978. function addStateEquality(stateEquality) {
  4979. var hash = Object.create(this.prototype.stateEquality);
  4980. __assign(hash, stateEquality);
  4981. this.prototype.stateEquality = hash;
  4982. }
  4983. // use other one
  4984. function setRef(ref, current) {
  4985. if (typeof ref === 'function') {
  4986. ref(current);
  4987. }
  4988. else if (ref) {
  4989. // see https://github.com/facebook/react/issues/13029
  4990. ref.current = current;
  4991. }
  4992. }
  4993. function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
  4994. switch (action.type) {
  4995. case 'RECEIVE_EVENTS': // raw
  4996. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
  4997. case 'ADD_EVENTS': // already parsed, but not expanded
  4998. return addEvent(eventStore, action.eventStore, // new ones
  4999. dateProfile ? dateProfile.activeRange : null, context);
  5000. case 'RESET_EVENTS':
  5001. return action.eventStore;
  5002. case 'MERGE_EVENTS': // already parsed and expanded
  5003. return mergeEventStores(eventStore, action.eventStore);
  5004. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  5005. case 'NEXT':
  5006. case 'CHANGE_DATE':
  5007. case 'CHANGE_VIEW_TYPE':
  5008. if (dateProfile) {
  5009. return expandRecurring(eventStore, dateProfile.activeRange, context);
  5010. }
  5011. return eventStore;
  5012. case 'REMOVE_EVENTS':
  5013. return excludeSubEventStore(eventStore, action.eventStore);
  5014. case 'REMOVE_EVENT_SOURCE':
  5015. return excludeEventsBySourceId(eventStore, action.sourceId);
  5016. case 'REMOVE_ALL_EVENT_SOURCES':
  5017. return filterEventStoreDefs(eventStore, function (eventDef) { return (!eventDef.sourceId // only keep events with no source id
  5018. ); });
  5019. case 'REMOVE_ALL_EVENTS':
  5020. return createEmptyEventStore();
  5021. default:
  5022. return eventStore;
  5023. }
  5024. }
  5025. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
  5026. if (eventSource && // not already removed
  5027. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  5028. ) {
  5029. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
  5030. if (fetchRange) {
  5031. subset = expandRecurring(subset, fetchRange, context);
  5032. }
  5033. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  5034. }
  5035. return eventStore;
  5036. }
  5037. function transformRawEvents(rawEvents, eventSource, context) {
  5038. var calEachTransform = context.options.eventDataTransform;
  5039. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  5040. if (sourceEachTransform) {
  5041. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  5042. }
  5043. if (calEachTransform) {
  5044. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  5045. }
  5046. return rawEvents;
  5047. }
  5048. function transformEachRawEvent(rawEvents, func) {
  5049. var refinedEvents;
  5050. if (!func) {
  5051. refinedEvents = rawEvents;
  5052. }
  5053. else {
  5054. refinedEvents = [];
  5055. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  5056. var rawEvent = rawEvents_1[_i];
  5057. var refinedEvent = func(rawEvent);
  5058. if (refinedEvent) {
  5059. refinedEvents.push(refinedEvent);
  5060. }
  5061. else if (refinedEvent == null) {
  5062. refinedEvents.push(rawEvent);
  5063. } // if a different falsy value, do nothing
  5064. }
  5065. }
  5066. return refinedEvents;
  5067. }
  5068. function addEvent(eventStore, subset, expandRange, context) {
  5069. if (expandRange) {
  5070. subset = expandRecurring(subset, expandRange, context);
  5071. }
  5072. return mergeEventStores(eventStore, subset);
  5073. }
  5074. function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
  5075. var defs = eventStore.defs;
  5076. var instances = mapHash(eventStore.instances, function (instance) {
  5077. var def = defs[instance.defId];
  5078. if (def.allDay || def.recurringDef) {
  5079. return instance; // isn't dependent on timezone
  5080. }
  5081. return __assign(__assign({}, instance), { range: {
  5082. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  5083. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
  5084. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  5085. });
  5086. return { defs: defs, instances: instances };
  5087. }
  5088. function excludeEventsBySourceId(eventStore, sourceId) {
  5089. return filterEventStoreDefs(eventStore, function (eventDef) { return eventDef.sourceId !== sourceId; });
  5090. }
  5091. // QUESTION: why not just return instances? do a general object-property-exclusion util
  5092. function excludeInstances(eventStore, removals) {
  5093. return {
  5094. defs: eventStore.defs,
  5095. instances: filterHash(eventStore.instances, function (instance) { return !removals[instance.instanceId]; }),
  5096. };
  5097. }
  5098. // high-level segmenting-aware tester functions
  5099. // ------------------------------------------------------------------------------------------------------------------------
  5100. function isInteractionValid(interaction, context) {
  5101. return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
  5102. }
  5103. function isDateSelectionValid(dateSelection, context) {
  5104. return isNewPropsValid({ dateSelection: dateSelection }, context);
  5105. }
  5106. function isNewPropsValid(newProps, context) {
  5107. var calendarState = context.getCurrentData();
  5108. var props = __assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  5109. return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
  5110. }
  5111. function isPropsValid(state, context, dateSpanMeta, filterConfig) {
  5112. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  5113. if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  5114. return false;
  5115. }
  5116. if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  5117. return false;
  5118. }
  5119. return true;
  5120. }
  5121. // Moving Event Validation
  5122. // ------------------------------------------------------------------------------------------------------------------------
  5123. function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
  5124. var currentState = context.getCurrentData();
  5125. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  5126. var subjectEventStore = interaction.mutatedEvents;
  5127. var subjectDefs = subjectEventStore.defs;
  5128. var subjectInstances = subjectEventStore.instances;
  5129. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  5130. state.eventUiBases :
  5131. { '': currentState.selectionConfig });
  5132. if (filterConfig) {
  5133. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  5134. }
  5135. // exclude the subject events. TODO: exclude defs too?
  5136. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
  5137. var otherDefs = otherEventStore.defs;
  5138. var otherInstances = otherEventStore.instances;
  5139. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  5140. for (var subjectInstanceId in subjectInstances) {
  5141. var subjectInstance = subjectInstances[subjectInstanceId];
  5142. var subjectRange = subjectInstance.range;
  5143. var subjectConfig = subjectConfigs[subjectInstance.defId];
  5144. var subjectDef = subjectDefs[subjectInstance.defId];
  5145. // constraint
  5146. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
  5147. return false;
  5148. }
  5149. // overlap
  5150. var eventOverlap = context.options.eventOverlap;
  5151. var eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
  5152. for (var otherInstanceId in otherInstances) {
  5153. var otherInstance = otherInstances[otherInstanceId];
  5154. // intersect! evaluate
  5155. if (rangesIntersect(subjectRange, otherInstance.range)) {
  5156. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  5157. // consider the other event's overlap. only do this if the subject event is a "real" event
  5158. if (otherOverlap === false && interaction.isEvent) {
  5159. return false;
  5160. }
  5161. if (subjectConfig.overlap === false) {
  5162. return false;
  5163. }
  5164. if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), // still event
  5165. new EventApi(context, subjectDef, subjectInstance))) {
  5166. return false;
  5167. }
  5168. }
  5169. }
  5170. // allow (a function)
  5171. var calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
  5172. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  5173. var subjectAllow = _a[_i];
  5174. var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
  5175. var origDef = calendarEventStore.defs[subjectDef.defId];
  5176. var origInstance = calendarEventStore.instances[subjectInstanceId];
  5177. var eventApi = void 0;
  5178. if (origDef) { // was previously in the calendar
  5179. eventApi = new EventApi(context, origDef, origInstance);
  5180. }
  5181. else { // was an external event
  5182. eventApi = new EventApi(context, subjectDef); // no instance, because had no dates
  5183. }
  5184. if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
  5185. return false;
  5186. }
  5187. }
  5188. }
  5189. return true;
  5190. }
  5191. // Date Selection Validation
  5192. // ------------------------------------------------------------------------------------------------------------------------
  5193. function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
  5194. var relevantEventStore = state.eventStore;
  5195. var relevantDefs = relevantEventStore.defs;
  5196. var relevantInstances = relevantEventStore.instances;
  5197. var selection = state.dateSelection;
  5198. var selectionRange = selection.range;
  5199. var selectionConfig = context.getCurrentData().selectionConfig;
  5200. if (filterConfig) {
  5201. selectionConfig = filterConfig(selectionConfig);
  5202. }
  5203. // constraint
  5204. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
  5205. return false;
  5206. }
  5207. // overlap
  5208. var selectOverlap = context.options.selectOverlap;
  5209. var selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
  5210. for (var relevantInstanceId in relevantInstances) {
  5211. var relevantInstance = relevantInstances[relevantInstanceId];
  5212. // intersect! evaluate
  5213. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  5214. if (selectionConfig.overlap === false) {
  5215. return false;
  5216. }
  5217. if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
  5218. return false;
  5219. }
  5220. }
  5221. }
  5222. // allow (a function)
  5223. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  5224. var selectionAllow = _a[_i];
  5225. var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
  5226. if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
  5227. return false;
  5228. }
  5229. }
  5230. return true;
  5231. }
  5232. // Constraint Utils
  5233. // ------------------------------------------------------------------------------------------------------------------------
  5234. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
  5235. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  5236. var constraint = constraints_1[_i];
  5237. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
  5238. return false;
  5239. }
  5240. }
  5241. return true;
  5242. }
  5243. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  5244. otherEventStore, // for if constraint is an even group ID
  5245. businessHoursUnexpanded, // for if constraint is 'businessHours'
  5246. context) {
  5247. if (constraint === 'businessHours') {
  5248. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
  5249. }
  5250. if (typeof constraint === 'string') { // an group ID
  5251. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) { return eventDef.groupId === constraint; }));
  5252. }
  5253. if (typeof constraint === 'object' && constraint) { // non-null object
  5254. return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
  5255. }
  5256. return []; // if it's false
  5257. }
  5258. // TODO: move to event-store file?
  5259. function eventStoreToRanges(eventStore) {
  5260. var instances = eventStore.instances;
  5261. var ranges = [];
  5262. for (var instanceId in instances) {
  5263. ranges.push(instances[instanceId].range);
  5264. }
  5265. return ranges;
  5266. }
  5267. // TODO: move to geom file?
  5268. function anyRangesContainRange(outerRanges, innerRange) {
  5269. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  5270. var outerRange = outerRanges_1[_i];
  5271. if (rangeContainsRange(outerRange, innerRange)) {
  5272. return true;
  5273. }
  5274. }
  5275. return false;
  5276. }
  5277. /*
  5278. an INTERACTABLE date component
  5279. PURPOSES:
  5280. - hook up to fg, fill, and mirror renderers
  5281. - interface for dragging and hits
  5282. */
  5283. var DateComponent = /** @class */ (function (_super) {
  5284. __extends(DateComponent, _super);
  5285. function DateComponent() {
  5286. var _this = _super !== null && _super.apply(this, arguments) || this;
  5287. _this.uid = guid();
  5288. return _this;
  5289. }
  5290. // Hit System
  5291. // -----------------------------------------------------------------------------------------------------------------
  5292. DateComponent.prototype.prepareHits = function () {
  5293. };
  5294. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  5295. return null; // this should be abstract
  5296. };
  5297. // Validation
  5298. // -----------------------------------------------------------------------------------------------------------------
  5299. DateComponent.prototype.isInteractionValid = function (interaction) {
  5300. var dateProfile = this.props.dateProfile; // HACK
  5301. var instances = interaction.mutatedEvents.instances;
  5302. if (dateProfile) { // HACK for MorePopover
  5303. for (var instanceId in instances) {
  5304. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  5305. return false;
  5306. }
  5307. }
  5308. }
  5309. return isInteractionValid(interaction, this.context);
  5310. };
  5311. DateComponent.prototype.isDateSelectionValid = function (selection) {
  5312. var dateProfile = this.props.dateProfile; // HACK
  5313. if (dateProfile && // HACK for MorePopover
  5314. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  5315. return false;
  5316. }
  5317. return isDateSelectionValid(selection, this.context);
  5318. };
  5319. // Pointer Interaction Utils
  5320. // -----------------------------------------------------------------------------------------------------------------
  5321. DateComponent.prototype.isValidSegDownEl = function (el) {
  5322. return !this.props.eventDrag && // HACK
  5323. !this.props.eventResize && // HACK
  5324. !elementClosest(el, '.fc-event-mirror');
  5325. };
  5326. DateComponent.prototype.isValidDateDownEl = function (el) {
  5327. return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
  5328. !elementClosest(el, '.fc-daygrid-more-link') && // a "more.." link
  5329. !elementClosest(el, 'a[data-navlink]') && // a clickable nav link
  5330. !elementClosest(el, '.fc-popover'); // hack
  5331. };
  5332. return DateComponent;
  5333. }(BaseComponent));
  5334. // TODO: easier way to add new hooks? need to update a million things
  5335. function createPlugin(input) {
  5336. return {
  5337. id: guid(),
  5338. deps: input.deps || [],
  5339. reducers: input.reducers || [],
  5340. isLoadingFuncs: input.isLoadingFuncs || [],
  5341. contextInit: [].concat(input.contextInit || []),
  5342. eventRefiners: input.eventRefiners || {},
  5343. eventDefMemberAdders: input.eventDefMemberAdders || [],
  5344. eventSourceRefiners: input.eventSourceRefiners || {},
  5345. isDraggableTransformers: input.isDraggableTransformers || [],
  5346. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  5347. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  5348. dateSelectionTransformers: input.dateSelectionTransformers || [],
  5349. datePointTransforms: input.datePointTransforms || [],
  5350. dateSpanTransforms: input.dateSpanTransforms || [],
  5351. views: input.views || {},
  5352. viewPropsTransformers: input.viewPropsTransformers || [],
  5353. isPropsValid: input.isPropsValid || null,
  5354. externalDefTransforms: input.externalDefTransforms || [],
  5355. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  5356. viewContainerAppends: input.viewContainerAppends || [],
  5357. eventDropTransformers: input.eventDropTransformers || [],
  5358. componentInteractions: input.componentInteractions || [],
  5359. calendarInteractions: input.calendarInteractions || [],
  5360. themeClasses: input.themeClasses || {},
  5361. eventSourceDefs: input.eventSourceDefs || [],
  5362. cmdFormatter: input.cmdFormatter,
  5363. recurringTypes: input.recurringTypes || [],
  5364. namedTimeZonedImpl: input.namedTimeZonedImpl,
  5365. initialView: input.initialView || '',
  5366. elementDraggingImpl: input.elementDraggingImpl,
  5367. optionChangeHandlers: input.optionChangeHandlers || {},
  5368. scrollGridImpl: input.scrollGridImpl || null,
  5369. contentTypeHandlers: input.contentTypeHandlers || {},
  5370. listenerRefiners: input.listenerRefiners || {},
  5371. optionRefiners: input.optionRefiners || {},
  5372. propSetHandlers: input.propSetHandlers || {},
  5373. };
  5374. }
  5375. function buildPluginHooks(pluginDefs, globalDefs) {
  5376. var isAdded = {};
  5377. var hooks = {
  5378. reducers: [],
  5379. isLoadingFuncs: [],
  5380. contextInit: [],
  5381. eventRefiners: {},
  5382. eventDefMemberAdders: [],
  5383. eventSourceRefiners: {},
  5384. isDraggableTransformers: [],
  5385. eventDragMutationMassagers: [],
  5386. eventDefMutationAppliers: [],
  5387. dateSelectionTransformers: [],
  5388. datePointTransforms: [],
  5389. dateSpanTransforms: [],
  5390. views: {},
  5391. viewPropsTransformers: [],
  5392. isPropsValid: null,
  5393. externalDefTransforms: [],
  5394. eventResizeJoinTransforms: [],
  5395. viewContainerAppends: [],
  5396. eventDropTransformers: [],
  5397. componentInteractions: [],
  5398. calendarInteractions: [],
  5399. themeClasses: {},
  5400. eventSourceDefs: [],
  5401. cmdFormatter: null,
  5402. recurringTypes: [],
  5403. namedTimeZonedImpl: null,
  5404. initialView: '',
  5405. elementDraggingImpl: null,
  5406. optionChangeHandlers: {},
  5407. scrollGridImpl: null,
  5408. contentTypeHandlers: {},
  5409. listenerRefiners: {},
  5410. optionRefiners: {},
  5411. propSetHandlers: {},
  5412. };
  5413. function addDefs(defs) {
  5414. for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
  5415. var def = defs_1[_i];
  5416. if (!isAdded[def.id]) {
  5417. isAdded[def.id] = true;
  5418. addDefs(def.deps);
  5419. hooks = combineHooks(hooks, def);
  5420. }
  5421. }
  5422. }
  5423. if (pluginDefs) {
  5424. addDefs(pluginDefs);
  5425. }
  5426. addDefs(globalDefs);
  5427. return hooks;
  5428. }
  5429. function buildBuildPluginHooks() {
  5430. var currentOverrideDefs = [];
  5431. var currentGlobalDefs = [];
  5432. var currentHooks;
  5433. return function (overrideDefs, globalDefs) {
  5434. if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
  5435. currentHooks = buildPluginHooks(overrideDefs, globalDefs);
  5436. }
  5437. currentOverrideDefs = overrideDefs;
  5438. currentGlobalDefs = globalDefs;
  5439. return currentHooks;
  5440. };
  5441. }
  5442. function combineHooks(hooks0, hooks1) {
  5443. return {
  5444. reducers: hooks0.reducers.concat(hooks1.reducers),
  5445. isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
  5446. contextInit: hooks0.contextInit.concat(hooks1.contextInit),
  5447. eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
  5448. eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
  5449. eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
  5450. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  5451. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  5452. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  5453. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  5454. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  5455. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  5456. views: __assign(__assign({}, hooks0.views), hooks1.views),
  5457. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  5458. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  5459. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  5460. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  5461. viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
  5462. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  5463. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  5464. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  5465. themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
  5466. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  5467. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  5468. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  5469. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  5470. initialView: hooks0.initialView || hooks1.initialView,
  5471. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  5472. optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
  5473. scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
  5474. contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
  5475. listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
  5476. optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
  5477. propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
  5478. };
  5479. }
  5480. var StandardTheme = /** @class */ (function (_super) {
  5481. __extends(StandardTheme, _super);
  5482. function StandardTheme() {
  5483. return _super !== null && _super.apply(this, arguments) || this;
  5484. }
  5485. return StandardTheme;
  5486. }(Theme));
  5487. StandardTheme.prototype.classes = {
  5488. root: 'fc-theme-standard',
  5489. tableCellShaded: 'fc-cell-shaded',
  5490. buttonGroup: 'fc-button-group',
  5491. button: 'fc-button fc-button-primary',
  5492. buttonActive: 'fc-button-active',
  5493. };
  5494. StandardTheme.prototype.baseIconClass = 'fc-icon';
  5495. StandardTheme.prototype.iconClasses = {
  5496. close: 'fc-icon-x',
  5497. prev: 'fc-icon-chevron-left',
  5498. next: 'fc-icon-chevron-right',
  5499. prevYear: 'fc-icon-chevrons-left',
  5500. nextYear: 'fc-icon-chevrons-right',
  5501. };
  5502. StandardTheme.prototype.rtlIconClasses = {
  5503. prev: 'fc-icon-chevron-right',
  5504. next: 'fc-icon-chevron-left',
  5505. prevYear: 'fc-icon-chevrons-right',
  5506. nextYear: 'fc-icon-chevrons-left',
  5507. };
  5508. StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  5509. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  5510. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  5511. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5512. var hash = {};
  5513. var viewType;
  5514. for (viewType in defaultConfigs) {
  5515. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5516. }
  5517. for (viewType in overrideConfigs) {
  5518. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5519. }
  5520. return hash;
  5521. }
  5522. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5523. if (hash[viewType]) {
  5524. return hash[viewType];
  5525. }
  5526. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5527. if (viewDef) {
  5528. hash[viewType] = viewDef;
  5529. }
  5530. return viewDef;
  5531. }
  5532. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5533. var defaultConfig = defaultConfigs[viewType];
  5534. var overrideConfig = overrideConfigs[viewType];
  5535. var queryProp = function (name) { return ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5536. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null)); };
  5537. var theComponent = queryProp('component');
  5538. var superType = queryProp('superType');
  5539. var superDef = null;
  5540. if (superType) {
  5541. if (superType === viewType) {
  5542. throw new Error('Can\'t have a custom view type that references itself');
  5543. }
  5544. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5545. }
  5546. if (!theComponent && superDef) {
  5547. theComponent = superDef.component;
  5548. }
  5549. if (!theComponent) {
  5550. return null; // don't throw a warning, might be settings for a single-unit view
  5551. }
  5552. return {
  5553. type: viewType,
  5554. component: theComponent,
  5555. defaults: __assign(__assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
  5556. overrides: __assign(__assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
  5557. };
  5558. }
  5559. /* eslint max-classes-per-file: off */
  5560. // NOTE: in JSX, you should always use this class with <HookProps> arg. otherwise, will default to any???
  5561. var RenderHook = /** @class */ (function (_super) {
  5562. __extends(RenderHook, _super);
  5563. function RenderHook() {
  5564. var _this = _super !== null && _super.apply(this, arguments) || this;
  5565. _this.rootElRef = createRef();
  5566. _this.handleRootEl = function (el) {
  5567. setRef(_this.rootElRef, el);
  5568. if (_this.props.elRef) {
  5569. setRef(_this.props.elRef, el);
  5570. }
  5571. };
  5572. return _this;
  5573. }
  5574. RenderHook.prototype.render = function () {
  5575. var _this = this;
  5576. var props = this.props;
  5577. var hookProps = props.hookProps;
  5578. return (createElement(MountHook, { hookProps: hookProps, didMount: props.didMount, willUnmount: props.willUnmount, elRef: this.handleRootEl }, function (rootElRef) { return (createElement(ContentHook, { hookProps: hookProps, content: props.content, defaultContent: props.defaultContent, backupElRef: _this.rootElRef }, function (innerElRef, innerContent) { return props.children(rootElRef, normalizeClassNames(props.classNames, hookProps), innerElRef, innerContent); })); }));
  5579. };
  5580. return RenderHook;
  5581. }(BaseComponent));
  5582. // TODO: rename to be about function, not default. use in above type
  5583. // for forcing rerender of components that use the ContentHook
  5584. var CustomContentRenderContext = createContext$1(0);
  5585. function ContentHook(props) {
  5586. return (createElement(CustomContentRenderContext.Consumer, null, function (renderId) { return (createElement(ContentHookInner, __assign({ renderId: renderId }, props))); }));
  5587. }
  5588. var ContentHookInner = /** @class */ (function (_super) {
  5589. __extends(ContentHookInner, _super);
  5590. function ContentHookInner() {
  5591. var _this = _super !== null && _super.apply(this, arguments) || this;
  5592. _this.innerElRef = createRef();
  5593. return _this;
  5594. }
  5595. ContentHookInner.prototype.render = function () {
  5596. return this.props.children(this.innerElRef, this.renderInnerContent());
  5597. };
  5598. ContentHookInner.prototype.componentDidMount = function () {
  5599. this.updateCustomContent();
  5600. };
  5601. ContentHookInner.prototype.componentDidUpdate = function () {
  5602. this.updateCustomContent();
  5603. };
  5604. ContentHookInner.prototype.componentWillUnmount = function () {
  5605. if (this.customContentInfo && this.customContentInfo.destroy) {
  5606. this.customContentInfo.destroy();
  5607. }
  5608. };
  5609. ContentHookInner.prototype.renderInnerContent = function () {
  5610. var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
  5611. var _a = this, props = _a.props, customContentInfo = _a.customContentInfo;
  5612. var rawVal = props.content;
  5613. var innerContent = normalizeContent(rawVal, props.hookProps);
  5614. var innerContentVDom = null;
  5615. if (innerContent === undefined) { // use the default
  5616. innerContent = normalizeContent(props.defaultContent, props.hookProps);
  5617. }
  5618. if (innerContent !== undefined) { // we allow custom content handlers to return nothing
  5619. if (customContentInfo) {
  5620. customContentInfo.contentVal = innerContent[customContentInfo.contentKey];
  5621. }
  5622. else if (typeof innerContent === 'object') {
  5623. // look for a prop that would indicate a custom content handler is needed
  5624. for (var contentKey in contentTypeHandlers) {
  5625. if (innerContent[contentKey] !== undefined) {
  5626. var stuff = contentTypeHandlers[contentKey]();
  5627. customContentInfo = this.customContentInfo = __assign({ contentKey: contentKey, contentVal: innerContent[contentKey] }, stuff);
  5628. break;
  5629. }
  5630. }
  5631. }
  5632. if (customContentInfo) {
  5633. innerContentVDom = []; // signal that something was specified
  5634. }
  5635. else {
  5636. innerContentVDom = innerContent; // assume a [p]react vdom node. use it
  5637. }
  5638. }
  5639. return innerContentVDom;
  5640. };
  5641. ContentHookInner.prototype.updateCustomContent = function () {
  5642. if (this.customContentInfo) {
  5643. this.customContentInfo.render(this.innerElRef.current || this.props.backupElRef.current, // the element to render into
  5644. this.customContentInfo.contentVal);
  5645. }
  5646. };
  5647. return ContentHookInner;
  5648. }(BaseComponent));
  5649. var MountHook = /** @class */ (function (_super) {
  5650. __extends(MountHook, _super);
  5651. function MountHook() {
  5652. var _this = _super !== null && _super.apply(this, arguments) || this;
  5653. _this.handleRootEl = function (rootEl) {
  5654. _this.rootEl = rootEl;
  5655. if (_this.props.elRef) {
  5656. setRef(_this.props.elRef, rootEl);
  5657. }
  5658. };
  5659. return _this;
  5660. }
  5661. MountHook.prototype.render = function () {
  5662. return this.props.children(this.handleRootEl);
  5663. };
  5664. MountHook.prototype.componentDidMount = function () {
  5665. var callback = this.props.didMount;
  5666. if (callback) {
  5667. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5668. }
  5669. };
  5670. MountHook.prototype.componentWillUnmount = function () {
  5671. var callback = this.props.willUnmount;
  5672. if (callback) {
  5673. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5674. }
  5675. };
  5676. return MountHook;
  5677. }(BaseComponent));
  5678. function buildClassNameNormalizer() {
  5679. var currentGenerator;
  5680. var currentHookProps;
  5681. var currentClassNames = [];
  5682. return function (generator, hookProps) {
  5683. if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
  5684. currentGenerator = generator;
  5685. currentHookProps = hookProps;
  5686. currentClassNames = normalizeClassNames(generator, hookProps);
  5687. }
  5688. return currentClassNames;
  5689. };
  5690. }
  5691. function normalizeClassNames(classNames, hookProps) {
  5692. if (typeof classNames === 'function') {
  5693. classNames = classNames(hookProps);
  5694. }
  5695. return parseClassNames(classNames);
  5696. }
  5697. function normalizeContent(input, hookProps) {
  5698. if (typeof input === 'function') {
  5699. return input(hookProps, createElement); // give the function the vdom-creation func
  5700. }
  5701. return input;
  5702. }
  5703. var ViewRoot = /** @class */ (function (_super) {
  5704. __extends(ViewRoot, _super);
  5705. function ViewRoot() {
  5706. var _this = _super !== null && _super.apply(this, arguments) || this;
  5707. _this.normalizeClassNames = buildClassNameNormalizer();
  5708. return _this;
  5709. }
  5710. ViewRoot.prototype.render = function () {
  5711. var _a = this, props = _a.props, context = _a.context;
  5712. var options = context.options;
  5713. var hookProps = { view: context.viewApi };
  5714. var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
  5715. return (createElement(MountHook, { hookProps: hookProps, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, ["fc-" + props.viewSpec.type + "-view", 'fc-view'].concat(customClassNames)); }));
  5716. };
  5717. return ViewRoot;
  5718. }(BaseComponent));
  5719. function parseViewConfigs(inputs) {
  5720. return mapHash(inputs, parseViewConfig);
  5721. }
  5722. function parseViewConfig(input) {
  5723. var rawOptions = typeof input === 'function' ?
  5724. { component: input } :
  5725. input;
  5726. var component = rawOptions.component;
  5727. if (rawOptions.content) {
  5728. component = createViewHookComponent(rawOptions);
  5729. // TODO: remove content/classNames/didMount/etc from options?
  5730. }
  5731. return {
  5732. superType: rawOptions.type,
  5733. component: component,
  5734. rawOptions: rawOptions,
  5735. };
  5736. }
  5737. function createViewHookComponent(options) {
  5738. return function (viewProps) { return (createElement(ViewContextType.Consumer, null, function (context) { return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (viewElRef, viewClassNames) {
  5739. var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
  5740. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.classNames, content: options.content, didMount: options.didMount, willUnmount: options.willUnmount, elRef: viewElRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("div", { className: viewClassNames.concat(customClassNames).join(' '), ref: rootElRef }, innerContent)); }));
  5741. })); })); };
  5742. }
  5743. function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5744. var defaultConfigs = parseViewConfigs(defaultInputs);
  5745. var overrideConfigs = parseViewConfigs(optionOverrides.views);
  5746. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5747. return mapHash(viewDefs, function (viewDef) { return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults); });
  5748. }
  5749. function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5750. var durationInput = viewDef.overrides.duration ||
  5751. viewDef.defaults.duration ||
  5752. dynamicOptionOverrides.duration ||
  5753. optionOverrides.duration;
  5754. var duration = null;
  5755. var durationUnit = '';
  5756. var singleUnit = '';
  5757. var singleUnitOverrides = {};
  5758. if (durationInput) {
  5759. duration = createDurationCached(durationInput);
  5760. if (duration) { // valid?
  5761. var denom = greatestDurationDenominator(duration);
  5762. durationUnit = denom.unit;
  5763. if (denom.value === 1) {
  5764. singleUnit = durationUnit;
  5765. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
  5766. }
  5767. }
  5768. }
  5769. var queryButtonText = function (optionsSubset) {
  5770. var buttonTextMap = optionsSubset.buttonText || {};
  5771. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5772. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5773. return buttonTextMap[buttonTextKey];
  5774. }
  5775. if (buttonTextMap[viewDef.type] != null) {
  5776. return buttonTextMap[viewDef.type];
  5777. }
  5778. if (buttonTextMap[singleUnit] != null) {
  5779. return buttonTextMap[singleUnit];
  5780. }
  5781. return null;
  5782. };
  5783. return {
  5784. type: viewDef.type,
  5785. component: viewDef.component,
  5786. duration: duration,
  5787. durationUnit: durationUnit,
  5788. singleUnit: singleUnit,
  5789. optionDefaults: viewDef.defaults,
  5790. optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
  5791. buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
  5792. queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
  5793. viewDef.overrides.buttonText,
  5794. buttonTextDefault: queryButtonText(localeDefaults) ||
  5795. viewDef.defaults.buttonText ||
  5796. queryButtonText(BASE_OPTION_DEFAULTS) ||
  5797. viewDef.type,
  5798. };
  5799. }
  5800. // hack to get memoization working
  5801. var durationInputMap = {};
  5802. function createDurationCached(durationInput) {
  5803. var json = JSON.stringify(durationInput);
  5804. var res = durationInputMap[json];
  5805. if (res === undefined) {
  5806. res = createDuration(durationInput);
  5807. durationInputMap[json] = res;
  5808. }
  5809. return res;
  5810. }
  5811. var DateProfileGenerator = /** @class */ (function () {
  5812. function DateProfileGenerator(props) {
  5813. this.props = props;
  5814. this.nowDate = getNow(props.nowInput, props.dateEnv);
  5815. this.initHiddenDays();
  5816. }
  5817. /* Date Range Computation
  5818. ------------------------------------------------------------------------------------------------------------------*/
  5819. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5820. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate, forceToValid) {
  5821. var dateEnv = this.props.dateEnv;
  5822. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5823. currentDateProfile.dateIncrement);
  5824. return this.build(prevDate, -1, forceToValid);
  5825. };
  5826. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5827. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate, forceToValid) {
  5828. var dateEnv = this.props.dateEnv;
  5829. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5830. currentDateProfile.dateIncrement);
  5831. return this.build(nextDate, 1, forceToValid);
  5832. };
  5833. // Builds a structure holding dates/ranges for rendering around the given date.
  5834. // Optional direction param indicates whether the date is being incremented/decremented
  5835. // from its previous value. decremented = -1, incremented = 1 (default).
  5836. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5837. if (forceToValid === void 0) { forceToValid = true; }
  5838. var props = this.props;
  5839. var validRange;
  5840. var currentInfo;
  5841. var isRangeAllDay;
  5842. var renderRange;
  5843. var activeRange;
  5844. var isValid;
  5845. validRange = this.buildValidRange();
  5846. validRange = this.trimHiddenDays(validRange);
  5847. if (forceToValid) {
  5848. currentDate = constrainMarkerToRange(currentDate, validRange);
  5849. }
  5850. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5851. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5852. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5853. renderRange = this.trimHiddenDays(renderRange);
  5854. activeRange = renderRange;
  5855. if (!props.showNonCurrentDates) {
  5856. activeRange = intersectRanges(activeRange, currentInfo.range);
  5857. }
  5858. activeRange = this.adjustActiveRange(activeRange);
  5859. activeRange = intersectRanges(activeRange, validRange); // might return null
  5860. // it's invalid if the originally requested date is not contained,
  5861. // or if the range is completely outside of the valid range.
  5862. isValid = rangesIntersect(currentInfo.range, validRange);
  5863. return {
  5864. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5865. // an object with optional start and end properties.
  5866. validRange: validRange,
  5867. // range the view is formally responsible for.
  5868. // for example, a month view might have 1st-31st, excluding padded dates
  5869. currentRange: currentInfo.range,
  5870. // name of largest unit being displayed, like "month" or "week"
  5871. currentRangeUnit: currentInfo.unit,
  5872. isRangeAllDay: isRangeAllDay,
  5873. // dates that display events and accept drag-n-drop
  5874. // will be `null` if no dates accept events
  5875. activeRange: activeRange,
  5876. // date range with a rendered skeleton
  5877. // includes not-active days that need some sort of DOM
  5878. renderRange: renderRange,
  5879. // Duration object that denotes the first visible time of any given day
  5880. slotMinTime: props.slotMinTime,
  5881. // Duration object that denotes the exclusive visible end time of any given day
  5882. slotMaxTime: props.slotMaxTime,
  5883. isValid: isValid,
  5884. // how far the current date will move for a prev/next operation
  5885. dateIncrement: this.buildDateIncrement(currentInfo.duration),
  5886. };
  5887. };
  5888. // Builds an object with optional start/end properties.
  5889. // Indicates the minimum/maximum dates to display.
  5890. // not responsible for trimming hidden days.
  5891. DateProfileGenerator.prototype.buildValidRange = function () {
  5892. var input = this.props.validRangeInput;
  5893. var simpleInput = typeof input === 'function'
  5894. ? input.call(this.props.calendarApi, this.nowDate)
  5895. : input;
  5896. return this.refineRange(simpleInput) ||
  5897. { start: null, end: null }; // completely open-ended
  5898. };
  5899. // Builds a structure with info about the "current" range, the range that is
  5900. // highlighted as being the current month for example.
  5901. // See build() for a description of `direction`.
  5902. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5903. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5904. var props = this.props;
  5905. var duration = null;
  5906. var unit = null;
  5907. var range = null;
  5908. var dayCount;
  5909. if (props.duration) {
  5910. duration = props.duration;
  5911. unit = props.durationUnit;
  5912. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5913. }
  5914. else if ((dayCount = this.props.dayCount)) {
  5915. unit = 'day';
  5916. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5917. }
  5918. else if ((range = this.buildCustomVisibleRange(date))) {
  5919. unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5920. }
  5921. else {
  5922. duration = this.getFallbackDuration();
  5923. unit = greatestDurationDenominator(duration).unit;
  5924. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5925. }
  5926. return { duration: duration, unit: unit, range: range };
  5927. };
  5928. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5929. return createDuration({ day: 1 });
  5930. };
  5931. // Returns a new activeRange to have time values (un-ambiguate)
  5932. // slotMinTime or slotMaxTime causes the range to expand.
  5933. DateProfileGenerator.prototype.adjustActiveRange = function (range) {
  5934. var _a = this.props, dateEnv = _a.dateEnv, usesMinMaxTime = _a.usesMinMaxTime, slotMinTime = _a.slotMinTime, slotMaxTime = _a.slotMaxTime;
  5935. var start = range.start, end = range.end;
  5936. if (usesMinMaxTime) {
  5937. // expand active range if slotMinTime is negative (why not when positive?)
  5938. if (asRoughDays(slotMinTime) < 0) {
  5939. start = startOfDay(start); // necessary?
  5940. start = dateEnv.add(start, slotMinTime);
  5941. }
  5942. // expand active range if slotMaxTime is beyond one day (why not when negative?)
  5943. if (asRoughDays(slotMaxTime) > 1) {
  5944. end = startOfDay(end); // necessary?
  5945. end = addDays(end, -1);
  5946. end = dateEnv.add(end, slotMaxTime);
  5947. }
  5948. }
  5949. return { start: start, end: end };
  5950. };
  5951. // Builds the "current" range when it is specified as an explicit duration.
  5952. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5953. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5954. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5955. var start;
  5956. var end;
  5957. var res;
  5958. // compute what the alignment should be
  5959. if (!dateAlignment) {
  5960. var dateIncrement = this.props.dateIncrement;
  5961. if (dateIncrement) {
  5962. // use the smaller of the two units
  5963. if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
  5964. dateAlignment = greatestDurationDenominator(dateIncrement).unit;
  5965. }
  5966. else {
  5967. dateAlignment = unit;
  5968. }
  5969. }
  5970. else {
  5971. dateAlignment = unit;
  5972. }
  5973. }
  5974. // if the view displays a single day or smaller
  5975. if (asRoughDays(duration) <= 1) {
  5976. if (this.isHiddenDay(start)) {
  5977. start = this.skipHiddenDays(start, direction);
  5978. start = startOfDay(start);
  5979. }
  5980. }
  5981. function computeRes() {
  5982. start = dateEnv.startOf(date, dateAlignment);
  5983. end = dateEnv.add(start, duration);
  5984. res = { start: start, end: end };
  5985. }
  5986. computeRes();
  5987. // if range is completely enveloped by hidden days, go past the hidden days
  5988. if (!this.trimHiddenDays(res)) {
  5989. date = this.skipHiddenDays(date, direction);
  5990. computeRes();
  5991. }
  5992. return res;
  5993. };
  5994. // Builds the "current" range when a dayCount is specified.
  5995. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5996. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5997. var runningCount = 0;
  5998. var start = date;
  5999. var end;
  6000. if (dateAlignment) {
  6001. start = dateEnv.startOf(start, dateAlignment);
  6002. }
  6003. start = startOfDay(start);
  6004. start = this.skipHiddenDays(start, direction);
  6005. end = start;
  6006. do {
  6007. end = addDays(end, 1);
  6008. if (!this.isHiddenDay(end)) {
  6009. runningCount += 1;
  6010. }
  6011. } while (runningCount < dayCount);
  6012. return { start: start, end: end };
  6013. };
  6014. // Builds a normalized range object for the "visible" range,
  6015. // which is a way to define the currentRange and activeRange at the same time.
  6016. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  6017. var props = this.props;
  6018. var input = props.visibleRangeInput;
  6019. var simpleInput = typeof input === 'function'
  6020. ? input.call(props.calendarApi, props.dateEnv.toDate(date))
  6021. : input;
  6022. var range = this.refineRange(simpleInput);
  6023. if (range && (range.start == null || range.end == null)) {
  6024. return null;
  6025. }
  6026. return range;
  6027. };
  6028. // Computes the range that will represent the element/cells for *rendering*,
  6029. // but which may have voided days/times.
  6030. // not responsible for trimming hidden days.
  6031. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  6032. return currentRange;
  6033. };
  6034. // Compute the duration value that should be added/substracted to the current date
  6035. // when a prev/next operation happens.
  6036. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  6037. var dateIncrement = this.props.dateIncrement;
  6038. var customAlignment;
  6039. if (dateIncrement) {
  6040. return dateIncrement;
  6041. }
  6042. if ((customAlignment = this.props.dateAlignment)) {
  6043. return createDuration(1, customAlignment);
  6044. }
  6045. if (fallback) {
  6046. return fallback;
  6047. }
  6048. return createDuration({ days: 1 });
  6049. };
  6050. DateProfileGenerator.prototype.refineRange = function (rangeInput) {
  6051. if (rangeInput) {
  6052. var range = parseRange(rangeInput, this.props.dateEnv);
  6053. if (range) {
  6054. range = computeVisibleDayRange(range);
  6055. }
  6056. return range;
  6057. }
  6058. return null;
  6059. };
  6060. /* Hidden Days
  6061. ------------------------------------------------------------------------------------------------------------------*/
  6062. // Initializes internal variables related to calculating hidden days-of-week
  6063. DateProfileGenerator.prototype.initHiddenDays = function () {
  6064. var hiddenDays = this.props.hiddenDays || []; // array of day-of-week indices that are hidden
  6065. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  6066. var dayCnt = 0;
  6067. var i;
  6068. if (this.props.weekends === false) {
  6069. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  6070. }
  6071. for (i = 0; i < 7; i += 1) {
  6072. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  6073. dayCnt += 1;
  6074. }
  6075. }
  6076. if (!dayCnt) {
  6077. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  6078. }
  6079. this.isHiddenDayHash = isHiddenDayHash;
  6080. };
  6081. // Remove days from the beginning and end of the range that are computed as hidden.
  6082. // If the whole range is trimmed off, returns null
  6083. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  6084. var start = range.start, end = range.end;
  6085. if (start) {
  6086. start = this.skipHiddenDays(start);
  6087. }
  6088. if (end) {
  6089. end = this.skipHiddenDays(end, -1, true);
  6090. }
  6091. if (start == null || end == null || start < end) {
  6092. return { start: start, end: end };
  6093. }
  6094. return null;
  6095. };
  6096. // Is the current day hidden?
  6097. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  6098. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  6099. if (day instanceof Date) {
  6100. day = day.getUTCDay();
  6101. }
  6102. return this.isHiddenDayHash[day];
  6103. };
  6104. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  6105. // DOES NOT CONSIDER validRange!
  6106. // If the initial value of `date` is not a hidden day, don't do anything.
  6107. // Pass `isExclusive` as `true` if you are dealing with an end date.
  6108. // `inc` defaults to `1` (increment one day forward each time)
  6109. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  6110. if (inc === void 0) { inc = 1; }
  6111. if (isExclusive === void 0) { isExclusive = false; }
  6112. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  6113. date = addDays(date, inc);
  6114. }
  6115. return date;
  6116. };
  6117. return DateProfileGenerator;
  6118. }());
  6119. function reduceViewType(viewType, action) {
  6120. switch (action.type) {
  6121. case 'CHANGE_VIEW_TYPE':
  6122. viewType = action.viewType;
  6123. }
  6124. return viewType;
  6125. }
  6126. function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
  6127. var _a;
  6128. switch (action.type) {
  6129. case 'SET_OPTION':
  6130. return __assign(__assign({}, dynamicOptionOverrides), (_a = {}, _a[action.optionName] = action.rawOptionValue, _a));
  6131. default:
  6132. return dynamicOptionOverrides;
  6133. }
  6134. }
  6135. function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
  6136. var dp;
  6137. switch (action.type) {
  6138. case 'CHANGE_VIEW_TYPE':
  6139. return dateProfileGenerator.build(action.dateMarker || currentDate);
  6140. case 'CHANGE_DATE':
  6141. if (!currentDateProfile.activeRange ||
  6142. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker) // don't move if date already in view
  6143. ) {
  6144. return dateProfileGenerator.build(action.dateMarker);
  6145. }
  6146. break;
  6147. case 'PREV':
  6148. dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
  6149. if (dp.isValid) {
  6150. return dp;
  6151. }
  6152. break;
  6153. case 'NEXT':
  6154. dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
  6155. if (dp.isValid) {
  6156. return dp;
  6157. }
  6158. break;
  6159. }
  6160. return currentDateProfile;
  6161. }
  6162. function initEventSources(calendarOptions, dateProfile, context) {
  6163. var activeRange = dateProfile ? dateProfile.activeRange : null;
  6164. return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
  6165. }
  6166. function reduceEventSources(eventSources, action, dateProfile, context) {
  6167. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6168. switch (action.type) {
  6169. case 'ADD_EVENT_SOURCES': // already parsed
  6170. return addSources(eventSources, action.sources, activeRange, context);
  6171. case 'REMOVE_EVENT_SOURCE':
  6172. return removeSource(eventSources, action.sourceId);
  6173. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6174. case 'NEXT':
  6175. case 'CHANGE_DATE':
  6176. case 'CHANGE_VIEW_TYPE':
  6177. if (dateProfile) {
  6178. return fetchDirtySources(eventSources, activeRange, context);
  6179. }
  6180. return eventSources;
  6181. case 'FETCH_EVENT_SOURCES':
  6182. return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
  6183. arrayToHash(action.sourceIds) :
  6184. excludeStaticSources(eventSources, context), activeRange, context);
  6185. case 'RECEIVE_EVENTS':
  6186. case 'RECEIVE_EVENT_ERROR':
  6187. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  6188. case 'REMOVE_ALL_EVENT_SOURCES':
  6189. return {};
  6190. default:
  6191. return eventSources;
  6192. }
  6193. }
  6194. function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
  6195. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6196. return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, context);
  6197. }
  6198. function computeEventSourcesLoading(eventSources) {
  6199. for (var sourceId in eventSources) {
  6200. if (eventSources[sourceId].isFetching) {
  6201. return true;
  6202. }
  6203. }
  6204. return false;
  6205. }
  6206. function addSources(eventSourceHash, sources, fetchRange, context) {
  6207. var hash = {};
  6208. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  6209. var source = sources_1[_i];
  6210. hash[source.sourceId] = source;
  6211. }
  6212. if (fetchRange) {
  6213. hash = fetchDirtySources(hash, fetchRange, context);
  6214. }
  6215. return __assign(__assign({}, eventSourceHash), hash);
  6216. }
  6217. function removeSource(eventSourceHash, sourceId) {
  6218. return filterHash(eventSourceHash, function (eventSource) { return eventSource.sourceId !== sourceId; });
  6219. }
  6220. function fetchDirtySources(sourceHash, fetchRange, context) {
  6221. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) { return isSourceDirty(eventSource, fetchRange, context); }), fetchRange, context);
  6222. }
  6223. function isSourceDirty(eventSource, fetchRange, context) {
  6224. if (!doesSourceNeedRange(eventSource, context)) {
  6225. return !eventSource.latestFetchId;
  6226. }
  6227. return !context.options.lazyFetching ||
  6228. !eventSource.fetchRange ||
  6229. eventSource.isFetching || // always cancel outdated in-progress fetches
  6230. fetchRange.start < eventSource.fetchRange.start ||
  6231. fetchRange.end > eventSource.fetchRange.end;
  6232. }
  6233. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, context) {
  6234. var nextSources = {};
  6235. for (var sourceId in prevSources) {
  6236. var source = prevSources[sourceId];
  6237. if (sourceIdHash[sourceId]) {
  6238. nextSources[sourceId] = fetchSource(source, fetchRange, context);
  6239. }
  6240. else {
  6241. nextSources[sourceId] = source;
  6242. }
  6243. }
  6244. return nextSources;
  6245. }
  6246. function fetchSource(eventSource, fetchRange, context) {
  6247. var options = context.options, calendarApi = context.calendarApi;
  6248. var sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
  6249. var fetchId = guid();
  6250. sourceDef.fetch({
  6251. eventSource: eventSource,
  6252. range: fetchRange,
  6253. context: context,
  6254. }, function (res) {
  6255. var rawEvents = res.rawEvents;
  6256. if (options.eventSourceSuccess) {
  6257. rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6258. }
  6259. if (eventSource.success) {
  6260. rawEvents = eventSource.success.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6261. }
  6262. context.dispatch({
  6263. type: 'RECEIVE_EVENTS',
  6264. sourceId: eventSource.sourceId,
  6265. fetchId: fetchId,
  6266. fetchRange: fetchRange,
  6267. rawEvents: rawEvents,
  6268. });
  6269. }, function (error) {
  6270. console.warn(error.message, error);
  6271. if (options.eventSourceFailure) {
  6272. options.eventSourceFailure.call(calendarApi, error);
  6273. }
  6274. if (eventSource.failure) {
  6275. eventSource.failure(error);
  6276. }
  6277. context.dispatch({
  6278. type: 'RECEIVE_EVENT_ERROR',
  6279. sourceId: eventSource.sourceId,
  6280. fetchId: fetchId,
  6281. fetchRange: fetchRange,
  6282. error: error,
  6283. });
  6284. });
  6285. return __assign(__assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
  6286. }
  6287. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  6288. var _a;
  6289. var eventSource = sourceHash[sourceId];
  6290. if (eventSource && // not already removed
  6291. fetchId === eventSource.latestFetchId) {
  6292. return __assign(__assign({}, sourceHash), (_a = {}, _a[sourceId] = __assign(__assign({}, eventSource), { isFetching: false, fetchRange: fetchRange }), _a));
  6293. }
  6294. return sourceHash;
  6295. }
  6296. function excludeStaticSources(eventSources, context) {
  6297. return filterHash(eventSources, function (eventSource) { return doesSourceNeedRange(eventSource, context); });
  6298. }
  6299. function parseInitialSources(rawOptions, context) {
  6300. var refiners = buildEventSourceRefiners(context);
  6301. var rawSources = [].concat(rawOptions.eventSources || []);
  6302. var sources = []; // parsed
  6303. if (rawOptions.initialEvents) {
  6304. rawSources.unshift(rawOptions.initialEvents);
  6305. }
  6306. if (rawOptions.events) {
  6307. rawSources.unshift(rawOptions.events);
  6308. }
  6309. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6310. var rawSource = rawSources_1[_i];
  6311. var source = parseEventSource(rawSource, context, refiners);
  6312. if (source) {
  6313. sources.push(source);
  6314. }
  6315. }
  6316. return sources;
  6317. }
  6318. function doesSourceNeedRange(eventSource, context) {
  6319. var defs = context.pluginHooks.eventSourceDefs;
  6320. return !defs[eventSource.sourceDefId].ignoreRange;
  6321. }
  6322. function reduceDateSelection(currentSelection, action) {
  6323. switch (action.type) {
  6324. case 'UNSELECT_DATES':
  6325. return null;
  6326. case 'SELECT_DATES':
  6327. return action.selection;
  6328. default:
  6329. return currentSelection;
  6330. }
  6331. }
  6332. function reduceSelectedEvent(currentInstanceId, action) {
  6333. switch (action.type) {
  6334. case 'UNSELECT_EVENT':
  6335. return '';
  6336. case 'SELECT_EVENT':
  6337. return action.eventInstanceId;
  6338. default:
  6339. return currentInstanceId;
  6340. }
  6341. }
  6342. function reduceEventDrag(currentDrag, action) {
  6343. var newDrag;
  6344. switch (action.type) {
  6345. case 'UNSET_EVENT_DRAG':
  6346. return null;
  6347. case 'SET_EVENT_DRAG':
  6348. newDrag = action.state;
  6349. return {
  6350. affectedEvents: newDrag.affectedEvents,
  6351. mutatedEvents: newDrag.mutatedEvents,
  6352. isEvent: newDrag.isEvent,
  6353. };
  6354. default:
  6355. return currentDrag;
  6356. }
  6357. }
  6358. function reduceEventResize(currentResize, action) {
  6359. var newResize;
  6360. switch (action.type) {
  6361. case 'UNSET_EVENT_RESIZE':
  6362. return null;
  6363. case 'SET_EVENT_RESIZE':
  6364. newResize = action.state;
  6365. return {
  6366. affectedEvents: newResize.affectedEvents,
  6367. mutatedEvents: newResize.mutatedEvents,
  6368. isEvent: newResize.isEvent,
  6369. };
  6370. default:
  6371. return currentResize;
  6372. }
  6373. }
  6374. function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6375. var viewsWithButtons = [];
  6376. var headerToolbar = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) : null;
  6377. var footerToolbar = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) : null;
  6378. return { headerToolbar: headerToolbar, footerToolbar: footerToolbar, viewsWithButtons: viewsWithButtons };
  6379. }
  6380. function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) {
  6381. return mapHash(sectionStrHash, function (sectionStr) { return parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons); });
  6382. }
  6383. /*
  6384. BAD: querying icons and text here. should be done at render time
  6385. */
  6386. function parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) {
  6387. var isRtl = calendarOptions.direction === 'rtl';
  6388. var calendarCustomButtons = calendarOptions.customButtons || {};
  6389. var calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
  6390. var calendarButtonText = calendarOptions.buttonText || {};
  6391. var sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
  6392. return sectionSubstrs.map(function (buttonGroupStr) { return (buttonGroupStr.split(',').map(function (buttonName) {
  6393. if (buttonName === 'title') {
  6394. return { buttonName: buttonName };
  6395. }
  6396. var customButtonProps;
  6397. var viewSpec;
  6398. var buttonClick;
  6399. var buttonIcon; // only one of these will be set
  6400. var buttonText; // "
  6401. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  6402. buttonClick = function (ev) {
  6403. if (customButtonProps.click) {
  6404. customButtonProps.click.call(ev.target, ev, ev.target);
  6405. }
  6406. };
  6407. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  6408. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6409. (buttonText = customButtonProps.text);
  6410. }
  6411. else if ((viewSpec = viewSpecs[buttonName])) {
  6412. viewsWithButtons.push(buttonName);
  6413. buttonClick = function () {
  6414. calendarApi.changeView(buttonName);
  6415. };
  6416. (buttonText = viewSpec.buttonTextOverride) ||
  6417. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6418. (buttonText = viewSpec.buttonTextDefault);
  6419. }
  6420. else if (calendarApi[buttonName]) { // a calendarApi method
  6421. buttonClick = function () {
  6422. calendarApi[buttonName]();
  6423. };
  6424. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6425. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6426. (buttonText = calendarButtonText[buttonName]);
  6427. // ^ everything else is considered default
  6428. }
  6429. return { buttonName: buttonName, buttonClick: buttonClick, buttonIcon: buttonIcon, buttonText: buttonText };
  6430. })); });
  6431. }
  6432. var eventSourceDef = {
  6433. ignoreRange: true,
  6434. parseMeta: function (refined) {
  6435. if (Array.isArray(refined.events)) {
  6436. return refined.events;
  6437. }
  6438. return null;
  6439. },
  6440. fetch: function (arg, success) {
  6441. success({
  6442. rawEvents: arg.eventSource.meta,
  6443. });
  6444. },
  6445. };
  6446. var arrayEventSourcePlugin = createPlugin({
  6447. eventSourceDefs: [eventSourceDef],
  6448. });
  6449. var eventSourceDef$1 = {
  6450. parseMeta: function (refined) {
  6451. if (typeof refined.events === 'function') {
  6452. return refined.events;
  6453. }
  6454. return null;
  6455. },
  6456. fetch: function (arg, success, failure) {
  6457. var dateEnv = arg.context.dateEnv;
  6458. var func = arg.eventSource.meta;
  6459. unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), function (rawEvents) {
  6460. success({ rawEvents: rawEvents }); // needs an object response
  6461. }, failure);
  6462. },
  6463. };
  6464. var funcEventSourcePlugin = createPlugin({
  6465. eventSourceDefs: [eventSourceDef$1],
  6466. });
  6467. function requestJson(method, url, params, successCallback, failureCallback) {
  6468. method = method.toUpperCase();
  6469. var body = null;
  6470. if (method === 'GET') {
  6471. url = injectQueryStringParams(url, params);
  6472. }
  6473. else {
  6474. body = encodeParams(params);
  6475. }
  6476. var xhr = new XMLHttpRequest();
  6477. xhr.open(method, url, true);
  6478. if (method !== 'GET') {
  6479. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6480. }
  6481. xhr.onload = function () {
  6482. if (xhr.status >= 200 && xhr.status < 400) {
  6483. var parsed = false;
  6484. var res = void 0;
  6485. try {
  6486. res = JSON.parse(xhr.responseText);
  6487. parsed = true;
  6488. }
  6489. catch (err) {
  6490. // will handle parsed=false
  6491. }
  6492. if (parsed) {
  6493. successCallback(res, xhr);
  6494. }
  6495. else {
  6496. failureCallback('Failure parsing JSON', xhr);
  6497. }
  6498. }
  6499. else {
  6500. failureCallback('Request failed', xhr);
  6501. }
  6502. };
  6503. xhr.onerror = function () {
  6504. failureCallback('Request failed', xhr);
  6505. };
  6506. xhr.send(body);
  6507. }
  6508. function injectQueryStringParams(url, params) {
  6509. return url +
  6510. (url.indexOf('?') === -1 ? '?' : '&') +
  6511. encodeParams(params);
  6512. }
  6513. function encodeParams(params) {
  6514. var parts = [];
  6515. for (var key in params) {
  6516. parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
  6517. }
  6518. return parts.join('&');
  6519. }
  6520. var JSON_FEED_EVENT_SOURCE_REFINERS = {
  6521. method: String,
  6522. extraParams: identity,
  6523. startParam: String,
  6524. endParam: String,
  6525. timeZoneParam: String,
  6526. };
  6527. var eventSourceDef$2 = {
  6528. parseMeta: function (refined) {
  6529. if (refined.url && (refined.format === 'json' || !refined.format)) {
  6530. return {
  6531. url: refined.url,
  6532. format: 'json',
  6533. method: (refined.method || 'GET').toUpperCase(),
  6534. extraParams: refined.extraParams,
  6535. startParam: refined.startParam,
  6536. endParam: refined.endParam,
  6537. timeZoneParam: refined.timeZoneParam,
  6538. };
  6539. }
  6540. return null;
  6541. },
  6542. fetch: function (arg, success, failure) {
  6543. var meta = arg.eventSource.meta;
  6544. var requestParams = buildRequestParams(meta, arg.range, arg.context);
  6545. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  6546. success({ rawEvents: rawEvents, xhr: xhr });
  6547. }, function (errorMessage, xhr) {
  6548. failure({ message: errorMessage, xhr: xhr });
  6549. });
  6550. },
  6551. };
  6552. var jsonFeedEventSourcePlugin = createPlugin({
  6553. eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
  6554. eventSourceDefs: [eventSourceDef$2],
  6555. });
  6556. function buildRequestParams(meta, range, context) {
  6557. var dateEnv = context.dateEnv, options = context.options;
  6558. var startParam;
  6559. var endParam;
  6560. var timeZoneParam;
  6561. var customRequestParams;
  6562. var params = {};
  6563. startParam = meta.startParam;
  6564. if (startParam == null) {
  6565. startParam = options.startParam;
  6566. }
  6567. endParam = meta.endParam;
  6568. if (endParam == null) {
  6569. endParam = options.endParam;
  6570. }
  6571. timeZoneParam = meta.timeZoneParam;
  6572. if (timeZoneParam == null) {
  6573. timeZoneParam = options.timeZoneParam;
  6574. }
  6575. // retrieve any outbound GET/POST data from the options
  6576. if (typeof meta.extraParams === 'function') {
  6577. // supplied as a function that returns a key/value object
  6578. customRequestParams = meta.extraParams();
  6579. }
  6580. else {
  6581. // probably supplied as a straight key/value object
  6582. customRequestParams = meta.extraParams || {};
  6583. }
  6584. __assign(params, customRequestParams);
  6585. params[startParam] = dateEnv.formatIso(range.start);
  6586. params[endParam] = dateEnv.formatIso(range.end);
  6587. if (dateEnv.timeZone !== 'local') {
  6588. params[timeZoneParam] = dateEnv.timeZone;
  6589. }
  6590. return params;
  6591. }
  6592. var SIMPLE_RECURRING_REFINERS = {
  6593. daysOfWeek: identity,
  6594. startTime: createDuration,
  6595. endTime: createDuration,
  6596. duration: createDuration,
  6597. startRecur: identity,
  6598. endRecur: identity,
  6599. };
  6600. var recurring = {
  6601. parse: function (refined, dateEnv) {
  6602. if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
  6603. var recurringData = {
  6604. daysOfWeek: refined.daysOfWeek || null,
  6605. startTime: refined.startTime || null,
  6606. endTime: refined.endTime || null,
  6607. startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
  6608. endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
  6609. };
  6610. var duration = void 0;
  6611. if (refined.duration) {
  6612. duration = refined.duration;
  6613. }
  6614. if (!duration && refined.startTime && refined.endTime) {
  6615. duration = subtractDurations(refined.endTime, refined.startTime);
  6616. }
  6617. return {
  6618. allDayGuess: Boolean(!refined.startTime && !refined.endTime),
  6619. duration: duration,
  6620. typeData: recurringData,
  6621. };
  6622. }
  6623. return null;
  6624. },
  6625. expand: function (typeData, framingRange, dateEnv) {
  6626. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  6627. if (clippedFramingRange) {
  6628. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  6629. }
  6630. return [];
  6631. },
  6632. };
  6633. var simpleRecurringEventsPlugin = createPlugin({
  6634. recurringTypes: [recurring],
  6635. eventRefiners: SIMPLE_RECURRING_REFINERS,
  6636. });
  6637. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  6638. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  6639. var dayMarker = startOfDay(framingRange.start);
  6640. var endMarker = framingRange.end;
  6641. var instanceStarts = [];
  6642. while (dayMarker < endMarker) {
  6643. var instanceStart
  6644. // if everyday, or this particular day-of-week
  6645. = void 0;
  6646. // if everyday, or this particular day-of-week
  6647. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  6648. if (startTime) {
  6649. instanceStart = dateEnv.add(dayMarker, startTime);
  6650. }
  6651. else {
  6652. instanceStart = dayMarker;
  6653. }
  6654. instanceStarts.push(instanceStart);
  6655. }
  6656. dayMarker = addDays(dayMarker, 1);
  6657. }
  6658. return instanceStarts;
  6659. }
  6660. var changeHandlerPlugin = createPlugin({
  6661. optionChangeHandlers: {
  6662. events: function (events, context) {
  6663. handleEventSources([events], context);
  6664. },
  6665. eventSources: handleEventSources,
  6666. },
  6667. });
  6668. /*
  6669. BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
  6670. */
  6671. function handleEventSources(inputs, context) {
  6672. var unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
  6673. var newInputs = [];
  6674. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  6675. var input = inputs_1[_i];
  6676. var inputFound = false;
  6677. for (var i = 0; i < unfoundSources.length; i += 1) {
  6678. if (unfoundSources[i]._raw === input) {
  6679. unfoundSources.splice(i, 1); // delete
  6680. inputFound = true;
  6681. break;
  6682. }
  6683. }
  6684. if (!inputFound) {
  6685. newInputs.push(input);
  6686. }
  6687. }
  6688. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  6689. var unfoundSource = unfoundSources_1[_a];
  6690. context.dispatch({
  6691. type: 'REMOVE_EVENT_SOURCE',
  6692. sourceId: unfoundSource.sourceId,
  6693. });
  6694. }
  6695. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  6696. var newInput = newInputs_1[_b];
  6697. context.calendarApi.addEventSource(newInput);
  6698. }
  6699. }
  6700. function handleDateProfile(dateProfile, context) {
  6701. context.emitter.trigger('datesSet', __assign(__assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
  6702. }
  6703. function handleEventStore(eventStore, context) {
  6704. var emitter = context.emitter;
  6705. if (emitter.hasHandlers('eventsSet')) {
  6706. emitter.trigger('eventsSet', buildEventApis(eventStore, context));
  6707. }
  6708. }
  6709. /*
  6710. this array is exposed on the root namespace so that UMD plugins can add to it.
  6711. see the rollup-bundles script.
  6712. */
  6713. var globalPlugins = [
  6714. arrayEventSourcePlugin,
  6715. funcEventSourcePlugin,
  6716. jsonFeedEventSourcePlugin,
  6717. simpleRecurringEventsPlugin,
  6718. changeHandlerPlugin,
  6719. createPlugin({
  6720. isLoadingFuncs: [
  6721. function (state) { return computeEventSourcesLoading(state.eventSources); },
  6722. ],
  6723. contentTypeHandlers: {
  6724. html: function () { return ({ render: injectHtml }); },
  6725. domNodes: function () { return ({ render: injectDomNodes }); },
  6726. },
  6727. propSetHandlers: {
  6728. dateProfile: handleDateProfile,
  6729. eventStore: handleEventStore,
  6730. },
  6731. }),
  6732. ];
  6733. function injectHtml(el, html) {
  6734. el.innerHTML = html;
  6735. }
  6736. function injectDomNodes(el, domNodes) {
  6737. var oldNodes = Array.prototype.slice.call(el.childNodes); // TODO: use array util
  6738. var newNodes = Array.prototype.slice.call(domNodes); // TODO: use array util
  6739. if (!isArraysEqual(oldNodes, newNodes)) {
  6740. for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) {
  6741. var newNode = newNodes_1[_i];
  6742. el.appendChild(newNode);
  6743. }
  6744. oldNodes.forEach(removeElement);
  6745. }
  6746. }
  6747. var DelayedRunner = /** @class */ (function () {
  6748. function DelayedRunner(drainedOption) {
  6749. this.drainedOption = drainedOption;
  6750. this.isRunning = false;
  6751. this.isDirty = false;
  6752. this.pauseDepths = {};
  6753. this.timeoutId = 0;
  6754. }
  6755. DelayedRunner.prototype.request = function (delay) {
  6756. this.isDirty = true;
  6757. if (!this.isPaused()) {
  6758. this.clearTimeout();
  6759. if (delay == null) {
  6760. this.tryDrain();
  6761. }
  6762. else {
  6763. this.timeoutId = setTimeout(// NOT OPTIMAL! TODO: look at debounce
  6764. this.tryDrain.bind(this), delay);
  6765. }
  6766. }
  6767. };
  6768. DelayedRunner.prototype.pause = function (scope) {
  6769. if (scope === void 0) { scope = ''; }
  6770. var pauseDepths = this.pauseDepths;
  6771. pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
  6772. this.clearTimeout();
  6773. };
  6774. DelayedRunner.prototype.resume = function (scope, force) {
  6775. if (scope === void 0) { scope = ''; }
  6776. var pauseDepths = this.pauseDepths;
  6777. if (scope in pauseDepths) {
  6778. if (force) {
  6779. delete pauseDepths[scope];
  6780. }
  6781. else {
  6782. pauseDepths[scope] -= 1;
  6783. var depth = pauseDepths[scope];
  6784. if (depth <= 0) {
  6785. delete pauseDepths[scope];
  6786. }
  6787. }
  6788. this.tryDrain();
  6789. }
  6790. };
  6791. DelayedRunner.prototype.isPaused = function () {
  6792. return Object.keys(this.pauseDepths).length;
  6793. };
  6794. DelayedRunner.prototype.tryDrain = function () {
  6795. if (!this.isRunning && !this.isPaused()) {
  6796. this.isRunning = true;
  6797. while (this.isDirty) {
  6798. this.isDirty = false;
  6799. this.drained(); // might set isDirty to true again
  6800. }
  6801. this.isRunning = false;
  6802. }
  6803. };
  6804. DelayedRunner.prototype.clear = function () {
  6805. this.clearTimeout();
  6806. this.isDirty = false;
  6807. this.pauseDepths = {};
  6808. };
  6809. DelayedRunner.prototype.clearTimeout = function () {
  6810. if (this.timeoutId) {
  6811. clearTimeout(this.timeoutId);
  6812. this.timeoutId = 0;
  6813. }
  6814. };
  6815. DelayedRunner.prototype.drained = function () {
  6816. if (this.drainedOption) {
  6817. this.drainedOption();
  6818. }
  6819. };
  6820. return DelayedRunner;
  6821. }());
  6822. var TaskRunner = /** @class */ (function () {
  6823. function TaskRunner(runTaskOption, drainedOption) {
  6824. this.runTaskOption = runTaskOption;
  6825. this.drainedOption = drainedOption;
  6826. this.queue = [];
  6827. this.delayedRunner = new DelayedRunner(this.drain.bind(this));
  6828. }
  6829. TaskRunner.prototype.request = function (task, delay) {
  6830. this.queue.push(task);
  6831. this.delayedRunner.request(delay);
  6832. };
  6833. TaskRunner.prototype.pause = function (scope) {
  6834. this.delayedRunner.pause(scope);
  6835. };
  6836. TaskRunner.prototype.resume = function (scope, force) {
  6837. this.delayedRunner.resume(scope, force);
  6838. };
  6839. TaskRunner.prototype.drain = function () {
  6840. var queue = this.queue;
  6841. while (queue.length) {
  6842. var completedTasks = [];
  6843. var task = void 0;
  6844. while ((task = queue.shift())) {
  6845. this.runTask(task);
  6846. completedTasks.push(task);
  6847. }
  6848. this.drained(completedTasks);
  6849. } // keep going, in case new tasks were added in the drained handler
  6850. };
  6851. TaskRunner.prototype.runTask = function (task) {
  6852. if (this.runTaskOption) {
  6853. this.runTaskOption(task);
  6854. }
  6855. };
  6856. TaskRunner.prototype.drained = function (completedTasks) {
  6857. if (this.drainedOption) {
  6858. this.drainedOption(completedTasks);
  6859. }
  6860. };
  6861. return TaskRunner;
  6862. }());
  6863. // Computes what the title at the top of the calendarApi should be for this view
  6864. function buildTitle(dateProfile, viewOptions, dateEnv) {
  6865. var range;
  6866. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6867. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6868. range = dateProfile.currentRange;
  6869. }
  6870. else { // for day units or smaller, use the actual day range
  6871. range = dateProfile.activeRange;
  6872. }
  6873. return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
  6874. isEndExclusive: dateProfile.isRangeAllDay,
  6875. defaultSeparator: viewOptions.titleRangeSeparator,
  6876. });
  6877. }
  6878. // Generates the format string that should be used to generate the title for the current date range.
  6879. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6880. function buildTitleFormat(dateProfile) {
  6881. var currentRangeUnit = dateProfile.currentRangeUnit;
  6882. if (currentRangeUnit === 'year') {
  6883. return { year: 'numeric' };
  6884. }
  6885. if (currentRangeUnit === 'month') {
  6886. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6887. }
  6888. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6889. if (days !== null && days > 1) {
  6890. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6891. return { year: 'numeric', month: 'short', day: 'numeric' };
  6892. }
  6893. // one day. longer, like "September 9 2014"
  6894. return { year: 'numeric', month: 'long', day: 'numeric' };
  6895. }
  6896. // in future refactor, do the redux-style function(state=initial) for initial-state
  6897. // also, whatever is happening in constructor, have it happen in action queue too
  6898. var CalendarDataManager = /** @class */ (function () {
  6899. function CalendarDataManager(props) {
  6900. var _this = this;
  6901. this.computeOptionsData = memoize(this._computeOptionsData);
  6902. this.computeCurrentViewData = memoize(this._computeCurrentViewData);
  6903. this.organizeRawLocales = memoize(organizeRawLocales);
  6904. this.buildLocale = memoize(buildLocale);
  6905. this.buildPluginHooks = buildBuildPluginHooks();
  6906. this.buildDateEnv = memoize(buildDateEnv$1);
  6907. this.buildTheme = memoize(buildTheme);
  6908. this.parseToolbars = memoize(parseToolbars);
  6909. this.buildViewSpecs = memoize(buildViewSpecs);
  6910. this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
  6911. this.buildViewApi = memoize(buildViewApi);
  6912. this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
  6913. this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
  6914. this.buildEventUiBases = memoize(buildEventUiBases);
  6915. this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
  6916. this.buildTitle = memoize(buildTitle);
  6917. this.emitter = new Emitter();
  6918. this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
  6919. this.currentCalendarOptionsInput = {};
  6920. this.currentCalendarOptionsRefined = {};
  6921. this.currentViewOptionsInput = {};
  6922. this.currentViewOptionsRefined = {};
  6923. this.currentCalendarOptionsRefiners = {};
  6924. this.getCurrentData = function () { return _this.data; };
  6925. this.dispatch = function (action) {
  6926. _this.actionRunner.request(action); // protects against recursive calls to _handleAction
  6927. };
  6928. this.props = props;
  6929. this.actionRunner.pause();
  6930. var dynamicOptionOverrides = {};
  6931. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  6932. var currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
  6933. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  6934. // wire things up
  6935. // TODO: not DRY
  6936. props.calendarApi.currentDataManager = this;
  6937. this.emitter.setThisContext(props.calendarApi);
  6938. this.emitter.setOptions(currentViewData.options);
  6939. var currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
  6940. var dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  6941. if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
  6942. currentDate = dateProfile.currentRange.start;
  6943. }
  6944. var calendarContext = {
  6945. dateEnv: optionsData.dateEnv,
  6946. options: optionsData.calendarOptions,
  6947. pluginHooks: optionsData.pluginHooks,
  6948. calendarApi: props.calendarApi,
  6949. dispatch: this.dispatch,
  6950. emitter: this.emitter,
  6951. getCurrentData: this.getCurrentData,
  6952. };
  6953. // needs to be after setThisContext
  6954. for (var _i = 0, _a = optionsData.pluginHooks.contextInit; _i < _a.length; _i++) {
  6955. var callback = _a[_i];
  6956. callback(calendarContext);
  6957. }
  6958. // NOT DRY
  6959. var eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
  6960. var initialState = {
  6961. dynamicOptionOverrides: dynamicOptionOverrides,
  6962. currentViewType: currentViewType,
  6963. currentDate: currentDate,
  6964. dateProfile: dateProfile,
  6965. businessHours: this.parseContextBusinessHours(calendarContext),
  6966. eventSources: eventSources,
  6967. eventUiBases: {},
  6968. eventStore: createEmptyEventStore(),
  6969. renderableEventStore: createEmptyEventStore(),
  6970. dateSelection: null,
  6971. eventSelection: '',
  6972. eventDrag: null,
  6973. eventResize: null,
  6974. selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
  6975. };
  6976. var contextAndState = __assign(__assign({}, calendarContext), initialState);
  6977. for (var _b = 0, _c = optionsData.pluginHooks.reducers; _b < _c.length; _b++) {
  6978. var reducer = _c[_b];
  6979. __assign(initialState, reducer(null, null, contextAndState));
  6980. }
  6981. if (computeIsLoading(initialState, calendarContext)) {
  6982. this.emitter.trigger('loading', true); // NOT DRY
  6983. }
  6984. this.state = initialState;
  6985. this.updateData();
  6986. this.actionRunner.resume();
  6987. }
  6988. CalendarDataManager.prototype.resetOptions = function (optionOverrides, append) {
  6989. var props = this.props;
  6990. props.optionOverrides = append
  6991. ? __assign(__assign({}, props.optionOverrides), optionOverrides) : optionOverrides;
  6992. this.actionRunner.request({
  6993. type: 'NOTHING',
  6994. });
  6995. };
  6996. CalendarDataManager.prototype._handleAction = function (action) {
  6997. var _a = this, props = _a.props, state = _a.state, emitter = _a.emitter;
  6998. var dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
  6999. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  7000. var currentViewType = reduceViewType(state.currentViewType, action);
  7001. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  7002. // wire things up
  7003. // TODO: not DRY
  7004. props.calendarApi.currentDataManager = this;
  7005. emitter.setThisContext(props.calendarApi);
  7006. emitter.setOptions(currentViewData.options);
  7007. var calendarContext = {
  7008. dateEnv: optionsData.dateEnv,
  7009. options: optionsData.calendarOptions,
  7010. pluginHooks: optionsData.pluginHooks,
  7011. calendarApi: props.calendarApi,
  7012. dispatch: this.dispatch,
  7013. emitter: emitter,
  7014. getCurrentData: this.getCurrentData,
  7015. };
  7016. var currentDate = state.currentDate, dateProfile = state.dateProfile;
  7017. if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
  7018. dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7019. }
  7020. currentDate = reduceCurrentDate(currentDate, action);
  7021. dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
  7022. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  7023. currentDate = dateProfile.currentRange.start;
  7024. }
  7025. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
  7026. var eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
  7027. var isEventsLoading = computeEventSourcesLoading(eventSources); // BAD. also called in this func in computeIsLoading
  7028. var renderableEventStore = (isEventsLoading && !currentViewData.options.progressiveEventRendering) ?
  7029. (state.renderableEventStore || eventStore) : // try from previous state
  7030. eventStore;
  7031. var _b = this.buildViewUiProps(calendarContext), eventUiSingleBase = _b.eventUiSingleBase, selectionConfig = _b.selectionConfig; // will memoize obj
  7032. var eventUiBySource = this.buildEventUiBySource(eventSources);
  7033. var eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  7034. var newState = {
  7035. dynamicOptionOverrides: dynamicOptionOverrides,
  7036. currentViewType: currentViewType,
  7037. currentDate: currentDate,
  7038. dateProfile: dateProfile,
  7039. eventSources: eventSources,
  7040. eventStore: eventStore,
  7041. renderableEventStore: renderableEventStore,
  7042. selectionConfig: selectionConfig,
  7043. eventUiBases: eventUiBases,
  7044. businessHours: this.parseContextBusinessHours(calendarContext),
  7045. dateSelection: reduceDateSelection(state.dateSelection, action),
  7046. eventSelection: reduceSelectedEvent(state.eventSelection, action),
  7047. eventDrag: reduceEventDrag(state.eventDrag, action),
  7048. eventResize: reduceEventResize(state.eventResize, action),
  7049. };
  7050. var contextAndState = __assign(__assign({}, calendarContext), newState);
  7051. for (var _i = 0, _c = optionsData.pluginHooks.reducers; _i < _c.length; _i++) {
  7052. var reducer = _c[_i];
  7053. __assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
  7054. }
  7055. var wasLoading = computeIsLoading(state, calendarContext);
  7056. var isLoading = computeIsLoading(newState, calendarContext);
  7057. // TODO: use propSetHandlers in plugin system
  7058. if (!wasLoading && isLoading) {
  7059. emitter.trigger('loading', true);
  7060. }
  7061. else if (wasLoading && !isLoading) {
  7062. emitter.trigger('loading', false);
  7063. }
  7064. this.state = newState;
  7065. if (props.onAction) {
  7066. props.onAction(action);
  7067. }
  7068. };
  7069. CalendarDataManager.prototype.updateData = function () {
  7070. var _a = this, props = _a.props, state = _a.state;
  7071. var oldData = this.data;
  7072. var optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
  7073. var currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
  7074. var data = this.data = __assign(__assign(__assign({ viewTitle: this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv), calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
  7075. var changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
  7076. var oldCalendarOptions = oldData && oldData.calendarOptions;
  7077. var newCalendarOptions = optionsData.calendarOptions;
  7078. if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
  7079. if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
  7080. // hack
  7081. state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
  7082. state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
  7083. }
  7084. for (var optionName in changeHandlers) {
  7085. if (oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
  7086. changeHandlers[optionName](newCalendarOptions[optionName], data);
  7087. }
  7088. }
  7089. }
  7090. if (props.onData) {
  7091. props.onData(data);
  7092. }
  7093. };
  7094. CalendarDataManager.prototype._computeOptionsData = function (optionOverrides, dynamicOptionOverrides, calendarApi) {
  7095. // TODO: blacklist options that are handled by optionChangeHandlers
  7096. var _a = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, pluginHooks = _a.pluginHooks, localeDefaults = _a.localeDefaults, availableLocaleData = _a.availableLocaleData, extra = _a.extra;
  7097. warnUnknownOptions(extra);
  7098. var dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
  7099. var viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides, localeDefaults);
  7100. var theme = this.buildTheme(refinedOptions, pluginHooks);
  7101. var toolbarConfig = this.parseToolbars(refinedOptions, optionOverrides, theme, viewSpecs, calendarApi);
  7102. return {
  7103. calendarOptions: refinedOptions,
  7104. pluginHooks: pluginHooks,
  7105. dateEnv: dateEnv,
  7106. viewSpecs: viewSpecs,
  7107. theme: theme,
  7108. toolbarConfig: toolbarConfig,
  7109. localeDefaults: localeDefaults,
  7110. availableRawLocales: availableLocaleData.map,
  7111. };
  7112. };
  7113. // always called from behind a memoizer
  7114. CalendarDataManager.prototype.processRawCalendarOptions = function (optionOverrides, dynamicOptionOverrides) {
  7115. var _a = mergeRawOptions([
  7116. BASE_OPTION_DEFAULTS,
  7117. optionOverrides,
  7118. dynamicOptionOverrides,
  7119. ]), locales = _a.locales, locale = _a.locale;
  7120. var availableLocaleData = this.organizeRawLocales(locales);
  7121. var availableRawLocales = availableLocaleData.map;
  7122. var localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
  7123. var pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
  7124. var refiners = this.currentCalendarOptionsRefiners = __assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7125. var extra = {};
  7126. var raw = mergeRawOptions([
  7127. BASE_OPTION_DEFAULTS,
  7128. localeDefaults,
  7129. optionOverrides,
  7130. dynamicOptionOverrides,
  7131. ]);
  7132. var refined = {};
  7133. var currentRaw = this.currentCalendarOptionsInput;
  7134. var currentRefined = this.currentCalendarOptionsRefined;
  7135. var anyChanges = false;
  7136. for (var optionName in raw) {
  7137. if (optionName !== 'plugins') { // because plugins is special-cased
  7138. if (raw[optionName] === currentRaw[optionName] ||
  7139. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  7140. (optionName in currentRaw) &&
  7141. COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName]))) {
  7142. refined[optionName] = currentRefined[optionName];
  7143. }
  7144. else if (refiners[optionName]) {
  7145. refined[optionName] = refiners[optionName](raw[optionName]);
  7146. anyChanges = true;
  7147. }
  7148. else {
  7149. extra[optionName] = currentRaw[optionName];
  7150. }
  7151. }
  7152. }
  7153. if (anyChanges) {
  7154. this.currentCalendarOptionsInput = raw;
  7155. this.currentCalendarOptionsRefined = refined;
  7156. }
  7157. return {
  7158. rawOptions: this.currentCalendarOptionsInput,
  7159. refinedOptions: this.currentCalendarOptionsRefined,
  7160. pluginHooks: pluginHooks,
  7161. availableLocaleData: availableLocaleData,
  7162. localeDefaults: localeDefaults,
  7163. extra: extra,
  7164. };
  7165. };
  7166. CalendarDataManager.prototype._computeCurrentViewData = function (viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
  7167. var viewSpec = optionsData.viewSpecs[viewType];
  7168. if (!viewSpec) {
  7169. throw new Error("viewType \"" + viewType + "\" is not available. Please make sure you've loaded all neccessary plugins");
  7170. }
  7171. var _a = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, extra = _a.extra;
  7172. warnUnknownOptions(extra);
  7173. var dateProfileGenerator = this.buildDateProfileGenerator({
  7174. dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
  7175. duration: viewSpec.duration,
  7176. durationUnit: viewSpec.durationUnit,
  7177. usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
  7178. dateEnv: optionsData.dateEnv,
  7179. calendarApi: this.props.calendarApi,
  7180. slotMinTime: refinedOptions.slotMinTime,
  7181. slotMaxTime: refinedOptions.slotMaxTime,
  7182. showNonCurrentDates: refinedOptions.showNonCurrentDates,
  7183. dayCount: refinedOptions.dayCount,
  7184. dateAlignment: refinedOptions.dateAlignment,
  7185. dateIncrement: refinedOptions.dateIncrement,
  7186. hiddenDays: refinedOptions.hiddenDays,
  7187. weekends: refinedOptions.weekends,
  7188. nowInput: refinedOptions.now,
  7189. validRangeInput: refinedOptions.validRange,
  7190. visibleRangeInput: refinedOptions.visibleRange,
  7191. monthMode: refinedOptions.monthMode,
  7192. fixedWeekCount: refinedOptions.fixedWeekCount,
  7193. });
  7194. var viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
  7195. return { viewSpec: viewSpec, options: refinedOptions, dateProfileGenerator: dateProfileGenerator, viewApi: viewApi };
  7196. };
  7197. CalendarDataManager.prototype.processRawViewOptions = function (viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
  7198. var raw = mergeRawOptions([
  7199. BASE_OPTION_DEFAULTS,
  7200. viewSpec.optionDefaults,
  7201. localeDefaults,
  7202. optionOverrides,
  7203. viewSpec.optionOverrides,
  7204. dynamicOptionOverrides,
  7205. ]);
  7206. var refiners = __assign(__assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7207. var refined = {};
  7208. var currentRaw = this.currentViewOptionsInput;
  7209. var currentRefined = this.currentViewOptionsRefined;
  7210. var anyChanges = false;
  7211. var extra = {};
  7212. for (var optionName in raw) {
  7213. if (raw[optionName] === currentRaw[optionName]) {
  7214. refined[optionName] = currentRefined[optionName];
  7215. }
  7216. else {
  7217. if (raw[optionName] === this.currentCalendarOptionsInput[optionName]) {
  7218. if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
  7219. refined[optionName] = this.currentCalendarOptionsRefined[optionName];
  7220. }
  7221. }
  7222. else if (refiners[optionName]) {
  7223. refined[optionName] = refiners[optionName](raw[optionName]);
  7224. }
  7225. else {
  7226. extra[optionName] = raw[optionName];
  7227. }
  7228. anyChanges = true;
  7229. }
  7230. }
  7231. if (anyChanges) {
  7232. this.currentViewOptionsInput = raw;
  7233. this.currentViewOptionsRefined = refined;
  7234. }
  7235. return {
  7236. rawOptions: this.currentViewOptionsInput,
  7237. refinedOptions: this.currentViewOptionsRefined,
  7238. extra: extra,
  7239. };
  7240. };
  7241. return CalendarDataManager;
  7242. }());
  7243. function buildDateEnv$1(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
  7244. var locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
  7245. return new DateEnv({
  7246. calendarSystem: 'gregory',
  7247. timeZone: timeZone,
  7248. namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
  7249. locale: locale,
  7250. weekNumberCalculation: weekNumberCalculation,
  7251. firstDay: firstDay,
  7252. weekText: weekText,
  7253. cmdFormatter: pluginHooks.cmdFormatter,
  7254. defaultSeparator: defaultSeparator,
  7255. });
  7256. }
  7257. function buildTheme(options, pluginHooks) {
  7258. var ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
  7259. return new ThemeClass(options);
  7260. }
  7261. function buildDateProfileGenerator(props) {
  7262. var DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
  7263. return new DateProfileGeneratorClass(props);
  7264. }
  7265. function buildViewApi(type, getCurrentData, dateEnv) {
  7266. return new ViewApi(type, getCurrentData, dateEnv);
  7267. }
  7268. function buildEventUiBySource(eventSources) {
  7269. return mapHash(eventSources, function (eventSource) { return eventSource.ui; });
  7270. }
  7271. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7272. var eventUiBases = { '': eventUiSingleBase };
  7273. for (var defId in eventDefs) {
  7274. var def = eventDefs[defId];
  7275. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7276. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7277. }
  7278. }
  7279. return eventUiBases;
  7280. }
  7281. function buildViewUiProps(calendarContext) {
  7282. var options = calendarContext.options;
  7283. return {
  7284. eventUiSingleBase: createEventUi({
  7285. display: options.eventDisplay,
  7286. editable: options.editable,
  7287. startEditable: options.eventStartEditable,
  7288. durationEditable: options.eventDurationEditable,
  7289. constraint: options.eventConstraint,
  7290. overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
  7291. allow: options.eventAllow,
  7292. backgroundColor: options.eventBackgroundColor,
  7293. borderColor: options.eventBorderColor,
  7294. textColor: options.eventTextColor,
  7295. color: options.eventColor,
  7296. }, calendarContext),
  7297. selectionConfig: createEventUi({
  7298. constraint: options.selectConstraint,
  7299. overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
  7300. allow: options.selectAllow,
  7301. }, calendarContext),
  7302. };
  7303. }
  7304. function computeIsLoading(state, context) {
  7305. for (var _i = 0, _a = context.pluginHooks.isLoadingFuncs; _i < _a.length; _i++) {
  7306. var isLoadingFunc = _a[_i];
  7307. if (isLoadingFunc(state)) {
  7308. return true;
  7309. }
  7310. }
  7311. return false;
  7312. }
  7313. function parseContextBusinessHours(calendarContext) {
  7314. return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
  7315. }
  7316. function warnUnknownOptions(options, viewName) {
  7317. for (var optionName in options) {
  7318. console.warn("Unknown option '" + optionName + "'" +
  7319. (viewName ? " for view '" + viewName + "'" : ''));
  7320. }
  7321. }
  7322. // TODO: move this to react plugin?
  7323. var CalendarDataProvider = /** @class */ (function (_super) {
  7324. __extends(CalendarDataProvider, _super);
  7325. function CalendarDataProvider(props) {
  7326. var _this = _super.call(this, props) || this;
  7327. _this.handleData = function (data) {
  7328. if (!_this.dataManager) { // still within initial run, before assignment in constructor
  7329. // eslint-disable-next-line react/no-direct-mutation-state
  7330. _this.state = data; // can't use setState yet
  7331. }
  7332. else {
  7333. _this.setState(data);
  7334. }
  7335. };
  7336. _this.dataManager = new CalendarDataManager({
  7337. optionOverrides: props.optionOverrides,
  7338. calendarApi: props.calendarApi,
  7339. onData: _this.handleData,
  7340. });
  7341. return _this;
  7342. }
  7343. CalendarDataProvider.prototype.render = function () {
  7344. return this.props.children(this.state);
  7345. };
  7346. CalendarDataProvider.prototype.componentDidUpdate = function (prevProps) {
  7347. var newOptionOverrides = this.props.optionOverrides;
  7348. if (newOptionOverrides !== prevProps.optionOverrides) { // prevent recursive handleData
  7349. this.dataManager.resetOptions(newOptionOverrides);
  7350. }
  7351. };
  7352. return CalendarDataProvider;
  7353. }(Component));
  7354. // HELPERS
  7355. /*
  7356. if nextDayThreshold is specified, slicing is done in an all-day fashion.
  7357. you can get nextDayThreshold from context.nextDayThreshold
  7358. */
  7359. function sliceEvents(props, allDay) {
  7360. return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
  7361. }
  7362. var NamedTimeZoneImpl = /** @class */ (function () {
  7363. function NamedTimeZoneImpl(timeZoneName) {
  7364. this.timeZoneName = timeZoneName;
  7365. }
  7366. return NamedTimeZoneImpl;
  7367. }());
  7368. var Interaction = /** @class */ (function () {
  7369. function Interaction(settings) {
  7370. this.component = settings.component;
  7371. }
  7372. Interaction.prototype.destroy = function () {
  7373. };
  7374. return Interaction;
  7375. }());
  7376. function parseInteractionSettings(component, input) {
  7377. return {
  7378. component: component,
  7379. el: input.el,
  7380. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
  7381. };
  7382. }
  7383. function interactionSettingsToStore(settings) {
  7384. var _a;
  7385. return _a = {},
  7386. _a[settings.component.uid] = settings,
  7387. _a;
  7388. }
  7389. // global state
  7390. var interactionSettingsStore = {};
  7391. /*
  7392. An abstraction for a dragging interaction originating on an event.
  7393. Does higher-level things than PointerDragger, such as possibly:
  7394. - a "mirror" that moves with the pointer
  7395. - a minimum number of pixels or other criteria for a true drag to begin
  7396. subclasses must emit:
  7397. - pointerdown
  7398. - dragstart
  7399. - dragmove
  7400. - pointerup
  7401. - dragend
  7402. */
  7403. var ElementDragging = /** @class */ (function () {
  7404. function ElementDragging(el, selector) {
  7405. this.emitter = new Emitter();
  7406. }
  7407. ElementDragging.prototype.destroy = function () {
  7408. };
  7409. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  7410. // optional if subclass doesn't want to support a mirror
  7411. };
  7412. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  7413. // optional if subclass doesn't want to support a mirror
  7414. };
  7415. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  7416. // optional
  7417. };
  7418. return ElementDragging;
  7419. }());
  7420. // TODO: get rid of this in favor of options system,
  7421. // tho it's really easy to access this globally rather than pass thru options.
  7422. var config = {};
  7423. /*
  7424. Information about what will happen when an external element is dragged-and-dropped
  7425. onto a calendar. Contains information for creating an event.
  7426. */
  7427. var DRAG_META_REFINERS = {
  7428. startTime: createDuration,
  7429. duration: createDuration,
  7430. create: Boolean,
  7431. sourceId: String,
  7432. };
  7433. function parseDragMeta(raw) {
  7434. var _a = refineProps(raw, DRAG_META_REFINERS), refined = _a.refined, extra = _a.extra;
  7435. return {
  7436. startTime: refined.startTime || null,
  7437. duration: refined.duration || null,
  7438. create: refined.create != null ? refined.create : true,
  7439. sourceId: refined.sourceId,
  7440. leftoverProps: extra,
  7441. };
  7442. }
  7443. var ToolbarSection = /** @class */ (function (_super) {
  7444. __extends(ToolbarSection, _super);
  7445. function ToolbarSection() {
  7446. return _super !== null && _super.apply(this, arguments) || this;
  7447. }
  7448. ToolbarSection.prototype.render = function () {
  7449. var _this = this;
  7450. var children = this.props.widgetGroups.map(function (widgetGroup) { return _this.renderWidgetGroup(widgetGroup); });
  7451. return createElement.apply(void 0, __spreadArrays(['div', { className: 'fc-toolbar-chunk' }], children));
  7452. };
  7453. ToolbarSection.prototype.renderWidgetGroup = function (widgetGroup) {
  7454. var props = this.props;
  7455. var theme = this.context.theme;
  7456. var children = [];
  7457. var isOnlyButtons = true;
  7458. for (var _i = 0, widgetGroup_1 = widgetGroup; _i < widgetGroup_1.length; _i++) {
  7459. var widget = widgetGroup_1[_i];
  7460. var buttonName = widget.buttonName, buttonClick = widget.buttonClick, buttonText = widget.buttonText, buttonIcon = widget.buttonIcon;
  7461. if (buttonName === 'title') {
  7462. isOnlyButtons = false;
  7463. children.push(createElement("h2", { className: "fc-toolbar-title" }, props.title));
  7464. }
  7465. else {
  7466. var ariaAttrs = buttonIcon ? { 'aria-label': buttonName } : {};
  7467. var buttonClasses = ["fc-" + buttonName + "-button", theme.getClass('button')];
  7468. if (buttonName === props.activeButton) {
  7469. buttonClasses.push(theme.getClass('buttonActive'));
  7470. }
  7471. var isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
  7472. (!props.isPrevEnabled && buttonName === 'prev') ||
  7473. (!props.isNextEnabled && buttonName === 'next');
  7474. children.push(createElement("button", __assign({ disabled: isDisabled, className: buttonClasses.join(' '), onClick: buttonClick, type: "button" }, ariaAttrs), buttonText || (buttonIcon ? createElement("span", { className: buttonIcon }) : '')));
  7475. }
  7476. }
  7477. if (children.length > 1) {
  7478. var groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
  7479. return createElement.apply(void 0, __spreadArrays(['div', { className: groupClassName }], children));
  7480. }
  7481. return children[0];
  7482. };
  7483. return ToolbarSection;
  7484. }(BaseComponent));
  7485. var Toolbar = /** @class */ (function (_super) {
  7486. __extends(Toolbar, _super);
  7487. function Toolbar() {
  7488. return _super !== null && _super.apply(this, arguments) || this;
  7489. }
  7490. Toolbar.prototype.render = function () {
  7491. var _a = this.props, model = _a.model, extraClassName = _a.extraClassName;
  7492. var forceLtr = false;
  7493. var startContent;
  7494. var endContent;
  7495. var centerContent = model.center;
  7496. if (model.left) {
  7497. forceLtr = true;
  7498. startContent = model.left;
  7499. }
  7500. else {
  7501. startContent = model.start;
  7502. }
  7503. if (model.right) {
  7504. forceLtr = true;
  7505. endContent = model.right;
  7506. }
  7507. else {
  7508. endContent = model.end;
  7509. }
  7510. var classNames = [
  7511. extraClassName || '',
  7512. 'fc-toolbar',
  7513. forceLtr ? 'fc-toolbar-ltr' : '',
  7514. ];
  7515. return (createElement("div", { className: classNames.join(' ') },
  7516. this.renderSection('start', startContent || []),
  7517. this.renderSection('center', centerContent || []),
  7518. this.renderSection('end', endContent || [])));
  7519. };
  7520. Toolbar.prototype.renderSection = function (key, widgetGroups) {
  7521. var props = this.props;
  7522. return (createElement(ToolbarSection, { key: key, widgetGroups: widgetGroups, title: props.title, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled }));
  7523. };
  7524. return Toolbar;
  7525. }(BaseComponent));
  7526. // TODO: do function component?
  7527. var ViewContainer = /** @class */ (function (_super) {
  7528. __extends(ViewContainer, _super);
  7529. function ViewContainer() {
  7530. var _this = _super !== null && _super.apply(this, arguments) || this;
  7531. _this.state = {
  7532. availableWidth: null,
  7533. };
  7534. _this.handleEl = function (el) {
  7535. _this.el = el;
  7536. setRef(_this.props.elRef, el);
  7537. _this.updateAvailableWidth();
  7538. };
  7539. _this.handleResize = function () {
  7540. _this.updateAvailableWidth();
  7541. };
  7542. return _this;
  7543. }
  7544. ViewContainer.prototype.render = function () {
  7545. var _a = this, props = _a.props, state = _a.state;
  7546. var aspectRatio = props.aspectRatio;
  7547. var classNames = [
  7548. 'fc-view-harness',
  7549. (aspectRatio || props.liquid || props.height)
  7550. ? 'fc-view-harness-active' // harness controls the height
  7551. : 'fc-view-harness-passive',
  7552. ];
  7553. var height = '';
  7554. var paddingBottom = '';
  7555. if (aspectRatio) {
  7556. if (state.availableWidth !== null) {
  7557. height = state.availableWidth / aspectRatio;
  7558. }
  7559. else {
  7560. // while waiting to know availableWidth, we can't set height to *zero*
  7561. // because will cause lots of unnecessary scrollbars within scrollgrid.
  7562. // BETTER: don't start rendering ANYTHING yet until we know container width
  7563. // NOTE: why not always use paddingBottom? Causes height oscillation (issue 5606)
  7564. paddingBottom = (1 / aspectRatio) * 100 + "%";
  7565. }
  7566. }
  7567. else {
  7568. height = props.height || '';
  7569. }
  7570. return (createElement("div", { ref: this.handleEl, onClick: props.onClick, className: classNames.join(' '), style: { height: height, paddingBottom: paddingBottom } }, props.children));
  7571. };
  7572. ViewContainer.prototype.componentDidMount = function () {
  7573. this.context.addResizeHandler(this.handleResize);
  7574. };
  7575. ViewContainer.prototype.componentWillUnmount = function () {
  7576. this.context.removeResizeHandler(this.handleResize);
  7577. };
  7578. ViewContainer.prototype.updateAvailableWidth = function () {
  7579. if (this.el && // needed. but why?
  7580. this.props.aspectRatio // aspectRatio is the only height setting that needs availableWidth
  7581. ) {
  7582. this.setState({ availableWidth: this.el.offsetWidth });
  7583. }
  7584. };
  7585. return ViewContainer;
  7586. }(BaseComponent));
  7587. /*
  7588. Detects when the user clicks on an event within a DateComponent
  7589. */
  7590. var EventClicking = /** @class */ (function (_super) {
  7591. __extends(EventClicking, _super);
  7592. function EventClicking(settings) {
  7593. var _this = _super.call(this, settings) || this;
  7594. _this.handleSegClick = function (ev, segEl) {
  7595. var component = _this.component;
  7596. var context = component.context;
  7597. var seg = getElSeg(segEl);
  7598. if (seg && // might be the <div> surrounding the more link
  7599. component.isValidSegDownEl(ev.target)) {
  7600. // our way to simulate a link click for elements that can't be <a> tags
  7601. // grab before trigger fired in case trigger trashes DOM thru rerendering
  7602. var hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
  7603. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  7604. context.emitter.trigger('eventClick', {
  7605. el: segEl,
  7606. event: new EventApi(component.context, seg.eventRange.def, seg.eventRange.instance),
  7607. jsEvent: ev,
  7608. view: context.viewApi,
  7609. });
  7610. if (url && !ev.defaultPrevented) {
  7611. window.location.href = url;
  7612. }
  7613. }
  7614. };
  7615. _this.destroy = listenBySelector(settings.el, 'click', '.fc-event', // on both fg and bg events
  7616. _this.handleSegClick);
  7617. return _this;
  7618. }
  7619. return EventClicking;
  7620. }(Interaction));
  7621. /*
  7622. Triggers events and adds/removes core classNames when the user's pointer
  7623. enters/leaves event-elements of a component.
  7624. */
  7625. var EventHovering = /** @class */ (function (_super) {
  7626. __extends(EventHovering, _super);
  7627. function EventHovering(settings) {
  7628. var _this = _super.call(this, settings) || this;
  7629. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  7630. _this.handleEventElRemove = function (el) {
  7631. if (el === _this.currentSegEl) {
  7632. _this.handleSegLeave(null, _this.currentSegEl);
  7633. }
  7634. };
  7635. _this.handleSegEnter = function (ev, segEl) {
  7636. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  7637. _this.currentSegEl = segEl;
  7638. _this.triggerEvent('eventMouseEnter', ev, segEl);
  7639. }
  7640. };
  7641. _this.handleSegLeave = function (ev, segEl) {
  7642. if (_this.currentSegEl) {
  7643. _this.currentSegEl = null;
  7644. _this.triggerEvent('eventMouseLeave', ev, segEl);
  7645. }
  7646. };
  7647. _this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event', // on both fg and bg events
  7648. _this.handleSegEnter, _this.handleSegLeave);
  7649. return _this;
  7650. }
  7651. EventHovering.prototype.destroy = function () {
  7652. this.removeHoverListeners();
  7653. };
  7654. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  7655. var component = this.component;
  7656. var context = component.context;
  7657. var seg = getElSeg(segEl);
  7658. if (!ev || component.isValidSegDownEl(ev.target)) {
  7659. context.emitter.trigger(publicEvName, {
  7660. el: segEl,
  7661. event: new EventApi(context, seg.eventRange.def, seg.eventRange.instance),
  7662. jsEvent: ev,
  7663. view: context.viewApi,
  7664. });
  7665. }
  7666. };
  7667. return EventHovering;
  7668. }(Interaction));
  7669. var CalendarContent = /** @class */ (function (_super) {
  7670. __extends(CalendarContent, _super);
  7671. function CalendarContent() {
  7672. var _this = _super !== null && _super.apply(this, arguments) || this;
  7673. _this.buildViewContext = memoize(buildViewContext);
  7674. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  7675. _this.buildToolbarProps = memoize(buildToolbarProps);
  7676. _this.handleNavLinkClick = buildDelegationHandler('a[data-navlink]', _this._handleNavLinkClick.bind(_this));
  7677. _this.headerRef = createRef();
  7678. _this.footerRef = createRef();
  7679. _this.interactionsStore = {};
  7680. // Component Registration
  7681. // -----------------------------------------------------------------------------------------------------------------
  7682. _this.registerInteractiveComponent = function (component, settingsInput) {
  7683. var settings = parseInteractionSettings(component, settingsInput);
  7684. var DEFAULT_INTERACTIONS = [
  7685. EventClicking,
  7686. EventHovering,
  7687. ];
  7688. var interactionClasses = DEFAULT_INTERACTIONS.concat(_this.props.pluginHooks.componentInteractions);
  7689. var interactions = interactionClasses.map(function (TheInteractionClass) { return new TheInteractionClass(settings); });
  7690. _this.interactionsStore[component.uid] = interactions;
  7691. interactionSettingsStore[component.uid] = settings;
  7692. };
  7693. _this.unregisterInteractiveComponent = function (component) {
  7694. for (var _i = 0, _a = _this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7695. var listener = _a[_i];
  7696. listener.destroy();
  7697. }
  7698. delete _this.interactionsStore[component.uid];
  7699. delete interactionSettingsStore[component.uid];
  7700. };
  7701. // Resizing
  7702. // -----------------------------------------------------------------------------------------------------------------
  7703. _this.resizeRunner = new DelayedRunner(function () {
  7704. _this.props.emitter.trigger('_resize', true); // should window resizes be considered "forced" ?
  7705. _this.props.emitter.trigger('windowResize', { view: _this.props.viewApi });
  7706. });
  7707. _this.handleWindowResize = function (ev) {
  7708. var options = _this.props.options;
  7709. if (options.handleWindowResize &&
  7710. ev.target === window // avoid jqui events
  7711. ) {
  7712. _this.resizeRunner.request(options.windowResizeDelay);
  7713. }
  7714. };
  7715. return _this;
  7716. }
  7717. /*
  7718. renders INSIDE of an outer div
  7719. */
  7720. CalendarContent.prototype.render = function () {
  7721. var props = this.props;
  7722. var toolbarConfig = props.toolbarConfig, options = props.options;
  7723. var toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, getNow(props.options.now, props.dateEnv), // TODO: use NowTimer????
  7724. props.viewTitle);
  7725. var viewVGrow = false;
  7726. var viewHeight = '';
  7727. var viewAspectRatio;
  7728. if (props.isHeightAuto || props.forPrint) {
  7729. viewHeight = '';
  7730. }
  7731. else if (options.height != null) {
  7732. viewVGrow = true;
  7733. }
  7734. else if (options.contentHeight != null) {
  7735. viewHeight = options.contentHeight;
  7736. }
  7737. else {
  7738. viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
  7739. }
  7740. var viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.theme, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
  7741. return (createElement(ViewContextType.Provider, { value: viewContext },
  7742. toolbarConfig.headerToolbar && (createElement(Toolbar, __assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.headerToolbar }, toolbarProps))),
  7743. createElement(ViewContainer, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, onClick: this.handleNavLinkClick },
  7744. this.renderView(props),
  7745. this.buildAppendContent()),
  7746. toolbarConfig.footerToolbar && (createElement(Toolbar, __assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footerToolbar }, toolbarProps)))));
  7747. };
  7748. CalendarContent.prototype.componentDidMount = function () {
  7749. var props = this.props;
  7750. this.calendarInteractions = props.pluginHooks.calendarInteractions
  7751. .map(function (CalendarInteractionClass) { return new CalendarInteractionClass(props); });
  7752. window.addEventListener('resize', this.handleWindowResize);
  7753. var propSetHandlers = props.pluginHooks.propSetHandlers;
  7754. for (var propName in propSetHandlers) {
  7755. propSetHandlers[propName](props[propName], props);
  7756. }
  7757. };
  7758. CalendarContent.prototype.componentDidUpdate = function (prevProps) {
  7759. var props = this.props;
  7760. var propSetHandlers = props.pluginHooks.propSetHandlers;
  7761. for (var propName in propSetHandlers) {
  7762. if (props[propName] !== prevProps[propName]) {
  7763. propSetHandlers[propName](props[propName], props);
  7764. }
  7765. }
  7766. };
  7767. CalendarContent.prototype.componentWillUnmount = function () {
  7768. window.removeEventListener('resize', this.handleWindowResize);
  7769. this.resizeRunner.clear();
  7770. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  7771. var interaction = _a[_i];
  7772. interaction.destroy();
  7773. }
  7774. this.props.emitter.trigger('_unmount');
  7775. };
  7776. CalendarContent.prototype._handleNavLinkClick = function (ev, anchorEl) {
  7777. var _a = this.props, dateEnv = _a.dateEnv, options = _a.options, calendarApi = _a.calendarApi;
  7778. var navLinkOptions = anchorEl.getAttribute('data-navlink');
  7779. navLinkOptions = navLinkOptions ? JSON.parse(navLinkOptions) : {};
  7780. var dateMarker = dateEnv.createMarker(navLinkOptions.date);
  7781. var viewType = navLinkOptions.type;
  7782. var customAction = viewType === 'day' ? options.navLinkDayClick :
  7783. viewType === 'week' ? options.navLinkWeekClick : null;
  7784. if (typeof customAction === 'function') {
  7785. customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
  7786. }
  7787. else {
  7788. if (typeof customAction === 'string') {
  7789. viewType = customAction;
  7790. }
  7791. calendarApi.zoomTo(dateMarker, viewType);
  7792. }
  7793. };
  7794. CalendarContent.prototype.buildAppendContent = function () {
  7795. var props = this.props;
  7796. var children = props.pluginHooks.viewContainerAppends.map(function (buildAppendContent) { return buildAppendContent(props); });
  7797. return createElement.apply(void 0, __spreadArrays([Fragment, {}], children));
  7798. };
  7799. CalendarContent.prototype.renderView = function (props) {
  7800. var pluginHooks = props.pluginHooks;
  7801. var viewSpec = props.viewSpec;
  7802. var viewProps = {
  7803. dateProfile: props.dateProfile,
  7804. businessHours: props.businessHours,
  7805. eventStore: props.renderableEventStore,
  7806. eventUiBases: props.eventUiBases,
  7807. dateSelection: props.dateSelection,
  7808. eventSelection: props.eventSelection,
  7809. eventDrag: props.eventDrag,
  7810. eventResize: props.eventResize,
  7811. isHeightAuto: props.isHeightAuto,
  7812. forPrint: props.forPrint,
  7813. };
  7814. var transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
  7815. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  7816. var transformer = transformers_1[_i];
  7817. __assign(viewProps, transformer.transform(viewProps, props));
  7818. }
  7819. var ViewComponent = viewSpec.component;
  7820. return (createElement(ViewComponent, __assign({}, viewProps)));
  7821. };
  7822. return CalendarContent;
  7823. }(PureComponent));
  7824. function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
  7825. // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
  7826. var todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
  7827. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
  7828. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
  7829. return {
  7830. title: title,
  7831. activeButton: viewSpec.type,
  7832. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  7833. isPrevEnabled: prevInfo.isValid,
  7834. isNextEnabled: nextInfo.isValid,
  7835. };
  7836. }
  7837. // Plugin
  7838. // -----------------------------------------------------------------------------------------------------------------
  7839. function buildViewPropTransformers(theClasses) {
  7840. return theClasses.map(function (TheClass) { return new TheClass(); });
  7841. }
  7842. var CalendarRoot = /** @class */ (function (_super) {
  7843. __extends(CalendarRoot, _super);
  7844. function CalendarRoot() {
  7845. var _this = _super !== null && _super.apply(this, arguments) || this;
  7846. _this.state = {
  7847. forPrint: false,
  7848. };
  7849. _this.handleBeforePrint = function () {
  7850. _this.setState({ forPrint: true });
  7851. };
  7852. _this.handleAfterPrint = function () {
  7853. _this.setState({ forPrint: false });
  7854. };
  7855. return _this;
  7856. }
  7857. CalendarRoot.prototype.render = function () {
  7858. var props = this.props;
  7859. var options = props.options;
  7860. var forPrint = this.state.forPrint;
  7861. var isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
  7862. var height = (!isHeightAuto && options.height != null) ? options.height : '';
  7863. var classNames = [
  7864. 'fc',
  7865. forPrint ? 'fc-media-print' : 'fc-media-screen',
  7866. "fc-direction-" + options.direction,
  7867. props.theme.getClass('root'),
  7868. ];
  7869. if (!getCanVGrowWithinCell()) {
  7870. classNames.push('fc-liquid-hack');
  7871. }
  7872. return props.children(classNames, height, isHeightAuto, forPrint);
  7873. };
  7874. CalendarRoot.prototype.componentDidMount = function () {
  7875. var emitter = this.props.emitter;
  7876. emitter.on('_beforeprint', this.handleBeforePrint);
  7877. emitter.on('_afterprint', this.handleAfterPrint);
  7878. };
  7879. CalendarRoot.prototype.componentWillUnmount = function () {
  7880. var emitter = this.props.emitter;
  7881. emitter.off('_beforeprint', this.handleBeforePrint);
  7882. emitter.off('_afterprint', this.handleAfterPrint);
  7883. };
  7884. return CalendarRoot;
  7885. }(BaseComponent));
  7886. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  7887. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  7888. // if more than one week row, or if there are a lot of columns with not much space,
  7889. // put just the day numbers will be in each cell
  7890. if (!datesRepDistinctDays || dayCnt > 10) {
  7891. return createFormatter({ weekday: 'short' }); // "Sat"
  7892. }
  7893. if (dayCnt > 1) {
  7894. return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }); // "Sat 11/12"
  7895. }
  7896. return createFormatter({ weekday: 'long' }); // "Saturday"
  7897. }
  7898. var CLASS_NAME = 'fc-col-header-cell'; // do the cushion too? no
  7899. function renderInner(hookProps) {
  7900. return hookProps.text;
  7901. }
  7902. var TableDateCell = /** @class */ (function (_super) {
  7903. __extends(TableDateCell, _super);
  7904. function TableDateCell() {
  7905. return _super !== null && _super.apply(this, arguments) || this;
  7906. }
  7907. TableDateCell.prototype.render = function () {
  7908. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options, theme = _a.theme, viewApi = _a.viewApi;
  7909. var props = this.props;
  7910. var date = props.date, dateProfile = props.dateProfile;
  7911. var dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
  7912. var classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
  7913. var text = dateEnv.format(date, props.dayHeaderFormat);
  7914. // if colCnt is 1, we are already in a day-view and don't need a navlink
  7915. var navLinkAttrs = (options.navLinks && !dayMeta.isDisabled && props.colCnt > 1)
  7916. ? { 'data-navlink': buildNavLinkData(date), tabIndex: 0 }
  7917. : {};
  7918. var hookProps = __assign(__assign(__assign({ date: dateEnv.toDate(date), view: viewApi }, props.extraHookProps), { text: text }), dayMeta);
  7919. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-date": !dayMeta.isDisabled ? formatDayString(date) : undefined, colSpan: props.colSpan }, props.extraDataAttrs),
  7920. createElement("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && (createElement("a", __assign({ ref: innerElRef, className: [
  7921. 'fc-col-header-cell-cushion',
  7922. props.isSticky ? 'fc-sticky' : '',
  7923. ].join(' ') }, navLinkAttrs), innerContent))))); }));
  7924. };
  7925. return TableDateCell;
  7926. }(BaseComponent));
  7927. var TableDowCell = /** @class */ (function (_super) {
  7928. __extends(TableDowCell, _super);
  7929. function TableDowCell() {
  7930. return _super !== null && _super.apply(this, arguments) || this;
  7931. }
  7932. TableDowCell.prototype.render = function () {
  7933. var props = this.props;
  7934. var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, viewApi = _a.viewApi, options = _a.options;
  7935. var date = addDays(new Date(259200000), props.dow); // start with Sun, 04 Jan 1970 00:00:00 GMT
  7936. var dateMeta = {
  7937. dow: props.dow,
  7938. isDisabled: false,
  7939. isFuture: false,
  7940. isPast: false,
  7941. isToday: false,
  7942. isOther: false,
  7943. };
  7944. var classNames = [CLASS_NAME].concat(getDayClassNames(dateMeta, theme), props.extraClassNames || []);
  7945. var text = dateEnv.format(date, props.dayHeaderFormat);
  7946. var hookProps = __assign(__assign(__assign(__assign({ // TODO: make this public?
  7947. date: date }, dateMeta), { view: viewApi }), props.extraHookProps), { text: text });
  7948. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("th", __assign({ ref: rootElRef, className: classNames.concat(customClassNames).join(' '), colSpan: props.colSpan }, props.extraDataAttrs),
  7949. createElement("div", { className: "fc-scrollgrid-sync-inner" },
  7950. createElement("a", { className: [
  7951. 'fc-col-header-cell-cushion',
  7952. props.isSticky ? 'fc-sticky' : '',
  7953. ].join(' '), ref: innerElRef }, innerContent)))); }));
  7954. };
  7955. return TableDowCell;
  7956. }(BaseComponent));
  7957. var NowTimer = /** @class */ (function (_super) {
  7958. __extends(NowTimer, _super);
  7959. function NowTimer(props, context) {
  7960. var _this = _super.call(this, props, context) || this;
  7961. _this.initialNowDate = getNow(context.options.now, context.dateEnv);
  7962. _this.initialNowQueriedMs = new Date().valueOf();
  7963. _this.state = _this.computeTiming().currentState;
  7964. return _this;
  7965. }
  7966. NowTimer.prototype.render = function () {
  7967. var _a = this, props = _a.props, state = _a.state;
  7968. return props.children(state.nowDate, state.todayRange);
  7969. };
  7970. NowTimer.prototype.componentDidMount = function () {
  7971. this.setTimeout();
  7972. };
  7973. NowTimer.prototype.componentDidUpdate = function (prevProps) {
  7974. if (prevProps.unit !== this.props.unit) {
  7975. this.clearTimeout();
  7976. this.setTimeout();
  7977. }
  7978. };
  7979. NowTimer.prototype.componentWillUnmount = function () {
  7980. this.clearTimeout();
  7981. };
  7982. NowTimer.prototype.computeTiming = function () {
  7983. var _a = this, props = _a.props, context = _a.context;
  7984. var unroundedNow = addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs);
  7985. var currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
  7986. var nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
  7987. var waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
  7988. // there is a max setTimeout ms value (https://stackoverflow.com/a/3468650/96342)
  7989. // ensure no longer than a day
  7990. waitMs = Math.min(1000 * 60 * 60 * 24, waitMs);
  7991. return {
  7992. currentState: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
  7993. nextState: { nowDate: nextUnitStart, todayRange: buildDayRange(nextUnitStart) },
  7994. waitMs: waitMs,
  7995. };
  7996. };
  7997. NowTimer.prototype.setTimeout = function () {
  7998. var _this = this;
  7999. var _a = this.computeTiming(), nextState = _a.nextState, waitMs = _a.waitMs;
  8000. this.timeoutId = setTimeout(function () {
  8001. _this.setState(nextState, function () {
  8002. _this.setTimeout();
  8003. });
  8004. }, waitMs);
  8005. };
  8006. NowTimer.prototype.clearTimeout = function () {
  8007. if (this.timeoutId) {
  8008. clearTimeout(this.timeoutId);
  8009. }
  8010. };
  8011. NowTimer.contextType = ViewContextType;
  8012. return NowTimer;
  8013. }(Component));
  8014. function buildDayRange(date) {
  8015. var start = startOfDay(date);
  8016. var end = addDays(start, 1);
  8017. return { start: start, end: end };
  8018. }
  8019. var DayHeader = /** @class */ (function (_super) {
  8020. __extends(DayHeader, _super);
  8021. function DayHeader() {
  8022. var _this = _super !== null && _super.apply(this, arguments) || this;
  8023. _this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
  8024. return _this;
  8025. }
  8026. DayHeader.prototype.render = function () {
  8027. var context = this.context;
  8028. var _a = this.props, dates = _a.dates, dateProfile = _a.dateProfile, datesRepDistinctDays = _a.datesRepDistinctDays, renderIntro = _a.renderIntro;
  8029. var dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
  8030. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement("tr", null,
  8031. renderIntro && renderIntro('day'),
  8032. dates.map(function (date) { return (datesRepDistinctDays ? (createElement(TableDateCell, { key: date.toISOString(), date: date, dateProfile: dateProfile, todayRange: todayRange, colCnt: dates.length, dayHeaderFormat: dayHeaderFormat })) : (createElement(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat: dayHeaderFormat }))); }))); }));
  8033. };
  8034. return DayHeader;
  8035. }(BaseComponent));
  8036. function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
  8037. return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
  8038. }
  8039. var DaySeriesModel = /** @class */ (function () {
  8040. function DaySeriesModel(range, dateProfileGenerator) {
  8041. var date = range.start;
  8042. var end = range.end;
  8043. var indices = [];
  8044. var dates = [];
  8045. var dayIndex = -1;
  8046. while (date < end) { // loop each day from start to end
  8047. if (dateProfileGenerator.isHiddenDay(date)) {
  8048. indices.push(dayIndex + 0.5); // mark that it's between indices
  8049. }
  8050. else {
  8051. dayIndex += 1;
  8052. indices.push(dayIndex);
  8053. dates.push(date);
  8054. }
  8055. date = addDays(date, 1);
  8056. }
  8057. this.dates = dates;
  8058. this.indices = indices;
  8059. this.cnt = dates.length;
  8060. }
  8061. DaySeriesModel.prototype.sliceRange = function (range) {
  8062. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8063. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8064. var clippedFirstIndex = Math.max(0, firstIndex);
  8065. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8066. // deal with in-between indices
  8067. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8068. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8069. if (clippedFirstIndex <= clippedLastIndex) {
  8070. return {
  8071. firstIndex: clippedFirstIndex,
  8072. lastIndex: clippedLastIndex,
  8073. isStart: firstIndex === clippedFirstIndex,
  8074. isEnd: lastIndex === clippedLastIndex,
  8075. };
  8076. }
  8077. return null;
  8078. };
  8079. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8080. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8081. // If before the first offset, returns a negative number.
  8082. // If after the last offset, returns an offset past the last cell offset.
  8083. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8084. DaySeriesModel.prototype.getDateDayIndex = function (date) {
  8085. var indices = this.indices;
  8086. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8087. if (dayOffset < 0) {
  8088. return indices[0] - 1;
  8089. }
  8090. if (dayOffset >= indices.length) {
  8091. return indices[indices.length - 1] + 1;
  8092. }
  8093. return indices[dayOffset];
  8094. };
  8095. return DaySeriesModel;
  8096. }());
  8097. var DayTableModel = /** @class */ (function () {
  8098. function DayTableModel(daySeries, breakOnWeeks) {
  8099. var dates = daySeries.dates;
  8100. var daysPerRow;
  8101. var firstDay;
  8102. var rowCnt;
  8103. if (breakOnWeeks) {
  8104. // count columns until the day-of-week repeats
  8105. firstDay = dates[0].getUTCDay();
  8106. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
  8107. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8108. break;
  8109. }
  8110. }
  8111. rowCnt = Math.ceil(dates.length / daysPerRow);
  8112. }
  8113. else {
  8114. rowCnt = 1;
  8115. daysPerRow = dates.length;
  8116. }
  8117. this.rowCnt = rowCnt;
  8118. this.colCnt = daysPerRow;
  8119. this.daySeries = daySeries;
  8120. this.cells = this.buildCells();
  8121. this.headerDates = this.buildHeaderDates();
  8122. }
  8123. DayTableModel.prototype.buildCells = function () {
  8124. var rows = [];
  8125. for (var row = 0; row < this.rowCnt; row += 1) {
  8126. var cells = [];
  8127. for (var col = 0; col < this.colCnt; col += 1) {
  8128. cells.push(this.buildCell(row, col));
  8129. }
  8130. rows.push(cells);
  8131. }
  8132. return rows;
  8133. };
  8134. DayTableModel.prototype.buildCell = function (row, col) {
  8135. var date = this.daySeries.dates[row * this.colCnt + col];
  8136. return {
  8137. key: date.toISOString(),
  8138. date: date,
  8139. };
  8140. };
  8141. DayTableModel.prototype.buildHeaderDates = function () {
  8142. var dates = [];
  8143. for (var col = 0; col < this.colCnt; col += 1) {
  8144. dates.push(this.cells[0][col].date);
  8145. }
  8146. return dates;
  8147. };
  8148. DayTableModel.prototype.sliceRange = function (range) {
  8149. var colCnt = this.colCnt;
  8150. var seriesSeg = this.daySeries.sliceRange(range);
  8151. var segs = [];
  8152. if (seriesSeg) {
  8153. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8154. var index = firstIndex;
  8155. while (index <= lastIndex) {
  8156. var row = Math.floor(index / colCnt);
  8157. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8158. segs.push({
  8159. row: row,
  8160. firstCol: index % colCnt,
  8161. lastCol: (nextIndex - 1) % colCnt,
  8162. isStart: seriesSeg.isStart && index === firstIndex,
  8163. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex,
  8164. });
  8165. index = nextIndex;
  8166. }
  8167. }
  8168. return segs;
  8169. };
  8170. return DayTableModel;
  8171. }());
  8172. var Slicer = /** @class */ (function () {
  8173. function Slicer() {
  8174. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8175. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8176. this.sliceEventStore = memoize(this._sliceEventStore);
  8177. this.sliceEventDrag = memoize(this._sliceInteraction);
  8178. this.sliceEventResize = memoize(this._sliceInteraction);
  8179. this.forceDayIfListItem = false; // hack
  8180. }
  8181. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, context) {
  8182. var extraArgs = [];
  8183. for (var _i = 4; _i < arguments.length; _i++) {
  8184. extraArgs[_i - 4] = arguments[_i];
  8185. }
  8186. var eventUiBases = props.eventUiBases;
  8187. var eventSegs = this.sliceEventStore.apply(this, __spreadArrays([props.eventStore, eventUiBases, dateProfile, nextDayThreshold], extraArgs));
  8188. return {
  8189. dateSelectionSegs: this.sliceDateSelection.apply(this, __spreadArrays([props.dateSelection, eventUiBases, context], extraArgs)),
  8190. businessHourSegs: this.sliceBusinessHours.apply(this, __spreadArrays([props.businessHours, dateProfile, nextDayThreshold, context], extraArgs)),
  8191. fgEventSegs: eventSegs.fg,
  8192. bgEventSegs: eventSegs.bg,
  8193. eventDrag: this.sliceEventDrag.apply(this, __spreadArrays([props.eventDrag, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8194. eventResize: this.sliceEventResize.apply(this, __spreadArrays([props.eventResize, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8195. eventSelection: props.eventSelection,
  8196. }; // TODO: give interactionSegs?
  8197. };
  8198. Slicer.prototype.sliceNowDate = function (// does not memoize
  8199. date, context) {
  8200. var extraArgs = [];
  8201. for (var _i = 2; _i < arguments.length; _i++) {
  8202. extraArgs[_i - 2] = arguments[_i];
  8203. }
  8204. return this._sliceDateSpan.apply(this, __spreadArrays([{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8205. {},
  8206. context], extraArgs));
  8207. };
  8208. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, context) {
  8209. var extraArgs = [];
  8210. for (var _i = 4; _i < arguments.length; _i++) {
  8211. extraArgs[_i - 4] = arguments[_i];
  8212. }
  8213. if (!businessHours) {
  8214. return [];
  8215. }
  8216. return this._sliceEventStore.apply(this, __spreadArrays([expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context),
  8217. {},
  8218. dateProfile,
  8219. nextDayThreshold], extraArgs)).bg;
  8220. };
  8221. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold) {
  8222. var extraArgs = [];
  8223. for (var _i = 4; _i < arguments.length; _i++) {
  8224. extraArgs[_i - 4] = arguments[_i];
  8225. }
  8226. if (eventStore) {
  8227. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8228. return {
  8229. bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
  8230. fg: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8231. };
  8232. }
  8233. return { bg: [], fg: [] };
  8234. };
  8235. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold) {
  8236. var extraArgs = [];
  8237. for (var _i = 4; _i < arguments.length; _i++) {
  8238. extraArgs[_i - 4] = arguments[_i];
  8239. }
  8240. if (!interaction) {
  8241. return null;
  8242. }
  8243. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8244. return {
  8245. segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8246. affectedInstances: interaction.affectedEvents.instances,
  8247. isEvent: interaction.isEvent,
  8248. };
  8249. };
  8250. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, context) {
  8251. var extraArgs = [];
  8252. for (var _i = 3; _i < arguments.length; _i++) {
  8253. extraArgs[_i - 3] = arguments[_i];
  8254. }
  8255. if (!dateSpan) {
  8256. return [];
  8257. }
  8258. var eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
  8259. var segs = this.sliceRange.apply(this, __spreadArrays([dateSpan.range], extraArgs));
  8260. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8261. var seg = segs_1[_a];
  8262. seg.eventRange = eventRange;
  8263. }
  8264. return segs;
  8265. };
  8266. /*
  8267. "complete" seg means it has component and eventRange
  8268. */
  8269. Slicer.prototype.sliceEventRanges = function (eventRanges, extraArgs) {
  8270. var segs = [];
  8271. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8272. var eventRange = eventRanges_1[_i];
  8273. segs.push.apply(segs, this.sliceEventRange(eventRange, extraArgs));
  8274. }
  8275. return segs;
  8276. };
  8277. /*
  8278. "complete" seg means it has component and eventRange
  8279. */
  8280. Slicer.prototype.sliceEventRange = function (eventRange, extraArgs) {
  8281. var dateRange = eventRange.range;
  8282. // hack to make multi-day events that are being force-displayed as list-items to take up only one day
  8283. if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
  8284. dateRange = {
  8285. start: dateRange.start,
  8286. end: addDays(dateRange.start, 1),
  8287. };
  8288. }
  8289. var segs = this.sliceRange.apply(this, __spreadArrays([dateRange], extraArgs));
  8290. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8291. var seg = segs_2[_i];
  8292. seg.eventRange = eventRange;
  8293. seg.isStart = eventRange.isStart && seg.isStart;
  8294. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8295. }
  8296. return segs;
  8297. };
  8298. return Slicer;
  8299. }());
  8300. /*
  8301. for incorporating slotMinTime/slotMaxTime if appropriate
  8302. TODO: should be part of DateProfile!
  8303. TimelineDateProfile already does this btw
  8304. */
  8305. function computeActiveRange(dateProfile, isComponentAllDay) {
  8306. var range = dateProfile.activeRange;
  8307. if (isComponentAllDay) {
  8308. return range;
  8309. }
  8310. return {
  8311. start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
  8312. end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5),
  8313. };
  8314. }
  8315. var VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
  8316. var Scroller = /** @class */ (function (_super) {
  8317. __extends(Scroller, _super);
  8318. function Scroller() {
  8319. var _this = _super !== null && _super.apply(this, arguments) || this;
  8320. _this.handleEl = function (el) {
  8321. _this.el = el;
  8322. setRef(_this.props.elRef, el);
  8323. };
  8324. return _this;
  8325. }
  8326. Scroller.prototype.render = function () {
  8327. var props = this.props;
  8328. var liquid = props.liquid, liquidIsAbsolute = props.liquidIsAbsolute;
  8329. var isAbsolute = liquid && liquidIsAbsolute;
  8330. var className = ['fc-scroller'];
  8331. if (liquid) {
  8332. if (liquidIsAbsolute) {
  8333. className.push('fc-scroller-liquid-absolute');
  8334. }
  8335. else {
  8336. className.push('fc-scroller-liquid');
  8337. }
  8338. }
  8339. return (createElement("div", { ref: this.handleEl, className: className.join(' '), style: {
  8340. overflowX: props.overflowX,
  8341. overflowY: props.overflowY,
  8342. left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
  8343. right: (isAbsolute && -(props.overcomeRight || 0)) || '',
  8344. bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
  8345. marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
  8346. marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
  8347. marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
  8348. maxHeight: props.maxHeight || '',
  8349. } }, props.children));
  8350. };
  8351. Scroller.prototype.needsXScrolling = function () {
  8352. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8353. return false;
  8354. }
  8355. // testing scrollWidth>clientWidth is unreliable cross-browser when pixel heights aren't integers.
  8356. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8357. // inner-child margins and absolute positioning
  8358. var el = this.el;
  8359. var realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
  8360. var children = el.children;
  8361. for (var i = 0; i < children.length; i += 1) {
  8362. var childEl = children[i];
  8363. if (childEl.getBoundingClientRect().width > realClientWidth) {
  8364. return true;
  8365. }
  8366. }
  8367. return false;
  8368. };
  8369. Scroller.prototype.needsYScrolling = function () {
  8370. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8371. return false;
  8372. }
  8373. // testing scrollHeight>clientHeight is unreliable cross-browser when pixel heights aren't integers.
  8374. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8375. // inner-child margins and absolute positioning
  8376. var el = this.el;
  8377. var realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
  8378. var children = el.children;
  8379. for (var i = 0; i < children.length; i += 1) {
  8380. var childEl = children[i];
  8381. if (childEl.getBoundingClientRect().height > realClientHeight) {
  8382. return true;
  8383. }
  8384. }
  8385. return false;
  8386. };
  8387. Scroller.prototype.getXScrollbarWidth = function () {
  8388. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8389. return 0;
  8390. }
  8391. return this.el.offsetHeight - this.el.clientHeight; // only works because we guarantee no borders. TODO: add to CSS with important?
  8392. };
  8393. Scroller.prototype.getYScrollbarWidth = function () {
  8394. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8395. return 0;
  8396. }
  8397. return this.el.offsetWidth - this.el.clientWidth; // only works because we guarantee no borders. TODO: add to CSS with important?
  8398. };
  8399. return Scroller;
  8400. }(BaseComponent));
  8401. /*
  8402. TODO: somehow infer OtherArgs from masterCallback?
  8403. TODO: infer RefType from masterCallback if provided
  8404. */
  8405. var RefMap = /** @class */ (function () {
  8406. function RefMap(masterCallback) {
  8407. var _this = this;
  8408. this.masterCallback = masterCallback;
  8409. this.currentMap = {};
  8410. this.depths = {};
  8411. this.callbackMap = {};
  8412. this.handleValue = function (val, key) {
  8413. var _a = _this, depths = _a.depths, currentMap = _a.currentMap;
  8414. var removed = false;
  8415. var added = false;
  8416. if (val !== null) {
  8417. // for bug... ACTUALLY: can probably do away with this now that callers don't share numeric indices anymore
  8418. removed = (key in currentMap);
  8419. currentMap[key] = val;
  8420. depths[key] = (depths[key] || 0) + 1;
  8421. added = true;
  8422. }
  8423. else {
  8424. depths[key] -= 1;
  8425. if (!depths[key]) {
  8426. delete currentMap[key];
  8427. delete _this.callbackMap[key];
  8428. removed = true;
  8429. }
  8430. }
  8431. if (_this.masterCallback) {
  8432. if (removed) {
  8433. _this.masterCallback(null, String(key));
  8434. }
  8435. if (added) {
  8436. _this.masterCallback(val, String(key));
  8437. }
  8438. }
  8439. };
  8440. }
  8441. RefMap.prototype.createRef = function (key) {
  8442. var _this = this;
  8443. var refCallback = this.callbackMap[key];
  8444. if (!refCallback) {
  8445. refCallback = this.callbackMap[key] = function (val) {
  8446. _this.handleValue(val, String(key));
  8447. };
  8448. }
  8449. return refCallback;
  8450. };
  8451. // TODO: check callers that don't care about order. should use getAll instead
  8452. // NOTE: this method has become less valuable now that we are encouraged to map order by some other index
  8453. // TODO: provide ONE array-export function, buildArray, which fails on non-numeric indexes. caller can manipulate and "collect"
  8454. RefMap.prototype.collect = function (startIndex, endIndex, step) {
  8455. return collectFromHash(this.currentMap, startIndex, endIndex, step);
  8456. };
  8457. RefMap.prototype.getAll = function () {
  8458. return hashValuesToArray(this.currentMap);
  8459. };
  8460. return RefMap;
  8461. }());
  8462. function computeShrinkWidth(chunkEls) {
  8463. var shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
  8464. var largestWidth = 0;
  8465. for (var _i = 0, shrinkCells_1 = shrinkCells; _i < shrinkCells_1.length; _i++) {
  8466. var shrinkCell = shrinkCells_1[_i];
  8467. largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
  8468. }
  8469. return Math.ceil(largestWidth); // <table> elements work best with integers. round up to ensure contents fits
  8470. }
  8471. function getSectionHasLiquidHeight(props, sectionConfig) {
  8472. return props.liquid && sectionConfig.liquid; // does the section do liquid-height? (need to have whole scrollgrid liquid-height as well)
  8473. }
  8474. function getAllowYScrolling(props, sectionConfig) {
  8475. return sectionConfig.maxHeight != null || // if its possible for the height to max out, we might need scrollbars
  8476. getSectionHasLiquidHeight(props, sectionConfig); // if the section is liquid height, it might condense enough to require scrollbars
  8477. }
  8478. // TODO: ONLY use `arg`. force out internal function to use same API
  8479. function renderChunkContent(sectionConfig, chunkConfig, arg) {
  8480. var expandRows = arg.expandRows;
  8481. var content = typeof chunkConfig.content === 'function' ?
  8482. chunkConfig.content(arg) :
  8483. createElement('table', {
  8484. className: [
  8485. chunkConfig.tableClassName,
  8486. sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : '',
  8487. ].join(' '),
  8488. style: {
  8489. minWidth: arg.tableMinWidth,
  8490. width: arg.clientWidth,
  8491. height: expandRows ? arg.clientHeight : '',
  8492. },
  8493. }, arg.tableColGroupNode, createElement('tbody', {}, typeof chunkConfig.rowContent === 'function' ? chunkConfig.rowContent(arg) : chunkConfig.rowContent));
  8494. return content;
  8495. }
  8496. function isColPropsEqual(cols0, cols1) {
  8497. return isArraysEqual(cols0, cols1, isPropsEqual);
  8498. }
  8499. function renderMicroColGroup(cols, shrinkWidth) {
  8500. var colNodes = [];
  8501. /*
  8502. for ColProps with spans, it would have been great to make a single <col span="">
  8503. HOWEVER, Chrome was getting messing up distributing the width to <td>/<th> elements with colspans.
  8504. SOLUTION: making individual <col> elements makes Chrome behave.
  8505. */
  8506. for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
  8507. var colProps = cols_1[_i];
  8508. var span = colProps.span || 1;
  8509. for (var i = 0; i < span; i += 1) {
  8510. colNodes.push(createElement("col", { style: {
  8511. width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
  8512. minWidth: colProps.minWidth || '',
  8513. } }));
  8514. }
  8515. }
  8516. return createElement.apply(void 0, __spreadArrays(['colgroup', {}], colNodes));
  8517. }
  8518. function sanitizeShrinkWidth(shrinkWidth) {
  8519. /* why 4? if we do 0, it will kill any border, which are needed for computeSmallestCellWidth
  8520. 4 accounts for 2 2-pixel borders. TODO: better solution? */
  8521. return shrinkWidth == null ? 4 : shrinkWidth;
  8522. }
  8523. function hasShrinkWidth(cols) {
  8524. for (var _i = 0, cols_2 = cols; _i < cols_2.length; _i++) {
  8525. var col = cols_2[_i];
  8526. if (col.width === 'shrink') {
  8527. return true;
  8528. }
  8529. }
  8530. return false;
  8531. }
  8532. function getScrollGridClassNames(liquid, context) {
  8533. var classNames = [
  8534. 'fc-scrollgrid',
  8535. context.theme.getClass('table'),
  8536. ];
  8537. if (liquid) {
  8538. classNames.push('fc-scrollgrid-liquid');
  8539. }
  8540. return classNames;
  8541. }
  8542. function getSectionClassNames(sectionConfig, wholeTableVGrow) {
  8543. var classNames = [
  8544. 'fc-scrollgrid-section',
  8545. "fc-scrollgrid-section-" + sectionConfig.type,
  8546. sectionConfig.className,
  8547. ];
  8548. if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
  8549. classNames.push('fc-scrollgrid-section-liquid');
  8550. }
  8551. if (sectionConfig.isSticky) {
  8552. classNames.push('fc-scrollgrid-section-sticky');
  8553. }
  8554. return classNames;
  8555. }
  8556. function renderScrollShim(arg) {
  8557. return (createElement("div", { className: "fc-scrollgrid-sticky-shim", style: {
  8558. width: arg.clientWidth,
  8559. minWidth: arg.tableMinWidth,
  8560. } }));
  8561. }
  8562. function getStickyHeaderDates(options) {
  8563. var stickyHeaderDates = options.stickyHeaderDates;
  8564. if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
  8565. stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
  8566. }
  8567. return stickyHeaderDates;
  8568. }
  8569. function getStickyFooterScrollbar(options) {
  8570. var stickyFooterScrollbar = options.stickyFooterScrollbar;
  8571. if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
  8572. stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
  8573. }
  8574. return stickyFooterScrollbar;
  8575. }
  8576. var SimpleScrollGrid = /** @class */ (function (_super) {
  8577. __extends(SimpleScrollGrid, _super);
  8578. function SimpleScrollGrid() {
  8579. var _this = _super !== null && _super.apply(this, arguments) || this;
  8580. _this.processCols = memoize(function (a) { return a; }, isColPropsEqual); // so we get same `cols` props every time
  8581. // yucky to memoize VNodes, but much more efficient for consumers
  8582. _this.renderMicroColGroup = memoize(renderMicroColGroup);
  8583. _this.scrollerRefs = new RefMap();
  8584. _this.scrollerElRefs = new RefMap(_this._handleScrollerEl.bind(_this));
  8585. _this.state = {
  8586. shrinkWidth: null,
  8587. forceYScrollbars: false,
  8588. scrollerClientWidths: {},
  8589. scrollerClientHeights: {},
  8590. };
  8591. // TODO: can do a really simple print-view. dont need to join rows
  8592. _this.handleSizing = function () {
  8593. _this.setState(__assign({ shrinkWidth: _this.computeShrinkWidth() }, _this.computeScrollerDims()));
  8594. };
  8595. return _this;
  8596. }
  8597. SimpleScrollGrid.prototype.render = function () {
  8598. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  8599. var sectionConfigs = props.sections || [];
  8600. var cols = this.processCols(props.cols);
  8601. var microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
  8602. var classNames = getScrollGridClassNames(props.liquid, context);
  8603. // TODO: make DRY
  8604. var configCnt = sectionConfigs.length;
  8605. var configI = 0;
  8606. var currentConfig;
  8607. var headSectionNodes = [];
  8608. var bodySectionNodes = [];
  8609. var footSectionNodes = [];
  8610. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
  8611. headSectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8612. configI += 1;
  8613. }
  8614. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
  8615. bodySectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8616. configI += 1;
  8617. }
  8618. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
  8619. footSectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8620. configI += 1;
  8621. }
  8622. // firefox bug: when setting height on table and there is a thead or tfoot,
  8623. // the necessary height:100% on the liquid-height body section forces the *whole* table to be taller. (bug #5524)
  8624. // use getCanVGrowWithinCell as a way to detect table-stupid firefox.
  8625. // if so, use a simpler dom structure, jam everything into a lone tbody.
  8626. var isBuggy = !getCanVGrowWithinCell();
  8627. return createElement('table', {
  8628. className: classNames.join(' '),
  8629. style: { height: props.height },
  8630. }, Boolean(!isBuggy && headSectionNodes.length) && createElement.apply(void 0, __spreadArrays(['thead', {}], headSectionNodes)), Boolean(!isBuggy && bodySectionNodes.length) && createElement.apply(void 0, __spreadArrays(['tbody', {}], bodySectionNodes)), Boolean(!isBuggy && footSectionNodes.length) && createElement.apply(void 0, __spreadArrays(['tfoot', {}], footSectionNodes)), isBuggy && createElement.apply(void 0, __spreadArrays(['tbody', {}], headSectionNodes, bodySectionNodes, footSectionNodes)));
  8631. };
  8632. SimpleScrollGrid.prototype.renderSection = function (sectionConfig, sectionI, microColGroupNode) {
  8633. if ('outerContent' in sectionConfig) {
  8634. return (createElement(Fragment, { key: sectionConfig.key }, sectionConfig.outerContent));
  8635. }
  8636. return (createElement("tr", { key: sectionConfig.key, className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, sectionI, microColGroupNode, sectionConfig.chunk)));
  8637. };
  8638. SimpleScrollGrid.prototype.renderChunkTd = function (sectionConfig, sectionI, microColGroupNode, chunkConfig) {
  8639. if ('outerContent' in chunkConfig) {
  8640. return chunkConfig.outerContent;
  8641. }
  8642. var props = this.props;
  8643. var _a = this.state, forceYScrollbars = _a.forceYScrollbars, scrollerClientWidths = _a.scrollerClientWidths, scrollerClientHeights = _a.scrollerClientHeights;
  8644. var needsYScrolling = getAllowYScrolling(props, sectionConfig); // TODO: do lazily. do in section config?
  8645. var isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
  8646. // for `!props.liquid` - is WHOLE scrollgrid natural height?
  8647. // TODO: do same thing in advanced scrollgrid? prolly not b/c always has horizontal scrollbars
  8648. var overflowY = !props.liquid ? 'visible' :
  8649. forceYScrollbars ? 'scroll' :
  8650. !needsYScrolling ? 'hidden' :
  8651. 'auto';
  8652. var content = renderChunkContent(sectionConfig, chunkConfig, {
  8653. tableColGroupNode: microColGroupNode,
  8654. tableMinWidth: '',
  8655. clientWidth: scrollerClientWidths[sectionI] !== undefined ? scrollerClientWidths[sectionI] : null,
  8656. clientHeight: scrollerClientHeights[sectionI] !== undefined ? scrollerClientHeights[sectionI] : null,
  8657. expandRows: sectionConfig.expandRows,
  8658. syncRowHeights: false,
  8659. rowSyncHeights: [],
  8660. reportRowHeightChange: function () { },
  8661. });
  8662. return (createElement("td", { ref: chunkConfig.elRef },
  8663. createElement("div", { className: "fc-scroller-harness" + (isLiquid ? ' fc-scroller-harness-liquid' : '') },
  8664. createElement(Scroller, { ref: this.scrollerRefs.createRef(sectionI), elRef: this.scrollerElRefs.createRef(sectionI), overflowY: overflowY, overflowX: !props.liquid ? 'visible' : 'hidden' /* natural height? */, maxHeight: sectionConfig.maxHeight, liquid: isLiquid, liquidIsAbsolute // because its within a harness
  8665. : true }, content))));
  8666. };
  8667. SimpleScrollGrid.prototype._handleScrollerEl = function (scrollerEl, key) {
  8668. var sectionI = parseInt(key, 10);
  8669. var chunkConfig = this.props.sections[sectionI].chunk;
  8670. setRef(chunkConfig.scrollerElRef, scrollerEl);
  8671. };
  8672. SimpleScrollGrid.prototype.componentDidMount = function () {
  8673. this.handleSizing();
  8674. this.context.addResizeHandler(this.handleSizing);
  8675. };
  8676. SimpleScrollGrid.prototype.componentDidUpdate = function () {
  8677. // TODO: need better solution when state contains non-sizing things
  8678. this.handleSizing();
  8679. };
  8680. SimpleScrollGrid.prototype.componentWillUnmount = function () {
  8681. this.context.removeResizeHandler(this.handleSizing);
  8682. };
  8683. SimpleScrollGrid.prototype.computeShrinkWidth = function () {
  8684. return hasShrinkWidth(this.props.cols)
  8685. ? computeShrinkWidth(this.scrollerElRefs.getAll())
  8686. : 0;
  8687. };
  8688. SimpleScrollGrid.prototype.computeScrollerDims = function () {
  8689. var scrollbarWidth = getScrollbarWidths();
  8690. var sectionCnt = this.props.sections.length;
  8691. var _a = this, scrollerRefs = _a.scrollerRefs, scrollerElRefs = _a.scrollerElRefs;
  8692. var forceYScrollbars = false;
  8693. var scrollerClientWidths = {};
  8694. var scrollerClientHeights = {};
  8695. for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) { // along edge
  8696. var scroller = scrollerRefs.currentMap[sectionI];
  8697. if (scroller && scroller.needsYScrolling()) {
  8698. forceYScrollbars = true;
  8699. break;
  8700. }
  8701. }
  8702. for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) { // along edge
  8703. var scrollerEl = scrollerElRefs.currentMap[sectionI];
  8704. if (scrollerEl) {
  8705. var harnessEl = scrollerEl.parentNode; // TODO: weird way to get this. need harness b/c doesn't include table borders
  8706. scrollerClientWidths[sectionI] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
  8707. ? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
  8708. : 0));
  8709. scrollerClientHeights[sectionI] = Math.floor(harnessEl.getBoundingClientRect().height);
  8710. }
  8711. }
  8712. return { forceYScrollbars: forceYScrollbars, scrollerClientWidths: scrollerClientWidths, scrollerClientHeights: scrollerClientHeights };
  8713. };
  8714. return SimpleScrollGrid;
  8715. }(BaseComponent));
  8716. SimpleScrollGrid.addStateEquality({
  8717. scrollerClientWidths: isPropsEqual,
  8718. scrollerClientHeights: isPropsEqual,
  8719. });
  8720. var EventRoot = /** @class */ (function (_super) {
  8721. __extends(EventRoot, _super);
  8722. function EventRoot() {
  8723. var _this = _super !== null && _super.apply(this, arguments) || this;
  8724. _this.elRef = createRef();
  8725. return _this;
  8726. }
  8727. EventRoot.prototype.render = function () {
  8728. var _a = this, props = _a.props, context = _a.context;
  8729. var options = context.options;
  8730. var seg = props.seg;
  8731. var eventRange = seg.eventRange;
  8732. var ui = eventRange.ui;
  8733. var hookProps = {
  8734. event: new EventApi(context, eventRange.def, eventRange.instance),
  8735. view: context.viewApi,
  8736. timeText: props.timeText,
  8737. textColor: ui.textColor,
  8738. backgroundColor: ui.backgroundColor,
  8739. borderColor: ui.borderColor,
  8740. isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
  8741. isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
  8742. isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
  8743. isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
  8744. isStart: Boolean(seg.isStart),
  8745. isEnd: Boolean(seg.isEnd),
  8746. isPast: Boolean(props.isPast),
  8747. isFuture: Boolean(props.isFuture),
  8748. isToday: Boolean(props.isToday),
  8749. isSelected: Boolean(props.isSelected),
  8750. isDragging: Boolean(props.isDragging),
  8751. isResizing: Boolean(props.isResizing),
  8752. };
  8753. var standardClassNames = getEventClassNames(hookProps).concat(ui.classNames);
  8754. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.eventClassNames, content: options.eventContent, defaultContent: props.defaultContent, didMount: options.eventDidMount, willUnmount: options.eventWillUnmount, elRef: this.elRef }, function (rootElRef, customClassNames, innerElRef, innerContent) { return props.children(rootElRef, standardClassNames.concat(customClassNames), innerElRef, innerContent, hookProps); }));
  8755. };
  8756. EventRoot.prototype.componentDidMount = function () {
  8757. setElSeg(this.elRef.current, this.props.seg);
  8758. };
  8759. /*
  8760. need to re-assign seg to the element if seg changes, even if the element is the same
  8761. */
  8762. EventRoot.prototype.componentDidUpdate = function (prevProps) {
  8763. var seg = this.props.seg;
  8764. if (seg !== prevProps.seg) {
  8765. setElSeg(this.elRef.current, seg);
  8766. }
  8767. };
  8768. return EventRoot;
  8769. }(BaseComponent));
  8770. // should not be a purecomponent
  8771. var StandardEvent = /** @class */ (function (_super) {
  8772. __extends(StandardEvent, _super);
  8773. function StandardEvent() {
  8774. return _super !== null && _super.apply(this, arguments) || this;
  8775. }
  8776. StandardEvent.prototype.render = function () {
  8777. var _a = this, props = _a.props, context = _a.context;
  8778. var seg = props.seg;
  8779. var timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat;
  8780. var timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
  8781. return (createElement(EventRoot, { seg: seg, timeText: timeText, disableDragging: props.disableDragging, disableResizing: props.disableResizing, defaultContent: props.defaultContent || renderInnerContent, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("a", __assign({ className: props.extraClassNames.concat(classNames).join(' '), style: {
  8782. borderColor: hookProps.borderColor,
  8783. backgroundColor: hookProps.backgroundColor,
  8784. }, ref: rootElRef }, getSegAnchorAttrs(seg)),
  8785. createElement("div", { className: "fc-event-main", ref: innerElRef, style: { color: hookProps.textColor } }, innerContent),
  8786. hookProps.isStartResizable &&
  8787. createElement("div", { className: "fc-event-resizer fc-event-resizer-start" }),
  8788. hookProps.isEndResizable &&
  8789. createElement("div", { className: "fc-event-resizer fc-event-resizer-end" }))); }));
  8790. };
  8791. return StandardEvent;
  8792. }(BaseComponent));
  8793. function renderInnerContent(innerProps) {
  8794. return (createElement("div", { className: "fc-event-main-frame" },
  8795. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  8796. createElement("div", { className: "fc-event-title-container" },
  8797. createElement("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || createElement(Fragment, null, "\u00A0")))));
  8798. }
  8799. function getSegAnchorAttrs(seg) {
  8800. var url = seg.eventRange.def.url;
  8801. return url ? { href: url } : {};
  8802. }
  8803. var NowIndicatorRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  8804. var options = context.options;
  8805. var hookProps = {
  8806. isAxis: props.isAxis,
  8807. date: context.dateEnv.toDate(props.date),
  8808. view: context.viewApi,
  8809. };
  8810. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.nowIndicatorClassNames, content: options.nowIndicatorContent, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children));
  8811. })); };
  8812. var DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  8813. var DayCellContent = /** @class */ (function (_super) {
  8814. __extends(DayCellContent, _super);
  8815. function DayCellContent() {
  8816. return _super !== null && _super.apply(this, arguments) || this;
  8817. }
  8818. DayCellContent.prototype.render = function () {
  8819. var _a = this, props = _a.props, context = _a.context;
  8820. var options = context.options;
  8821. var hookProps = refineDayCellHookProps({
  8822. date: props.date,
  8823. dateProfile: props.dateProfile,
  8824. todayRange: props.todayRange,
  8825. showDayNumber: props.showDayNumber,
  8826. extraProps: props.extraHookProps,
  8827. viewApi: context.viewApi,
  8828. dateEnv: context.dateEnv,
  8829. });
  8830. return (createElement(ContentHook, { hookProps: hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children));
  8831. };
  8832. return DayCellContent;
  8833. }(BaseComponent));
  8834. function refineDayCellHookProps(raw) {
  8835. var date = raw.date, dateEnv = raw.dateEnv;
  8836. var dayMeta = getDateMeta(date, raw.todayRange, null, raw.dateProfile);
  8837. return __assign(__assign(__assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { dayNumberText: raw.showDayNumber ? dateEnv.format(date, DAY_NUM_FORMAT) : '' }), raw.extraProps);
  8838. }
  8839. var DayCellRoot = /** @class */ (function (_super) {
  8840. __extends(DayCellRoot, _super);
  8841. function DayCellRoot() {
  8842. var _this = _super !== null && _super.apply(this, arguments) || this;
  8843. _this.refineHookProps = memoizeObjArg(refineDayCellHookProps);
  8844. _this.normalizeClassNames = buildClassNameNormalizer();
  8845. return _this;
  8846. }
  8847. DayCellRoot.prototype.render = function () {
  8848. var _a = this, props = _a.props, context = _a.context;
  8849. var options = context.options;
  8850. var hookProps = this.refineHookProps({
  8851. date: props.date,
  8852. dateProfile: props.dateProfile,
  8853. todayRange: props.todayRange,
  8854. showDayNumber: props.showDayNumber,
  8855. extraProps: props.extraHookProps,
  8856. viewApi: context.viewApi,
  8857. dateEnv: context.dateEnv,
  8858. });
  8859. var classNames = getDayClassNames(hookProps, context.theme).concat(hookProps.isDisabled
  8860. ? [] // don't use custom classNames if disabled
  8861. : this.normalizeClassNames(options.dayCellClassNames, hookProps));
  8862. var dataAttrs = hookProps.isDisabled ? {} : {
  8863. 'data-date': formatDayString(props.date),
  8864. };
  8865. return (createElement(MountHook, { hookProps: hookProps, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, classNames, dataAttrs, hookProps.isDisabled); }));
  8866. };
  8867. return DayCellRoot;
  8868. }(BaseComponent));
  8869. function renderFill(fillType) {
  8870. return (createElement("div", { className: "fc-" + fillType }));
  8871. }
  8872. var BgEvent = function (props) { return (createElement(EventRoot, { defaultContent: renderInnerContent$1, seg: props.seg /* uselesss i think */, timeText: "", disableDragging: true, disableResizing: true, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("div", { ref: rootElRef, className: ['fc-bg-event'].concat(classNames).join(' '), style: {
  8873. backgroundColor: hookProps.backgroundColor,
  8874. } }, innerContent)); })); };
  8875. function renderInnerContent$1(props) {
  8876. var title = props.event.title;
  8877. return title && (createElement("div", { className: "fc-event-title" }, props.event.title));
  8878. }
  8879. var WeekNumberRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  8880. var dateEnv = context.dateEnv, options = context.options;
  8881. var date = props.date;
  8882. var format = options.weekNumberFormat || props.defaultFormat;
  8883. var num = dateEnv.computeWeekNumber(date); // TODO: somehow use for formatting as well?
  8884. var text = dateEnv.format(date, format);
  8885. var hookProps = { num: num, text: text, date: date };
  8886. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.weekNumberClassNames, content: options.weekNumberContent, defaultContent: renderInner$1, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children));
  8887. })); };
  8888. function renderInner$1(innerProps) {
  8889. return innerProps.text;
  8890. }
  8891. // exports
  8892. // --------------------------------------------------------------------------------------------------
  8893. var version = '5.5.0'; // important to type it, so .d.ts has generic string
  8894. var Calendar = /** @class */ (function (_super) {
  8895. __extends(Calendar, _super);
  8896. function Calendar(el, optionOverrides) {
  8897. if (optionOverrides === void 0) { optionOverrides = {}; }
  8898. var _this = _super.call(this) || this;
  8899. _this.isRendering = false;
  8900. _this.isRendered = false;
  8901. _this.currentClassNames = [];
  8902. _this.customContentRenderId = 0; // will affect custom generated classNames?
  8903. _this.handleAction = function (action) {
  8904. // actions we know we want to render immediately
  8905. switch (action.type) {
  8906. case 'SET_EVENT_DRAG':
  8907. case 'SET_EVENT_RESIZE':
  8908. _this.renderRunner.tryDrain();
  8909. }
  8910. };
  8911. _this.handleData = function (data) {
  8912. _this.currentData = data;
  8913. _this.renderRunner.request(data.calendarOptions.rerenderDelay);
  8914. };
  8915. _this.handleRenderRequest = function () {
  8916. if (_this.isRendering) {
  8917. _this.isRendered = true;
  8918. var currentData_1 = _this.currentData;
  8919. render(createElement(CalendarRoot, { options: currentData_1.calendarOptions, theme: currentData_1.theme, emitter: currentData_1.emitter }, function (classNames, height, isHeightAuto, forPrint) {
  8920. _this.setClassNames(classNames);
  8921. _this.setHeight(height);
  8922. return (createElement(CustomContentRenderContext.Provider, { value: _this.customContentRenderId },
  8923. createElement(CalendarContent, __assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData_1))));
  8924. }), _this.el);
  8925. }
  8926. else if (_this.isRendered) {
  8927. _this.isRendered = false;
  8928. unmountComponentAtNode$1(_this.el);
  8929. _this.setClassNames([]);
  8930. _this.setHeight('');
  8931. }
  8932. flushToDom$1();
  8933. };
  8934. _this.el = el;
  8935. _this.renderRunner = new DelayedRunner(_this.handleRenderRequest);
  8936. new CalendarDataManager({
  8937. optionOverrides: optionOverrides,
  8938. calendarApi: _this,
  8939. onAction: _this.handleAction,
  8940. onData: _this.handleData,
  8941. });
  8942. return _this;
  8943. }
  8944. Object.defineProperty(Calendar.prototype, "view", {
  8945. get: function () { return this.currentData.viewApi; } // for public API
  8946. ,
  8947. enumerable: false,
  8948. configurable: true
  8949. });
  8950. Calendar.prototype.render = function () {
  8951. var wasRendering = this.isRendering;
  8952. if (!wasRendering) {
  8953. this.isRendering = true;
  8954. }
  8955. else {
  8956. this.customContentRenderId += 1;
  8957. }
  8958. this.renderRunner.request();
  8959. if (wasRendering) {
  8960. this.updateSize();
  8961. }
  8962. };
  8963. Calendar.prototype.destroy = function () {
  8964. if (this.isRendering) {
  8965. this.isRendering = false;
  8966. this.renderRunner.request();
  8967. }
  8968. };
  8969. Calendar.prototype.updateSize = function () {
  8970. _super.prototype.updateSize.call(this);
  8971. flushToDom$1();
  8972. };
  8973. Calendar.prototype.batchRendering = function (func) {
  8974. this.renderRunner.pause('batchRendering');
  8975. func();
  8976. this.renderRunner.resume('batchRendering');
  8977. };
  8978. Calendar.prototype.pauseRendering = function () {
  8979. this.renderRunner.pause('pauseRendering');
  8980. };
  8981. Calendar.prototype.resumeRendering = function () {
  8982. this.renderRunner.resume('pauseRendering', true);
  8983. };
  8984. Calendar.prototype.resetOptions = function (optionOverrides, append) {
  8985. this.currentDataManager.resetOptions(optionOverrides, append);
  8986. };
  8987. Calendar.prototype.setClassNames = function (classNames) {
  8988. if (!isArraysEqual(classNames, this.currentClassNames)) {
  8989. var classList = this.el.classList;
  8990. for (var _i = 0, _a = this.currentClassNames; _i < _a.length; _i++) {
  8991. var className = _a[_i];
  8992. classList.remove(className);
  8993. }
  8994. for (var _b = 0, classNames_1 = classNames; _b < classNames_1.length; _b++) {
  8995. var className = classNames_1[_b];
  8996. classList.add(className);
  8997. }
  8998. this.currentClassNames = classNames;
  8999. }
  9000. };
  9001. Calendar.prototype.setHeight = function (height) {
  9002. applyStyleProp(this.el, 'height', height);
  9003. };
  9004. return Calendar;
  9005. }(CalendarApi));
  9006. config.touchMouseIgnoreWait = 500;
  9007. var ignoreMouseDepth = 0;
  9008. var listenerCnt = 0;
  9009. var isWindowTouchMoveCancelled = false;
  9010. /*
  9011. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  9012. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  9013. Also, tracks if there was touch-scrolling.
  9014. Also, can prevent touch-scrolling from happening.
  9015. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  9016. emits:
  9017. - pointerdown
  9018. - pointermove
  9019. - pointerup
  9020. */
  9021. var PointerDragging = /** @class */ (function () {
  9022. function PointerDragging(containerEl) {
  9023. var _this = this;
  9024. this.subjectEl = null;
  9025. // options that can be directly assigned by caller
  9026. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  9027. this.handleSelector = '';
  9028. this.shouldIgnoreMove = false;
  9029. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  9030. // internal states
  9031. this.isDragging = false;
  9032. this.isTouchDragging = false;
  9033. this.wasTouchScroll = false;
  9034. // Mouse
  9035. // ----------------------------------------------------------------------------------------------------
  9036. this.handleMouseDown = function (ev) {
  9037. if (!_this.shouldIgnoreMouse() &&
  9038. isPrimaryMouseButton(ev) &&
  9039. _this.tryStart(ev)) {
  9040. var pev = _this.createEventFromMouse(ev, true);
  9041. _this.emitter.trigger('pointerdown', pev);
  9042. _this.initScrollWatch(pev);
  9043. if (!_this.shouldIgnoreMove) {
  9044. document.addEventListener('mousemove', _this.handleMouseMove);
  9045. }
  9046. document.addEventListener('mouseup', _this.handleMouseUp);
  9047. }
  9048. };
  9049. this.handleMouseMove = function (ev) {
  9050. var pev = _this.createEventFromMouse(ev);
  9051. _this.recordCoords(pev);
  9052. _this.emitter.trigger('pointermove', pev);
  9053. };
  9054. this.handleMouseUp = function (ev) {
  9055. document.removeEventListener('mousemove', _this.handleMouseMove);
  9056. document.removeEventListener('mouseup', _this.handleMouseUp);
  9057. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  9058. _this.cleanup(); // call last so that pointerup has access to props
  9059. };
  9060. // Touch
  9061. // ----------------------------------------------------------------------------------------------------
  9062. this.handleTouchStart = function (ev) {
  9063. if (_this.tryStart(ev)) {
  9064. _this.isTouchDragging = true;
  9065. var pev = _this.createEventFromTouch(ev, true);
  9066. _this.emitter.trigger('pointerdown', pev);
  9067. _this.initScrollWatch(pev);
  9068. // unlike mouse, need to attach to target, not document
  9069. // https://stackoverflow.com/a/45760014
  9070. var targetEl = ev.target;
  9071. if (!_this.shouldIgnoreMove) {
  9072. targetEl.addEventListener('touchmove', _this.handleTouchMove);
  9073. }
  9074. targetEl.addEventListener('touchend', _this.handleTouchEnd);
  9075. targetEl.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  9076. // attach a handler to get called when ANY scroll action happens on the page.
  9077. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  9078. // http://stackoverflow.com/a/32954565/96342
  9079. window.addEventListener('scroll', _this.handleTouchScroll, true);
  9080. }
  9081. };
  9082. this.handleTouchMove = function (ev) {
  9083. var pev = _this.createEventFromTouch(ev);
  9084. _this.recordCoords(pev);
  9085. _this.emitter.trigger('pointermove', pev);
  9086. };
  9087. this.handleTouchEnd = function (ev) {
  9088. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  9089. var targetEl = ev.target;
  9090. targetEl.removeEventListener('touchmove', _this.handleTouchMove);
  9091. targetEl.removeEventListener('touchend', _this.handleTouchEnd);
  9092. targetEl.removeEventListener('touchcancel', _this.handleTouchEnd);
  9093. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  9094. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  9095. _this.cleanup(); // call last so that pointerup has access to props
  9096. _this.isTouchDragging = false;
  9097. startIgnoringMouse();
  9098. }
  9099. };
  9100. this.handleTouchScroll = function () {
  9101. _this.wasTouchScroll = true;
  9102. };
  9103. this.handleScroll = function (ev) {
  9104. if (!_this.shouldIgnoreMove) {
  9105. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  9106. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  9107. _this.emitter.trigger('pointermove', {
  9108. origEvent: ev,
  9109. isTouch: _this.isTouchDragging,
  9110. subjectEl: _this.subjectEl,
  9111. pageX: pageX,
  9112. pageY: pageY,
  9113. deltaX: pageX - _this.origPageX,
  9114. deltaY: pageY - _this.origPageY,
  9115. });
  9116. }
  9117. };
  9118. this.containerEl = containerEl;
  9119. this.emitter = new Emitter();
  9120. containerEl.addEventListener('mousedown', this.handleMouseDown);
  9121. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  9122. listenerCreated();
  9123. }
  9124. PointerDragging.prototype.destroy = function () {
  9125. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  9126. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  9127. listenerDestroyed();
  9128. };
  9129. PointerDragging.prototype.tryStart = function (ev) {
  9130. var subjectEl = this.querySubjectEl(ev);
  9131. var downEl = ev.target;
  9132. if (subjectEl &&
  9133. (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
  9134. this.subjectEl = subjectEl;
  9135. this.isDragging = true; // do this first so cancelTouchScroll will work
  9136. this.wasTouchScroll = false;
  9137. return true;
  9138. }
  9139. return false;
  9140. };
  9141. PointerDragging.prototype.cleanup = function () {
  9142. isWindowTouchMoveCancelled = false;
  9143. this.isDragging = false;
  9144. this.subjectEl = null;
  9145. // keep wasTouchScroll around for later access
  9146. this.destroyScrollWatch();
  9147. };
  9148. PointerDragging.prototype.querySubjectEl = function (ev) {
  9149. if (this.selector) {
  9150. return elementClosest(ev.target, this.selector);
  9151. }
  9152. return this.containerEl;
  9153. };
  9154. PointerDragging.prototype.shouldIgnoreMouse = function () {
  9155. return ignoreMouseDepth || this.isTouchDragging;
  9156. };
  9157. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  9158. PointerDragging.prototype.cancelTouchScroll = function () {
  9159. if (this.isDragging) {
  9160. isWindowTouchMoveCancelled = true;
  9161. }
  9162. };
  9163. // Scrolling that simulates pointermoves
  9164. // ----------------------------------------------------------------------------------------------------
  9165. PointerDragging.prototype.initScrollWatch = function (ev) {
  9166. if (this.shouldWatchScroll) {
  9167. this.recordCoords(ev);
  9168. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  9169. }
  9170. };
  9171. PointerDragging.prototype.recordCoords = function (ev) {
  9172. if (this.shouldWatchScroll) {
  9173. this.prevPageX = ev.pageX;
  9174. this.prevPageY = ev.pageY;
  9175. this.prevScrollX = window.pageXOffset;
  9176. this.prevScrollY = window.pageYOffset;
  9177. }
  9178. };
  9179. PointerDragging.prototype.destroyScrollWatch = function () {
  9180. if (this.shouldWatchScroll) {
  9181. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  9182. }
  9183. };
  9184. // Event Normalization
  9185. // ----------------------------------------------------------------------------------------------------
  9186. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  9187. var deltaX = 0;
  9188. var deltaY = 0;
  9189. // TODO: repeat code
  9190. if (isFirst) {
  9191. this.origPageX = ev.pageX;
  9192. this.origPageY = ev.pageY;
  9193. }
  9194. else {
  9195. deltaX = ev.pageX - this.origPageX;
  9196. deltaY = ev.pageY - this.origPageY;
  9197. }
  9198. return {
  9199. origEvent: ev,
  9200. isTouch: false,
  9201. subjectEl: this.subjectEl,
  9202. pageX: ev.pageX,
  9203. pageY: ev.pageY,
  9204. deltaX: deltaX,
  9205. deltaY: deltaY,
  9206. };
  9207. };
  9208. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  9209. var touches = ev.touches;
  9210. var pageX;
  9211. var pageY;
  9212. var deltaX = 0;
  9213. var deltaY = 0;
  9214. // if touch coords available, prefer,
  9215. // because FF would give bad ev.pageX ev.pageY
  9216. if (touches && touches.length) {
  9217. pageX = touches[0].pageX;
  9218. pageY = touches[0].pageY;
  9219. }
  9220. else {
  9221. pageX = ev.pageX;
  9222. pageY = ev.pageY;
  9223. }
  9224. // TODO: repeat code
  9225. if (isFirst) {
  9226. this.origPageX = pageX;
  9227. this.origPageY = pageY;
  9228. }
  9229. else {
  9230. deltaX = pageX - this.origPageX;
  9231. deltaY = pageY - this.origPageY;
  9232. }
  9233. return {
  9234. origEvent: ev,
  9235. isTouch: true,
  9236. subjectEl: this.subjectEl,
  9237. pageX: pageX,
  9238. pageY: pageY,
  9239. deltaX: deltaX,
  9240. deltaY: deltaY,
  9241. };
  9242. };
  9243. return PointerDragging;
  9244. }());
  9245. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  9246. function isPrimaryMouseButton(ev) {
  9247. return ev.button === 0 && !ev.ctrlKey;
  9248. }
  9249. // Ignoring fake mouse events generated by touch
  9250. // ----------------------------------------------------------------------------------------------------
  9251. function startIgnoringMouse() {
  9252. ignoreMouseDepth += 1;
  9253. setTimeout(function () {
  9254. ignoreMouseDepth -= 1;
  9255. }, config.touchMouseIgnoreWait);
  9256. }
  9257. // We want to attach touchmove as early as possible for Safari
  9258. // ----------------------------------------------------------------------------------------------------
  9259. function listenerCreated() {
  9260. listenerCnt += 1;
  9261. if (listenerCnt === 1) {
  9262. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  9263. }
  9264. }
  9265. function listenerDestroyed() {
  9266. listenerCnt -= 1;
  9267. if (!listenerCnt) {
  9268. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  9269. }
  9270. }
  9271. function onWindowTouchMove(ev) {
  9272. if (isWindowTouchMoveCancelled) {
  9273. ev.preventDefault();
  9274. }
  9275. }
  9276. /*
  9277. An effect in which an element follows the movement of a pointer across the screen.
  9278. The moving element is a clone of some other element.
  9279. Must call start + handleMove + stop.
  9280. */
  9281. var ElementMirror = /** @class */ (function () {
  9282. function ElementMirror() {
  9283. this.isVisible = false; // must be explicitly enabled
  9284. this.sourceEl = null;
  9285. this.mirrorEl = null;
  9286. this.sourceElRect = null; // screen coords relative to viewport
  9287. // options that can be set directly by caller
  9288. this.parentNode = document.body;
  9289. this.zIndex = 9999;
  9290. this.revertDuration = 0;
  9291. }
  9292. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  9293. this.sourceEl = sourceEl;
  9294. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  9295. this.origScreenX = pageX - window.pageXOffset;
  9296. this.origScreenY = pageY - window.pageYOffset;
  9297. this.deltaX = 0;
  9298. this.deltaY = 0;
  9299. this.updateElPosition();
  9300. };
  9301. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  9302. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  9303. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  9304. this.updateElPosition();
  9305. };
  9306. // can be called before start
  9307. ElementMirror.prototype.setIsVisible = function (bool) {
  9308. if (bool) {
  9309. if (!this.isVisible) {
  9310. if (this.mirrorEl) {
  9311. this.mirrorEl.style.display = '';
  9312. }
  9313. this.isVisible = bool; // needs to happen before updateElPosition
  9314. this.updateElPosition(); // because was not updating the position while invisible
  9315. }
  9316. }
  9317. else if (this.isVisible) {
  9318. if (this.mirrorEl) {
  9319. this.mirrorEl.style.display = 'none';
  9320. }
  9321. this.isVisible = bool;
  9322. }
  9323. };
  9324. // always async
  9325. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  9326. var _this = this;
  9327. var done = function () {
  9328. _this.cleanup();
  9329. callback();
  9330. };
  9331. if (needsRevertAnimation &&
  9332. this.mirrorEl &&
  9333. this.isVisible &&
  9334. this.revertDuration && // if 0, transition won't work
  9335. (this.deltaX || this.deltaY) // if same coords, transition won't work
  9336. ) {
  9337. this.doRevertAnimation(done, this.revertDuration);
  9338. }
  9339. else {
  9340. setTimeout(done, 0);
  9341. }
  9342. };
  9343. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  9344. var mirrorEl = this.mirrorEl;
  9345. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  9346. mirrorEl.style.transition =
  9347. 'top ' + revertDuration + 'ms,' +
  9348. 'left ' + revertDuration + 'ms';
  9349. applyStyle(mirrorEl, {
  9350. left: finalSourceElRect.left,
  9351. top: finalSourceElRect.top,
  9352. });
  9353. whenTransitionDone(mirrorEl, function () {
  9354. mirrorEl.style.transition = '';
  9355. callback();
  9356. });
  9357. };
  9358. ElementMirror.prototype.cleanup = function () {
  9359. if (this.mirrorEl) {
  9360. removeElement(this.mirrorEl);
  9361. this.mirrorEl = null;
  9362. }
  9363. this.sourceEl = null;
  9364. };
  9365. ElementMirror.prototype.updateElPosition = function () {
  9366. if (this.sourceEl && this.isVisible) {
  9367. applyStyle(this.getMirrorEl(), {
  9368. left: this.sourceElRect.left + this.deltaX,
  9369. top: this.sourceElRect.top + this.deltaY,
  9370. });
  9371. }
  9372. };
  9373. ElementMirror.prototype.getMirrorEl = function () {
  9374. var sourceElRect = this.sourceElRect;
  9375. var mirrorEl = this.mirrorEl;
  9376. if (!mirrorEl) {
  9377. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  9378. // we don't want long taps or any mouse interaction causing selection/menus.
  9379. // would use preventSelection(), but that prevents selectstart, causing problems.
  9380. mirrorEl.classList.add('fc-unselectable');
  9381. mirrorEl.classList.add('fc-event-dragging');
  9382. applyStyle(mirrorEl, {
  9383. position: 'fixed',
  9384. zIndex: this.zIndex,
  9385. visibility: '',
  9386. boxSizing: 'border-box',
  9387. width: sourceElRect.right - sourceElRect.left,
  9388. height: sourceElRect.bottom - sourceElRect.top,
  9389. right: 'auto',
  9390. bottom: 'auto',
  9391. margin: 0,
  9392. });
  9393. this.parentNode.appendChild(mirrorEl);
  9394. }
  9395. return mirrorEl;
  9396. };
  9397. return ElementMirror;
  9398. }());
  9399. /*
  9400. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  9401. in addition the "client rectangle" of the element.. the area within the scrollbars.
  9402. The cache can be in one of two modes:
  9403. - doesListening:false - ignores when the container is scrolled by someone else
  9404. - doesListening:true - watch for scrolling and update the cache
  9405. */
  9406. var ScrollGeomCache = /** @class */ (function (_super) {
  9407. __extends(ScrollGeomCache, _super);
  9408. function ScrollGeomCache(scrollController, doesListening) {
  9409. var _this = _super.call(this) || this;
  9410. _this.handleScroll = function () {
  9411. _this.scrollTop = _this.scrollController.getScrollTop();
  9412. _this.scrollLeft = _this.scrollController.getScrollLeft();
  9413. _this.handleScrollChange();
  9414. };
  9415. _this.scrollController = scrollController;
  9416. _this.doesListening = doesListening;
  9417. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  9418. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  9419. _this.scrollWidth = scrollController.getScrollWidth();
  9420. _this.scrollHeight = scrollController.getScrollHeight();
  9421. _this.clientWidth = scrollController.getClientWidth();
  9422. _this.clientHeight = scrollController.getClientHeight();
  9423. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  9424. if (_this.doesListening) {
  9425. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  9426. }
  9427. return _this;
  9428. }
  9429. ScrollGeomCache.prototype.destroy = function () {
  9430. if (this.doesListening) {
  9431. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  9432. }
  9433. };
  9434. ScrollGeomCache.prototype.getScrollTop = function () {
  9435. return this.scrollTop;
  9436. };
  9437. ScrollGeomCache.prototype.getScrollLeft = function () {
  9438. return this.scrollLeft;
  9439. };
  9440. ScrollGeomCache.prototype.setScrollTop = function (top) {
  9441. this.scrollController.setScrollTop(top);
  9442. if (!this.doesListening) {
  9443. // we are not relying on the element to normalize out-of-bounds scroll values
  9444. // so we need to sanitize ourselves
  9445. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  9446. this.handleScrollChange();
  9447. }
  9448. };
  9449. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  9450. this.scrollController.setScrollLeft(top);
  9451. if (!this.doesListening) {
  9452. // we are not relying on the element to normalize out-of-bounds scroll values
  9453. // so we need to sanitize ourselves
  9454. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  9455. this.handleScrollChange();
  9456. }
  9457. };
  9458. ScrollGeomCache.prototype.getClientWidth = function () {
  9459. return this.clientWidth;
  9460. };
  9461. ScrollGeomCache.prototype.getClientHeight = function () {
  9462. return this.clientHeight;
  9463. };
  9464. ScrollGeomCache.prototype.getScrollWidth = function () {
  9465. return this.scrollWidth;
  9466. };
  9467. ScrollGeomCache.prototype.getScrollHeight = function () {
  9468. return this.scrollHeight;
  9469. };
  9470. ScrollGeomCache.prototype.handleScrollChange = function () {
  9471. };
  9472. return ScrollGeomCache;
  9473. }(ScrollController));
  9474. var ElementScrollGeomCache = /** @class */ (function (_super) {
  9475. __extends(ElementScrollGeomCache, _super);
  9476. function ElementScrollGeomCache(el, doesListening) {
  9477. return _super.call(this, new ElementScrollController(el), doesListening) || this;
  9478. }
  9479. ElementScrollGeomCache.prototype.getEventTarget = function () {
  9480. return this.scrollController.el;
  9481. };
  9482. ElementScrollGeomCache.prototype.computeClientRect = function () {
  9483. return computeInnerRect(this.scrollController.el);
  9484. };
  9485. return ElementScrollGeomCache;
  9486. }(ScrollGeomCache));
  9487. var WindowScrollGeomCache = /** @class */ (function (_super) {
  9488. __extends(WindowScrollGeomCache, _super);
  9489. function WindowScrollGeomCache(doesListening) {
  9490. return _super.call(this, new WindowScrollController(), doesListening) || this;
  9491. }
  9492. WindowScrollGeomCache.prototype.getEventTarget = function () {
  9493. return window;
  9494. };
  9495. WindowScrollGeomCache.prototype.computeClientRect = function () {
  9496. return {
  9497. left: this.scrollLeft,
  9498. right: this.scrollLeft + this.clientWidth,
  9499. top: this.scrollTop,
  9500. bottom: this.scrollTop + this.clientHeight,
  9501. };
  9502. };
  9503. // the window is the only scroll object that changes it's rectangle relative
  9504. // to the document's topleft as it scrolls
  9505. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  9506. this.clientRect = this.computeClientRect();
  9507. };
  9508. return WindowScrollGeomCache;
  9509. }(ScrollGeomCache));
  9510. // If available we are using native "performance" API instead of "Date"
  9511. // Read more about it on MDN:
  9512. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  9513. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  9514. /*
  9515. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  9516. approaches the edge.
  9517. The caller must call start + handleMove + stop.
  9518. */
  9519. var AutoScroller = /** @class */ (function () {
  9520. function AutoScroller() {
  9521. var _this = this;
  9522. // options that can be set by caller
  9523. this.isEnabled = true;
  9524. this.scrollQuery = [window, '.fc-scroller'];
  9525. this.edgeThreshold = 50; // pixels
  9526. this.maxVelocity = 300; // pixels per second
  9527. // internal state
  9528. this.pointerScreenX = null;
  9529. this.pointerScreenY = null;
  9530. this.isAnimating = false;
  9531. this.scrollCaches = null;
  9532. // protect against the initial pointerdown being too close to an edge and starting the scroll
  9533. this.everMovedUp = false;
  9534. this.everMovedDown = false;
  9535. this.everMovedLeft = false;
  9536. this.everMovedRight = false;
  9537. this.animate = function () {
  9538. if (_this.isAnimating) { // wasn't cancelled between animation calls
  9539. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  9540. if (edge) {
  9541. var now = getTime();
  9542. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  9543. _this.requestAnimation(now);
  9544. }
  9545. else {
  9546. _this.isAnimating = false; // will stop animation
  9547. }
  9548. }
  9549. };
  9550. }
  9551. AutoScroller.prototype.start = function (pageX, pageY) {
  9552. if (this.isEnabled) {
  9553. this.scrollCaches = this.buildCaches();
  9554. this.pointerScreenX = null;
  9555. this.pointerScreenY = null;
  9556. this.everMovedUp = false;
  9557. this.everMovedDown = false;
  9558. this.everMovedLeft = false;
  9559. this.everMovedRight = false;
  9560. this.handleMove(pageX, pageY);
  9561. }
  9562. };
  9563. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  9564. if (this.isEnabled) {
  9565. var pointerScreenX = pageX - window.pageXOffset;
  9566. var pointerScreenY = pageY - window.pageYOffset;
  9567. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  9568. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  9569. if (yDelta < 0) {
  9570. this.everMovedUp = true;
  9571. }
  9572. else if (yDelta > 0) {
  9573. this.everMovedDown = true;
  9574. }
  9575. if (xDelta < 0) {
  9576. this.everMovedLeft = true;
  9577. }
  9578. else if (xDelta > 0) {
  9579. this.everMovedRight = true;
  9580. }
  9581. this.pointerScreenX = pointerScreenX;
  9582. this.pointerScreenY = pointerScreenY;
  9583. if (!this.isAnimating) {
  9584. this.isAnimating = true;
  9585. this.requestAnimation(getTime());
  9586. }
  9587. }
  9588. };
  9589. AutoScroller.prototype.stop = function () {
  9590. if (this.isEnabled) {
  9591. this.isAnimating = false; // will stop animation
  9592. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9593. var scrollCache = _a[_i];
  9594. scrollCache.destroy();
  9595. }
  9596. this.scrollCaches = null;
  9597. }
  9598. };
  9599. AutoScroller.prototype.requestAnimation = function (now) {
  9600. this.msSinceRequest = now;
  9601. requestAnimationFrame(this.animate);
  9602. };
  9603. AutoScroller.prototype.handleSide = function (edge, seconds) {
  9604. var scrollCache = edge.scrollCache;
  9605. var edgeThreshold = this.edgeThreshold;
  9606. var invDistance = edgeThreshold - edge.distance;
  9607. var velocity = // the closer to the edge, the faster we scroll
  9608. ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
  9609. this.maxVelocity * seconds;
  9610. var sign = 1;
  9611. switch (edge.name) {
  9612. case 'left':
  9613. sign = -1;
  9614. // falls through
  9615. case 'right':
  9616. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  9617. break;
  9618. case 'top':
  9619. sign = -1;
  9620. // falls through
  9621. case 'bottom':
  9622. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  9623. break;
  9624. }
  9625. };
  9626. // left/top are relative to document topleft
  9627. AutoScroller.prototype.computeBestEdge = function (left, top) {
  9628. var edgeThreshold = this.edgeThreshold;
  9629. var bestSide = null;
  9630. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9631. var scrollCache = _a[_i];
  9632. var rect = scrollCache.clientRect;
  9633. var leftDist = left - rect.left;
  9634. var rightDist = rect.right - left;
  9635. var topDist = top - rect.top;
  9636. var bottomDist = rect.bottom - top;
  9637. // completely within the rect?
  9638. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  9639. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  9640. (!bestSide || bestSide.distance > topDist)) {
  9641. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  9642. }
  9643. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  9644. (!bestSide || bestSide.distance > bottomDist)) {
  9645. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  9646. }
  9647. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  9648. (!bestSide || bestSide.distance > leftDist)) {
  9649. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  9650. }
  9651. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  9652. (!bestSide || bestSide.distance > rightDist)) {
  9653. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  9654. }
  9655. }
  9656. }
  9657. return bestSide;
  9658. };
  9659. AutoScroller.prototype.buildCaches = function () {
  9660. return this.queryScrollEls().map(function (el) {
  9661. if (el === window) {
  9662. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  9663. }
  9664. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  9665. });
  9666. };
  9667. AutoScroller.prototype.queryScrollEls = function () {
  9668. var els = [];
  9669. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  9670. var query = _a[_i];
  9671. if (typeof query === 'object') {
  9672. els.push(query);
  9673. }
  9674. else {
  9675. els.push.apply(els, Array.prototype.slice.call(document.querySelectorAll(query)));
  9676. }
  9677. }
  9678. return els;
  9679. };
  9680. return AutoScroller;
  9681. }());
  9682. /*
  9683. Monitors dragging on an element. Has a number of high-level features:
  9684. - minimum distance required before dragging
  9685. - minimum wait time ("delay") before dragging
  9686. - a mirror element that follows the pointer
  9687. */
  9688. var FeaturefulElementDragging = /** @class */ (function (_super) {
  9689. __extends(FeaturefulElementDragging, _super);
  9690. function FeaturefulElementDragging(containerEl, selector) {
  9691. var _this = _super.call(this, containerEl) || this;
  9692. // options that can be directly set by caller
  9693. // the caller can also set the PointerDragging's options as well
  9694. _this.delay = null;
  9695. _this.minDistance = 0;
  9696. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  9697. _this.mirrorNeedsRevert = false;
  9698. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  9699. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  9700. _this.isDelayEnded = false;
  9701. _this.isDistanceSurpassed = false;
  9702. _this.delayTimeoutId = null;
  9703. _this.onPointerDown = function (ev) {
  9704. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  9705. _this.isInteracting = true;
  9706. _this.isDelayEnded = false;
  9707. _this.isDistanceSurpassed = false;
  9708. preventSelection(document.body);
  9709. preventContextMenu(document.body);
  9710. // prevent links from being visited if there's an eventual drag.
  9711. // also prevents selection in older browsers (maybe?).
  9712. // not necessary for touch, besides, browser would complain about passiveness.
  9713. if (!ev.isTouch) {
  9714. ev.origEvent.preventDefault();
  9715. }
  9716. _this.emitter.trigger('pointerdown', ev);
  9717. if (_this.isInteracting && // not destroyed via pointerdown handler
  9718. !_this.pointer.shouldIgnoreMove) {
  9719. // actions related to initiating dragstart+dragmove+dragend...
  9720. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  9721. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  9722. _this.startDelay(ev);
  9723. if (!_this.minDistance) {
  9724. _this.handleDistanceSurpassed(ev);
  9725. }
  9726. }
  9727. }
  9728. };
  9729. _this.onPointerMove = function (ev) {
  9730. if (_this.isInteracting) {
  9731. _this.emitter.trigger('pointermove', ev);
  9732. if (!_this.isDistanceSurpassed) {
  9733. var minDistance = _this.minDistance;
  9734. var distanceSq = void 0; // current distance from the origin, squared
  9735. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  9736. distanceSq = deltaX * deltaX + deltaY * deltaY;
  9737. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  9738. _this.handleDistanceSurpassed(ev);
  9739. }
  9740. }
  9741. if (_this.isDragging) {
  9742. // a real pointer move? (not one simulated by scrolling)
  9743. if (ev.origEvent.type !== 'scroll') {
  9744. _this.mirror.handleMove(ev.pageX, ev.pageY);
  9745. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  9746. }
  9747. _this.emitter.trigger('dragmove', ev);
  9748. }
  9749. }
  9750. };
  9751. _this.onPointerUp = function (ev) {
  9752. if (_this.isInteracting) {
  9753. _this.isInteracting = false;
  9754. allowSelection(document.body);
  9755. allowContextMenu(document.body);
  9756. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  9757. if (_this.isDragging) {
  9758. _this.autoScroller.stop();
  9759. _this.tryStopDrag(ev); // which will stop the mirror
  9760. }
  9761. if (_this.delayTimeoutId) {
  9762. clearTimeout(_this.delayTimeoutId);
  9763. _this.delayTimeoutId = null;
  9764. }
  9765. }
  9766. };
  9767. var pointer = _this.pointer = new PointerDragging(containerEl);
  9768. pointer.emitter.on('pointerdown', _this.onPointerDown);
  9769. pointer.emitter.on('pointermove', _this.onPointerMove);
  9770. pointer.emitter.on('pointerup', _this.onPointerUp);
  9771. if (selector) {
  9772. pointer.selector = selector;
  9773. }
  9774. _this.mirror = new ElementMirror();
  9775. _this.autoScroller = new AutoScroller();
  9776. return _this;
  9777. }
  9778. FeaturefulElementDragging.prototype.destroy = function () {
  9779. this.pointer.destroy();
  9780. // HACK: simulate a pointer-up to end the current drag
  9781. // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
  9782. this.onPointerUp({});
  9783. };
  9784. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  9785. var _this = this;
  9786. if (typeof this.delay === 'number') {
  9787. this.delayTimeoutId = setTimeout(function () {
  9788. _this.delayTimeoutId = null;
  9789. _this.handleDelayEnd(ev);
  9790. }, this.delay); // not assignable to number!
  9791. }
  9792. else {
  9793. this.handleDelayEnd(ev);
  9794. }
  9795. };
  9796. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  9797. this.isDelayEnded = true;
  9798. this.tryStartDrag(ev);
  9799. };
  9800. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  9801. this.isDistanceSurpassed = true;
  9802. this.tryStartDrag(ev);
  9803. };
  9804. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  9805. if (this.isDelayEnded && this.isDistanceSurpassed) {
  9806. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  9807. this.isDragging = true;
  9808. this.mirrorNeedsRevert = false;
  9809. this.autoScroller.start(ev.pageX, ev.pageY);
  9810. this.emitter.trigger('dragstart', ev);
  9811. if (this.touchScrollAllowed === false) {
  9812. this.pointer.cancelTouchScroll();
  9813. }
  9814. }
  9815. }
  9816. };
  9817. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  9818. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  9819. // that come from the document to fire beforehand. much more convenient this way.
  9820. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
  9821. };
  9822. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  9823. this.isDragging = false;
  9824. this.emitter.trigger('dragend', ev);
  9825. };
  9826. // fill in the implementations...
  9827. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  9828. this.pointer.shouldIgnoreMove = bool;
  9829. };
  9830. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  9831. this.mirror.setIsVisible(bool);
  9832. };
  9833. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  9834. this.mirrorNeedsRevert = bool;
  9835. };
  9836. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  9837. this.autoScroller.isEnabled = bool;
  9838. };
  9839. return FeaturefulElementDragging;
  9840. }(ElementDragging));
  9841. /*
  9842. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  9843. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  9844. Does not access the DOM after instantiation, so highly performant.
  9845. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  9846. and an determine if a given point is inside the combined clipping rectangle.
  9847. */
  9848. var OffsetTracker = /** @class */ (function () {
  9849. function OffsetTracker(el) {
  9850. this.origRect = computeRect(el);
  9851. // will work fine for divs that have overflow:hidden
  9852. this.scrollCaches = getClippingParents(el).map(function (scrollEl) { return new ElementScrollGeomCache(scrollEl, true); });
  9853. }
  9854. OffsetTracker.prototype.destroy = function () {
  9855. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9856. var scrollCache = _a[_i];
  9857. scrollCache.destroy();
  9858. }
  9859. };
  9860. OffsetTracker.prototype.computeLeft = function () {
  9861. var left = this.origRect.left;
  9862. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9863. var scrollCache = _a[_i];
  9864. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  9865. }
  9866. return left;
  9867. };
  9868. OffsetTracker.prototype.computeTop = function () {
  9869. var top = this.origRect.top;
  9870. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9871. var scrollCache = _a[_i];
  9872. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  9873. }
  9874. return top;
  9875. };
  9876. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  9877. var point = { left: pageX, top: pageY };
  9878. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9879. var scrollCache = _a[_i];
  9880. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  9881. !pointInsideRect(point, scrollCache.clientRect)) {
  9882. return false;
  9883. }
  9884. }
  9885. return true;
  9886. };
  9887. return OffsetTracker;
  9888. }());
  9889. // certain clipping containers should never constrain interactions, like <html> and <body>
  9890. // https://github.com/fullcalendar/fullcalendar/issues/3615
  9891. function isIgnoredClipping(node) {
  9892. var tagName = node.tagName;
  9893. return tagName === 'HTML' || tagName === 'BODY';
  9894. }
  9895. /*
  9896. Tracks movement over multiple droppable areas (aka "hits")
  9897. that exist in one or more DateComponents.
  9898. Relies on an existing draggable.
  9899. emits:
  9900. - pointerdown
  9901. - dragstart
  9902. - hitchange - fires initially, even if not over a hit
  9903. - pointerup
  9904. - (hitchange - again, to null, if ended over a hit)
  9905. - dragend
  9906. */
  9907. var HitDragging = /** @class */ (function () {
  9908. function HitDragging(dragging, droppableStore) {
  9909. var _this = this;
  9910. // options that can be set by caller
  9911. this.useSubjectCenter = false;
  9912. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  9913. this.initialHit = null;
  9914. this.movingHit = null;
  9915. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  9916. this.handlePointerDown = function (ev) {
  9917. var dragging = _this.dragging;
  9918. _this.initialHit = null;
  9919. _this.movingHit = null;
  9920. _this.finalHit = null;
  9921. _this.prepareHits();
  9922. _this.processFirstCoord(ev);
  9923. if (_this.initialHit || !_this.requireInitial) {
  9924. dragging.setIgnoreMove(false);
  9925. // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  9926. _this.emitter.trigger('pointerdown', ev);
  9927. }
  9928. else {
  9929. dragging.setIgnoreMove(true);
  9930. }
  9931. };
  9932. this.handleDragStart = function (ev) {
  9933. _this.emitter.trigger('dragstart', ev);
  9934. _this.handleMove(ev, true); // force = fire even if initially null
  9935. };
  9936. this.handleDragMove = function (ev) {
  9937. _this.emitter.trigger('dragmove', ev);
  9938. _this.handleMove(ev);
  9939. };
  9940. this.handlePointerUp = function (ev) {
  9941. _this.releaseHits();
  9942. _this.emitter.trigger('pointerup', ev);
  9943. };
  9944. this.handleDragEnd = function (ev) {
  9945. if (_this.movingHit) {
  9946. _this.emitter.trigger('hitupdate', null, true, ev);
  9947. }
  9948. _this.finalHit = _this.movingHit;
  9949. _this.movingHit = null;
  9950. _this.emitter.trigger('dragend', ev);
  9951. };
  9952. this.droppableStore = droppableStore;
  9953. dragging.emitter.on('pointerdown', this.handlePointerDown);
  9954. dragging.emitter.on('dragstart', this.handleDragStart);
  9955. dragging.emitter.on('dragmove', this.handleDragMove);
  9956. dragging.emitter.on('pointerup', this.handlePointerUp);
  9957. dragging.emitter.on('dragend', this.handleDragEnd);
  9958. this.dragging = dragging;
  9959. this.emitter = new Emitter();
  9960. }
  9961. // sets initialHit
  9962. // sets coordAdjust
  9963. HitDragging.prototype.processFirstCoord = function (ev) {
  9964. var origPoint = { left: ev.pageX, top: ev.pageY };
  9965. var adjustedPoint = origPoint;
  9966. var subjectEl = ev.subjectEl;
  9967. var subjectRect;
  9968. if (subjectEl !== document) {
  9969. subjectRect = computeRect(subjectEl);
  9970. adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
  9971. }
  9972. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  9973. if (initialHit) {
  9974. if (this.useSubjectCenter && subjectRect) {
  9975. var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
  9976. if (slicedSubjectRect) {
  9977. adjustedPoint = getRectCenter(slicedSubjectRect);
  9978. }
  9979. }
  9980. this.coordAdjust = diffPoints(adjustedPoint, origPoint);
  9981. }
  9982. else {
  9983. this.coordAdjust = { left: 0, top: 0 };
  9984. }
  9985. };
  9986. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  9987. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  9988. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  9989. this.movingHit = hit;
  9990. this.emitter.trigger('hitupdate', hit, false, ev);
  9991. }
  9992. };
  9993. HitDragging.prototype.prepareHits = function () {
  9994. this.offsetTrackers = mapHash(this.droppableStore, function (interactionSettings) {
  9995. interactionSettings.component.prepareHits();
  9996. return new OffsetTracker(interactionSettings.el);
  9997. });
  9998. };
  9999. HitDragging.prototype.releaseHits = function () {
  10000. var offsetTrackers = this.offsetTrackers;
  10001. for (var id in offsetTrackers) {
  10002. offsetTrackers[id].destroy();
  10003. }
  10004. this.offsetTrackers = {};
  10005. };
  10006. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  10007. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  10008. var bestHit = null;
  10009. for (var id in droppableStore) {
  10010. var component = droppableStore[id].component;
  10011. var offsetTracker = offsetTrackers[id];
  10012. if (offsetTracker && // wasn't destroyed mid-drag
  10013. offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  10014. var originLeft = offsetTracker.computeLeft();
  10015. var originTop = offsetTracker.computeTop();
  10016. var positionLeft = offsetLeft - originLeft;
  10017. var positionTop = offsetTop - originTop;
  10018. var origRect = offsetTracker.origRect;
  10019. var width = origRect.right - origRect.left;
  10020. var height = origRect.bottom - origRect.top;
  10021. if (
  10022. // must be within the element's bounds
  10023. positionLeft >= 0 && positionLeft < width &&
  10024. positionTop >= 0 && positionTop < height) {
  10025. var hit = component.queryHit(positionLeft, positionTop, width, height);
  10026. var dateProfile = component.context.getCurrentData().dateProfile;
  10027. if (hit &&
  10028. (
  10029. // make sure the hit is within activeRange, meaning it's not a deal cell
  10030. rangeContainsRange(dateProfile.activeRange, hit.dateSpan.range)) &&
  10031. (!bestHit || hit.layer > bestHit.layer)) {
  10032. // TODO: better way to re-orient rectangle
  10033. hit.rect.left += originLeft;
  10034. hit.rect.right += originLeft;
  10035. hit.rect.top += originTop;
  10036. hit.rect.bottom += originTop;
  10037. bestHit = hit;
  10038. }
  10039. }
  10040. }
  10041. }
  10042. return bestHit;
  10043. };
  10044. return HitDragging;
  10045. }());
  10046. function isHitsEqual(hit0, hit1) {
  10047. if (!hit0 && !hit1) {
  10048. return true;
  10049. }
  10050. if (Boolean(hit0) !== Boolean(hit1)) {
  10051. return false;
  10052. }
  10053. return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  10054. }
  10055. function buildDatePointApiWithContext(dateSpan, context) {
  10056. var props = {};
  10057. for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
  10058. var transform = _a[_i];
  10059. __assign(props, transform(dateSpan, context));
  10060. }
  10061. __assign(props, buildDatePointApi(dateSpan, context.dateEnv));
  10062. return props;
  10063. }
  10064. function buildDatePointApi(span, dateEnv) {
  10065. return {
  10066. date: dateEnv.toDate(span.range.start),
  10067. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  10068. allDay: span.allDay,
  10069. };
  10070. }
  10071. /*
  10072. Monitors when the user clicks on a specific date/time of a component.
  10073. A pointerdown+pointerup on the same "hit" constitutes a click.
  10074. */
  10075. var DateClicking = /** @class */ (function (_super) {
  10076. __extends(DateClicking, _super);
  10077. function DateClicking(settings) {
  10078. var _this = _super.call(this, settings) || this;
  10079. _this.handlePointerDown = function (pev) {
  10080. var dragging = _this.dragging;
  10081. var downEl = pev.origEvent.target;
  10082. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  10083. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(downEl));
  10084. };
  10085. // won't even fire if moving was ignored
  10086. _this.handleDragEnd = function (ev) {
  10087. var component = _this.component;
  10088. var pointer = _this.dragging.pointer;
  10089. if (!pointer.wasTouchScroll) {
  10090. var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
  10091. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  10092. var context = component.context;
  10093. var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
  10094. context.emitter.trigger('dateClick', arg);
  10095. }
  10096. }
  10097. };
  10098. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  10099. _this.dragging = new FeaturefulElementDragging(settings.el);
  10100. _this.dragging.autoScroller.isEnabled = false;
  10101. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10102. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10103. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10104. return _this;
  10105. }
  10106. DateClicking.prototype.destroy = function () {
  10107. this.dragging.destroy();
  10108. };
  10109. return DateClicking;
  10110. }(Interaction));
  10111. /*
  10112. Tracks when the user selects a portion of time of a component,
  10113. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  10114. */
  10115. var DateSelecting = /** @class */ (function (_super) {
  10116. __extends(DateSelecting, _super);
  10117. function DateSelecting(settings) {
  10118. var _this = _super.call(this, settings) || this;
  10119. _this.dragSelection = null;
  10120. _this.handlePointerDown = function (ev) {
  10121. var _a = _this, component = _a.component, dragging = _a.dragging;
  10122. var options = component.context.options;
  10123. var canSelect = options.selectable &&
  10124. component.isValidDateDownEl(ev.origEvent.target);
  10125. // don't bother to watch expensive moves if component won't do selection
  10126. dragging.setIgnoreMove(!canSelect);
  10127. // if touch, require user to hold down
  10128. dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
  10129. };
  10130. _this.handleDragStart = function (ev) {
  10131. _this.component.context.calendarApi.unselect(ev); // unselect previous selections
  10132. };
  10133. _this.handleHitUpdate = function (hit, isFinal) {
  10134. var context = _this.component.context;
  10135. var dragSelection = null;
  10136. var isInvalid = false;
  10137. if (hit) {
  10138. dragSelection = joinHitsIntoSelection(_this.hitDragging.initialHit, hit, context.pluginHooks.dateSelectionTransformers);
  10139. if (!dragSelection || !_this.component.isDateSelectionValid(dragSelection)) {
  10140. isInvalid = true;
  10141. dragSelection = null;
  10142. }
  10143. }
  10144. if (dragSelection) {
  10145. context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  10146. }
  10147. else if (!isFinal) { // only unselect if moved away while dragging
  10148. context.dispatch({ type: 'UNSELECT_DATES' });
  10149. }
  10150. if (!isInvalid) {
  10151. enableCursor();
  10152. }
  10153. else {
  10154. disableCursor();
  10155. }
  10156. if (!isFinal) {
  10157. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  10158. }
  10159. };
  10160. _this.handlePointerUp = function (pev) {
  10161. if (_this.dragSelection) {
  10162. // selection is already rendered, so just need to report selection
  10163. triggerDateSelect(_this.dragSelection, pev, _this.component.context);
  10164. _this.dragSelection = null;
  10165. }
  10166. };
  10167. var component = settings.component;
  10168. var options = component.context.options;
  10169. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10170. dragging.touchScrollAllowed = false;
  10171. dragging.minDistance = options.selectMinDistance || 0;
  10172. dragging.autoScroller.isEnabled = options.dragScroll;
  10173. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10174. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10175. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10176. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10177. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10178. return _this;
  10179. }
  10180. DateSelecting.prototype.destroy = function () {
  10181. this.dragging.destroy();
  10182. };
  10183. return DateSelecting;
  10184. }(Interaction));
  10185. function getComponentTouchDelay(component) {
  10186. var options = component.context.options;
  10187. var delay = options.selectLongPressDelay;
  10188. if (delay == null) {
  10189. delay = options.longPressDelay;
  10190. }
  10191. return delay;
  10192. }
  10193. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  10194. var dateSpan0 = hit0.dateSpan;
  10195. var dateSpan1 = hit1.dateSpan;
  10196. var ms = [
  10197. dateSpan0.range.start,
  10198. dateSpan0.range.end,
  10199. dateSpan1.range.start,
  10200. dateSpan1.range.end,
  10201. ];
  10202. ms.sort(compareNumbers);
  10203. var props = {};
  10204. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  10205. var transformer = dateSelectionTransformers_1[_i];
  10206. var res = transformer(hit0, hit1);
  10207. if (res === false) {
  10208. return null;
  10209. }
  10210. if (res) {
  10211. __assign(props, res);
  10212. }
  10213. }
  10214. props.range = { start: ms[0], end: ms[3] };
  10215. props.allDay = dateSpan0.allDay;
  10216. return props;
  10217. }
  10218. var EventDragging = /** @class */ (function (_super) {
  10219. __extends(EventDragging, _super);
  10220. function EventDragging(settings) {
  10221. var _this = _super.call(this, settings) || this;
  10222. // internal state
  10223. _this.subjectEl = null;
  10224. _this.subjectSeg = null; // the seg being selected/dragged
  10225. _this.isDragging = false;
  10226. _this.eventRange = null;
  10227. _this.relevantEvents = null; // the events being dragged
  10228. _this.receivingContext = null;
  10229. _this.validMutation = null;
  10230. _this.mutatedRelevantEvents = null;
  10231. _this.handlePointerDown = function (ev) {
  10232. var origTarget = ev.origEvent.target;
  10233. var _a = _this, component = _a.component, dragging = _a.dragging;
  10234. var mirror = dragging.mirror;
  10235. var options = component.context.options;
  10236. var initialContext = component.context;
  10237. _this.subjectEl = ev.subjectEl;
  10238. var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
  10239. var eventRange = _this.eventRange = subjectSeg.eventRange;
  10240. var eventInstanceId = eventRange.instance.instanceId;
  10241. _this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
  10242. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  10243. dragging.delay =
  10244. // only do a touch delay if touch and this event hasn't been selected yet
  10245. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  10246. getComponentTouchDelay$1(component) :
  10247. null;
  10248. if (options.fixedMirrorParent) {
  10249. mirror.parentNode = options.fixedMirrorParent;
  10250. }
  10251. else {
  10252. mirror.parentNode = elementClosest(origTarget, '.fc');
  10253. }
  10254. mirror.revertDuration = options.dragRevertDuration;
  10255. var isValid = component.isValidSegDownEl(origTarget) &&
  10256. !elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
  10257. dragging.setIgnoreMove(!isValid);
  10258. // disable dragging for elements that are resizable (ie, selectable)
  10259. // but are not draggable
  10260. _this.isDragging = isValid &&
  10261. ev.subjectEl.classList.contains('fc-event-draggable');
  10262. };
  10263. _this.handleDragStart = function (ev) {
  10264. var initialContext = _this.component.context;
  10265. var eventRange = _this.eventRange;
  10266. var eventInstanceId = eventRange.instance.instanceId;
  10267. if (ev.isTouch) {
  10268. // need to select a different event?
  10269. if (eventInstanceId !== _this.component.props.eventSelection) {
  10270. initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  10271. }
  10272. }
  10273. else {
  10274. // if now using mouse, but was previous touch interaction, clear selected event
  10275. initialContext.dispatch({ type: 'UNSELECT_EVENT' });
  10276. }
  10277. if (_this.isDragging) {
  10278. initialContext.calendarApi.unselect(ev); // unselect *date* selection
  10279. initialContext.emitter.trigger('eventDragStart', {
  10280. el: _this.subjectEl,
  10281. event: new EventApi(initialContext, eventRange.def, eventRange.instance),
  10282. jsEvent: ev.origEvent,
  10283. view: initialContext.viewApi,
  10284. });
  10285. }
  10286. };
  10287. _this.handleHitUpdate = function (hit, isFinal) {
  10288. if (!_this.isDragging) {
  10289. return;
  10290. }
  10291. var relevantEvents = _this.relevantEvents;
  10292. var initialHit = _this.hitDragging.initialHit;
  10293. var initialContext = _this.component.context;
  10294. // states based on new hit
  10295. var receivingContext = null;
  10296. var mutation = null;
  10297. var mutatedRelevantEvents = null;
  10298. var isInvalid = false;
  10299. var interaction = {
  10300. affectedEvents: relevantEvents,
  10301. mutatedEvents: createEmptyEventStore(),
  10302. isEvent: true,
  10303. };
  10304. if (hit) {
  10305. var receivingComponent = hit.component;
  10306. receivingContext = receivingComponent.context;
  10307. var receivingOptions = receivingContext.options;
  10308. if (initialContext === receivingContext ||
  10309. (receivingOptions.editable && receivingOptions.droppable)) {
  10310. mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
  10311. if (mutation) {
  10312. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
  10313. interaction.mutatedEvents = mutatedRelevantEvents;
  10314. if (!receivingComponent.isInteractionValid(interaction)) {
  10315. isInvalid = true;
  10316. mutation = null;
  10317. mutatedRelevantEvents = null;
  10318. interaction.mutatedEvents = createEmptyEventStore();
  10319. }
  10320. }
  10321. }
  10322. else {
  10323. receivingContext = null;
  10324. }
  10325. }
  10326. _this.displayDrag(receivingContext, interaction);
  10327. if (!isInvalid) {
  10328. enableCursor();
  10329. }
  10330. else {
  10331. disableCursor();
  10332. }
  10333. if (!isFinal) {
  10334. if (initialContext === receivingContext && // TODO: write test for this
  10335. isHitsEqual(initialHit, hit)) {
  10336. mutation = null;
  10337. }
  10338. _this.dragging.setMirrorNeedsRevert(!mutation);
  10339. // render the mirror if no already-rendered mirror
  10340. // TODO: wish we could somehow wait for dispatch to guarantee render
  10341. _this.dragging.setMirrorIsVisible(!hit || !document.querySelector('.fc-event-mirror'));
  10342. // assign states based on new hit
  10343. _this.receivingContext = receivingContext;
  10344. _this.validMutation = mutation;
  10345. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  10346. }
  10347. };
  10348. _this.handlePointerUp = function () {
  10349. if (!_this.isDragging) {
  10350. _this.cleanup(); // because handleDragEnd won't fire
  10351. }
  10352. };
  10353. _this.handleDragEnd = function (ev) {
  10354. if (_this.isDragging) {
  10355. var initialContext_1 = _this.component.context;
  10356. var initialView = initialContext_1.viewApi;
  10357. var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
  10358. var eventDef = _this.eventRange.def;
  10359. var eventInstance = _this.eventRange.instance;
  10360. var eventApi = new EventApi(initialContext_1, eventDef, eventInstance);
  10361. var relevantEvents_1 = _this.relevantEvents;
  10362. var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
  10363. var finalHit = _this.hitDragging.finalHit;
  10364. _this.clearDrag(); // must happen after revert animation
  10365. initialContext_1.emitter.trigger('eventDragStop', {
  10366. el: _this.subjectEl,
  10367. event: eventApi,
  10368. jsEvent: ev.origEvent,
  10369. view: initialView,
  10370. });
  10371. if (validMutation) {
  10372. // dropped within same calendar
  10373. if (receivingContext_1 === initialContext_1) {
  10374. var updatedEventApi = new EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
  10375. initialContext_1.dispatch({
  10376. type: 'MERGE_EVENTS',
  10377. eventStore: mutatedRelevantEvents_1,
  10378. });
  10379. var eventChangeArg = {
  10380. oldEvent: eventApi,
  10381. event: updatedEventApi,
  10382. relatedEvents: buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
  10383. revert: function () {
  10384. initialContext_1.dispatch({
  10385. type: 'MERGE_EVENTS',
  10386. eventStore: relevantEvents_1,
  10387. });
  10388. },
  10389. };
  10390. var transformed = {};
  10391. for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
  10392. var transformer = _b[_i];
  10393. __assign(transformed, transformer(validMutation, initialContext_1));
  10394. }
  10395. initialContext_1.emitter.trigger('eventDrop', __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
  10396. initialContext_1.emitter.trigger('eventChange', eventChangeArg);
  10397. // dropped in different calendar
  10398. }
  10399. else if (receivingContext_1) {
  10400. var eventRemoveArg = {
  10401. event: eventApi,
  10402. relatedEvents: buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
  10403. revert: function () {
  10404. initialContext_1.dispatch({
  10405. type: 'MERGE_EVENTS',
  10406. eventStore: relevantEvents_1,
  10407. });
  10408. },
  10409. };
  10410. initialContext_1.emitter.trigger('eventLeave', __assign(__assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
  10411. initialContext_1.dispatch({
  10412. type: 'REMOVE_EVENTS',
  10413. eventStore: relevantEvents_1,
  10414. });
  10415. initialContext_1.emitter.trigger('eventRemove', eventRemoveArg);
  10416. var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
  10417. var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
  10418. var addedEventApi = new EventApi(receivingContext_1, addedEventDef, addedEventInstance);
  10419. receivingContext_1.dispatch({
  10420. type: 'MERGE_EVENTS',
  10421. eventStore: mutatedRelevantEvents_1,
  10422. });
  10423. var eventAddArg = {
  10424. event: addedEventApi,
  10425. relatedEvents: buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
  10426. revert: function () {
  10427. receivingContext_1.dispatch({
  10428. type: 'REMOVE_EVENTS',
  10429. eventStore: mutatedRelevantEvents_1,
  10430. });
  10431. },
  10432. };
  10433. receivingContext_1.emitter.trigger('eventAdd', eventAddArg);
  10434. if (ev.isTouch) {
  10435. receivingContext_1.dispatch({
  10436. type: 'SELECT_EVENT',
  10437. eventInstanceId: eventInstance.instanceId,
  10438. });
  10439. }
  10440. receivingContext_1.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component.context.viewApi }));
  10441. receivingContext_1.emitter.trigger('eventReceive', __assign(__assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.component.context.viewApi }));
  10442. }
  10443. }
  10444. else {
  10445. initialContext_1.emitter.trigger('_noEventDrop');
  10446. }
  10447. }
  10448. _this.cleanup();
  10449. };
  10450. var component = _this.component;
  10451. var options = component.context.options;
  10452. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10453. dragging.pointer.selector = EventDragging.SELECTOR;
  10454. dragging.touchScrollAllowed = false;
  10455. dragging.autoScroller.isEnabled = options.dragScroll;
  10456. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
  10457. hitDragging.useSubjectCenter = settings.useEventCenter;
  10458. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10459. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10460. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10461. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10462. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10463. return _this;
  10464. }
  10465. EventDragging.prototype.destroy = function () {
  10466. this.dragging.destroy();
  10467. };
  10468. // render a drag state on the next receivingCalendar
  10469. EventDragging.prototype.displayDrag = function (nextContext, state) {
  10470. var initialContext = this.component.context;
  10471. var prevContext = this.receivingContext;
  10472. // does the previous calendar need to be cleared?
  10473. if (prevContext && prevContext !== nextContext) {
  10474. // does the initial calendar need to be cleared?
  10475. // if so, don't clear all the way. we still need to to hide the affectedEvents
  10476. if (prevContext === initialContext) {
  10477. prevContext.dispatch({
  10478. type: 'SET_EVENT_DRAG',
  10479. state: {
  10480. affectedEvents: state.affectedEvents,
  10481. mutatedEvents: createEmptyEventStore(),
  10482. isEvent: true,
  10483. },
  10484. });
  10485. // completely clear the old calendar if it wasn't the initial
  10486. }
  10487. else {
  10488. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10489. }
  10490. }
  10491. if (nextContext) {
  10492. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  10493. }
  10494. };
  10495. EventDragging.prototype.clearDrag = function () {
  10496. var initialCalendar = this.component.context;
  10497. var receivingContext = this.receivingContext;
  10498. if (receivingContext) {
  10499. receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10500. }
  10501. // the initial calendar might have an dummy drag state from displayDrag
  10502. if (initialCalendar !== receivingContext) {
  10503. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10504. }
  10505. };
  10506. EventDragging.prototype.cleanup = function () {
  10507. this.subjectSeg = null;
  10508. this.isDragging = false;
  10509. this.eventRange = null;
  10510. this.relevantEvents = null;
  10511. this.receivingContext = null;
  10512. this.validMutation = null;
  10513. this.mutatedRelevantEvents = null;
  10514. };
  10515. // TODO: test this in IE11
  10516. // QUESTION: why do we need it on the resizable???
  10517. EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
  10518. return EventDragging;
  10519. }(Interaction));
  10520. function computeEventMutation(hit0, hit1, massagers) {
  10521. var dateSpan0 = hit0.dateSpan;
  10522. var dateSpan1 = hit1.dateSpan;
  10523. var date0 = dateSpan0.range.start;
  10524. var date1 = dateSpan1.range.start;
  10525. var standardProps = {};
  10526. if (dateSpan0.allDay !== dateSpan1.allDay) {
  10527. standardProps.allDay = dateSpan1.allDay;
  10528. standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
  10529. if (dateSpan1.allDay) {
  10530. // means date1 is already start-of-day,
  10531. // but date0 needs to be converted
  10532. date0 = startOfDay(date0);
  10533. }
  10534. }
  10535. var delta = diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
  10536. hit0.component.largeUnit :
  10537. null);
  10538. if (delta.milliseconds) { // has hours/minutes/seconds
  10539. standardProps.allDay = false;
  10540. }
  10541. var mutation = {
  10542. datesDelta: delta,
  10543. standardProps: standardProps,
  10544. };
  10545. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  10546. var massager = massagers_1[_i];
  10547. massager(mutation, hit0, hit1);
  10548. }
  10549. return mutation;
  10550. }
  10551. function getComponentTouchDelay$1(component) {
  10552. var options = component.context.options;
  10553. var delay = options.eventLongPressDelay;
  10554. if (delay == null) {
  10555. delay = options.longPressDelay;
  10556. }
  10557. return delay;
  10558. }
  10559. var EventResizing = /** @class */ (function (_super) {
  10560. __extends(EventResizing, _super);
  10561. function EventResizing(settings) {
  10562. var _this = _super.call(this, settings) || this;
  10563. // internal state
  10564. _this.draggingSegEl = null;
  10565. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  10566. _this.eventRange = null;
  10567. _this.relevantEvents = null;
  10568. _this.validMutation = null;
  10569. _this.mutatedRelevantEvents = null;
  10570. _this.handlePointerDown = function (ev) {
  10571. var component = _this.component;
  10572. var segEl = _this.querySegEl(ev);
  10573. var seg = getElSeg(segEl);
  10574. var eventRange = _this.eventRange = seg.eventRange;
  10575. _this.dragging.minDistance = component.context.options.eventDragMinDistance;
  10576. // if touch, need to be working with a selected event
  10577. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  10578. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  10579. };
  10580. _this.handleDragStart = function (ev) {
  10581. var context = _this.component.context;
  10582. var eventRange = _this.eventRange;
  10583. _this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
  10584. var segEl = _this.querySegEl(ev);
  10585. _this.draggingSegEl = segEl;
  10586. _this.draggingSeg = getElSeg(segEl);
  10587. context.calendarApi.unselect();
  10588. context.emitter.trigger('eventResizeStart', {
  10589. el: segEl,
  10590. event: new EventApi(context, eventRange.def, eventRange.instance),
  10591. jsEvent: ev.origEvent,
  10592. view: context.viewApi,
  10593. });
  10594. };
  10595. _this.handleHitUpdate = function (hit, isFinal, ev) {
  10596. var context = _this.component.context;
  10597. var relevantEvents = _this.relevantEvents;
  10598. var initialHit = _this.hitDragging.initialHit;
  10599. var eventInstance = _this.eventRange.instance;
  10600. var mutation = null;
  10601. var mutatedRelevantEvents = null;
  10602. var isInvalid = false;
  10603. var interaction = {
  10604. affectedEvents: relevantEvents,
  10605. mutatedEvents: createEmptyEventStore(),
  10606. isEvent: true,
  10607. };
  10608. if (hit) {
  10609. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range, context.pluginHooks.eventResizeJoinTransforms);
  10610. }
  10611. if (mutation) {
  10612. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
  10613. interaction.mutatedEvents = mutatedRelevantEvents;
  10614. if (!_this.component.isInteractionValid(interaction)) {
  10615. isInvalid = true;
  10616. mutation = null;
  10617. mutatedRelevantEvents = null;
  10618. interaction.mutatedEvents = null;
  10619. }
  10620. }
  10621. if (mutatedRelevantEvents) {
  10622. context.dispatch({
  10623. type: 'SET_EVENT_RESIZE',
  10624. state: interaction,
  10625. });
  10626. }
  10627. else {
  10628. context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  10629. }
  10630. if (!isInvalid) {
  10631. enableCursor();
  10632. }
  10633. else {
  10634. disableCursor();
  10635. }
  10636. if (!isFinal) {
  10637. if (mutation && isHitsEqual(initialHit, hit)) {
  10638. mutation = null;
  10639. }
  10640. _this.validMutation = mutation;
  10641. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  10642. }
  10643. };
  10644. _this.handleDragEnd = function (ev) {
  10645. var context = _this.component.context;
  10646. var eventDef = _this.eventRange.def;
  10647. var eventInstance = _this.eventRange.instance;
  10648. var eventApi = new EventApi(context, eventDef, eventInstance);
  10649. var relevantEvents = _this.relevantEvents;
  10650. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  10651. context.emitter.trigger('eventResizeStop', {
  10652. el: _this.draggingSegEl,
  10653. event: eventApi,
  10654. jsEvent: ev.origEvent,
  10655. view: context.viewApi,
  10656. });
  10657. if (_this.validMutation) {
  10658. var updatedEventApi = new EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  10659. context.dispatch({
  10660. type: 'MERGE_EVENTS',
  10661. eventStore: mutatedRelevantEvents,
  10662. });
  10663. var eventChangeArg = {
  10664. oldEvent: eventApi,
  10665. event: updatedEventApi,
  10666. relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
  10667. revert: function () {
  10668. context.dispatch({
  10669. type: 'MERGE_EVENTS',
  10670. eventStore: relevantEvents,
  10671. });
  10672. },
  10673. };
  10674. context.emitter.trigger('eventResize', __assign(__assign({}, eventChangeArg), { el: _this.draggingSegEl, startDelta: _this.validMutation.startDelta || createDuration(0), endDelta: _this.validMutation.endDelta || createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
  10675. context.emitter.trigger('eventChange', eventChangeArg);
  10676. }
  10677. else {
  10678. context.emitter.trigger('_noEventResize');
  10679. }
  10680. // reset all internal state
  10681. _this.draggingSeg = null;
  10682. _this.relevantEvents = null;
  10683. _this.validMutation = null;
  10684. // okay to keep eventInstance around. useful to set it in handlePointerDown
  10685. };
  10686. var component = settings.component;
  10687. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10688. dragging.pointer.selector = '.fc-event-resizer';
  10689. dragging.touchScrollAllowed = false;
  10690. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  10691. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10692. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10693. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10694. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10695. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10696. return _this;
  10697. }
  10698. EventResizing.prototype.destroy = function () {
  10699. this.dragging.destroy();
  10700. };
  10701. EventResizing.prototype.querySegEl = function (ev) {
  10702. return elementClosest(ev.subjectEl, '.fc-event');
  10703. };
  10704. return EventResizing;
  10705. }(Interaction));
  10706. function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
  10707. var dateEnv = hit0.component.context.dateEnv;
  10708. var date0 = hit0.dateSpan.range.start;
  10709. var date1 = hit1.dateSpan.range.start;
  10710. var delta = diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
  10711. var props = {};
  10712. for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
  10713. var transform = transforms_1[_i];
  10714. var res = transform(hit0, hit1);
  10715. if (res === false) {
  10716. return null;
  10717. }
  10718. if (res) {
  10719. __assign(props, res);
  10720. }
  10721. }
  10722. if (isFromStart) {
  10723. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  10724. props.startDelta = delta;
  10725. return props;
  10726. }
  10727. }
  10728. else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  10729. props.endDelta = delta;
  10730. return props;
  10731. }
  10732. return null;
  10733. }
  10734. var UnselectAuto = /** @class */ (function () {
  10735. function UnselectAuto(context) {
  10736. var _this = this;
  10737. this.context = context;
  10738. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  10739. this.matchesCancel = false;
  10740. this.matchesEvent = false;
  10741. this.onSelect = function (selectInfo) {
  10742. if (selectInfo.jsEvent) {
  10743. _this.isRecentPointerDateSelect = true;
  10744. }
  10745. };
  10746. this.onDocumentPointerDown = function (pev) {
  10747. var unselectCancel = _this.context.options.unselectCancel;
  10748. var downEl = pev.origEvent.target;
  10749. _this.matchesCancel = !!elementClosest(downEl, unselectCancel);
  10750. _this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
  10751. };
  10752. this.onDocumentPointerUp = function (pev) {
  10753. var context = _this.context;
  10754. var documentPointer = _this.documentPointer;
  10755. var calendarState = context.getCurrentData();
  10756. // touch-scrolling should never unfocus any type of selection
  10757. if (!documentPointer.wasTouchScroll) {
  10758. if (calendarState.dateSelection && // an existing date selection?
  10759. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  10760. ) {
  10761. var unselectAuto = context.options.unselectAuto;
  10762. if (unselectAuto && (!unselectAuto || !_this.matchesCancel)) {
  10763. context.calendarApi.unselect(pev);
  10764. }
  10765. }
  10766. if (calendarState.eventSelection && // an existing event selected?
  10767. !_this.matchesEvent // interaction DIDN'T start on an event
  10768. ) {
  10769. context.dispatch({ type: 'UNSELECT_EVENT' });
  10770. }
  10771. }
  10772. _this.isRecentPointerDateSelect = false;
  10773. };
  10774. var documentPointer = this.documentPointer = new PointerDragging(document);
  10775. documentPointer.shouldIgnoreMove = true;
  10776. documentPointer.shouldWatchScroll = false;
  10777. documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
  10778. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  10779. /*
  10780. TODO: better way to know about whether there was a selection with the pointer
  10781. */
  10782. context.emitter.on('select', this.onSelect);
  10783. }
  10784. UnselectAuto.prototype.destroy = function () {
  10785. this.context.emitter.off('select', this.onSelect);
  10786. this.documentPointer.destroy();
  10787. };
  10788. return UnselectAuto;
  10789. }());
  10790. var OPTION_REFINERS = {
  10791. fixedMirrorParent: identity,
  10792. };
  10793. var LISTENER_REFINERS = {
  10794. dateClick: identity,
  10795. eventDragStart: identity,
  10796. eventDragStop: identity,
  10797. eventDrop: identity,
  10798. eventResizeStart: identity,
  10799. eventResizeStop: identity,
  10800. eventResize: identity,
  10801. drop: identity,
  10802. eventReceive: identity,
  10803. eventLeave: identity,
  10804. };
  10805. /*
  10806. Given an already instantiated draggable object for one-or-more elements,
  10807. Interprets any dragging as an attempt to drag an events that lives outside
  10808. of a calendar onto a calendar.
  10809. */
  10810. var ExternalElementDragging = /** @class */ (function () {
  10811. function ExternalElementDragging(dragging, suppliedDragMeta) {
  10812. var _this = this;
  10813. this.receivingContext = null;
  10814. this.droppableEvent = null; // will exist for all drags, even if create:false
  10815. this.suppliedDragMeta = null;
  10816. this.dragMeta = null;
  10817. this.handleDragStart = function (ev) {
  10818. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  10819. };
  10820. this.handleHitUpdate = function (hit, isFinal, ev) {
  10821. var dragging = _this.hitDragging.dragging;
  10822. var receivingContext = null;
  10823. var droppableEvent = null;
  10824. var isInvalid = false;
  10825. var interaction = {
  10826. affectedEvents: createEmptyEventStore(),
  10827. mutatedEvents: createEmptyEventStore(),
  10828. isEvent: _this.dragMeta.create,
  10829. };
  10830. if (hit) {
  10831. receivingContext = hit.component.context;
  10832. if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
  10833. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
  10834. interaction.mutatedEvents = eventTupleToStore(droppableEvent);
  10835. isInvalid = !isInteractionValid(interaction, receivingContext);
  10836. if (isInvalid) {
  10837. interaction.mutatedEvents = createEmptyEventStore();
  10838. droppableEvent = null;
  10839. }
  10840. }
  10841. }
  10842. _this.displayDrag(receivingContext, interaction);
  10843. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  10844. // TODO: wish we could somehow wait for dispatch to guarantee render
  10845. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
  10846. if (!isInvalid) {
  10847. enableCursor();
  10848. }
  10849. else {
  10850. disableCursor();
  10851. }
  10852. if (!isFinal) {
  10853. dragging.setMirrorNeedsRevert(!droppableEvent);
  10854. _this.receivingContext = receivingContext;
  10855. _this.droppableEvent = droppableEvent;
  10856. }
  10857. };
  10858. this.handleDragEnd = function (pev) {
  10859. var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
  10860. _this.clearDrag();
  10861. if (receivingContext && droppableEvent) {
  10862. var finalHit = _this.hitDragging.finalHit;
  10863. var finalView = finalHit.component.context.viewApi;
  10864. var dragMeta = _this.dragMeta;
  10865. receivingContext.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
  10866. if (dragMeta.create) {
  10867. var addingEvents_1 = eventTupleToStore(droppableEvent);
  10868. receivingContext.dispatch({
  10869. type: 'MERGE_EVENTS',
  10870. eventStore: addingEvents_1,
  10871. });
  10872. if (pev.isTouch) {
  10873. receivingContext.dispatch({
  10874. type: 'SELECT_EVENT',
  10875. eventInstanceId: droppableEvent.instance.instanceId,
  10876. });
  10877. }
  10878. // signal that an external event landed
  10879. receivingContext.emitter.trigger('eventReceive', {
  10880. event: new EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
  10881. relatedEvents: [],
  10882. revert: function () {
  10883. receivingContext.dispatch({
  10884. type: 'REMOVE_EVENTS',
  10885. eventStore: addingEvents_1,
  10886. });
  10887. },
  10888. draggedEl: pev.subjectEl,
  10889. view: finalView,
  10890. });
  10891. }
  10892. }
  10893. _this.receivingContext = null;
  10894. _this.droppableEvent = null;
  10895. };
  10896. var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
  10897. hitDragging.requireInitial = false; // will start outside of a component
  10898. hitDragging.emitter.on('dragstart', this.handleDragStart);
  10899. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  10900. hitDragging.emitter.on('dragend', this.handleDragEnd);
  10901. this.suppliedDragMeta = suppliedDragMeta;
  10902. }
  10903. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  10904. if (typeof this.suppliedDragMeta === 'object') {
  10905. return parseDragMeta(this.suppliedDragMeta);
  10906. }
  10907. if (typeof this.suppliedDragMeta === 'function') {
  10908. return parseDragMeta(this.suppliedDragMeta(subjectEl));
  10909. }
  10910. return getDragMetaFromEl(subjectEl);
  10911. };
  10912. ExternalElementDragging.prototype.displayDrag = function (nextContext, state) {
  10913. var prevContext = this.receivingContext;
  10914. if (prevContext && prevContext !== nextContext) {
  10915. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10916. }
  10917. if (nextContext) {
  10918. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  10919. }
  10920. };
  10921. ExternalElementDragging.prototype.clearDrag = function () {
  10922. if (this.receivingContext) {
  10923. this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10924. }
  10925. };
  10926. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingContext) {
  10927. var dropAccept = receivingContext.options.dropAccept;
  10928. if (typeof dropAccept === 'function') {
  10929. return dropAccept.call(receivingContext.calendarApi, el);
  10930. }
  10931. if (typeof dropAccept === 'string' && dropAccept) {
  10932. return Boolean(elementMatches(el, dropAccept));
  10933. }
  10934. return true;
  10935. };
  10936. return ExternalElementDragging;
  10937. }());
  10938. // Utils for computing event store from the DragMeta
  10939. // ----------------------------------------------------------------------------------------------------
  10940. function computeEventForDateSpan(dateSpan, dragMeta, context) {
  10941. var defProps = __assign({}, dragMeta.leftoverProps);
  10942. for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
  10943. var transform = _a[_i];
  10944. __assign(defProps, transform(dateSpan, dragMeta));
  10945. }
  10946. var _b = refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
  10947. var def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
  10948. context);
  10949. var start = dateSpan.range.start;
  10950. // only rely on time info if drop zone is all-day,
  10951. // otherwise, we already know the time
  10952. if (dateSpan.allDay && dragMeta.startTime) {
  10953. start = context.dateEnv.add(start, dragMeta.startTime);
  10954. }
  10955. var end = dragMeta.duration ?
  10956. context.dateEnv.add(start, dragMeta.duration) :
  10957. getDefaultEventEnd(dateSpan.allDay, start, context);
  10958. var instance = createEventInstance(def.defId, { start: start, end: end });
  10959. return { def: def, instance: instance };
  10960. }
  10961. // Utils for extracting data from element
  10962. // ----------------------------------------------------------------------------------------------------
  10963. function getDragMetaFromEl(el) {
  10964. var str = getEmbeddedElData(el, 'event');
  10965. var obj = str ?
  10966. JSON.parse(str) :
  10967. { create: false }; // if no embedded data, assume no event creation
  10968. return parseDragMeta(obj);
  10969. }
  10970. config.dataAttrPrefix = '';
  10971. function getEmbeddedElData(el, name) {
  10972. var prefix = config.dataAttrPrefix;
  10973. var prefixedName = (prefix ? prefix + '-' : '') + name;
  10974. return el.getAttribute('data-' + prefixedName) || '';
  10975. }
  10976. /*
  10977. Makes an element (that is *external* to any calendar) draggable.
  10978. Can pass in data that determines how an event will be created when dropped onto a calendar.
  10979. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  10980. */
  10981. var ExternalDraggable = /** @class */ (function () {
  10982. function ExternalDraggable(el, settings) {
  10983. var _this = this;
  10984. if (settings === void 0) { settings = {}; }
  10985. this.handlePointerDown = function (ev) {
  10986. var dragging = _this.dragging;
  10987. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  10988. dragging.minDistance =
  10989. minDistance != null ?
  10990. minDistance :
  10991. (ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance);
  10992. dragging.delay =
  10993. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  10994. (longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay) :
  10995. 0;
  10996. };
  10997. this.handleDragStart = function (ev) {
  10998. if (ev.isTouch &&
  10999. _this.dragging.delay &&
  11000. ev.subjectEl.classList.contains('fc-event')) {
  11001. _this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
  11002. }
  11003. };
  11004. this.settings = settings;
  11005. var dragging = this.dragging = new FeaturefulElementDragging(el);
  11006. dragging.touchScrollAllowed = false;
  11007. if (settings.itemSelector != null) {
  11008. dragging.pointer.selector = settings.itemSelector;
  11009. }
  11010. if (settings.appendTo != null) {
  11011. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  11012. }
  11013. dragging.emitter.on('pointerdown', this.handlePointerDown);
  11014. dragging.emitter.on('dragstart', this.handleDragStart);
  11015. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11016. }
  11017. ExternalDraggable.prototype.destroy = function () {
  11018. this.dragging.destroy();
  11019. };
  11020. return ExternalDraggable;
  11021. }());
  11022. /*
  11023. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  11024. The third-party system is responsible for drawing the visuals effects of the drag.
  11025. This class simply monitors for pointer movements and fires events.
  11026. It also has the ability to hide the moving element (the "mirror") during the drag.
  11027. */
  11028. var InferredElementDragging = /** @class */ (function (_super) {
  11029. __extends(InferredElementDragging, _super);
  11030. function InferredElementDragging(containerEl) {
  11031. var _this = _super.call(this, containerEl) || this;
  11032. _this.shouldIgnoreMove = false;
  11033. _this.mirrorSelector = '';
  11034. _this.currentMirrorEl = null;
  11035. _this.handlePointerDown = function (ev) {
  11036. _this.emitter.trigger('pointerdown', ev);
  11037. if (!_this.shouldIgnoreMove) {
  11038. // fire dragstart right away. does not support delay or min-distance
  11039. _this.emitter.trigger('dragstart', ev);
  11040. }
  11041. };
  11042. _this.handlePointerMove = function (ev) {
  11043. if (!_this.shouldIgnoreMove) {
  11044. _this.emitter.trigger('dragmove', ev);
  11045. }
  11046. };
  11047. _this.handlePointerUp = function (ev) {
  11048. _this.emitter.trigger('pointerup', ev);
  11049. if (!_this.shouldIgnoreMove) {
  11050. // fire dragend right away. does not support a revert animation
  11051. _this.emitter.trigger('dragend', ev);
  11052. }
  11053. };
  11054. var pointer = _this.pointer = new PointerDragging(containerEl);
  11055. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  11056. pointer.emitter.on('pointermove', _this.handlePointerMove);
  11057. pointer.emitter.on('pointerup', _this.handlePointerUp);
  11058. return _this;
  11059. }
  11060. InferredElementDragging.prototype.destroy = function () {
  11061. this.pointer.destroy();
  11062. };
  11063. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  11064. this.shouldIgnoreMove = bool;
  11065. };
  11066. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  11067. if (bool) {
  11068. // restore a previously hidden element.
  11069. // use the reference in case the selector class has already been removed.
  11070. if (this.currentMirrorEl) {
  11071. this.currentMirrorEl.style.visibility = '';
  11072. this.currentMirrorEl = null;
  11073. }
  11074. }
  11075. else {
  11076. var mirrorEl = this.mirrorSelector ?
  11077. document.querySelector(this.mirrorSelector) :
  11078. null;
  11079. if (mirrorEl) {
  11080. this.currentMirrorEl = mirrorEl;
  11081. mirrorEl.style.visibility = 'hidden';
  11082. }
  11083. }
  11084. };
  11085. return InferredElementDragging;
  11086. }(ElementDragging));
  11087. /*
  11088. Bridges third-party drag-n-drop systems with FullCalendar.
  11089. Must be instantiated and destroyed by caller.
  11090. */
  11091. var ThirdPartyDraggable = /** @class */ (function () {
  11092. function ThirdPartyDraggable(containerOrSettings, settings) {
  11093. var containerEl = document;
  11094. if (
  11095. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  11096. containerOrSettings === document ||
  11097. containerOrSettings instanceof Element) {
  11098. containerEl = containerOrSettings;
  11099. settings = settings || {};
  11100. }
  11101. else {
  11102. settings = (containerOrSettings || {});
  11103. }
  11104. var dragging = this.dragging = new InferredElementDragging(containerEl);
  11105. if (typeof settings.itemSelector === 'string') {
  11106. dragging.pointer.selector = settings.itemSelector;
  11107. }
  11108. else if (containerEl === document) {
  11109. dragging.pointer.selector = '[data-event]';
  11110. }
  11111. if (typeof settings.mirrorSelector === 'string') {
  11112. dragging.mirrorSelector = settings.mirrorSelector;
  11113. }
  11114. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11115. }
  11116. ThirdPartyDraggable.prototype.destroy = function () {
  11117. this.dragging.destroy();
  11118. };
  11119. return ThirdPartyDraggable;
  11120. }());
  11121. var interactionPlugin = createPlugin({
  11122. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
  11123. calendarInteractions: [UnselectAuto],
  11124. elementDraggingImpl: FeaturefulElementDragging,
  11125. optionRefiners: OPTION_REFINERS,
  11126. listenerRefiners: LISTENER_REFINERS,
  11127. });
  11128. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  11129. ----------------------------------------------------------------------------------------------------------------------*/
  11130. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  11131. // It is responsible for managing width/height.
  11132. var TableView = /** @class */ (function (_super) {
  11133. __extends(TableView, _super);
  11134. function TableView() {
  11135. var _this = _super !== null && _super.apply(this, arguments) || this;
  11136. _this.headerElRef = createRef();
  11137. return _this;
  11138. }
  11139. TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) {
  11140. var _a = this, props = _a.props, context = _a.context;
  11141. var sections = [];
  11142. var stickyHeaderDates = getStickyHeaderDates(context.options);
  11143. if (headerRowContent) {
  11144. sections.push({
  11145. type: 'header',
  11146. key: 'header',
  11147. isSticky: stickyHeaderDates,
  11148. chunk: {
  11149. elRef: this.headerElRef,
  11150. tableClassName: 'fc-col-header',
  11151. rowContent: headerRowContent,
  11152. },
  11153. });
  11154. }
  11155. sections.push({
  11156. type: 'body',
  11157. key: 'body',
  11158. liquid: true,
  11159. chunk: { content: bodyContent },
  11160. });
  11161. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11162. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); }));
  11163. };
  11164. TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) {
  11165. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  11166. if (!ScrollGrid) {
  11167. throw new Error('No ScrollGrid implementation');
  11168. }
  11169. var _a = this, props = _a.props, context = _a.context;
  11170. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  11171. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  11172. var sections = [];
  11173. if (headerRowContent) {
  11174. sections.push({
  11175. type: 'header',
  11176. key: 'header',
  11177. isSticky: stickyHeaderDates,
  11178. chunks: [{
  11179. key: 'main',
  11180. elRef: this.headerElRef,
  11181. tableClassName: 'fc-col-header',
  11182. rowContent: headerRowContent,
  11183. }],
  11184. });
  11185. }
  11186. sections.push({
  11187. type: 'body',
  11188. key: 'body',
  11189. liquid: true,
  11190. chunks: [{
  11191. key: 'main',
  11192. content: bodyContent,
  11193. }],
  11194. });
  11195. if (stickyFooterScrollbar) {
  11196. sections.push({
  11197. type: 'footer',
  11198. key: 'footer',
  11199. isSticky: true,
  11200. chunks: [{
  11201. key: 'main',
  11202. content: renderScrollShim,
  11203. }],
  11204. });
  11205. }
  11206. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11207. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); }));
  11208. };
  11209. return TableView;
  11210. }(DateComponent));
  11211. function splitSegsByRow(segs, rowCnt) {
  11212. var byRow = [];
  11213. for (var i = 0; i < rowCnt; i += 1) {
  11214. byRow[i] = [];
  11215. }
  11216. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11217. var seg = segs_1[_i];
  11218. byRow[seg.row].push(seg);
  11219. }
  11220. return byRow;
  11221. }
  11222. function splitSegsByFirstCol(segs, colCnt) {
  11223. var byCol = [];
  11224. for (var i = 0; i < colCnt; i += 1) {
  11225. byCol[i] = [];
  11226. }
  11227. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11228. var seg = segs_2[_i];
  11229. byCol[seg.firstCol].push(seg);
  11230. }
  11231. return byCol;
  11232. }
  11233. function splitInteractionByRow(ui, rowCnt) {
  11234. var byRow = [];
  11235. if (!ui) {
  11236. for (var i = 0; i < rowCnt; i += 1) {
  11237. byRow[i] = null;
  11238. }
  11239. }
  11240. else {
  11241. for (var i = 0; i < rowCnt; i += 1) {
  11242. byRow[i] = {
  11243. affectedInstances: ui.affectedInstances,
  11244. isEvent: ui.isEvent,
  11245. segs: [],
  11246. };
  11247. }
  11248. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  11249. var seg = _a[_i];
  11250. byRow[seg.row].segs.push(seg);
  11251. }
  11252. }
  11253. return byRow;
  11254. }
  11255. var TableCellTop = /** @class */ (function (_super) {
  11256. __extends(TableCellTop, _super);
  11257. function TableCellTop() {
  11258. return _super !== null && _super.apply(this, arguments) || this;
  11259. }
  11260. TableCellTop.prototype.render = function () {
  11261. var props = this.props;
  11262. var navLinkAttrs = this.context.options.navLinks
  11263. ? { 'data-navlink': buildNavLinkData(props.date), tabIndex: 0 }
  11264. : {};
  11265. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, defaultContent: renderTopInner }, function (innerElRef, innerContent) { return ((innerContent || props.forceDayTop) && (createElement("div", { className: "fc-daygrid-day-top", ref: innerElRef },
  11266. createElement("a", __assign({ className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\u00A0"))))); }));
  11267. };
  11268. return TableCellTop;
  11269. }(BaseComponent));
  11270. function renderTopInner(props) {
  11271. return props.dayNumberText;
  11272. }
  11273. var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'narrow' });
  11274. var TableCell = /** @class */ (function (_super) {
  11275. __extends(TableCell, _super);
  11276. function TableCell() {
  11277. var _this = _super !== null && _super.apply(this, arguments) || this;
  11278. _this.handleRootEl = function (el) {
  11279. _this.rootEl = el;
  11280. setRef(_this.props.elRef, el);
  11281. };
  11282. _this.handleMoreLinkClick = function (ev) {
  11283. var props = _this.props;
  11284. if (props.onMoreClick) {
  11285. var allSegs = props.segsByEachCol;
  11286. var hiddenSegs = allSegs.filter(function (seg) { return props.segIsHidden[seg.eventRange.instance.instanceId]; });
  11287. props.onMoreClick({
  11288. date: props.date,
  11289. allSegs: allSegs,
  11290. hiddenSegs: hiddenSegs,
  11291. moreCnt: props.moreCnt,
  11292. dayEl: _this.rootEl,
  11293. ev: ev,
  11294. });
  11295. }
  11296. };
  11297. return _this;
  11298. }
  11299. TableCell.prototype.render = function () {
  11300. var _this = this;
  11301. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  11302. var props = this.props;
  11303. var date = props.date, dateProfile = props.dateProfile;
  11304. var hookProps = {
  11305. num: props.moreCnt,
  11306. text: props.buildMoreLinkText(props.moreCnt),
  11307. view: viewApi,
  11308. };
  11309. var navLinkAttrs = options.navLinks
  11310. ? { 'data-navlink': buildNavLinkData(date, 'week'), tabIndex: 0 }
  11311. : {};
  11312. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function (dayElRef, dayClassNames, rootDataAttrs, isDisabled) { return (createElement("td", __assign({ ref: dayElRef, className: ['fc-daygrid-day'].concat(dayClassNames, props.extraClassNames || []).join(' ') }, rootDataAttrs, props.extraDataAttrs),
  11313. createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ },
  11314. props.showWeekNumber && (createElement(WeekNumberRoot, { date: date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function (weekElRef, weekClassNames, innerElRef, innerContent) { return (createElement("a", __assign({ ref: weekElRef, className: ['fc-daygrid-week-number'].concat(weekClassNames).join(' ') }, navLinkAttrs), innerContent)); })),
  11315. !isDisabled && (createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })),
  11316. createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef, style: { paddingBottom: props.fgPaddingBottom } },
  11317. props.fgContent,
  11318. Boolean(props.moreCnt) && (createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
  11319. createElement(RenderHook, { hookProps: hookProps, classNames: options.moreLinkClassNames, content: options.moreLinkContent, defaultContent: renderMoreLinkInner, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("a", { ref: rootElRef, className: ['fc-daygrid-more-link'].concat(classNames).join(' '), onClick: _this.handleMoreLinkClick }, innerContent)); })))),
  11320. createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); }));
  11321. };
  11322. return TableCell;
  11323. }(DateComponent));
  11324. TableCell.addPropsEquality({
  11325. onMoreClick: true,
  11326. });
  11327. function renderMoreLinkInner(props) {
  11328. return props.text;
  11329. }
  11330. var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  11331. hour: 'numeric',
  11332. minute: '2-digit',
  11333. omitZeroMinute: true,
  11334. meridiem: 'narrow',
  11335. });
  11336. function hasListItemDisplay(seg) {
  11337. var display = seg.eventRange.ui.display;
  11338. return display === 'list-item' || (display === 'auto' &&
  11339. !seg.eventRange.def.allDay &&
  11340. seg.firstCol === seg.lastCol && // can't be multi-day
  11341. seg.isStart && // "
  11342. seg.isEnd // "
  11343. );
  11344. }
  11345. var TableListItemEvent = /** @class */ (function (_super) {
  11346. __extends(TableListItemEvent, _super);
  11347. function TableListItemEvent() {
  11348. return _super !== null && _super.apply(this, arguments) || this;
  11349. }
  11350. TableListItemEvent.prototype.render = function () {
  11351. var _a = this, props = _a.props, context = _a.context;
  11352. var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  11353. var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  11354. return (createElement(EventRoot, { seg: props.seg, timeText: timeText, defaultContent: renderInnerContent$2, isDragging: props.isDragging, isResizing: false, isDateSelecting: false, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function (rootElRef, classNames, innerElRef, innerContent) { return ( // we don't use styles!
  11355. createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs$1(props.seg)), innerContent)); }));
  11356. };
  11357. return TableListItemEvent;
  11358. }(BaseComponent));
  11359. function renderInnerContent$2(innerProps) {
  11360. return (createElement(Fragment, null,
  11361. createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }),
  11362. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  11363. createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\u00A0"))));
  11364. }
  11365. function getSegAnchorAttrs$1(seg) {
  11366. var url = seg.eventRange.def.url;
  11367. return url ? { href: url } : {};
  11368. }
  11369. var TableBlockEvent = /** @class */ (function (_super) {
  11370. __extends(TableBlockEvent, _super);
  11371. function TableBlockEvent() {
  11372. return _super !== null && _super.apply(this, arguments) || this;
  11373. }
  11374. TableBlockEvent.prototype.render = function () {
  11375. var props = this.props;
  11376. return (createElement(StandardEvent, __assign({}, props, { extraClassNames: ['fc-daygrid-event', 'fc-daygrid-block-event', 'fc-h-event'], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay })));
  11377. };
  11378. return TableBlockEvent;
  11379. }(BaseComponent));
  11380. function computeFgSegPlacement(// for one row. TODO: print mode?
  11381. cellModels, segs, dayMaxEvents, dayMaxEventRows, eventHeights, maxContentHeight, colCnt, eventOrderSpecs) {
  11382. var colPlacements = []; // if event spans multiple cols, its present in each col
  11383. var moreCnts = []; // by-col
  11384. var segIsHidden = {};
  11385. var segTops = {}; // always populated for each seg
  11386. var segMarginTops = {}; // simetimes populated for each seg
  11387. var moreTops = {};
  11388. var paddingBottoms = {}; // for each cell's inner-wrapper div
  11389. for (var i = 0; i < colCnt; i += 1) {
  11390. colPlacements.push([]);
  11391. moreCnts.push(0);
  11392. }
  11393. segs = sortEventSegs(segs, eventOrderSpecs);
  11394. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11395. var seg = segs_1[_i];
  11396. var instanceId = seg.eventRange.instance.instanceId;
  11397. var eventHeight = eventHeights[instanceId + ':' + seg.firstCol];
  11398. placeSeg(seg, eventHeight || 0); // will keep colPlacements sorted by top
  11399. }
  11400. if (dayMaxEvents === true || dayMaxEventRows === true) {
  11401. limitByMaxHeight(moreCnts, segIsHidden, colPlacements, maxContentHeight); // populates moreCnts/segIsHidden
  11402. }
  11403. else if (typeof dayMaxEvents === 'number') {
  11404. limitByMaxEvents(moreCnts, segIsHidden, colPlacements, dayMaxEvents); // populates moreCnts/segIsHidden
  11405. }
  11406. else if (typeof dayMaxEventRows === 'number') {
  11407. limitByMaxRows(moreCnts, segIsHidden, colPlacements, dayMaxEventRows); // populates moreCnts/segIsHidden
  11408. }
  11409. // computes segTops/segMarginTops/moreTops/paddingBottoms
  11410. for (var col = 0; col < colCnt; col += 1) {
  11411. var placements = colPlacements[col];
  11412. var currentNonAbsBottom = 0;
  11413. var currentAbsHeight = 0;
  11414. for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
  11415. var placement = placements_1[_a];
  11416. var seg = placement.seg;
  11417. if (!segIsHidden[seg.eventRange.instance.instanceId]) {
  11418. segTops[seg.eventRange.instance.instanceId] = placement.top; // from top of container
  11419. if (seg.firstCol === seg.lastCol && seg.isStart && seg.isEnd) { // TODO: simpler way? NOT DRY
  11420. segMarginTops[seg.eventRange.instance.instanceId] =
  11421. placement.top - currentNonAbsBottom; // from previous seg bottom
  11422. currentAbsHeight = 0;
  11423. currentNonAbsBottom = placement.bottom;
  11424. }
  11425. else { // multi-col event, abs positioned
  11426. currentAbsHeight = placement.bottom - currentNonAbsBottom;
  11427. }
  11428. }
  11429. }
  11430. if (currentAbsHeight) {
  11431. if (moreCnts[col]) {
  11432. moreTops[col] = currentAbsHeight;
  11433. }
  11434. else {
  11435. paddingBottoms[col] = currentAbsHeight;
  11436. }
  11437. }
  11438. }
  11439. function placeSeg(seg, segHeight) {
  11440. if (!tryPlaceSegAt(seg, segHeight, 0)) {
  11441. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11442. for (var _i = 0, _a = colPlacements[col]; _i < _a.length; _i++) { // will repeat multi-day segs!!!!!!! bad!!!!!!
  11443. var placement = _a[_i];
  11444. if (tryPlaceSegAt(seg, segHeight, placement.bottom)) {
  11445. return;
  11446. }
  11447. }
  11448. }
  11449. }
  11450. }
  11451. function tryPlaceSegAt(seg, segHeight, top) {
  11452. if (canPlaceSegAt(seg, segHeight, top)) {
  11453. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11454. var placements = colPlacements[col];
  11455. var insertionIndex = 0;
  11456. while (insertionIndex < placements.length &&
  11457. top >= placements[insertionIndex].top) {
  11458. insertionIndex += 1;
  11459. }
  11460. placements.splice(insertionIndex, 0, {
  11461. seg: seg,
  11462. top: top,
  11463. bottom: top + segHeight,
  11464. });
  11465. }
  11466. return true;
  11467. }
  11468. return false;
  11469. }
  11470. function canPlaceSegAt(seg, segHeight, top) {
  11471. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11472. for (var _i = 0, _a = colPlacements[col]; _i < _a.length; _i++) {
  11473. var placement = _a[_i];
  11474. if (top < placement.bottom && top + segHeight > placement.top) { // collide?
  11475. return false;
  11476. }
  11477. }
  11478. }
  11479. return true;
  11480. }
  11481. // what does this do!?
  11482. for (var instanceIdAndFirstCol in eventHeights) {
  11483. if (!eventHeights[instanceIdAndFirstCol]) {
  11484. segIsHidden[instanceIdAndFirstCol.split(':')[0]] = true;
  11485. }
  11486. }
  11487. var segsByFirstCol = colPlacements.map(extractFirstColSegs); // operates on the sorted cols
  11488. var segsByEachCol = colPlacements.map(function (placements, col) {
  11489. var segsForCols = extractAllColSegs(placements);
  11490. segsForCols = resliceDaySegs(segsForCols, cellModels[col].date, col);
  11491. return segsForCols;
  11492. });
  11493. return {
  11494. segsByFirstCol: segsByFirstCol,
  11495. segsByEachCol: segsByEachCol,
  11496. segIsHidden: segIsHidden,
  11497. segTops: segTops,
  11498. segMarginTops: segMarginTops,
  11499. moreCnts: moreCnts,
  11500. moreTops: moreTops,
  11501. paddingBottoms: paddingBottoms,
  11502. };
  11503. }
  11504. function extractFirstColSegs(oneColPlacements, col) {
  11505. var segs = [];
  11506. for (var _i = 0, oneColPlacements_1 = oneColPlacements; _i < oneColPlacements_1.length; _i++) {
  11507. var placement = oneColPlacements_1[_i];
  11508. if (placement.seg.firstCol === col) {
  11509. segs.push(placement.seg);
  11510. }
  11511. }
  11512. return segs;
  11513. }
  11514. function extractAllColSegs(oneColPlacements) {
  11515. var segs = [];
  11516. for (var _i = 0, oneColPlacements_2 = oneColPlacements; _i < oneColPlacements_2.length; _i++) {
  11517. var placement = oneColPlacements_2[_i];
  11518. segs.push(placement.seg);
  11519. }
  11520. return segs;
  11521. }
  11522. function limitByMaxHeight(hiddenCnts, segIsHidden, colPlacements, maxContentHeight) {
  11523. limitEvents(hiddenCnts, segIsHidden, colPlacements, true, function (placement) { return placement.bottom <= maxContentHeight; });
  11524. }
  11525. function limitByMaxEvents(hiddenCnts, segIsHidden, colPlacements, dayMaxEvents) {
  11526. limitEvents(hiddenCnts, segIsHidden, colPlacements, false, function (placement, levelIndex) { return levelIndex < dayMaxEvents; });
  11527. }
  11528. function limitByMaxRows(hiddenCnts, segIsHidden, colPlacements, dayMaxEventRows) {
  11529. limitEvents(hiddenCnts, segIsHidden, colPlacements, true, function (placement, levelIndex) { return levelIndex < dayMaxEventRows; });
  11530. }
  11531. /*
  11532. populates the given hiddenCnts/segIsHidden, which are supplied empty.
  11533. TODO: return them instead
  11534. */
  11535. function limitEvents(hiddenCnts, segIsHidden, colPlacements, _moreLinkConsumesLevel, isPlacementInBounds) {
  11536. var colCnt = hiddenCnts.length;
  11537. var segIsVisible = {}; // TODO: instead, use segIsHidden with true/false?
  11538. var visibleColPlacements = []; // will mirror colPlacements
  11539. for (var col = 0; col < colCnt; col += 1) {
  11540. visibleColPlacements.push([]);
  11541. }
  11542. for (var col = 0; col < colCnt; col += 1) {
  11543. var placements = colPlacements[col];
  11544. var level = 0;
  11545. for (var _i = 0, placements_2 = placements; _i < placements_2.length; _i++) {
  11546. var placement = placements_2[_i];
  11547. if (isPlacementInBounds(placement, level)) {
  11548. recordVisible(placement);
  11549. }
  11550. else {
  11551. recordHidden(placement, level, _moreLinkConsumesLevel);
  11552. }
  11553. // only considered a level if the seg had height
  11554. if (placement.top !== placement.bottom) {
  11555. level += 1;
  11556. }
  11557. }
  11558. }
  11559. function recordVisible(placement) {
  11560. var seg = placement.seg;
  11561. var instanceId = seg.eventRange.instance.instanceId;
  11562. if (!segIsVisible[instanceId]) {
  11563. segIsVisible[instanceId] = true;
  11564. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11565. var destPlacements = visibleColPlacements[col];
  11566. var newPosition = 0;
  11567. // insert while keeping top sorted in each column
  11568. while (newPosition < destPlacements.length &&
  11569. placement.top >= destPlacements[newPosition].top) {
  11570. newPosition += 1;
  11571. }
  11572. destPlacements.splice(newPosition, 0, placement);
  11573. }
  11574. }
  11575. }
  11576. function recordHidden(placement, currentLevel, moreLinkConsumesLevel) {
  11577. var seg = placement.seg;
  11578. var instanceId = seg.eventRange.instance.instanceId;
  11579. if (!segIsHidden[instanceId]) {
  11580. segIsHidden[instanceId] = true;
  11581. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11582. hiddenCnts[col] += 1;
  11583. var hiddenCnt = hiddenCnts[col];
  11584. if (moreLinkConsumesLevel && hiddenCnt === 1 && currentLevel > 0) {
  11585. var doomedLevel = currentLevel - 1;
  11586. while (visibleColPlacements[col].length > doomedLevel) {
  11587. recordHidden(visibleColPlacements[col].pop(), // removes
  11588. visibleColPlacements[col].length, // will execute after the pop. will be the index of the removed placement
  11589. false);
  11590. }
  11591. }
  11592. }
  11593. }
  11594. }
  11595. }
  11596. // Given the events within an array of segment objects, reslice them to be in a single day
  11597. function resliceDaySegs(segs, dayDate, colIndex) {
  11598. var dayStart = dayDate;
  11599. var dayEnd = addDays(dayStart, 1);
  11600. var dayRange = { start: dayStart, end: dayEnd };
  11601. var newSegs = [];
  11602. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11603. var seg = segs_2[_i];
  11604. var eventRange = seg.eventRange;
  11605. var origRange = eventRange.range;
  11606. var slicedRange = intersectRanges(origRange, dayRange);
  11607. if (slicedRange) {
  11608. newSegs.push(__assign(__assign({}, seg), { firstCol: colIndex, lastCol: colIndex, eventRange: {
  11609. def: eventRange.def,
  11610. ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
  11611. instance: eventRange.instance,
  11612. range: slicedRange,
  11613. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  11614. }
  11615. }
  11616. return newSegs;
  11617. }
  11618. var TableRow = /** @class */ (function (_super) {
  11619. __extends(TableRow, _super);
  11620. function TableRow() {
  11621. var _this = _super !== null && _super.apply(this, arguments) || this;
  11622. _this.cellElRefs = new RefMap(); // the <td>
  11623. _this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  11624. _this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  11625. _this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  11626. _this.rootElRef = createRef();
  11627. _this.state = {
  11628. framePositions: null,
  11629. maxContentHeight: null,
  11630. segHeights: {},
  11631. };
  11632. return _this;
  11633. }
  11634. TableRow.prototype.render = function () {
  11635. var _this = this;
  11636. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  11637. var colCnt = props.cells.length;
  11638. var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  11639. var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  11640. var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  11641. var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  11642. var _b = computeFgSegPlacement(props.cells, props.fgEventSegs, props.dayMaxEvents, props.dayMaxEventRows, state.segHeights, state.maxContentHeight, colCnt, context.options.eventOrder), paddingBottoms = _b.paddingBottoms, segsByFirstCol = _b.segsByFirstCol, segsByEachCol = _b.segsByEachCol, segIsHidden = _b.segIsHidden, segTops = _b.segTops, segMarginTops = _b.segMarginTops, moreCnts = _b.moreCnts, moreTops = _b.moreTops;
  11643. var selectedInstanceHash = // TODO: messy way to compute this
  11644. (props.eventDrag && props.eventDrag.affectedInstances) ||
  11645. (props.eventResize && props.eventResize.affectedInstances) ||
  11646. {};
  11647. return (createElement("tr", { ref: this.rootElRef },
  11648. props.renderIntro && props.renderIntro(),
  11649. props.cells.map(function (cell, col) {
  11650. var normalFgNodes = _this.renderFgSegs(segsByFirstCol[col], segIsHidden, segTops, segMarginTops, selectedInstanceHash, props.todayRange);
  11651. var mirrorFgNodes = _this.renderFgSegs(mirrorSegsByCol[col], {}, segTops, // use same tops as real rendering
  11652. {}, {}, props.todayRange, Boolean(props.eventDrag), Boolean(props.eventResize), false);
  11653. return (createElement(TableCell, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), innerElRef: _this.frameElRefs.createRef(cell.key) /* FF <td> problem, but okay to use for left/right. TODO: rename prop */, dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers, showWeekNumber: props.showWeekNumbers && col === 0, forceDayTop: props.showWeekNumbers /* even displaying weeknum for row, not necessarily day */, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, moreCnt: moreCnts[col], buildMoreLinkText: props.buildMoreLinkText, onMoreClick: function (arg) {
  11654. props.onMoreClick(__assign(__assign({}, arg), { fromCol: col }));
  11655. }, segIsHidden: segIsHidden, moreMarginTop: moreTops[col] /* rename */, segsByEachCol: segsByEachCol[col], fgPaddingBottom: paddingBottoms[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: ( // Fragment scopes the keys
  11656. createElement(Fragment, null,
  11657. createElement(Fragment, null, normalFgNodes),
  11658. createElement(Fragment, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  11659. createElement(Fragment, null,
  11660. _this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  11661. _this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  11662. _this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))) }));
  11663. })));
  11664. };
  11665. TableRow.prototype.componentDidMount = function () {
  11666. this.updateSizing(true);
  11667. };
  11668. TableRow.prototype.componentDidUpdate = function (prevProps, prevState) {
  11669. var currentProps = this.props;
  11670. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  11671. };
  11672. TableRow.prototype.getHighlightSegs = function () {
  11673. var props = this.props;
  11674. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  11675. return props.eventDrag.segs;
  11676. }
  11677. if (props.eventResize && props.eventResize.segs.length) { // messy check
  11678. return props.eventResize.segs;
  11679. }
  11680. return props.dateSelectionSegs;
  11681. };
  11682. TableRow.prototype.getMirrorSegs = function () {
  11683. var props = this.props;
  11684. if (props.eventResize && props.eventResize.segs.length) { // messy check
  11685. return props.eventResize.segs;
  11686. }
  11687. return [];
  11688. };
  11689. TableRow.prototype.renderFgSegs = function (segs, segIsHidden, // does NOT mean display:hidden
  11690. segTops, segMarginTops, selectedInstanceHash, todayRange, isDragging, isResizing, isDateSelecting) {
  11691. var context = this.context;
  11692. var eventSelection = this.props.eventSelection;
  11693. var framePositions = this.state.framePositions;
  11694. var defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  11695. var nodes = [];
  11696. if (framePositions) {
  11697. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11698. var seg = segs_1[_i];
  11699. var instanceId = seg.eventRange.instance.instanceId;
  11700. var isMirror = isDragging || isResizing || isDateSelecting;
  11701. var isSelected = selectedInstanceHash[instanceId];
  11702. var isInvisible = segIsHidden[instanceId] || isSelected;
  11703. // TODO: simpler way? NOT DRY
  11704. var isAbsolute = segIsHidden[instanceId] || isMirror || seg.firstCol !== seg.lastCol || !seg.isStart || !seg.isEnd;
  11705. var marginTop = void 0;
  11706. var top_1 = void 0;
  11707. var left = void 0;
  11708. var right = void 0;
  11709. if (isAbsolute) {
  11710. top_1 = segTops[instanceId];
  11711. if (context.isRtl) {
  11712. right = 0;
  11713. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  11714. }
  11715. else {
  11716. left = 0;
  11717. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  11718. }
  11719. }
  11720. else {
  11721. marginTop = segMarginTops[instanceId];
  11722. }
  11723. /*
  11724. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  11725. */
  11726. nodes.push(createElement("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: instanceId,
  11727. // in print mode when in mult cols, could collide
  11728. ref: isMirror ? null : this.segHarnessRefs.createRef(instanceId + ':' + seg.firstCol), style: {
  11729. visibility: isInvisible ? 'hidden' : '',
  11730. marginTop: marginTop || '',
  11731. top: top_1 || '',
  11732. left: left || '',
  11733. right: right || '',
  11734. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd: defaultDisplayEventEnd }, getSegMeta(seg, todayRange))))));
  11735. }
  11736. }
  11737. return nodes;
  11738. };
  11739. TableRow.prototype.renderFillSegs = function (segs, fillType) {
  11740. var isRtl = this.context.isRtl;
  11741. var todayRange = this.props.todayRange;
  11742. var framePositions = this.state.framePositions;
  11743. var nodes = [];
  11744. if (framePositions) {
  11745. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11746. var seg = segs_2[_i];
  11747. var leftRightCss = isRtl ? {
  11748. right: 0,
  11749. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
  11750. } : {
  11751. left: 0,
  11752. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  11753. };
  11754. nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
  11755. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  11756. renderFill(fillType)));
  11757. }
  11758. }
  11759. return createElement.apply(void 0, __spreadArrays([Fragment, {}], nodes));
  11760. };
  11761. TableRow.prototype.updateSizing = function (isExternalSizingChange) {
  11762. var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
  11763. if (props.clientWidth !== null) { // positioning ready?
  11764. if (isExternalSizingChange) {
  11765. var frameEls = props.cells.map(function (cell) { return frameElRefs.currentMap[cell.key]; });
  11766. if (frameEls.length) {
  11767. var originEl = this.rootElRef.current;
  11768. this.setState({
  11769. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  11770. false),
  11771. });
  11772. }
  11773. }
  11774. var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  11775. this.setState({
  11776. segHeights: this.computeSegHeights(),
  11777. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
  11778. });
  11779. }
  11780. };
  11781. TableRow.prototype.computeSegHeights = function () {
  11782. return mapHash(this.segHarnessRefs.currentMap, function (eventHarnessEl) { return (eventHarnessEl.getBoundingClientRect().height); });
  11783. };
  11784. TableRow.prototype.computeMaxContentHeight = function () {
  11785. var firstKey = this.props.cells[0].key;
  11786. var cellEl = this.cellElRefs.currentMap[firstKey];
  11787. var fcContainerEl = this.fgElRefs.currentMap[firstKey];
  11788. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  11789. };
  11790. TableRow.prototype.getCellEls = function () {
  11791. var elMap = this.cellElRefs.currentMap;
  11792. return this.props.cells.map(function (cell) { return elMap[cell.key]; });
  11793. };
  11794. return TableRow;
  11795. }(DateComponent));
  11796. TableRow.addPropsEquality({
  11797. onMoreClick: true,
  11798. });
  11799. TableRow.addStateEquality({
  11800. segHeights: isPropsEqual,
  11801. });
  11802. var PADDING_FROM_VIEWPORT = 10;
  11803. var SCROLL_DEBOUNCE = 10;
  11804. var Popover = /** @class */ (function (_super) {
  11805. __extends(Popover, _super);
  11806. function Popover() {
  11807. var _this = _super !== null && _super.apply(this, arguments) || this;
  11808. _this.repositioner = new DelayedRunner(_this.updateSize.bind(_this));
  11809. _this.handleRootEl = function (el) {
  11810. _this.rootEl = el;
  11811. if (_this.props.elRef) {
  11812. setRef(_this.props.elRef, el);
  11813. }
  11814. };
  11815. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  11816. _this.handleDocumentMousedown = function (ev) {
  11817. var onClose = _this.props.onClose;
  11818. // only hide the popover if the click happened outside the popover
  11819. if (onClose && !_this.rootEl.contains(ev.target)) {
  11820. onClose();
  11821. }
  11822. };
  11823. _this.handleDocumentScroll = function () {
  11824. _this.repositioner.request(SCROLL_DEBOUNCE);
  11825. };
  11826. _this.handleCloseClick = function () {
  11827. var onClose = _this.props.onClose;
  11828. if (onClose) {
  11829. onClose();
  11830. }
  11831. };
  11832. return _this;
  11833. }
  11834. Popover.prototype.render = function () {
  11835. var theme = this.context.theme;
  11836. var props = this.props;
  11837. var classNames = [
  11838. 'fc-popover',
  11839. theme.getClass('popover'),
  11840. ].concat(props.extraClassNames || []);
  11841. return (createElement("div", __assign({ className: classNames.join(' ') }, props.extraAttrs, { ref: this.handleRootEl }),
  11842. createElement("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
  11843. createElement("span", { className: "fc-popover-title" }, props.title),
  11844. createElement("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), onClick: this.handleCloseClick })),
  11845. createElement("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)));
  11846. };
  11847. Popover.prototype.componentDidMount = function () {
  11848. document.addEventListener('mousedown', this.handleDocumentMousedown);
  11849. document.addEventListener('scroll', this.handleDocumentScroll);
  11850. this.updateSize();
  11851. };
  11852. Popover.prototype.componentWillUnmount = function () {
  11853. document.removeEventListener('mousedown', this.handleDocumentMousedown);
  11854. document.removeEventListener('scroll', this.handleDocumentScroll);
  11855. };
  11856. // TODO: adjust on window resize
  11857. /*
  11858. NOTE: the popover is position:fixed, so coordinates are relative to the viewport
  11859. NOTE: the PARENT calls this as well, on window resize. we would have wanted to use the repositioner,
  11860. but need to ensure that all other components have updated size first (for alignmentEl)
  11861. */
  11862. Popover.prototype.updateSize = function () {
  11863. var _a = this.props, alignmentEl = _a.alignmentEl, topAlignmentEl = _a.topAlignmentEl;
  11864. var rootEl = this.rootEl;
  11865. if (!rootEl) {
  11866. return; // not sure why this was null, but we shouldn't let external components call updateSize() anyway
  11867. }
  11868. var dims = rootEl.getBoundingClientRect(); // only used for width,height
  11869. var alignment = alignmentEl.getBoundingClientRect();
  11870. var top = topAlignmentEl ? topAlignmentEl.getBoundingClientRect().top : alignment.top;
  11871. top = Math.min(top, window.innerHeight - dims.height - PADDING_FROM_VIEWPORT);
  11872. top = Math.max(top, PADDING_FROM_VIEWPORT);
  11873. var left;
  11874. if (this.context.isRtl) {
  11875. left = alignment.right - dims.width;
  11876. }
  11877. else {
  11878. left = alignment.left;
  11879. }
  11880. left = Math.min(left, window.innerWidth - dims.width - PADDING_FROM_VIEWPORT);
  11881. left = Math.max(left, PADDING_FROM_VIEWPORT);
  11882. applyStyle(rootEl, { top: top, left: left });
  11883. };
  11884. return Popover;
  11885. }(BaseComponent));
  11886. var MorePopover = /** @class */ (function (_super) {
  11887. __extends(MorePopover, _super);
  11888. function MorePopover() {
  11889. var _this = _super !== null && _super.apply(this, arguments) || this;
  11890. _this.rootElRef = createRef();
  11891. return _this;
  11892. }
  11893. MorePopover.prototype.render = function () {
  11894. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv;
  11895. var props = this.props;
  11896. var date = props.date, hiddenInstances = props.hiddenInstances, todayRange = props.todayRange, dateProfile = props.dateProfile, selectedInstanceId = props.selectedInstanceId;
  11897. var title = dateEnv.format(date, options.dayPopoverFormat);
  11898. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: todayRange, elRef: this.rootElRef }, function (rootElRef, dayClassNames, dataAttrs) { return (createElement(Popover, { elRef: rootElRef, title: title, extraClassNames: ['fc-more-popover'].concat(dayClassNames), extraAttrs: dataAttrs, onClose: props.onCloseClick, alignmentEl: props.alignmentEl, topAlignmentEl: props.topAlignmentEl },
  11899. createElement(DayCellContent, { date: date, dateProfile: dateProfile, todayRange: todayRange }, function (innerElRef, innerContent) { return (innerContent &&
  11900. createElement("div", { className: "fc-more-popover-misc", ref: innerElRef }, innerContent)); }),
  11901. props.segs.map(function (seg) {
  11902. var instanceId = seg.eventRange.instance.instanceId;
  11903. return (createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
  11904. visibility: hiddenInstances[instanceId] ? 'hidden' : '',
  11905. } }, hasListItemDisplay(seg) ? (createElement(TableListItemEvent, __assign({ seg: seg, isDragging: false, isSelected: instanceId === selectedInstanceId, defaultDisplayEventEnd: false }, getSegMeta(seg, todayRange)))) : (createElement(TableBlockEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === selectedInstanceId, defaultDisplayEventEnd: false }, getSegMeta(seg, todayRange))))));
  11906. }))); }));
  11907. };
  11908. MorePopover.prototype.positionToHit = function (positionLeft, positionTop, originEl) {
  11909. var rootEl = this.rootElRef.current;
  11910. if (!originEl || !rootEl) { // why?
  11911. return null;
  11912. }
  11913. var originRect = originEl.getBoundingClientRect();
  11914. var elRect = rootEl.getBoundingClientRect();
  11915. var newOriginLeft = elRect.left - originRect.left;
  11916. var newOriginTop = elRect.top - originRect.top;
  11917. var localLeft = positionLeft - newOriginLeft;
  11918. var localTop = positionTop - newOriginTop;
  11919. var date = this.props.date;
  11920. if ( // ugly way to detect intersection
  11921. localLeft >= 0 && localLeft < elRect.width &&
  11922. localTop >= 0 && localTop < elRect.height) {
  11923. return {
  11924. dateSpan: {
  11925. allDay: true,
  11926. range: { start: date, end: addDays(date, 1) },
  11927. },
  11928. dayEl: rootEl,
  11929. relativeRect: {
  11930. left: newOriginLeft,
  11931. top: newOriginTop,
  11932. right: elRect.width,
  11933. bottom: elRect.height,
  11934. },
  11935. layer: 1,
  11936. };
  11937. }
  11938. return null;
  11939. };
  11940. return MorePopover;
  11941. }(DateComponent));
  11942. var Table = /** @class */ (function (_super) {
  11943. __extends(Table, _super);
  11944. function Table() {
  11945. var _this = _super !== null && _super.apply(this, arguments) || this;
  11946. _this.splitBusinessHourSegs = memoize(splitSegsByRow);
  11947. _this.splitBgEventSegs = memoize(splitSegsByRow);
  11948. _this.splitFgEventSegs = memoize(splitSegsByRow);
  11949. _this.splitDateSelectionSegs = memoize(splitSegsByRow);
  11950. _this.splitEventDrag = memoize(splitInteractionByRow);
  11951. _this.splitEventResize = memoize(splitInteractionByRow);
  11952. _this.buildBuildMoreLinkText = memoize(buildBuildMoreLinkText);
  11953. _this.morePopoverRef = createRef();
  11954. _this.rowRefs = new RefMap();
  11955. _this.state = {
  11956. morePopoverState: null,
  11957. };
  11958. _this.handleRootEl = function (rootEl) {
  11959. _this.rootEl = rootEl;
  11960. setRef(_this.props.elRef, rootEl);
  11961. };
  11962. // TODO: bad names "more link click" versus "more click"
  11963. _this.handleMoreLinkClick = function (arg) {
  11964. var context = _this.context;
  11965. var dateEnv = context.dateEnv;
  11966. var clickOption = context.options.moreLinkClick;
  11967. function segForPublic(seg) {
  11968. var _a = seg.eventRange, def = _a.def, instance = _a.instance, range = _a.range;
  11969. return {
  11970. event: new EventApi(context, def, instance),
  11971. start: dateEnv.toDate(range.start),
  11972. end: dateEnv.toDate(range.end),
  11973. isStart: seg.isStart,
  11974. isEnd: seg.isEnd,
  11975. };
  11976. }
  11977. if (typeof clickOption === 'function') {
  11978. clickOption = clickOption({
  11979. date: dateEnv.toDate(arg.date),
  11980. allDay: true,
  11981. allSegs: arg.allSegs.map(segForPublic),
  11982. hiddenSegs: arg.hiddenSegs.map(segForPublic),
  11983. jsEvent: arg.ev,
  11984. view: context.viewApi,
  11985. }); // hack to handle void
  11986. }
  11987. if (!clickOption || clickOption === 'popover') {
  11988. _this.setState({
  11989. morePopoverState: __assign(__assign({}, arg), { currentFgEventSegs: _this.props.fgEventSegs, fromRow: arg.fromRow, fromCol: arg.fromCol }),
  11990. });
  11991. }
  11992. else if (typeof clickOption === 'string') { // a view name
  11993. context.calendarApi.zoomTo(arg.date, clickOption);
  11994. }
  11995. };
  11996. _this.handleMorePopoverClose = function () {
  11997. _this.setState({
  11998. morePopoverState: null,
  11999. });
  12000. };
  12001. return _this;
  12002. }
  12003. Table.prototype.render = function () {
  12004. var _this = this;
  12005. var props = this.props;
  12006. var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
  12007. var morePopoverState = this.state.morePopoverState;
  12008. var rowCnt = props.cells.length;
  12009. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  12010. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  12011. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  12012. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  12013. var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  12014. var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  12015. var buildMoreLinkText = this.buildBuildMoreLinkText(this.context.options.moreLinkText);
  12016. var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  12017. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  12018. // TODO: best place to normalize these options?
  12019. if (limitViaBalanced && !expandRows) {
  12020. limitViaBalanced = false;
  12021. dayMaxEventRows = null;
  12022. dayMaxEvents = null;
  12023. }
  12024. var classNames = [
  12025. 'fc-daygrid-body',
  12026. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  12027. expandRows ? '' : 'fc-daygrid-body-natural',
  12028. ];
  12029. return (createElement("div", { className: classNames.join(' '), ref: this.handleRootEl, style: {
  12030. // these props are important to give this wrapper correct dimensions for interactions
  12031. // TODO: if we set it here, can we avoid giving to inner tables?
  12032. width: props.clientWidth,
  12033. minWidth: props.tableMinWidth,
  12034. } },
  12035. createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement(Fragment, null,
  12036. createElement("table", { className: "fc-scrollgrid-sync-table", style: {
  12037. width: props.clientWidth,
  12038. minWidth: props.tableMinWidth,
  12039. height: expandRows ? props.clientHeight : '',
  12040. } },
  12041. props.colGroupNode,
  12042. createElement("tbody", null, props.cells.map(function (cells, row) { return (createElement(TableRow, { ref: _this.rowRefs.createRef(row), key: cells.length
  12043. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  12044. : row // in case there are no cells (like when resource view is loading)
  12045. , showDayNumbers: rowCnt > 1, showWeekNumbers: props.showWeekNumbers, todayRange: todayRange, dateProfile: dateProfile, cells: cells, renderIntro: props.renderRowIntro, businessHourSegs: businessHourSegsByRow[row], eventSelection: props.eventSelection, bgEventSegs: bgEventSegsByRow[row].filter(isSegAllDay) /* hack */, fgEventSegs: fgEventSegsByRow[row], dateSelectionSegs: dateSelectionSegsByRow[row], eventDrag: eventDragByRow[row], eventResize: eventResizeByRow[row], dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows, clientWidth: props.clientWidth, clientHeight: props.clientHeight, buildMoreLinkText: buildMoreLinkText, onMoreClick: function (arg) {
  12046. _this.handleMoreLinkClick(__assign(__assign({}, arg), { fromRow: row }));
  12047. } })); }))),
  12048. (!props.forPrint && morePopoverState && morePopoverState.currentFgEventSegs === props.fgEventSegs) && (createElement(MorePopover, { ref: _this.morePopoverRef, date: morePopoverState.date, dateProfile: dateProfile, segs: morePopoverState.allSegs, alignmentEl: morePopoverState.dayEl, topAlignmentEl: rowCnt === 1 ? props.headerAlignElRef.current : null, onCloseClick: _this.handleMorePopoverClose, selectedInstanceId: props.eventSelection, hiddenInstances: // yuck
  12049. (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  12050. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  12051. {}, todayRange: todayRange })))); })));
  12052. };
  12053. // Hit System
  12054. // ----------------------------------------------------------------------------------------------------
  12055. Table.prototype.prepareHits = function () {
  12056. this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map(function (rowObj) { return rowObj.getCellEls()[0]; }), // first cell el in each row. TODO: not optimal
  12057. false, true);
  12058. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  12059. true, // horizontal
  12060. false);
  12061. };
  12062. Table.prototype.positionToHit = function (leftPosition, topPosition) {
  12063. var morePopover = this.morePopoverRef.current;
  12064. var morePopoverHit = morePopover ? morePopover.positionToHit(leftPosition, topPosition, this.rootEl) : null;
  12065. var morePopoverState = this.state.morePopoverState;
  12066. if (morePopoverHit) {
  12067. return __assign({ row: morePopoverState.fromRow, col: morePopoverState.fromCol }, morePopoverHit);
  12068. }
  12069. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  12070. var col = colPositions.leftToIndex(leftPosition);
  12071. var row = rowPositions.topToIndex(topPosition);
  12072. if (row != null && col != null) {
  12073. return {
  12074. row: row,
  12075. col: col,
  12076. dateSpan: {
  12077. range: this.getCellRange(row, col),
  12078. allDay: true,
  12079. },
  12080. dayEl: this.getCellEl(row, col),
  12081. relativeRect: {
  12082. left: colPositions.lefts[col],
  12083. right: colPositions.rights[col],
  12084. top: rowPositions.tops[row],
  12085. bottom: rowPositions.bottoms[row],
  12086. },
  12087. };
  12088. }
  12089. return null;
  12090. };
  12091. Table.prototype.getCellEl = function (row, col) {
  12092. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  12093. };
  12094. Table.prototype.getCellRange = function (row, col) {
  12095. var start = this.props.cells[row][col].date;
  12096. var end = addDays(start, 1);
  12097. return { start: start, end: end };
  12098. };
  12099. return Table;
  12100. }(DateComponent));
  12101. function buildBuildMoreLinkText(moreLinkTextInput) {
  12102. if (typeof moreLinkTextInput === 'function') {
  12103. return moreLinkTextInput;
  12104. }
  12105. return function (num) { return "+" + num + " " + moreLinkTextInput; };
  12106. }
  12107. function isSegAllDay(seg) {
  12108. return seg.eventRange.def.allDay;
  12109. }
  12110. var DayTableSlicer = /** @class */ (function (_super) {
  12111. __extends(DayTableSlicer, _super);
  12112. function DayTableSlicer() {
  12113. var _this = _super !== null && _super.apply(this, arguments) || this;
  12114. _this.forceDayIfListItem = true;
  12115. return _this;
  12116. }
  12117. DayTableSlicer.prototype.sliceRange = function (dateRange, dayTableModel) {
  12118. return dayTableModel.sliceRange(dateRange);
  12119. };
  12120. return DayTableSlicer;
  12121. }(Slicer));
  12122. var DayTable = /** @class */ (function (_super) {
  12123. __extends(DayTable, _super);
  12124. function DayTable() {
  12125. var _this = _super !== null && _super.apply(this, arguments) || this;
  12126. _this.slicer = new DayTableSlicer();
  12127. _this.tableRef = createRef();
  12128. _this.handleRootEl = function (rootEl) {
  12129. if (rootEl) {
  12130. _this.context.registerInteractiveComponent(_this, { el: rootEl });
  12131. }
  12132. else {
  12133. _this.context.unregisterInteractiveComponent(_this);
  12134. }
  12135. };
  12136. return _this;
  12137. }
  12138. DayTable.prototype.render = function () {
  12139. var _a = this, props = _a.props, context = _a.context;
  12140. return (createElement(Table, __assign({ ref: this.tableRef, elRef: this.handleRootEl }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint })));
  12141. };
  12142. DayTable.prototype.prepareHits = function () {
  12143. this.tableRef.current.prepareHits();
  12144. };
  12145. DayTable.prototype.queryHit = function (positionLeft, positionTop) {
  12146. var rawHit = this.tableRef.current.positionToHit(positionLeft, positionTop);
  12147. if (rawHit) {
  12148. return {
  12149. component: this,
  12150. dateSpan: rawHit.dateSpan,
  12151. dayEl: rawHit.dayEl,
  12152. rect: {
  12153. left: rawHit.relativeRect.left,
  12154. right: rawHit.relativeRect.right,
  12155. top: rawHit.relativeRect.top,
  12156. bottom: rawHit.relativeRect.bottom,
  12157. },
  12158. layer: 0,
  12159. };
  12160. }
  12161. return null;
  12162. };
  12163. return DayTable;
  12164. }(DateComponent));
  12165. var DayTableView = /** @class */ (function (_super) {
  12166. __extends(DayTableView, _super);
  12167. function DayTableView() {
  12168. var _this = _super !== null && _super.apply(this, arguments) || this;
  12169. _this.buildDayTableModel = memoize(buildDayTableModel);
  12170. _this.headerRef = createRef();
  12171. _this.tableRef = createRef();
  12172. return _this;
  12173. }
  12174. DayTableView.prototype.render = function () {
  12175. var _this = this;
  12176. var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
  12177. var props = this.props;
  12178. var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  12179. var headerContent = options.dayHeaders && (createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
  12180. var bodyContent = function (contentArg) { return (createElement(DayTable, { ref: _this.tableRef, dateProfile: props.dateProfile, dayTableModel: dayTableModel, businessHours: props.businessHours, dateSelection: props.dateSelection, eventStore: props.eventStore, eventUiBases: props.eventUiBases, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, nextDayThreshold: options.nextDayThreshold, colGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, dayMaxEvents: options.dayMaxEvents, dayMaxEventRows: options.dayMaxEventRows, showWeekNumbers: options.weekNumbers, expandRows: !props.isHeightAuto, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint })); };
  12181. return options.dayMinWidth
  12182. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  12183. : this.renderSimpleLayout(headerContent, bodyContent);
  12184. };
  12185. return DayTableView;
  12186. }(TableView));
  12187. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  12188. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  12189. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  12190. }
  12191. var TableDateProfileGenerator = /** @class */ (function (_super) {
  12192. __extends(TableDateProfileGenerator, _super);
  12193. function TableDateProfileGenerator() {
  12194. return _super !== null && _super.apply(this, arguments) || this;
  12195. }
  12196. // Computes the date range that will be rendered.
  12197. TableDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  12198. var dateEnv = this.props.dateEnv;
  12199. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  12200. var start = renderRange.start;
  12201. var end = renderRange.end;
  12202. var endOfWeek;
  12203. // year and month views should be aligned with weeks. this is already done for week
  12204. if (/^(year|month)$/.test(currentRangeUnit)) {
  12205. start = dateEnv.startOfWeek(start);
  12206. // make end-of-week if not already
  12207. endOfWeek = dateEnv.startOfWeek(end);
  12208. if (endOfWeek.valueOf() !== end.valueOf()) {
  12209. end = addWeeks(endOfWeek, 1);
  12210. }
  12211. }
  12212. // ensure 6 weeks
  12213. if (this.props.monthMode &&
  12214. this.props.fixedWeekCount) {
  12215. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  12216. diffWeeks(start, end));
  12217. end = addWeeks(end, 6 - rowCnt);
  12218. }
  12219. return { start: start, end: end };
  12220. };
  12221. return TableDateProfileGenerator;
  12222. }(DateProfileGenerator));
  12223. var OPTION_REFINERS$1 = {
  12224. moreLinkClick: identity,
  12225. moreLinkClassNames: identity,
  12226. moreLinkContent: identity,
  12227. moreLinkDidMount: identity,
  12228. moreLinkWillUnmount: identity,
  12229. };
  12230. var dayGridPlugin = createPlugin({
  12231. initialView: 'dayGridMonth',
  12232. optionRefiners: OPTION_REFINERS$1,
  12233. views: {
  12234. dayGrid: {
  12235. component: DayTableView,
  12236. dateProfileGeneratorClass: TableDateProfileGenerator,
  12237. },
  12238. dayGridDay: {
  12239. type: 'dayGrid',
  12240. duration: { days: 1 },
  12241. },
  12242. dayGridWeek: {
  12243. type: 'dayGrid',
  12244. duration: { weeks: 1 },
  12245. },
  12246. dayGridMonth: {
  12247. type: 'dayGrid',
  12248. duration: { months: 1 },
  12249. monthMode: true,
  12250. fixedWeekCount: true,
  12251. },
  12252. },
  12253. });
  12254. var AllDaySplitter = /** @class */ (function (_super) {
  12255. __extends(AllDaySplitter, _super);
  12256. function AllDaySplitter() {
  12257. return _super !== null && _super.apply(this, arguments) || this;
  12258. }
  12259. AllDaySplitter.prototype.getKeyInfo = function () {
  12260. return {
  12261. allDay: {},
  12262. timed: {},
  12263. };
  12264. };
  12265. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  12266. if (dateSpan.allDay) {
  12267. return ['allDay'];
  12268. }
  12269. return ['timed'];
  12270. };
  12271. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  12272. if (!eventDef.allDay) {
  12273. return ['timed'];
  12274. }
  12275. if (hasBgRendering(eventDef)) {
  12276. return ['timed', 'allDay'];
  12277. }
  12278. return ['allDay'];
  12279. };
  12280. return AllDaySplitter;
  12281. }(Splitter));
  12282. var DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
  12283. hour: 'numeric',
  12284. minute: '2-digit',
  12285. omitZeroMinute: true,
  12286. meridiem: 'short',
  12287. });
  12288. function TimeColsAxisCell(props) {
  12289. var classNames = [
  12290. 'fc-timegrid-slot',
  12291. 'fc-timegrid-slot-label',
  12292. props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor',
  12293. ];
  12294. return (createElement(ViewContextType.Consumer, null, function (context) {
  12295. if (!props.isLabeled) {
  12296. return (createElement("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
  12297. }
  12298. var dateEnv = context.dateEnv, options = context.options, viewApi = context.viewApi;
  12299. var labelFormat = // TODO: fully pre-parse
  12300. options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
  12301. Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
  12302. createFormatter(options.slotLabelFormat);
  12303. var hookProps = {
  12304. level: 0,
  12305. time: props.time,
  12306. date: dateEnv.toDate(props.date),
  12307. view: viewApi,
  12308. text: dateEnv.format(props.date, labelFormat),
  12309. };
  12310. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLabelClassNames, content: options.slotLabelContent, defaultContent: renderInnerContent$3, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": props.isoTimeStr },
  12311. createElement("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" },
  12312. createElement("div", { className: "fc-timegrid-slot-label-cushion fc-scrollgrid-shrink-cushion", ref: innerElRef }, innerContent)))); }));
  12313. }));
  12314. }
  12315. function renderInnerContent$3(props) {
  12316. return props.text;
  12317. }
  12318. var TimeBodyAxis = /** @class */ (function (_super) {
  12319. __extends(TimeBodyAxis, _super);
  12320. function TimeBodyAxis() {
  12321. return _super !== null && _super.apply(this, arguments) || this;
  12322. }
  12323. TimeBodyAxis.prototype.render = function () {
  12324. return this.props.slatMetas.map(function (slatMeta) { return (createElement("tr", { key: slatMeta.key },
  12325. createElement(TimeColsAxisCell, __assign({}, slatMeta)))); });
  12326. };
  12327. return TimeBodyAxis;
  12328. }(BaseComponent));
  12329. var DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'short' });
  12330. var AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
  12331. var TimeColsView = /** @class */ (function (_super) {
  12332. __extends(TimeColsView, _super);
  12333. function TimeColsView() {
  12334. var _this = _super !== null && _super.apply(this, arguments) || this;
  12335. _this.allDaySplitter = new AllDaySplitter(); // for use by subclasses
  12336. _this.headerElRef = createRef();
  12337. _this.rootElRef = createRef();
  12338. _this.scrollerElRef = createRef();
  12339. _this.state = {
  12340. slatCoords: null,
  12341. };
  12342. _this.handleScrollTopRequest = function (scrollTop) {
  12343. var scrollerEl = _this.scrollerElRef.current;
  12344. if (scrollerEl) { // TODO: not sure how this could ever be null. weirdness with the reducer
  12345. scrollerEl.scrollTop = scrollTop;
  12346. }
  12347. };
  12348. /* Header Render Methods
  12349. ------------------------------------------------------------------------------------------------------------------*/
  12350. _this.renderHeadAxis = function (rowKey, frameHeight) {
  12351. if (frameHeight === void 0) { frameHeight = ''; }
  12352. var options = _this.context.options;
  12353. var dateProfile = _this.props.dateProfile;
  12354. var range = dateProfile.renderRange;
  12355. var dayCnt = diffDays(range.start, range.end);
  12356. var navLinkAttrs = (options.navLinks && dayCnt === 1) // only do in day views (to avoid doing in week views that dont need it)
  12357. ? { 'data-navlink': buildNavLinkData(range.start, 'week'), tabIndex: 0 }
  12358. : {};
  12359. if (options.weekNumbers && rowKey === 'day') {
  12360. return (createElement(WeekNumberRoot, { date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("th", { ref: rootElRef, className: [
  12361. 'fc-timegrid-axis',
  12362. 'fc-scrollgrid-shrink',
  12363. ].concat(classNames).join(' ') },
  12364. createElement("div", { className: "fc-timegrid-axis-frame fc-scrollgrid-shrink-frame fc-timegrid-axis-frame-liquid", style: { height: frameHeight } },
  12365. createElement("a", __assign({ ref: innerElRef, className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner" }, navLinkAttrs), innerContent)))); }));
  12366. }
  12367. return (createElement("th", { className: "fc-timegrid-axis" },
  12368. createElement("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } })));
  12369. };
  12370. /* Table Component Render Methods
  12371. ------------------------------------------------------------------------------------------------------------------*/
  12372. // only a one-way height sync. we don't send the axis inner-content height to the DayGrid,
  12373. // but DayGrid still needs to have classNames on inner elements in order to measure.
  12374. _this.renderTableRowAxis = function (rowHeight) {
  12375. var _a = _this.context, options = _a.options, viewApi = _a.viewApi;
  12376. var hookProps = {
  12377. text: options.allDayText,
  12378. view: viewApi,
  12379. };
  12380. return (
  12381. // TODO: make reusable hook. used in list view too
  12382. createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: [
  12383. 'fc-timegrid-axis',
  12384. 'fc-scrollgrid-shrink',
  12385. ].concat(classNames).join(' ') },
  12386. createElement("div", { className: 'fc-timegrid-axis-frame fc-scrollgrid-shrink-frame' + (rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : ''), style: { height: rowHeight } },
  12387. createElement("span", { className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner", ref: innerElRef }, innerContent)))); }));
  12388. };
  12389. _this.handleSlatCoords = function (slatCoords) {
  12390. _this.setState({ slatCoords: slatCoords });
  12391. };
  12392. return _this;
  12393. }
  12394. // rendering
  12395. // ----------------------------------------------------------------------------------------------------
  12396. TimeColsView.prototype.renderSimpleLayout = function (headerRowContent, allDayContent, timeContent) {
  12397. var _a = this, context = _a.context, props = _a.props;
  12398. var sections = [];
  12399. var stickyHeaderDates = getStickyHeaderDates(context.options);
  12400. if (headerRowContent) {
  12401. sections.push({
  12402. type: 'header',
  12403. key: 'header',
  12404. isSticky: stickyHeaderDates,
  12405. chunk: {
  12406. elRef: this.headerElRef,
  12407. tableClassName: 'fc-col-header',
  12408. rowContent: headerRowContent,
  12409. },
  12410. });
  12411. }
  12412. if (allDayContent) {
  12413. sections.push({
  12414. type: 'body',
  12415. key: 'all-day',
  12416. chunk: { content: allDayContent },
  12417. });
  12418. sections.push({
  12419. type: 'body',
  12420. key: 'all-day-divider',
  12421. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12422. createElement("tr", { className: "fc-scrollgrid-section" },
  12423. createElement("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  12424. });
  12425. }
  12426. sections.push({
  12427. type: 'body',
  12428. key: 'body',
  12429. liquid: true,
  12430. expandRows: Boolean(context.options.expandRows),
  12431. chunk: {
  12432. scrollerElRef: this.scrollerElRef,
  12433. content: timeContent,
  12434. },
  12435. });
  12436. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12437. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, cols: [{ width: 'shrink' }], sections: sections }))); }));
  12438. };
  12439. TimeColsView.prototype.renderHScrollLayout = function (headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
  12440. var _this = this;
  12441. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  12442. if (!ScrollGrid) {
  12443. throw new Error('No ScrollGrid implementation');
  12444. }
  12445. var _a = this, context = _a.context, props = _a.props;
  12446. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  12447. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  12448. var sections = [];
  12449. if (headerRowContent) {
  12450. sections.push({
  12451. type: 'header',
  12452. key: 'header',
  12453. isSticky: stickyHeaderDates,
  12454. syncRowHeights: true,
  12455. chunks: [
  12456. {
  12457. key: 'axis',
  12458. rowContent: function (arg) { return (createElement("tr", null, _this.renderHeadAxis('day', arg.rowSyncHeights[0]))); },
  12459. },
  12460. {
  12461. key: 'cols',
  12462. elRef: this.headerElRef,
  12463. tableClassName: 'fc-col-header',
  12464. rowContent: headerRowContent,
  12465. },
  12466. ],
  12467. });
  12468. }
  12469. if (allDayContent) {
  12470. sections.push({
  12471. type: 'body',
  12472. key: 'all-day',
  12473. syncRowHeights: true,
  12474. chunks: [
  12475. {
  12476. key: 'axis',
  12477. rowContent: function (contentArg) { return (createElement("tr", null, _this.renderTableRowAxis(contentArg.rowSyncHeights[0]))); },
  12478. },
  12479. {
  12480. key: 'cols',
  12481. content: allDayContent,
  12482. },
  12483. ],
  12484. });
  12485. sections.push({
  12486. key: 'all-day-divider',
  12487. type: 'body',
  12488. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12489. createElement("tr", { className: "fc-scrollgrid-section" },
  12490. createElement("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  12491. });
  12492. }
  12493. var isNowIndicator = context.options.nowIndicator;
  12494. sections.push({
  12495. type: 'body',
  12496. key: 'body',
  12497. liquid: true,
  12498. expandRows: Boolean(context.options.expandRows),
  12499. chunks: [
  12500. {
  12501. key: 'axis',
  12502. content: function (arg) { return (
  12503. // TODO: make this now-indicator arrow more DRY with TimeColsContent
  12504. createElement("div", { className: "fc-timegrid-axis-chunk" },
  12505. createElement("table", { style: { height: arg.expandRows ? arg.clientHeight : '' } },
  12506. arg.tableColGroupNode,
  12507. createElement("tbody", null,
  12508. createElement(TimeBodyAxis, { slatMetas: slatMetas }))),
  12509. createElement("div", { className: "fc-timegrid-now-indicator-container" },
  12510. createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' /* hacky */ }, function (nowDate) {
  12511. var nowIndicatorTop = isNowIndicator &&
  12512. slatCoords &&
  12513. slatCoords.safeComputeTop(nowDate); // might return void
  12514. if (typeof nowIndicatorTop === 'number') {
  12515. return (createElement(NowIndicatorRoot, { isAxis: true, date: nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); }));
  12516. }
  12517. return null;
  12518. })))); },
  12519. },
  12520. {
  12521. key: 'cols',
  12522. scrollerElRef: this.scrollerElRef,
  12523. content: timeContent,
  12524. },
  12525. ],
  12526. });
  12527. if (stickyFooterScrollbar) {
  12528. sections.push({
  12529. key: 'footer',
  12530. type: 'footer',
  12531. isSticky: true,
  12532. chunks: [
  12533. {
  12534. key: 'axis',
  12535. content: renderScrollShim,
  12536. },
  12537. {
  12538. key: 'cols',
  12539. content: renderScrollShim,
  12540. },
  12541. ],
  12542. });
  12543. }
  12544. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12545. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, colGroups: [
  12546. { width: 'shrink', cols: [{ width: 'shrink' }] },
  12547. { cols: [{ span: colCnt, minWidth: dayMinWidth }] },
  12548. ], sections: sections }))); }));
  12549. };
  12550. /* Dimensions
  12551. ------------------------------------------------------------------------------------------------------------------*/
  12552. TimeColsView.prototype.getAllDayMaxEventProps = function () {
  12553. var _a = this.context.options, dayMaxEvents = _a.dayMaxEvents, dayMaxEventRows = _a.dayMaxEventRows;
  12554. if (dayMaxEvents === true || dayMaxEventRows === true) { // is auto?
  12555. dayMaxEvents = undefined;
  12556. dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS; // make sure "auto" goes to a real number
  12557. }
  12558. return { dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows };
  12559. };
  12560. return TimeColsView;
  12561. }(DateComponent));
  12562. function renderAllDayInner(hookProps) {
  12563. return hookProps.text;
  12564. }
  12565. var TimeColsSlatsCoords = /** @class */ (function () {
  12566. function TimeColsSlatsCoords(positions, dateProfile, slatMetas) {
  12567. this.positions = positions;
  12568. this.dateProfile = dateProfile;
  12569. this.slatMetas = slatMetas;
  12570. }
  12571. TimeColsSlatsCoords.prototype.safeComputeTop = function (date) {
  12572. var dateProfile = this.dateProfile;
  12573. if (rangeContainsMarker(dateProfile.currentRange, date)) {
  12574. var startOfDayDate = startOfDay(date);
  12575. var timeMs = date.valueOf() - startOfDayDate.valueOf();
  12576. if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
  12577. timeMs < asRoughMs(dateProfile.slotMaxTime)) {
  12578. return this.computeTimeTop(createDuration(timeMs));
  12579. }
  12580. }
  12581. return null;
  12582. };
  12583. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  12584. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  12585. TimeColsSlatsCoords.prototype.computeDateTop = function (when, startOfDayDate) {
  12586. if (!startOfDayDate) {
  12587. startOfDayDate = startOfDay(when);
  12588. }
  12589. return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
  12590. };
  12591. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  12592. // This is a makeshify way to compute the time-top. Assumes all slatMetas dates are uniform.
  12593. // Eventually allow computation with arbirary slat dates.
  12594. TimeColsSlatsCoords.prototype.computeTimeTop = function (duration) {
  12595. var _a = this, positions = _a.positions, dateProfile = _a.dateProfile, slatMetas = _a.slatMetas;
  12596. var len = positions.els.length;
  12597. // we assume dates are uniform
  12598. var slotDurationMs = slatMetas[1].date.valueOf() - slatMetas[0].date.valueOf();
  12599. // floating-point value of # of slots covered
  12600. var slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / slotDurationMs;
  12601. var slatIndex;
  12602. var slatRemainder;
  12603. // compute a floating-point number for how many slats should be progressed through.
  12604. // from 0 to number of slats (inclusive)
  12605. // constrained because slotMinTime/slotMaxTime might be customized.
  12606. slatCoverage = Math.max(0, slatCoverage);
  12607. slatCoverage = Math.min(len, slatCoverage);
  12608. // an integer index of the furthest whole slat
  12609. // from 0 to number slats (*exclusive*, so len-1)
  12610. slatIndex = Math.floor(slatCoverage);
  12611. slatIndex = Math.min(slatIndex, len - 1);
  12612. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  12613. // could be 1.0 if slatCoverage is covering *all* the slots
  12614. slatRemainder = slatCoverage - slatIndex;
  12615. return positions.tops[slatIndex] +
  12616. positions.getHeight(slatIndex) * slatRemainder;
  12617. };
  12618. return TimeColsSlatsCoords;
  12619. }());
  12620. var TimeColsSlatsBody = /** @class */ (function (_super) {
  12621. __extends(TimeColsSlatsBody, _super);
  12622. function TimeColsSlatsBody() {
  12623. return _super !== null && _super.apply(this, arguments) || this;
  12624. }
  12625. TimeColsSlatsBody.prototype.render = function () {
  12626. var _a = this, props = _a.props, context = _a.context;
  12627. var options = context.options;
  12628. var slatElRefs = props.slatElRefs;
  12629. return (createElement("tbody", null, props.slatMetas.map(function (slatMeta, i) {
  12630. var hookProps = {
  12631. time: slatMeta.time,
  12632. date: context.dateEnv.toDate(slatMeta.date),
  12633. view: context.viewApi,
  12634. };
  12635. var classNames = [
  12636. 'fc-timegrid-slot',
  12637. 'fc-timegrid-slot-lane',
  12638. slatMeta.isLabeled ? '' : 'fc-timegrid-slot-minor',
  12639. ];
  12640. return (createElement("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
  12641. props.axis && (createElement(TimeColsAxisCell, __assign({}, slatMeta))),
  12642. createElement(RenderHook, { hookProps: hookProps, classNames: options.slotLaneClassNames, content: options.slotLaneContent, didMount: options.slotLaneDidMount, willUnmount: options.slotLaneWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-time": slatMeta.isoTimeStr }, innerContent)); })));
  12643. })));
  12644. };
  12645. return TimeColsSlatsBody;
  12646. }(BaseComponent));
  12647. /*
  12648. for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  12649. */
  12650. var TimeColsSlats = /** @class */ (function (_super) {
  12651. __extends(TimeColsSlats, _super);
  12652. function TimeColsSlats() {
  12653. var _this = _super !== null && _super.apply(this, arguments) || this;
  12654. _this.rootElRef = createRef();
  12655. _this.slatElRefs = new RefMap();
  12656. return _this;
  12657. }
  12658. TimeColsSlats.prototype.render = function () {
  12659. var _a = this, props = _a.props, context = _a.context;
  12660. return (createElement("div", { className: "fc-timegrid-slots", ref: this.rootElRef },
  12661. createElement("table", { className: context.theme.getClass('table'), style: {
  12662. minWidth: props.tableMinWidth,
  12663. width: props.clientWidth,
  12664. height: props.minHeight,
  12665. } },
  12666. props.tableColGroupNode /* relies on there only being a single <col> for the axis */,
  12667. createElement(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
  12668. };
  12669. TimeColsSlats.prototype.componentDidMount = function () {
  12670. this.updateSizing();
  12671. };
  12672. TimeColsSlats.prototype.componentDidUpdate = function () {
  12673. this.updateSizing();
  12674. };
  12675. TimeColsSlats.prototype.componentWillUnmount = function () {
  12676. if (this.props.onCoords) {
  12677. this.props.onCoords(null);
  12678. }
  12679. };
  12680. TimeColsSlats.prototype.updateSizing = function () {
  12681. var props = this.props;
  12682. if (props.onCoords &&
  12683. props.clientWidth !== null // means sizing has stabilized
  12684. ) {
  12685. var rootEl = this.rootElRef.current;
  12686. if (rootEl.offsetHeight) { // not hidden by css
  12687. props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, props.slatMetas));
  12688. }
  12689. }
  12690. };
  12691. return TimeColsSlats;
  12692. }(BaseComponent));
  12693. function collectSlatEls(elMap, slatMetas) {
  12694. return slatMetas.map(function (slatMeta) { return elMap[slatMeta.key]; });
  12695. }
  12696. function splitSegsByCol(segs, colCnt) {
  12697. var segsByCol = [];
  12698. var i;
  12699. for (i = 0; i < colCnt; i += 1) {
  12700. segsByCol.push([]);
  12701. }
  12702. if (segs) {
  12703. for (i = 0; i < segs.length; i += 1) {
  12704. segsByCol[segs[i].col].push(segs[i]);
  12705. }
  12706. }
  12707. return segsByCol;
  12708. }
  12709. function splitInteractionByCol(ui, colCnt) {
  12710. var byRow = [];
  12711. if (!ui) {
  12712. for (var i = 0; i < colCnt; i += 1) {
  12713. byRow[i] = null;
  12714. }
  12715. }
  12716. else {
  12717. for (var i = 0; i < colCnt; i += 1) {
  12718. byRow[i] = {
  12719. affectedInstances: ui.affectedInstances,
  12720. isEvent: ui.isEvent,
  12721. segs: [],
  12722. };
  12723. }
  12724. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  12725. var seg = _a[_i];
  12726. byRow[seg.col].segs.push(seg);
  12727. }
  12728. }
  12729. return byRow;
  12730. }
  12731. // UNFORTUNATELY, assigns results to the top/bottom/level/forwardCoord/backwardCoord props of the actual segs.
  12732. // TODO: return hash (by instanceId) of results
  12733. function computeSegCoords(segs, dayDate, slatCoords, eventMinHeight, eventOrderSpecs) {
  12734. computeSegVerticals(segs, dayDate, slatCoords, eventMinHeight);
  12735. return computeSegHorizontals(segs, eventOrderSpecs); // requires top/bottom from computeSegVerticals
  12736. }
  12737. // For each segment in an array, computes and assigns its top and bottom properties
  12738. function computeSegVerticals(segs, dayDate, slatCoords, eventMinHeight) {
  12739. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  12740. var seg = segs_1[_i];
  12741. seg.top = slatCoords.computeDateTop(seg.start, dayDate);
  12742. seg.bottom = Math.max(seg.top + (eventMinHeight || 0), // yuck
  12743. slatCoords.computeDateTop(seg.end, dayDate));
  12744. }
  12745. }
  12746. // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
  12747. // Assumed the segs are already ordered.
  12748. // NOTE: Also reorders the given array by date!
  12749. function computeSegHorizontals(segs, eventOrderSpecs) {
  12750. // IMPORTANT TO CLEAR OLD RESULTS :(
  12751. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  12752. var seg = segs_2[_i];
  12753. seg.level = null;
  12754. seg.forwardCoord = null;
  12755. seg.backwardCoord = null;
  12756. seg.forwardPressure = null;
  12757. }
  12758. segs = sortEventSegs(segs, eventOrderSpecs);
  12759. var level0;
  12760. var levels = buildSlotSegLevels(segs);
  12761. computeForwardSlotSegs(levels);
  12762. if ((level0 = levels[0])) {
  12763. for (var _a = 0, level0_1 = level0; _a < level0_1.length; _a++) {
  12764. var seg = level0_1[_a];
  12765. computeSlotSegPressures(seg);
  12766. }
  12767. for (var _b = 0, level0_2 = level0; _b < level0_2.length; _b++) {
  12768. var seg = level0_2[_b];
  12769. computeSegForwardBack(seg, 0, 0, eventOrderSpecs);
  12770. }
  12771. }
  12772. return segs;
  12773. }
  12774. // Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
  12775. // left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
  12776. function buildSlotSegLevels(segs) {
  12777. var levels = [];
  12778. var i;
  12779. var seg;
  12780. var j;
  12781. for (i = 0; i < segs.length; i += 1) {
  12782. seg = segs[i];
  12783. // go through all the levels and stop on the first level where there are no collisions
  12784. for (j = 0; j < levels.length; j += 1) {
  12785. if (!computeSlotSegCollisions(seg, levels[j]).length) {
  12786. break;
  12787. }
  12788. }
  12789. seg.level = j;
  12790. (levels[j] || (levels[j] = [])).push(seg);
  12791. }
  12792. return levels;
  12793. }
  12794. // Find all the segments in `otherSegs` that vertically collide with `seg`.
  12795. // Append into an optionally-supplied `results` array and return.
  12796. function computeSlotSegCollisions(seg, otherSegs, results) {
  12797. if (results === void 0) { results = []; }
  12798. for (var i = 0; i < otherSegs.length; i += 1) {
  12799. if (isSlotSegCollision(seg, otherSegs[i])) {
  12800. results.push(otherSegs[i]);
  12801. }
  12802. }
  12803. return results;
  12804. }
  12805. // Do these segments occupy the same vertical space?
  12806. function isSlotSegCollision(seg1, seg2) {
  12807. return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
  12808. }
  12809. // For every segment, figure out the other segments that are in subsequent
  12810. // levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
  12811. function computeForwardSlotSegs(levels) {
  12812. var i;
  12813. var level;
  12814. var j;
  12815. var seg;
  12816. var k;
  12817. for (i = 0; i < levels.length; i += 1) {
  12818. level = levels[i];
  12819. for (j = 0; j < level.length; j += 1) {
  12820. seg = level[j];
  12821. seg.forwardSegs = [];
  12822. for (k = i + 1; k < levels.length; k += 1) {
  12823. computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
  12824. }
  12825. }
  12826. }
  12827. }
  12828. // Figure out which path forward (via seg.forwardSegs) results in the longest path until
  12829. // the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
  12830. function computeSlotSegPressures(seg) {
  12831. var forwardSegs = seg.forwardSegs;
  12832. var forwardPressure = 0;
  12833. var i;
  12834. var forwardSeg;
  12835. if (seg.forwardPressure == null) { // not already computed
  12836. for (i = 0; i < forwardSegs.length; i += 1) {
  12837. forwardSeg = forwardSegs[i];
  12838. // figure out the child's maximum forward path
  12839. computeSlotSegPressures(forwardSeg);
  12840. // either use the existing maximum, or use the child's forward pressure
  12841. // plus one (for the forwardSeg itself)
  12842. forwardPressure = Math.max(forwardPressure, 1 + forwardSeg.forwardPressure);
  12843. }
  12844. seg.forwardPressure = forwardPressure;
  12845. }
  12846. }
  12847. // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
  12848. // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
  12849. // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
  12850. //
  12851. // The segment might be part of a "series", which means consecutive segments with the same pressure
  12852. // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
  12853. // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
  12854. // coordinate of the first segment in the series.
  12855. function computeSegForwardBack(seg, seriesBackwardPressure, seriesBackwardCoord, eventOrderSpecs) {
  12856. var forwardSegs = seg.forwardSegs;
  12857. var i;
  12858. if (seg.forwardCoord == null) { // not already computed
  12859. if (!forwardSegs.length) {
  12860. // if there are no forward segments, this segment should butt up against the edge
  12861. seg.forwardCoord = 1;
  12862. }
  12863. else {
  12864. // sort highest pressure first
  12865. sortForwardSegs(forwardSegs, eventOrderSpecs);
  12866. // this segment's forwardCoord will be calculated from the backwardCoord of the
  12867. // highest-pressure forward segment.
  12868. computeSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord, eventOrderSpecs);
  12869. seg.forwardCoord = forwardSegs[0].backwardCoord;
  12870. }
  12871. // calculate the backwardCoord from the forwardCoord. consider the series
  12872. seg.backwardCoord = seg.forwardCoord -
  12873. (seg.forwardCoord - seriesBackwardCoord) / // available width for series
  12874. (seriesBackwardPressure + 1); // # of segments in the series
  12875. // use this segment's coordinates to computed the coordinates of the less-pressurized
  12876. // forward segments
  12877. for (i = 0; i < forwardSegs.length; i += 1) {
  12878. computeSegForwardBack(forwardSegs[i], 0, seg.forwardCoord, eventOrderSpecs);
  12879. }
  12880. }
  12881. }
  12882. function sortForwardSegs(forwardSegs, eventOrderSpecs) {
  12883. var objs = forwardSegs.map(buildTimeGridSegCompareObj);
  12884. var specs = [
  12885. // put higher-pressure first
  12886. { field: 'forwardPressure', order: -1 },
  12887. // put segments that are closer to initial edge first (and favor ones with no coords yet)
  12888. { field: 'backwardCoord', order: 1 },
  12889. ].concat(eventOrderSpecs);
  12890. objs.sort(function (obj0, obj1) { return compareByFieldSpecs(obj0, obj1, specs); });
  12891. return objs.map(function (c) { return c._seg; });
  12892. }
  12893. function buildTimeGridSegCompareObj(seg) {
  12894. var obj = buildSegCompareObj(seg);
  12895. obj.forwardPressure = seg.forwardPressure;
  12896. obj.backwardCoord = seg.backwardCoord;
  12897. return obj;
  12898. }
  12899. var DEFAULT_TIME_FORMAT = createFormatter({
  12900. hour: 'numeric',
  12901. minute: '2-digit',
  12902. meridiem: false,
  12903. });
  12904. var TimeColEvent = /** @class */ (function (_super) {
  12905. __extends(TimeColEvent, _super);
  12906. function TimeColEvent() {
  12907. return _super !== null && _super.apply(this, arguments) || this;
  12908. }
  12909. TimeColEvent.prototype.render = function () {
  12910. var classNames = [
  12911. 'fc-timegrid-event',
  12912. 'fc-v-event',
  12913. ];
  12914. if (this.props.isCondensed) {
  12915. classNames.push('fc-timegrid-event-condensed');
  12916. }
  12917. return (createElement(StandardEvent, __assign({}, this.props, { defaultTimeFormat: DEFAULT_TIME_FORMAT, extraClassNames: classNames })));
  12918. };
  12919. return TimeColEvent;
  12920. }(BaseComponent));
  12921. var TimeColMisc = /** @class */ (function (_super) {
  12922. __extends(TimeColMisc, _super);
  12923. function TimeColMisc() {
  12924. return _super !== null && _super.apply(this, arguments) || this;
  12925. }
  12926. TimeColMisc.prototype.render = function () {
  12927. var props = this.props;
  12928. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (innerElRef, innerContent) { return (innerContent &&
  12929. createElement("div", { className: "fc-timegrid-col-misc", ref: innerElRef }, innerContent)); }));
  12930. };
  12931. return TimeColMisc;
  12932. }(BaseComponent));
  12933. config.timeGridEventCondensedHeight = 30;
  12934. var TimeCol = /** @class */ (function (_super) {
  12935. __extends(TimeCol, _super);
  12936. function TimeCol() {
  12937. return _super !== null && _super.apply(this, arguments) || this;
  12938. }
  12939. TimeCol.prototype.render = function () {
  12940. var _this = this;
  12941. var _a = this, props = _a.props, context = _a.context;
  12942. var isSelectMirror = context.options.selectMirror;
  12943. var mirrorSegs = (props.eventDrag && props.eventDrag.segs) ||
  12944. (props.eventResize && props.eventResize.segs) ||
  12945. (isSelectMirror && props.dateSelectionSegs) ||
  12946. [];
  12947. var interactionAffectedInstances = // TODO: messy way to compute this
  12948. (props.eventDrag && props.eventDrag.affectedInstances) ||
  12949. (props.eventResize && props.eventResize.affectedInstances) ||
  12950. {};
  12951. return (createElement(DayCellRoot, { elRef: props.elRef, date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (rootElRef, classNames, dataAttrs) { return (createElement("td", __assign({ ref: rootElRef, className: ['fc-timegrid-col'].concat(classNames, props.extraClassNames || []).join(' ') }, dataAttrs, props.extraDataAttrs),
  12952. createElement("div", { className: "fc-timegrid-col-frame" },
  12953. createElement("div", { className: "fc-timegrid-col-bg" },
  12954. _this.renderFillSegs(props.businessHourSegs, 'non-business'),
  12955. _this.renderFillSegs(props.bgEventSegs, 'bg-event'),
  12956. _this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
  12957. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(props.fgEventSegs, interactionAffectedInstances)),
  12958. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror))),
  12959. createElement("div", { className: "fc-timegrid-now-indicator-container" }, _this.renderNowIndicator(props.nowIndicatorSegs)),
  12960. createElement(TimeColMisc, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps })))); }));
  12961. };
  12962. TimeCol.prototype.renderFgSegs = function (segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  12963. var props = this.props;
  12964. if (props.forPrint) {
  12965. return this.renderPrintFgSegs(segs);
  12966. }
  12967. if (props.slatCoords) {
  12968. return this.renderPositionedFgSegs(segs, segIsInvisible, isDragging, isResizing, isDateSelecting);
  12969. }
  12970. return null;
  12971. };
  12972. TimeCol.prototype.renderPrintFgSegs = function (segs) {
  12973. var _a = this, props = _a.props, context = _a.context;
  12974. // not DRY
  12975. segs = sortEventSegs(segs, context.options.eventOrder);
  12976. return segs.map(function (seg) { return (createElement("div", { className: "fc-timegrid-event-harness", key: seg.eventRange.instance.instanceId },
  12977. createElement(TimeColEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isCondensed: false }, getSegMeta(seg, props.todayRange, props.nowDate))))); });
  12978. };
  12979. TimeCol.prototype.renderPositionedFgSegs = function (segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  12980. var _this = this;
  12981. var _a = this, context = _a.context, props = _a.props;
  12982. // assigns TO THE SEGS THEMSELVES
  12983. // also, receives resorted array
  12984. segs = computeSegCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight, context.options.eventOrder);
  12985. return segs.map(function (seg) {
  12986. var instanceId = seg.eventRange.instance.instanceId;
  12987. var isMirror = isDragging || isResizing || isDateSelecting;
  12988. var positionCss = isMirror
  12989. // will span entire column width
  12990. // also, won't assign z-index, which is good, fc-event-mirror will overpower other harnesses
  12991. ? __assign({ left: 0, right: 0 }, _this.computeSegTopBottomCss(seg)) : _this.computeFgSegPositionCss(seg);
  12992. return (createElement("div", { className: 'fc-timegrid-event-harness' + (seg.level > 0 ? ' fc-timegrid-event-harness-inset' : ''), key: instanceId, style: __assign({ visibility: segIsInvisible[instanceId] ? 'hidden' : '' }, positionCss) },
  12993. createElement(TimeColEvent, __assign({ seg: seg, isDragging: isDragging, isResizing: isResizing, isDateSelecting: isDateSelecting, isSelected: instanceId === props.eventSelection, isCondensed: (seg.bottom - seg.top) < config.timeGridEventCondensedHeight }, getSegMeta(seg, props.todayRange, props.nowDate)))));
  12994. });
  12995. };
  12996. TimeCol.prototype.renderFillSegs = function (segs, fillType) {
  12997. var _this = this;
  12998. var _a = this, context = _a.context, props = _a.props;
  12999. if (!props.slatCoords) {
  13000. return null;
  13001. }
  13002. // BAD: assigns TO THE SEGS THEMSELVES
  13003. computeSegVerticals(segs, props.date, props.slatCoords, context.options.eventMinHeight);
  13004. var children = segs.map(function (seg) { return (createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-timegrid-bg-harness", style: _this.computeSegTopBottomCss(seg) }, fillType === 'bg-event' ?
  13005. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
  13006. renderFill(fillType))); });
  13007. return createElement(Fragment, null, children);
  13008. };
  13009. TimeCol.prototype.renderNowIndicator = function (segs) {
  13010. var _a = this.props, slatCoords = _a.slatCoords, date = _a.date;
  13011. if (!slatCoords) {
  13012. return null;
  13013. }
  13014. return segs.map(function (seg, i) { return (createElement(NowIndicatorRoot, { isAxis: false, date: date,
  13015. // key doesn't matter. will only ever be one
  13016. key: i }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-line'].concat(classNames).join(' '), style: { top: slatCoords.computeDateTop(seg.start, date) } }, innerContent)); })); });
  13017. };
  13018. TimeCol.prototype.computeFgSegPositionCss = function (seg) {
  13019. var _a = this.context, isRtl = _a.isRtl, options = _a.options;
  13020. var shouldOverlap = options.slotEventOverlap;
  13021. var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
  13022. var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
  13023. var left; // amount of space from left edge, a fraction of the total width
  13024. var right; // amount of space from right edge, a fraction of the total width
  13025. if (shouldOverlap) {
  13026. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  13027. forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
  13028. }
  13029. if (isRtl) {
  13030. left = 1 - forwardCoord;
  13031. right = backwardCoord;
  13032. }
  13033. else {
  13034. left = backwardCoord;
  13035. right = 1 - forwardCoord;
  13036. }
  13037. var props = {
  13038. zIndex: seg.level + 1,
  13039. left: left * 100 + '%',
  13040. right: right * 100 + '%',
  13041. };
  13042. if (shouldOverlap && seg.forwardPressure) {
  13043. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  13044. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  13045. }
  13046. return __assign(__assign({}, props), this.computeSegTopBottomCss(seg));
  13047. };
  13048. TimeCol.prototype.computeSegTopBottomCss = function (seg) {
  13049. return {
  13050. top: seg.top,
  13051. bottom: -seg.bottom,
  13052. };
  13053. };
  13054. return TimeCol;
  13055. }(BaseComponent));
  13056. var TimeColsContent = /** @class */ (function (_super) {
  13057. __extends(TimeColsContent, _super);
  13058. function TimeColsContent() {
  13059. var _this = _super !== null && _super.apply(this, arguments) || this;
  13060. _this.splitFgEventSegs = memoize(splitSegsByCol);
  13061. _this.splitBgEventSegs = memoize(splitSegsByCol);
  13062. _this.splitBusinessHourSegs = memoize(splitSegsByCol);
  13063. _this.splitNowIndicatorSegs = memoize(splitSegsByCol);
  13064. _this.splitDateSelectionSegs = memoize(splitSegsByCol);
  13065. _this.splitEventDrag = memoize(splitInteractionByCol);
  13066. _this.splitEventResize = memoize(splitInteractionByCol);
  13067. _this.rootElRef = createRef();
  13068. _this.cellElRefs = new RefMap();
  13069. return _this;
  13070. }
  13071. TimeColsContent.prototype.render = function () {
  13072. var _this = this;
  13073. var _a = this, props = _a.props, context = _a.context;
  13074. var nowIndicatorTop = context.options.nowIndicator &&
  13075. props.slatCoords &&
  13076. props.slatCoords.safeComputeTop(props.nowDate); // might return void
  13077. var colCnt = props.cells.length;
  13078. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
  13079. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
  13080. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
  13081. var nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
  13082. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
  13083. var eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
  13084. var eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
  13085. return (createElement("div", { className: "fc-timegrid-cols", ref: this.rootElRef },
  13086. createElement("table", { style: {
  13087. minWidth: props.tableMinWidth,
  13088. width: props.clientWidth,
  13089. } },
  13090. props.tableColGroupNode,
  13091. createElement("tbody", null,
  13092. createElement("tr", null,
  13093. props.axis && (createElement("td", { className: "fc-timegrid-col fc-timegrid-axis" },
  13094. createElement("div", { className: "fc-timegrid-col-frame" },
  13095. createElement("div", { className: "fc-timegrid-now-indicator-container" }, typeof nowIndicatorTop === 'number' && (createElement(NowIndicatorRoot, { isAxis: true, date: props.nowDate }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { ref: rootElRef, className: ['fc-timegrid-now-indicator-arrow'].concat(classNames).join(' '), style: { top: nowIndicatorTop } }, innerContent)); })))))),
  13096. props.cells.map(function (cell, i) { return (createElement(TimeCol, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, fgEventSegs: fgEventSegsByRow[i], bgEventSegs: bgEventSegsByRow[i], businessHourSegs: businessHourSegsByRow[i], nowIndicatorSegs: nowIndicatorSegsByRow[i], dateSelectionSegs: dateSelectionSegsByRow[i], eventDrag: eventDragByRow[i], eventResize: eventResizeByRow[i], slatCoords: props.slatCoords, eventSelection: props.eventSelection, forPrint: props.forPrint })); }))))));
  13097. };
  13098. TimeColsContent.prototype.componentDidMount = function () {
  13099. this.updateCoords();
  13100. };
  13101. TimeColsContent.prototype.componentDidUpdate = function () {
  13102. this.updateCoords();
  13103. };
  13104. TimeColsContent.prototype.updateCoords = function () {
  13105. var props = this.props;
  13106. if (props.onColCoords &&
  13107. props.clientWidth !== null // means sizing has stabilized
  13108. ) {
  13109. props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, // horizontal
  13110. false));
  13111. }
  13112. };
  13113. return TimeColsContent;
  13114. }(BaseComponent));
  13115. function collectCellEls(elMap, cells) {
  13116. return cells.map(function (cell) { return elMap[cell.key]; });
  13117. }
  13118. /* A component that renders one or more columns of vertical time slots
  13119. ----------------------------------------------------------------------------------------------------------------------*/
  13120. var TimeCols = /** @class */ (function (_super) {
  13121. __extends(TimeCols, _super);
  13122. function TimeCols() {
  13123. var _this = _super !== null && _super.apply(this, arguments) || this;
  13124. _this.processSlotOptions = memoize(processSlotOptions);
  13125. _this.state = {
  13126. slatCoords: null,
  13127. };
  13128. _this.handleScrollRequest = function (request) {
  13129. var onScrollTopRequest = _this.props.onScrollTopRequest;
  13130. var slatCoords = _this.state.slatCoords;
  13131. if (onScrollTopRequest && slatCoords) {
  13132. if (request.time) {
  13133. var top_1 = slatCoords.computeTimeTop(request.time);
  13134. top_1 = Math.ceil(top_1); // zoom can give weird floating-point values. rather scroll a little bit further
  13135. if (top_1) {
  13136. top_1 += 1; // to overcome top border that slots beyond the first have. looks better
  13137. }
  13138. onScrollTopRequest(top_1);
  13139. }
  13140. return true;
  13141. }
  13142. return false;
  13143. };
  13144. _this.handleColCoords = function (colCoords) {
  13145. _this.colCoords = colCoords;
  13146. };
  13147. _this.handleSlatCoords = function (slatCoords) {
  13148. _this.setState({ slatCoords: slatCoords });
  13149. if (_this.props.onSlatCoords) {
  13150. _this.props.onSlatCoords(slatCoords);
  13151. }
  13152. };
  13153. return _this;
  13154. }
  13155. TimeCols.prototype.render = function () {
  13156. var _a = this, props = _a.props, state = _a.state;
  13157. return (createElement("div", { className: "fc-timegrid-body", ref: props.rootElRef, style: {
  13158. // these props are important to give this wrapper correct dimensions for interactions
  13159. // TODO: if we set it here, can we avoid giving to inner tables?
  13160. width: props.clientWidth,
  13161. minWidth: props.tableMinWidth,
  13162. } },
  13163. createElement(TimeColsSlats, { axis: props.axis, dateProfile: props.dateProfile, slatMetas: props.slatMetas, clientWidth: props.clientWidth, minHeight: props.expandRows ? props.clientHeight : '', tableMinWidth: props.tableMinWidth, tableColGroupNode: props.axis ? props.tableColGroupNode : null /* axis depends on the colgroup's shrinking */, onCoords: this.handleSlatCoords }),
  13164. createElement(TimeColsContent, { cells: props.cells, axis: props.axis, dateProfile: props.dateProfile, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange, nowDate: props.nowDate, nowIndicatorSegs: props.nowIndicatorSegs, clientWidth: props.clientWidth, tableMinWidth: props.tableMinWidth, tableColGroupNode: props.tableColGroupNode, slatCoords: state.slatCoords, onColCoords: this.handleColCoords, forPrint: props.forPrint })));
  13165. };
  13166. TimeCols.prototype.componentDidMount = function () {
  13167. this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
  13168. };
  13169. TimeCols.prototype.componentDidUpdate = function (prevProps) {
  13170. this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
  13171. };
  13172. TimeCols.prototype.componentWillUnmount = function () {
  13173. this.scrollResponder.detach();
  13174. };
  13175. TimeCols.prototype.positionToHit = function (positionLeft, positionTop) {
  13176. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
  13177. var colCoords = this.colCoords;
  13178. var dateProfile = this.props.dateProfile;
  13179. var slatCoords = this.state.slatCoords;
  13180. var _b = this.processSlotOptions(this.props.slotDuration, options.snapDuration), snapDuration = _b.snapDuration, snapsPerSlot = _b.snapsPerSlot;
  13181. var colIndex = colCoords.leftToIndex(positionLeft);
  13182. var slatIndex = slatCoords.positions.topToIndex(positionTop);
  13183. if (colIndex != null && slatIndex != null) {
  13184. var slatTop = slatCoords.positions.tops[slatIndex];
  13185. var slatHeight = slatCoords.positions.getHeight(slatIndex);
  13186. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  13187. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  13188. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  13189. var dayDate = this.props.cells[colIndex].date;
  13190. var time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
  13191. var start = dateEnv.add(dayDate, time);
  13192. var end = dateEnv.add(start, snapDuration);
  13193. return {
  13194. col: colIndex,
  13195. dateSpan: {
  13196. range: { start: start, end: end },
  13197. allDay: false,
  13198. },
  13199. dayEl: colCoords.els[colIndex],
  13200. relativeRect: {
  13201. left: colCoords.lefts[colIndex],
  13202. right: colCoords.rights[colIndex],
  13203. top: slatTop,
  13204. bottom: slatTop + slatHeight,
  13205. },
  13206. };
  13207. }
  13208. return null;
  13209. };
  13210. return TimeCols;
  13211. }(BaseComponent));
  13212. function processSlotOptions(slotDuration, snapDurationOverride) {
  13213. var snapDuration = snapDurationOverride || slotDuration;
  13214. var snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
  13215. if (snapsPerSlot === null) {
  13216. snapDuration = slotDuration;
  13217. snapsPerSlot = 1;
  13218. // TODO: say warning?
  13219. }
  13220. return { snapDuration: snapDuration, snapsPerSlot: snapsPerSlot };
  13221. }
  13222. var DayTimeColsSlicer = /** @class */ (function (_super) {
  13223. __extends(DayTimeColsSlicer, _super);
  13224. function DayTimeColsSlicer() {
  13225. return _super !== null && _super.apply(this, arguments) || this;
  13226. }
  13227. DayTimeColsSlicer.prototype.sliceRange = function (range, dayRanges) {
  13228. var segs = [];
  13229. for (var col = 0; col < dayRanges.length; col += 1) {
  13230. var segRange = intersectRanges(range, dayRanges[col]);
  13231. if (segRange) {
  13232. segs.push({
  13233. start: segRange.start,
  13234. end: segRange.end,
  13235. isStart: segRange.start.valueOf() === range.start.valueOf(),
  13236. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  13237. col: col,
  13238. });
  13239. }
  13240. }
  13241. return segs;
  13242. };
  13243. return DayTimeColsSlicer;
  13244. }(Slicer));
  13245. var DayTimeCols = /** @class */ (function (_super) {
  13246. __extends(DayTimeCols, _super);
  13247. function DayTimeCols() {
  13248. var _this = _super !== null && _super.apply(this, arguments) || this;
  13249. _this.buildDayRanges = memoize(buildDayRanges);
  13250. _this.slicer = new DayTimeColsSlicer();
  13251. _this.timeColsRef = createRef();
  13252. _this.handleRootEl = function (rootEl) {
  13253. if (rootEl) {
  13254. _this.context.registerInteractiveComponent(_this, { el: rootEl });
  13255. }
  13256. else {
  13257. _this.context.unregisterInteractiveComponent(_this);
  13258. }
  13259. };
  13260. return _this;
  13261. }
  13262. DayTimeCols.prototype.render = function () {
  13263. var _this = this;
  13264. var _a = this, props = _a.props, context = _a.context;
  13265. var dateProfile = props.dateProfile, dayTableModel = props.dayTableModel;
  13266. var isNowIndicator = context.options.nowIndicator;
  13267. var dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
  13268. // give it the first row of cells
  13269. // TODO: would move this further down hierarchy, but sliceNowDate needs it
  13270. return (createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' }, function (nowDate, todayRange) { return (createElement(TimeCols, __assign({ ref: _this.timeColsRef, rootElRef: _this.handleRootEl }, _this.slicer.sliceProps(props, dateProfile, null, context, dayRanges), { forPrint: props.forPrint, axis: props.axis, dateProfile: dateProfile, slatMetas: props.slatMetas, slotDuration: props.slotDuration, cells: dayTableModel.cells[0], tableColGroupNode: props.tableColGroupNode, tableMinWidth: props.tableMinWidth, clientWidth: props.clientWidth, clientHeight: props.clientHeight, expandRows: props.expandRows, nowDate: nowDate, nowIndicatorSegs: isNowIndicator && _this.slicer.sliceNowDate(nowDate, context, dayRanges), todayRange: todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords }))); }));
  13271. };
  13272. DayTimeCols.prototype.queryHit = function (positionLeft, positionTop) {
  13273. var rawHit = this.timeColsRef.current.positionToHit(positionLeft, positionTop);
  13274. if (rawHit) {
  13275. return {
  13276. component: this,
  13277. dateSpan: rawHit.dateSpan,
  13278. dayEl: rawHit.dayEl,
  13279. rect: {
  13280. left: rawHit.relativeRect.left,
  13281. right: rawHit.relativeRect.right,
  13282. top: rawHit.relativeRect.top,
  13283. bottom: rawHit.relativeRect.bottom,
  13284. },
  13285. layer: 0,
  13286. };
  13287. }
  13288. return null;
  13289. };
  13290. return DayTimeCols;
  13291. }(DateComponent));
  13292. function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
  13293. var ranges = [];
  13294. for (var _i = 0, _a = dayTableModel.headerDates; _i < _a.length; _i++) {
  13295. var date = _a[_i];
  13296. ranges.push({
  13297. start: dateEnv.add(date, dateProfile.slotMinTime),
  13298. end: dateEnv.add(date, dateProfile.slotMaxTime),
  13299. });
  13300. }
  13301. return ranges;
  13302. }
  13303. // potential nice values for the slot-duration and interval-duration
  13304. // from largest to smallest
  13305. var STOCK_SUB_DURATIONS = [
  13306. { hours: 1 },
  13307. { minutes: 30 },
  13308. { minutes: 15 },
  13309. { seconds: 30 },
  13310. { seconds: 15 },
  13311. ];
  13312. function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
  13313. var dayStart = new Date(0);
  13314. var slatTime = slotMinTime;
  13315. var slatIterator = createDuration(0);
  13316. var labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
  13317. var metas = [];
  13318. while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
  13319. var date = dateEnv.add(dayStart, slatTime);
  13320. var isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
  13321. metas.push({
  13322. date: date,
  13323. time: slatTime,
  13324. key: date.toISOString(),
  13325. isoTimeStr: formatIsoTimeString(date),
  13326. isLabeled: isLabeled,
  13327. });
  13328. slatTime = addDurations(slatTime, slotDuration);
  13329. slatIterator = addDurations(slatIterator, slotDuration);
  13330. }
  13331. return metas;
  13332. }
  13333. // Computes an automatic value for slotLabelInterval
  13334. function computeLabelInterval(slotDuration) {
  13335. var i;
  13336. var labelInterval;
  13337. var slotsPerLabel;
  13338. // find the smallest stock label interval that results in more than one slots-per-label
  13339. for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i -= 1) {
  13340. labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
  13341. slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
  13342. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  13343. return labelInterval;
  13344. }
  13345. }
  13346. return slotDuration; // fall back
  13347. }
  13348. var DayTimeColsView = /** @class */ (function (_super) {
  13349. __extends(DayTimeColsView, _super);
  13350. function DayTimeColsView() {
  13351. var _this = _super !== null && _super.apply(this, arguments) || this;
  13352. _this.buildTimeColsModel = memoize(buildTimeColsModel);
  13353. _this.buildSlatMetas = memoize(buildSlatMetas);
  13354. return _this;
  13355. }
  13356. DayTimeColsView.prototype.render = function () {
  13357. var _this = this;
  13358. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv, dateProfileGenerator = _a.dateProfileGenerator;
  13359. var props = this.props;
  13360. var dateProfile = props.dateProfile;
  13361. var dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
  13362. var splitProps = this.allDaySplitter.splitProps(props);
  13363. var slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
  13364. var dayMinWidth = options.dayMinWidth;
  13365. var hasAttachedAxis = !dayMinWidth;
  13366. var hasDetachedAxis = dayMinWidth;
  13367. var headerContent = options.dayHeaders && (createElement(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null }));
  13368. var allDayContent = (options.allDaySlot !== false) && (function (contentArg) { return (createElement(DayTable, __assign({}, splitProps.allDay, { dateProfile: dateProfile, dayTableModel: dayTableModel, nextDayThreshold: options.nextDayThreshold, tableMinWidth: contentArg.tableMinWidth, colGroupNode: contentArg.tableColGroupNode, renderRowIntro: hasAttachedAxis ? _this.renderTableRowAxis : null, showWeekNumbers: false, expandRows: false, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint }, _this.getAllDayMaxEventProps()))); });
  13369. var timeGridContent = function (contentArg) { return (createElement(DayTimeCols, __assign({}, splitProps.timed, { dayTableModel: dayTableModel, dateProfile: dateProfile, axis: hasAttachedAxis, slotDuration: options.slotDuration, slatMetas: slatMetas, forPrint: props.forPrint, tableColGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, onSlatCoords: _this.handleSlatCoords, expandRows: contentArg.expandRows, onScrollTopRequest: _this.handleScrollTopRequest }))); };
  13370. return hasDetachedAxis
  13371. ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
  13372. : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
  13373. };
  13374. return DayTimeColsView;
  13375. }(TimeColsView));
  13376. function buildTimeColsModel(dateProfile, dateProfileGenerator) {
  13377. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  13378. return new DayTableModel(daySeries, false);
  13379. }
  13380. var OPTION_REFINERS$2 = {
  13381. allDaySlot: Boolean,
  13382. };
  13383. var timeGridPlugin = createPlugin({
  13384. initialView: 'timeGridWeek',
  13385. optionRefiners: OPTION_REFINERS$2,
  13386. views: {
  13387. timeGrid: {
  13388. component: DayTimeColsView,
  13389. usesMinMaxTime: true,
  13390. allDaySlot: true,
  13391. slotDuration: '00:30:00',
  13392. slotEventOverlap: true,
  13393. },
  13394. timeGridDay: {
  13395. type: 'timeGrid',
  13396. duration: { days: 1 },
  13397. },
  13398. timeGridWeek: {
  13399. type: 'timeGrid',
  13400. duration: { weeks: 1 },
  13401. },
  13402. },
  13403. });
  13404. var ListViewHeaderRow = /** @class */ (function (_super) {
  13405. __extends(ListViewHeaderRow, _super);
  13406. function ListViewHeaderRow() {
  13407. return _super !== null && _super.apply(this, arguments) || this;
  13408. }
  13409. ListViewHeaderRow.prototype.render = function () {
  13410. var _a = this.props, dayDate = _a.dayDate, todayRange = _a.todayRange;
  13411. var _b = this.context, theme = _b.theme, dateEnv = _b.dateEnv, options = _b.options, viewApi = _b.viewApi;
  13412. var dayMeta = getDateMeta(dayDate, todayRange);
  13413. // will ever be falsy?
  13414. var text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : '';
  13415. // will ever be falsy? also, BAD NAME "alt"
  13416. var sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : '';
  13417. var navLinkData = options.navLinks
  13418. ? buildNavLinkData(dayDate)
  13419. : null;
  13420. var hookProps = __assign({ date: dateEnv.toDate(dayDate), view: viewApi, text: text,
  13421. sideText: sideText,
  13422. navLinkData: navLinkData }, dayMeta);
  13423. var classNames = ['fc-list-day'].concat(getDayClassNames(dayMeta, theme));
  13424. // TODO: make a reusable HOC for dayHeader (used in daygrid/timegrid too)
  13425. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInnerContent$4, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function (rootElRef, customClassNames, innerElRef, innerContent) { return (createElement("tr", { ref: rootElRef, className: classNames.concat(customClassNames).join(' '), "data-date": formatDayString(dayDate) },
  13426. createElement("th", { colSpan: 3 },
  13427. createElement("div", { className: 'fc-list-day-cushion ' + theme.getClass('tableCellShaded'), ref: innerElRef }, innerContent)))); }));
  13428. };
  13429. return ListViewHeaderRow;
  13430. }(BaseComponent));
  13431. function renderInnerContent$4(props) {
  13432. var navLinkAttrs = props.navLinkData // is there a type for this?
  13433. ? { 'data-navlink': props.navLinkData, tabIndex: 0 }
  13434. : {};
  13435. return (createElement(Fragment, null,
  13436. props.text && (createElement("a", __assign({ className: "fc-list-day-text" }, navLinkAttrs), props.text)),
  13437. props.sideText && (createElement("a", __assign({ className: "fc-list-day-side-text" }, navLinkAttrs), props.sideText))));
  13438. }
  13439. var DEFAULT_TIME_FORMAT$1 = createFormatter({
  13440. hour: 'numeric',
  13441. minute: '2-digit',
  13442. meridiem: 'short',
  13443. });
  13444. var ListViewEventRow = /** @class */ (function (_super) {
  13445. __extends(ListViewEventRow, _super);
  13446. function ListViewEventRow() {
  13447. return _super !== null && _super.apply(this, arguments) || this;
  13448. }
  13449. ListViewEventRow.prototype.render = function () {
  13450. var _a = this, props = _a.props, context = _a.context;
  13451. var seg = props.seg;
  13452. var timeFormat = context.options.eventTimeFormat || DEFAULT_TIME_FORMAT$1;
  13453. return (createElement(EventRoot, { seg: seg, timeText: "" // BAD. because of all-day content
  13454. , disableDragging: true, disableResizing: true, defaultContent: renderEventInnerContent, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday, isSelected: props.isSelected, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting }, function (rootElRef, classNames, innerElRef, innerContent, hookProps) { return (createElement("tr", { className: ['fc-list-event', hookProps.event.url ? 'fc-event-forced-url' : ''].concat(classNames).join(' '), ref: rootElRef },
  13455. buildTimeContent(seg, timeFormat, context),
  13456. createElement("td", { className: "fc-list-event-graphic" },
  13457. createElement("span", { className: "fc-list-event-dot", style: { borderColor: hookProps.borderColor || hookProps.backgroundColor } })),
  13458. createElement("td", { className: "fc-list-event-title", ref: innerElRef }, innerContent))); }));
  13459. };
  13460. return ListViewEventRow;
  13461. }(BaseComponent));
  13462. function renderEventInnerContent(props) {
  13463. var event = props.event;
  13464. var url = event.url;
  13465. var anchorAttrs = url ? { href: url } : {};
  13466. return (createElement("a", __assign({}, anchorAttrs), event.title));
  13467. }
  13468. function buildTimeContent(seg, timeFormat, context) {
  13469. var options = context.options;
  13470. if (options.displayEventTime !== false) {
  13471. var eventDef = seg.eventRange.def;
  13472. var eventInstance = seg.eventRange.instance;
  13473. var doAllDay = false;
  13474. var timeText = void 0;
  13475. if (eventDef.allDay) {
  13476. doAllDay = true;
  13477. }
  13478. else if (isMultiDayRange(seg.eventRange.range)) { // TODO: use (!isStart || !isEnd) instead?
  13479. if (seg.isStart) {
  13480. timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
  13481. }
  13482. else if (seg.isEnd) {
  13483. timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
  13484. }
  13485. else {
  13486. doAllDay = true;
  13487. }
  13488. }
  13489. else {
  13490. timeText = buildSegTimeText(seg, timeFormat, context);
  13491. }
  13492. if (doAllDay) {
  13493. var hookProps = {
  13494. text: context.options.allDayText,
  13495. view: context.viewApi,
  13496. };
  13497. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner$1, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("td", { className: ['fc-list-event-time'].concat(classNames).join(' '), ref: rootElRef }, innerContent)); }));
  13498. }
  13499. return (createElement("td", { className: "fc-list-event-time" }, timeText));
  13500. }
  13501. return null;
  13502. }
  13503. function renderAllDayInner$1(hookProps) {
  13504. return hookProps.text;
  13505. }
  13506. /*
  13507. Responsible for the scroller, and forwarding event-related actions into the "grid".
  13508. */
  13509. var ListView = /** @class */ (function (_super) {
  13510. __extends(ListView, _super);
  13511. function ListView() {
  13512. var _this = _super !== null && _super.apply(this, arguments) || this;
  13513. _this.computeDateVars = memoize(computeDateVars);
  13514. _this.eventStoreToSegs = memoize(_this._eventStoreToSegs);
  13515. _this.setRootEl = function (rootEl) {
  13516. if (rootEl) {
  13517. _this.context.registerInteractiveComponent(_this, {
  13518. el: rootEl,
  13519. });
  13520. }
  13521. else {
  13522. _this.context.unregisterInteractiveComponent(_this);
  13523. }
  13524. };
  13525. return _this;
  13526. }
  13527. ListView.prototype.render = function () {
  13528. var _this = this;
  13529. var _a = this, props = _a.props, context = _a.context;
  13530. var extraClassNames = [
  13531. 'fc-list',
  13532. context.theme.getClass('table'),
  13533. context.options.stickyHeaderDates !== false ? 'fc-list-sticky' : '',
  13534. ];
  13535. var _b = this.computeDateVars(props.dateProfile), dayDates = _b.dayDates, dayRanges = _b.dayRanges;
  13536. var eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
  13537. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.setRootEl }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: extraClassNames.concat(classNames).join(' ') },
  13538. createElement(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
  13539. _this.renderSegList(eventSegs, dayDates) :
  13540. _this.renderEmptyMessage()))); }));
  13541. };
  13542. ListView.prototype.renderEmptyMessage = function () {
  13543. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  13544. var hookProps = {
  13545. text: options.noEventsText,
  13546. view: viewApi,
  13547. };
  13548. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.noEventsClassNames, content: options.noEventsContent, defaultContent: renderNoEventsInner, didMount: options.noEventsDidMount, willUnmount: options.noEventsWillUnmount }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("div", { className: ['fc-list-empty'].concat(classNames).join(' '), ref: rootElRef },
  13549. createElement("div", { className: "fc-list-empty-cushion", ref: innerElRef }, innerContent))); }));
  13550. };
  13551. ListView.prototype.renderSegList = function (allSegs, dayDates) {
  13552. var _a = this.context, theme = _a.theme, options = _a.options;
  13553. var segsByDay = groupSegsByDay(allSegs); // sparse array
  13554. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) {
  13555. var innerNodes = [];
  13556. for (var dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
  13557. var daySegs = segsByDay[dayIndex];
  13558. if (daySegs) { // sparse array, so might be undefined
  13559. var dayStr = dayDates[dayIndex].toISOString();
  13560. // append a day header
  13561. innerNodes.push(createElement(ListViewHeaderRow, { key: dayStr, dayDate: dayDates[dayIndex], todayRange: todayRange }));
  13562. daySegs = sortEventSegs(daySegs, options.eventOrder);
  13563. for (var _i = 0, daySegs_1 = daySegs; _i < daySegs_1.length; _i++) {
  13564. var seg = daySegs_1[_i];
  13565. innerNodes.push(createElement(ListViewEventRow, __assign({ key: dayStr + ':' + seg.eventRange.instance.instanceId /* are multiple segs for an instanceId */, seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false }, getSegMeta(seg, todayRange, nowDate))));
  13566. }
  13567. }
  13568. }
  13569. return (createElement("table", { className: 'fc-list-table ' + theme.getClass('table') },
  13570. createElement("tbody", null, innerNodes)));
  13571. }));
  13572. };
  13573. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  13574. return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
  13575. };
  13576. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  13577. var segs = [];
  13578. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  13579. var eventRange = eventRanges_1[_i];
  13580. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  13581. }
  13582. return segs;
  13583. };
  13584. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  13585. var dateEnv = this.context.dateEnv;
  13586. var nextDayThreshold = this.context.options.nextDayThreshold;
  13587. var range = eventRange.range;
  13588. var allDay = eventRange.def.allDay;
  13589. var dayIndex;
  13590. var segRange;
  13591. var seg;
  13592. var segs = [];
  13593. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
  13594. segRange = intersectRanges(range, dayRanges[dayIndex]);
  13595. if (segRange) {
  13596. seg = {
  13597. component: this,
  13598. eventRange: eventRange,
  13599. start: segRange.start,
  13600. end: segRange.end,
  13601. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  13602. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  13603. dayIndex: dayIndex,
  13604. };
  13605. segs.push(seg);
  13606. // detect when range won't go fully into the next day,
  13607. // and mutate the latest seg to the be the end.
  13608. if (!seg.isEnd && !allDay &&
  13609. dayIndex + 1 < dayRanges.length &&
  13610. range.end <
  13611. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  13612. seg.end = range.end;
  13613. seg.isEnd = true;
  13614. break;
  13615. }
  13616. }
  13617. }
  13618. return segs;
  13619. };
  13620. return ListView;
  13621. }(DateComponent));
  13622. function renderNoEventsInner(hookProps) {
  13623. return hookProps.text;
  13624. }
  13625. function computeDateVars(dateProfile) {
  13626. var dayStart = startOfDay(dateProfile.renderRange.start);
  13627. var viewEnd = dateProfile.renderRange.end;
  13628. var dayDates = [];
  13629. var dayRanges = [];
  13630. while (dayStart < viewEnd) {
  13631. dayDates.push(dayStart);
  13632. dayRanges.push({
  13633. start: dayStart,
  13634. end: addDays(dayStart, 1),
  13635. });
  13636. dayStart = addDays(dayStart, 1);
  13637. }
  13638. return { dayDates: dayDates, dayRanges: dayRanges };
  13639. }
  13640. // Returns a sparse array of arrays, segs grouped by their dayIndex
  13641. function groupSegsByDay(segs) {
  13642. var segsByDay = []; // sparse array
  13643. var i;
  13644. var seg;
  13645. for (i = 0; i < segs.length; i += 1) {
  13646. seg = segs[i];
  13647. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  13648. .push(seg);
  13649. }
  13650. return segsByDay;
  13651. }
  13652. var OPTION_REFINERS$3 = {
  13653. listDayFormat: createFalsableFormatter,
  13654. listDaySideFormat: createFalsableFormatter,
  13655. noEventsClassNames: identity,
  13656. noEventsContent: identity,
  13657. noEventsDidMount: identity,
  13658. noEventsWillUnmount: identity,
  13659. };
  13660. function createFalsableFormatter(input) {
  13661. return input === false ? null : createFormatter(input);
  13662. }
  13663. var listPlugin = createPlugin({
  13664. optionRefiners: OPTION_REFINERS$3,
  13665. views: {
  13666. list: {
  13667. component: ListView,
  13668. buttonTextKey: 'list',
  13669. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  13670. },
  13671. listDay: {
  13672. type: 'list',
  13673. duration: { days: 1 },
  13674. listDayFormat: { weekday: 'long' },
  13675. },
  13676. listWeek: {
  13677. type: 'list',
  13678. duration: { weeks: 1 },
  13679. listDayFormat: { weekday: 'long' },
  13680. listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  13681. },
  13682. listMonth: {
  13683. type: 'list',
  13684. duration: { month: 1 },
  13685. listDaySideFormat: { weekday: 'long' },
  13686. },
  13687. listYear: {
  13688. type: 'list',
  13689. duration: { year: 1 },
  13690. listDaySideFormat: { weekday: 'long' },
  13691. },
  13692. },
  13693. });
  13694. var BootstrapTheme = /** @class */ (function (_super) {
  13695. __extends(BootstrapTheme, _super);
  13696. function BootstrapTheme() {
  13697. return _super !== null && _super.apply(this, arguments) || this;
  13698. }
  13699. return BootstrapTheme;
  13700. }(Theme));
  13701. BootstrapTheme.prototype.classes = {
  13702. root: 'fc-theme-bootstrap',
  13703. table: 'table-bordered',
  13704. tableCellShaded: 'table-active',
  13705. buttonGroup: 'btn-group',
  13706. button: 'btn btn-primary',
  13707. buttonActive: 'active',
  13708. popover: 'popover',
  13709. popoverHeader: 'popover-header',
  13710. popoverContent: 'popover-body',
  13711. };
  13712. BootstrapTheme.prototype.baseIconClass = 'fa';
  13713. BootstrapTheme.prototype.iconClasses = {
  13714. close: 'fa-times',
  13715. prev: 'fa-chevron-left',
  13716. next: 'fa-chevron-right',
  13717. prevYear: 'fa-angle-double-left',
  13718. nextYear: 'fa-angle-double-right',
  13719. };
  13720. BootstrapTheme.prototype.rtlIconClasses = {
  13721. prev: 'fa-chevron-right',
  13722. next: 'fa-chevron-left',
  13723. prevYear: 'fa-angle-double-right',
  13724. nextYear: 'fa-angle-double-left',
  13725. };
  13726. BootstrapTheme.prototype.iconOverrideOption = 'bootstrapFontAwesome'; // TODO: make TS-friendly. move the option-processing into this plugin
  13727. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  13728. BootstrapTheme.prototype.iconOverridePrefix = 'fa-';
  13729. var plugin = createPlugin({
  13730. themeClasses: {
  13731. bootstrap: BootstrapTheme,
  13732. },
  13733. });
  13734. // rename this file to options.ts like other packages?
  13735. var OPTION_REFINERS$4 = {
  13736. googleCalendarApiKey: String,
  13737. };
  13738. var EVENT_SOURCE_REFINERS$1 = {
  13739. googleCalendarApiKey: String,
  13740. googleCalendarId: String,
  13741. googleCalendarApiBase: String,
  13742. extraParams: identity,
  13743. };
  13744. // TODO: expose somehow
  13745. var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
  13746. var eventSourceDef$3 = {
  13747. parseMeta: function (refined) {
  13748. var googleCalendarId = refined.googleCalendarId;
  13749. if (!googleCalendarId && refined.url) {
  13750. googleCalendarId = parseGoogleCalendarId(refined.url);
  13751. }
  13752. if (googleCalendarId) {
  13753. return {
  13754. googleCalendarId: googleCalendarId,
  13755. googleCalendarApiKey: refined.googleCalendarApiKey,
  13756. googleCalendarApiBase: refined.googleCalendarApiBase,
  13757. extraParams: refined.extraParams,
  13758. };
  13759. }
  13760. return null;
  13761. },
  13762. fetch: function (arg, onSuccess, onFailure) {
  13763. var _a = arg.context, dateEnv = _a.dateEnv, options = _a.options;
  13764. var meta = arg.eventSource.meta;
  13765. var apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
  13766. if (!apiKey) {
  13767. onFailure({
  13768. message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
  13769. });
  13770. }
  13771. else {
  13772. var url = buildUrl(meta);
  13773. // TODO: make DRY with json-feed-event-source
  13774. var extraParams = meta.extraParams;
  13775. var extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
  13776. var requestParams_1 = buildRequestParams$1(arg.range, apiKey, extraParamsObj, dateEnv);
  13777. requestJson('GET', url, requestParams_1, function (body, xhr) {
  13778. if (body.error) {
  13779. onFailure({
  13780. message: 'Google Calendar API: ' + body.error.message,
  13781. errors: body.error.errors,
  13782. xhr: xhr,
  13783. });
  13784. }
  13785. else {
  13786. onSuccess({
  13787. rawEvents: gcalItemsToRawEventDefs(body.items, requestParams_1.timeZone),
  13788. xhr: xhr,
  13789. });
  13790. }
  13791. }, function (message, xhr) {
  13792. onFailure({ message: message, xhr: xhr });
  13793. });
  13794. }
  13795. },
  13796. };
  13797. function parseGoogleCalendarId(url) {
  13798. var match;
  13799. // detect if the ID was specified as a single string.
  13800. // will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
  13801. if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
  13802. return url;
  13803. }
  13804. if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) ||
  13805. (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
  13806. return decodeURIComponent(match[1]);
  13807. }
  13808. return null;
  13809. }
  13810. function buildUrl(meta) {
  13811. var apiBase = meta.googleCalendarApiBase;
  13812. if (!apiBase) {
  13813. apiBase = API_BASE;
  13814. }
  13815. return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events';
  13816. }
  13817. function buildRequestParams$1(range, apiKey, extraParams, dateEnv) {
  13818. var params;
  13819. var startStr;
  13820. var endStr;
  13821. if (dateEnv.canComputeOffset) {
  13822. // strings will naturally have offsets, which GCal needs
  13823. startStr = dateEnv.formatIso(range.start);
  13824. endStr = dateEnv.formatIso(range.end);
  13825. }
  13826. else {
  13827. // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
  13828. // from the UTC day-start to guarantee we're getting all the events
  13829. // (start/end will be UTC-coerced dates, so toISOString is okay)
  13830. startStr = addDays(range.start, -1).toISOString();
  13831. endStr = addDays(range.end, 1).toISOString();
  13832. }
  13833. params = __assign(__assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
  13834. if (dateEnv.timeZone !== 'local') {
  13835. params.timeZone = dateEnv.timeZone;
  13836. }
  13837. return params;
  13838. }
  13839. function gcalItemsToRawEventDefs(items, gcalTimezone) {
  13840. return items.map(function (item) { return gcalItemToRawEventDef(item, gcalTimezone); });
  13841. }
  13842. function gcalItemToRawEventDef(item, gcalTimezone) {
  13843. var url = item.htmlLink || null;
  13844. // make the URLs for each event show times in the correct timezone
  13845. if (url && gcalTimezone) {
  13846. url = injectQsComponent(url, 'ctz=' + gcalTimezone);
  13847. }
  13848. return {
  13849. id: item.id,
  13850. title: item.summary,
  13851. start: item.start.dateTime || item.start.date,
  13852. end: item.end.dateTime || item.end.date,
  13853. url: url,
  13854. location: item.location,
  13855. description: item.description,
  13856. };
  13857. }
  13858. // Injects a string like "arg=value" into the querystring of a URL
  13859. // TODO: move to a general util file?
  13860. function injectQsComponent(url, component) {
  13861. // inject it after the querystring but before the fragment
  13862. return url.replace(/(\?.*?)?(#|$)/, function (whole, qs, hash) { return (qs ? qs + '&' : '?') + component + hash; });
  13863. }
  13864. var googleCalendarPlugin = createPlugin({
  13865. eventSourceDefs: [eventSourceDef$3],
  13866. optionRefiners: OPTION_REFINERS$4,
  13867. eventSourceRefiners: EVENT_SOURCE_REFINERS$1,
  13868. });
  13869. globalPlugins.push(interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin, plugin, googleCalendarPlugin);
  13870. exports.BASE_OPTION_DEFAULTS = BASE_OPTION_DEFAULTS;
  13871. exports.BASE_OPTION_REFINERS = BASE_OPTION_REFINERS;
  13872. exports.BaseComponent = BaseComponent;
  13873. exports.BgEvent = BgEvent;
  13874. exports.BootstrapTheme = BootstrapTheme;
  13875. exports.Calendar = Calendar;
  13876. exports.CalendarApi = CalendarApi;
  13877. exports.CalendarContent = CalendarContent;
  13878. exports.CalendarDataManager = CalendarDataManager;
  13879. exports.CalendarDataProvider = CalendarDataProvider;
  13880. exports.CalendarRoot = CalendarRoot;
  13881. exports.Component = Component;
  13882. exports.ContentHook = ContentHook;
  13883. exports.CustomContentRenderContext = CustomContentRenderContext;
  13884. exports.DateComponent = DateComponent;
  13885. exports.DateEnv = DateEnv;
  13886. exports.DateProfileGenerator = DateProfileGenerator;
  13887. exports.DayCellContent = DayCellContent;
  13888. exports.DayCellRoot = DayCellRoot;
  13889. exports.DayGridView = DayTableView;
  13890. exports.DayHeader = DayHeader;
  13891. exports.DaySeriesModel = DaySeriesModel;
  13892. exports.DayTable = DayTable;
  13893. exports.DayTableModel = DayTableModel;
  13894. exports.DayTableSlicer = DayTableSlicer;
  13895. exports.DayTimeCols = DayTimeCols;
  13896. exports.DayTimeColsSlicer = DayTimeColsSlicer;
  13897. exports.DayTimeColsView = DayTimeColsView;
  13898. exports.DelayedRunner = DelayedRunner;
  13899. exports.Draggable = ExternalDraggable;
  13900. exports.ElementDragging = ElementDragging;
  13901. exports.ElementScrollController = ElementScrollController;
  13902. exports.Emitter = Emitter;
  13903. exports.EventApi = EventApi;
  13904. exports.EventRoot = EventRoot;
  13905. exports.EventSourceApi = EventSourceApi;
  13906. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  13907. exports.Fragment = Fragment;
  13908. exports.Interaction = Interaction;
  13909. exports.ListView = ListView;
  13910. exports.MountHook = MountHook;
  13911. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  13912. exports.NowIndicatorRoot = NowIndicatorRoot;
  13913. exports.NowTimer = NowTimer;
  13914. exports.PointerDragging = PointerDragging;
  13915. exports.PositionCache = PositionCache;
  13916. exports.RefMap = RefMap;
  13917. exports.RenderHook = RenderHook;
  13918. exports.ScrollController = ScrollController;
  13919. exports.ScrollResponder = ScrollResponder;
  13920. exports.Scroller = Scroller;
  13921. exports.SimpleScrollGrid = SimpleScrollGrid;
  13922. exports.Slicer = Slicer;
  13923. exports.Splitter = Splitter;
  13924. exports.StandardEvent = StandardEvent;
  13925. exports.Table = Table;
  13926. exports.TableDateCell = TableDateCell;
  13927. exports.TableDowCell = TableDowCell;
  13928. exports.TableView = TableView;
  13929. exports.Theme = Theme;
  13930. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  13931. exports.TimeCols = TimeCols;
  13932. exports.TimeColsSlatsCoords = TimeColsSlatsCoords;
  13933. exports.TimeColsView = TimeColsView;
  13934. exports.ViewApi = ViewApi;
  13935. exports.ViewContextType = ViewContextType;
  13936. exports.ViewRoot = ViewRoot;
  13937. exports.WeekNumberRoot = WeekNumberRoot;
  13938. exports.WindowScrollController = WindowScrollController;
  13939. exports.addDays = addDays;
  13940. exports.addDurations = addDurations;
  13941. exports.addMs = addMs;
  13942. exports.addWeeks = addWeeks;
  13943. exports.allowContextMenu = allowContextMenu;
  13944. exports.allowSelection = allowSelection;
  13945. exports.applyMutationToEventStore = applyMutationToEventStore;
  13946. exports.applyStyle = applyStyle;
  13947. exports.applyStyleProp = applyStyleProp;
  13948. exports.asCleanDays = asCleanDays;
  13949. exports.asRoughMinutes = asRoughMinutes;
  13950. exports.asRoughMs = asRoughMs;
  13951. exports.asRoughSeconds = asRoughSeconds;
  13952. exports.buildClassNameNormalizer = buildClassNameNormalizer;
  13953. exports.buildDayRanges = buildDayRanges;
  13954. exports.buildDayTableModel = buildDayTableModel;
  13955. exports.buildEventApis = buildEventApis;
  13956. exports.buildEventRangeKey = buildEventRangeKey;
  13957. exports.buildHashFromArray = buildHashFromArray;
  13958. exports.buildNavLinkData = buildNavLinkData;
  13959. exports.buildSegCompareObj = buildSegCompareObj;
  13960. exports.buildSegTimeText = buildSegTimeText;
  13961. exports.buildSlatMetas = buildSlatMetas;
  13962. exports.buildTimeColsModel = buildTimeColsModel;
  13963. exports.collectFromHash = collectFromHash;
  13964. exports.combineEventUis = combineEventUis;
  13965. exports.compareByFieldSpec = compareByFieldSpec;
  13966. exports.compareByFieldSpecs = compareByFieldSpecs;
  13967. exports.compareNumbers = compareNumbers;
  13968. exports.compareObjs = compareObjs;
  13969. exports.computeEdges = computeEdges;
  13970. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  13971. exports.computeHeightAndMargins = computeHeightAndMargins;
  13972. exports.computeInnerRect = computeInnerRect;
  13973. exports.computeRect = computeRect;
  13974. exports.computeSegDraggable = computeSegDraggable;
  13975. exports.computeSegEndResizable = computeSegEndResizable;
  13976. exports.computeSegStartResizable = computeSegStartResizable;
  13977. exports.computeShrinkWidth = computeShrinkWidth;
  13978. exports.computeSmallestCellWidth = computeSmallestCellWidth;
  13979. exports.computeVisibleDayRange = computeVisibleDayRange;
  13980. exports.config = config;
  13981. exports.constrainPoint = constrainPoint;
  13982. exports.createContext = createContext$1;
  13983. exports.createDuration = createDuration;
  13984. exports.createElement = createElement;
  13985. exports.createEmptyEventStore = createEmptyEventStore;
  13986. exports.createEventInstance = createEventInstance;
  13987. exports.createEventUi = createEventUi;
  13988. exports.createFormatter = createFormatter;
  13989. exports.createPlugin = createPlugin;
  13990. exports.createRef = createRef;
  13991. exports.diffDates = diffDates;
  13992. exports.diffDayAndTime = diffDayAndTime;
  13993. exports.diffDays = diffDays;
  13994. exports.diffPoints = diffPoints;
  13995. exports.diffWeeks = diffWeeks;
  13996. exports.diffWholeDays = diffWholeDays;
  13997. exports.diffWholeWeeks = diffWholeWeeks;
  13998. exports.disableCursor = disableCursor;
  13999. exports.elementClosest = elementClosest;
  14000. exports.elementMatches = elementMatches;
  14001. exports.enableCursor = enableCursor;
  14002. exports.eventTupleToStore = eventTupleToStore;
  14003. exports.filterEventStoreDefs = filterEventStoreDefs;
  14004. exports.filterHash = filterHash;
  14005. exports.findDirectChildren = findDirectChildren;
  14006. exports.findElements = findElements;
  14007. exports.flexibleCompare = flexibleCompare;
  14008. exports.flushToDom = flushToDom$1;
  14009. exports.formatDate = formatDate;
  14010. exports.formatDayString = formatDayString;
  14011. exports.formatIsoTimeString = formatIsoTimeString;
  14012. exports.formatRange = formatRange;
  14013. exports.getAllowYScrolling = getAllowYScrolling;
  14014. exports.getCanVGrowWithinCell = getCanVGrowWithinCell;
  14015. exports.getClippingParents = getClippingParents;
  14016. exports.getDateMeta = getDateMeta;
  14017. exports.getDayClassNames = getDayClassNames;
  14018. exports.getDefaultEventEnd = getDefaultEventEnd;
  14019. exports.getElSeg = getElSeg;
  14020. exports.getEventClassNames = getEventClassNames;
  14021. exports.getIsRtlScrollbarOnLeft = getIsRtlScrollbarOnLeft;
  14022. exports.getRectCenter = getRectCenter;
  14023. exports.getRelevantEvents = getRelevantEvents;
  14024. exports.getScrollGridClassNames = getScrollGridClassNames;
  14025. exports.getScrollbarWidths = getScrollbarWidths;
  14026. exports.getSectionClassNames = getSectionClassNames;
  14027. exports.getSectionHasLiquidHeight = getSectionHasLiquidHeight;
  14028. exports.getSegMeta = getSegMeta;
  14029. exports.getSlotClassNames = getSlotClassNames;
  14030. exports.getStickyFooterScrollbar = getStickyFooterScrollbar;
  14031. exports.getStickyHeaderDates = getStickyHeaderDates;
  14032. exports.getUnequalProps = getUnequalProps;
  14033. exports.globalLocales = globalLocales;
  14034. exports.globalPlugins = globalPlugins;
  14035. exports.greatestDurationDenominator = greatestDurationDenominator;
  14036. exports.guid = guid;
  14037. exports.hasBgRendering = hasBgRendering;
  14038. exports.hasShrinkWidth = hasShrinkWidth;
  14039. exports.identity = identity;
  14040. exports.interactionSettingsStore = interactionSettingsStore;
  14041. exports.interactionSettingsToStore = interactionSettingsToStore;
  14042. exports.intersectRanges = intersectRanges;
  14043. exports.intersectRects = intersectRects;
  14044. exports.isArraysEqual = isArraysEqual;
  14045. exports.isColPropsEqual = isColPropsEqual;
  14046. exports.isDateSpansEqual = isDateSpansEqual;
  14047. exports.isInt = isInt;
  14048. exports.isInteractionValid = isInteractionValid;
  14049. exports.isMultiDayRange = isMultiDayRange;
  14050. exports.isPropsEqual = isPropsEqual;
  14051. exports.isPropsValid = isPropsValid;
  14052. exports.isValidDate = isValidDate;
  14053. exports.listenBySelector = listenBySelector;
  14054. exports.mapHash = mapHash;
  14055. exports.memoize = memoize;
  14056. exports.memoizeArraylike = memoizeArraylike;
  14057. exports.memoizeHashlike = memoizeHashlike;
  14058. exports.memoizeObjArg = memoizeObjArg;
  14059. exports.mergeEventStores = mergeEventStores;
  14060. exports.multiplyDuration = multiplyDuration;
  14061. exports.padStart = padStart;
  14062. exports.parseBusinessHours = parseBusinessHours;
  14063. exports.parseClassNames = parseClassNames;
  14064. exports.parseDragMeta = parseDragMeta;
  14065. exports.parseEventDef = parseEventDef;
  14066. exports.parseFieldSpecs = parseFieldSpecs;
  14067. exports.parseMarker = parse;
  14068. exports.pointInsideRect = pointInsideRect;
  14069. exports.preventContextMenu = preventContextMenu;
  14070. exports.preventDefault = preventDefault;
  14071. exports.preventSelection = preventSelection;
  14072. exports.rangeContainsMarker = rangeContainsMarker;
  14073. exports.rangeContainsRange = rangeContainsRange;
  14074. exports.rangesEqual = rangesEqual;
  14075. exports.rangesIntersect = rangesIntersect;
  14076. exports.refineEventDef = refineEventDef;
  14077. exports.refineProps = refineProps;
  14078. exports.removeElement = removeElement;
  14079. exports.removeExact = removeExact;
  14080. exports.render = render;
  14081. exports.renderChunkContent = renderChunkContent;
  14082. exports.renderFill = renderFill;
  14083. exports.renderMicroColGroup = renderMicroColGroup;
  14084. exports.renderScrollShim = renderScrollShim;
  14085. exports.requestJson = requestJson;
  14086. exports.sanitizeShrinkWidth = sanitizeShrinkWidth;
  14087. exports.setElSeg = setElSeg;
  14088. exports.setRef = setRef;
  14089. exports.sliceEventStore = sliceEventStore;
  14090. exports.sliceEvents = sliceEvents;
  14091. exports.sortEventSegs = sortEventSegs;
  14092. exports.startOfDay = startOfDay;
  14093. exports.translateRect = translateRect;
  14094. exports.triggerDateSelect = triggerDateSelect;
  14095. exports.unmountComponentAtNode = unmountComponentAtNode$1;
  14096. exports.unpromisify = unpromisify;
  14097. exports.version = version;
  14098. exports.whenTransitionDone = whenTransitionDone;
  14099. exports.wholeDivideDurations = wholeDivideDurations;
  14100. Object.defineProperty(exports, '__esModule', { value: true });
  14101. return exports;
  14102. }({}));