main.js 658 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281
  1. /*!
  2. FullCalendar v5.3.2
  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 h(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 v(n,f,i,t,null)}function v(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:o};return null==o&&(r.__v=r),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=i,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,h){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?v(null,k,null,null,k):Array.isArray(k)?v(p,{children:k},null,null,null):null!=k.__e||null!=k.__c?v(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,h),(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),h||"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,h,v,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=(h=u.__c=i.__c).__=h.__E:("prototype"in P&&P.prototype.render?u.__c=h=new P(g,x):(u.__c=h=new d(g,x),h.constructor=P,h.render=M),b&&b.sub(h),h.props=g,h.state||(h.state={}),h.context=x,h.__n=t,v=h.__d=!0,h.__h=[]),null==h.__s&&(h.__s=h.state),null!=P.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=s({},h.__s)),s(h.__s,P.getDerivedStateFromProps(g,h.__s))),y=h.props,_=h.state,v)null==P.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else {if(null==P.getDerivedStateFromProps&&g!==y&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(g,x),!h.__e&&null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(g,h.__s,x)||u.__v===i.__v){h.props=g,h.state=h.__s,u.__v!==i.__v&&(h.__d=!1),h.__v=u,u.__e=i.__e,u.__k=i.__k,h.__h.length&&f.push(h),T(u,e,l);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(g,h.__s,x),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(y,_,w);});}h.context=x,h.props=g,h.state=h.__s,(a=n.__r)&&a(u),h.__d=!1,h.__v=u,h.__P=l,a=h.render(h.props,h.state,h.context),h.state=h.__s,null!=h.getChildContext&&(t=s(s({},t),h.getChildContext())),v||null==h.getSnapshotBeforeUpdate||(w=h.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),h.base=u.__e,u.__h=null,h.__h.length&&f.push(h),k&&(h.__E=h.__=null),h.__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,h,v,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)),h=(p=u.props||f).dangerouslySetInnerHTML,v=d.dangerouslySetInnerHTML,!c){if(null!=o)for(p={},y=0;y<n.attributes.length;y++)p[n.attributes[y].name]=n.attributes[y].value;(v||h)&&(v&&(h&&v.__html==h.__html||v.__html===n.innerHTML)||(n.innerHTML=v&&v.__html||""));}A(n,d,p,t,c),v?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=h(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}},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: h,
  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(h(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 h('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. // only relevant to json-feed event sources
  152. get: function () {
  153. return this.internalEventSource.meta.url;
  154. },
  155. enumerable: false,
  156. configurable: true
  157. });
  158. return EventSourceApi;
  159. }());
  160. function removeElement(el) {
  161. if (el.parentNode) {
  162. el.parentNode.removeChild(el);
  163. }
  164. }
  165. // Querying
  166. // ----------------------------------------------------------------------------------------------------------------
  167. function elementClosest(el, selector) {
  168. if (el.closest) {
  169. return el.closest(selector);
  170. // really bad fallback for IE
  171. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  172. }
  173. if (!document.documentElement.contains(el)) {
  174. return null;
  175. }
  176. do {
  177. if (elementMatches(el, selector)) {
  178. return el;
  179. }
  180. el = (el.parentElement || el.parentNode);
  181. } while (el !== null && el.nodeType === 1);
  182. return null;
  183. }
  184. function elementMatches(el, selector) {
  185. var method = el.matches || el.matchesSelector || el.msMatchesSelector;
  186. return method.call(el, selector);
  187. }
  188. // accepts multiple subject els
  189. // returns a real array. good for methods like forEach
  190. // TODO: accept the document
  191. function findElements(container, selector) {
  192. var containers = container instanceof HTMLElement ? [container] : container;
  193. var allMatches = [];
  194. for (var i = 0; i < containers.length; i += 1) {
  195. var matches = containers[i].querySelectorAll(selector);
  196. for (var j = 0; j < matches.length; j += 1) {
  197. allMatches.push(matches[j]);
  198. }
  199. }
  200. return allMatches;
  201. }
  202. // accepts multiple subject els
  203. // only queries direct child elements // TODO: rename to findDirectChildren!
  204. function findDirectChildren(parent, selector) {
  205. var parents = parent instanceof HTMLElement ? [parent] : parent;
  206. var allMatches = [];
  207. for (var i = 0; i < parents.length; i += 1) {
  208. var childNodes = parents[i].children; // only ever elements
  209. for (var j = 0; j < childNodes.length; j += 1) {
  210. var childNode = childNodes[j];
  211. if (!selector || elementMatches(childNode, selector)) {
  212. allMatches.push(childNode);
  213. }
  214. }
  215. }
  216. return allMatches;
  217. }
  218. // Style
  219. // ----------------------------------------------------------------------------------------------------------------
  220. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  221. function applyStyle(el, props) {
  222. for (var propName in props) {
  223. applyStyleProp(el, propName, props[propName]);
  224. }
  225. }
  226. function applyStyleProp(el, name, val) {
  227. if (val == null) {
  228. el.style[name] = '';
  229. }
  230. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  231. el.style[name] = val + "px";
  232. }
  233. else {
  234. el.style[name] = val;
  235. }
  236. }
  237. // Stops a mouse/touch event from doing it's native browser action
  238. function preventDefault(ev) {
  239. ev.preventDefault();
  240. }
  241. // Event Delegation
  242. // ----------------------------------------------------------------------------------------------------------------
  243. function buildDelegationHandler(selector, handler) {
  244. return function (ev) {
  245. var matchedChild = elementClosest(ev.target, selector);
  246. if (matchedChild) {
  247. handler.call(matchedChild, ev, matchedChild);
  248. }
  249. };
  250. }
  251. function listenBySelector(container, eventType, selector, handler) {
  252. var attachedHandler = buildDelegationHandler(selector, handler);
  253. container.addEventListener(eventType, attachedHandler);
  254. return function () {
  255. container.removeEventListener(eventType, attachedHandler);
  256. };
  257. }
  258. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  259. var currentMatchedChild;
  260. return listenBySelector(container, 'mouseover', selector, function (mouseOverEv, matchedChild) {
  261. if (matchedChild !== currentMatchedChild) {
  262. currentMatchedChild = matchedChild;
  263. onMouseEnter(mouseOverEv, matchedChild);
  264. var realOnMouseLeave_1 = function (mouseLeaveEv) {
  265. currentMatchedChild = null;
  266. onMouseLeave(mouseLeaveEv, matchedChild);
  267. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  268. };
  269. // listen to the next mouseleave, and then unattach
  270. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  271. }
  272. });
  273. }
  274. // Animation
  275. // ----------------------------------------------------------------------------------------------------------------
  276. var transitionEventNames = [
  277. 'webkitTransitionEnd',
  278. 'otransitionend',
  279. 'oTransitionEnd',
  280. 'msTransitionEnd',
  281. 'transitionend',
  282. ];
  283. // triggered only when the next single subsequent transition finishes
  284. function whenTransitionDone(el, callback) {
  285. var realCallback = function (ev) {
  286. callback(ev);
  287. transitionEventNames.forEach(function (eventName) {
  288. el.removeEventListener(eventName, realCallback);
  289. });
  290. };
  291. transitionEventNames.forEach(function (eventName) {
  292. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  293. });
  294. }
  295. var guidNumber = 0;
  296. function guid() {
  297. guidNumber += 1;
  298. return String(guidNumber);
  299. }
  300. /* FullCalendar-specific DOM Utilities
  301. ----------------------------------------------------------------------------------------------------------------------*/
  302. // Make the mouse cursor express that an event is not allowed in the current area
  303. function disableCursor() {
  304. document.body.classList.add('fc-not-allowed');
  305. }
  306. // Returns the mouse cursor to its original look
  307. function enableCursor() {
  308. document.body.classList.remove('fc-not-allowed');
  309. }
  310. /* Selection
  311. ----------------------------------------------------------------------------------------------------------------------*/
  312. function preventSelection(el) {
  313. el.classList.add('fc-unselectable');
  314. el.addEventListener('selectstart', preventDefault);
  315. }
  316. function allowSelection(el) {
  317. el.classList.remove('fc-unselectable');
  318. el.removeEventListener('selectstart', preventDefault);
  319. }
  320. /* Context Menu
  321. ----------------------------------------------------------------------------------------------------------------------*/
  322. function preventContextMenu(el) {
  323. el.addEventListener('contextmenu', preventDefault);
  324. }
  325. function allowContextMenu(el) {
  326. el.removeEventListener('contextmenu', preventDefault);
  327. }
  328. function parseFieldSpecs(input) {
  329. var specs = [];
  330. var tokens = [];
  331. var i;
  332. var token;
  333. if (typeof input === 'string') {
  334. tokens = input.split(/\s*,\s*/);
  335. }
  336. else if (typeof input === 'function') {
  337. tokens = [input];
  338. }
  339. else if (Array.isArray(input)) {
  340. tokens = input;
  341. }
  342. for (i = 0; i < tokens.length; i += 1) {
  343. token = tokens[i];
  344. if (typeof token === 'string') {
  345. specs.push(token.charAt(0) === '-' ?
  346. { field: token.substring(1), order: -1 } :
  347. { field: token, order: 1 });
  348. }
  349. else if (typeof token === 'function') {
  350. specs.push({ func: token });
  351. }
  352. }
  353. return specs;
  354. }
  355. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  356. var i;
  357. var cmp;
  358. for (i = 0; i < fieldSpecs.length; i += 1) {
  359. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  360. if (cmp) {
  361. return cmp;
  362. }
  363. }
  364. return 0;
  365. }
  366. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  367. if (fieldSpec.func) {
  368. return fieldSpec.func(obj0, obj1);
  369. }
  370. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  371. * (fieldSpec.order || 1);
  372. }
  373. function flexibleCompare(a, b) {
  374. if (!a && !b) {
  375. return 0;
  376. }
  377. if (b == null) {
  378. return -1;
  379. }
  380. if (a == null) {
  381. return 1;
  382. }
  383. if (typeof a === 'string' || typeof b === 'string') {
  384. return String(a).localeCompare(String(b));
  385. }
  386. return a - b;
  387. }
  388. /* String Utilities
  389. ----------------------------------------------------------------------------------------------------------------------*/
  390. function padStart(val, len) {
  391. var s = String(val);
  392. return '000'.substr(0, len - s.length) + s;
  393. }
  394. /* Number Utilities
  395. ----------------------------------------------------------------------------------------------------------------------*/
  396. function compareNumbers(a, b) {
  397. return a - b;
  398. }
  399. function isInt(n) {
  400. return n % 1 === 0;
  401. }
  402. /* FC-specific DOM dimension stuff
  403. ----------------------------------------------------------------------------------------------------------------------*/
  404. function computeSmallestCellWidth(cellEl) {
  405. var allWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-frame');
  406. var contentWidthEl = cellEl.querySelector('.fc-scrollgrid-shrink-cushion');
  407. if (!allWidthEl) {
  408. throw new Error('needs fc-scrollgrid-shrink-frame className'); // TODO: use const
  409. }
  410. if (!contentWidthEl) {
  411. throw new Error('needs fc-scrollgrid-shrink-cushion className');
  412. }
  413. return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + // the cell padding+border
  414. contentWidthEl.getBoundingClientRect().width;
  415. }
  416. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  417. // Adding
  418. function addWeeks(m, n) {
  419. var a = dateToUtcArray(m);
  420. a[2] += n * 7;
  421. return arrayToUtcDate(a);
  422. }
  423. function addDays(m, n) {
  424. var a = dateToUtcArray(m);
  425. a[2] += n;
  426. return arrayToUtcDate(a);
  427. }
  428. function addMs(m, n) {
  429. var a = dateToUtcArray(m);
  430. a[6] += n;
  431. return arrayToUtcDate(a);
  432. }
  433. // Diffing (all return floats)
  434. // TODO: why not use ranges?
  435. function diffWeeks(m0, m1) {
  436. return diffDays(m0, m1) / 7;
  437. }
  438. function diffDays(m0, m1) {
  439. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  440. }
  441. function diffHours(m0, m1) {
  442. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  443. }
  444. function diffMinutes(m0, m1) {
  445. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  446. }
  447. function diffSeconds(m0, m1) {
  448. return (m1.valueOf() - m0.valueOf()) / 1000;
  449. }
  450. function diffDayAndTime(m0, m1) {
  451. var m0day = startOfDay(m0);
  452. var m1day = startOfDay(m1);
  453. return {
  454. years: 0,
  455. months: 0,
  456. days: Math.round(diffDays(m0day, m1day)),
  457. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf()),
  458. };
  459. }
  460. // Diffing Whole Units
  461. function diffWholeWeeks(m0, m1) {
  462. var d = diffWholeDays(m0, m1);
  463. if (d !== null && d % 7 === 0) {
  464. return d / 7;
  465. }
  466. return null;
  467. }
  468. function diffWholeDays(m0, m1) {
  469. if (timeAsMs(m0) === timeAsMs(m1)) {
  470. return Math.round(diffDays(m0, m1));
  471. }
  472. return null;
  473. }
  474. // Start-Of
  475. function startOfDay(m) {
  476. return arrayToUtcDate([
  477. m.getUTCFullYear(),
  478. m.getUTCMonth(),
  479. m.getUTCDate(),
  480. ]);
  481. }
  482. function startOfHour(m) {
  483. return arrayToUtcDate([
  484. m.getUTCFullYear(),
  485. m.getUTCMonth(),
  486. m.getUTCDate(),
  487. m.getUTCHours(),
  488. ]);
  489. }
  490. function startOfMinute(m) {
  491. return arrayToUtcDate([
  492. m.getUTCFullYear(),
  493. m.getUTCMonth(),
  494. m.getUTCDate(),
  495. m.getUTCHours(),
  496. m.getUTCMinutes(),
  497. ]);
  498. }
  499. function startOfSecond(m) {
  500. return arrayToUtcDate([
  501. m.getUTCFullYear(),
  502. m.getUTCMonth(),
  503. m.getUTCDate(),
  504. m.getUTCHours(),
  505. m.getUTCMinutes(),
  506. m.getUTCSeconds(),
  507. ]);
  508. }
  509. // Week Computation
  510. function weekOfYear(marker, dow, doy) {
  511. var y = marker.getUTCFullYear();
  512. var w = weekOfGivenYear(marker, y, dow, doy);
  513. if (w < 1) {
  514. return weekOfGivenYear(marker, y - 1, dow, doy);
  515. }
  516. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  517. if (nextW >= 1) {
  518. return Math.min(w, nextW);
  519. }
  520. return w;
  521. }
  522. function weekOfGivenYear(marker, year, dow, doy) {
  523. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  524. var dayStart = startOfDay(marker);
  525. var days = Math.round(diffDays(firstWeekStart, dayStart));
  526. return Math.floor(days / 7) + 1; // zero-indexed
  527. }
  528. // start-of-first-week - start-of-year
  529. function firstWeekOffset(year, dow, doy) {
  530. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  531. var fwd = 7 + dow - doy;
  532. // first-week day local weekday -- which local weekday is fwd
  533. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  534. return -fwdlw + fwd - 1;
  535. }
  536. // Array Conversion
  537. function dateToLocalArray(date) {
  538. return [
  539. date.getFullYear(),
  540. date.getMonth(),
  541. date.getDate(),
  542. date.getHours(),
  543. date.getMinutes(),
  544. date.getSeconds(),
  545. date.getMilliseconds(),
  546. ];
  547. }
  548. function arrayToLocalDate(a) {
  549. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  550. a[3] || 0, a[4] || 0, a[5] || 0);
  551. }
  552. function dateToUtcArray(date) {
  553. return [
  554. date.getUTCFullYear(),
  555. date.getUTCMonth(),
  556. date.getUTCDate(),
  557. date.getUTCHours(),
  558. date.getUTCMinutes(),
  559. date.getUTCSeconds(),
  560. date.getUTCMilliseconds(),
  561. ];
  562. }
  563. function arrayToUtcDate(a) {
  564. // according to web standards (and Safari), a month index is required.
  565. // massage if only given a year.
  566. if (a.length === 1) {
  567. a = a.concat([0]);
  568. }
  569. return new Date(Date.UTC.apply(Date, a));
  570. }
  571. // Other Utils
  572. function isValidDate(m) {
  573. return !isNaN(m.valueOf());
  574. }
  575. function timeAsMs(m) {
  576. return m.getUTCHours() * 1000 * 60 * 60 +
  577. m.getUTCMinutes() * 1000 * 60 +
  578. m.getUTCSeconds() * 1000 +
  579. m.getUTCMilliseconds();
  580. }
  581. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  582. return {
  583. instanceId: guid(),
  584. defId: defId,
  585. range: range,
  586. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  587. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo,
  588. };
  589. }
  590. var hasOwnProperty = Object.prototype.hasOwnProperty;
  591. // Merges an array of objects into a single object.
  592. // The second argument allows for an array of property names who's object values will be merged together.
  593. function mergeProps(propObjs, complexPropsMap) {
  594. var dest = {};
  595. if (complexPropsMap) {
  596. for (var name_1 in complexPropsMap) {
  597. var complexObjs = [];
  598. // collect the trailing object values, stopping when a non-object is discovered
  599. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  600. var val = propObjs[i][name_1];
  601. if (typeof val === 'object' && val) { // non-null object
  602. complexObjs.unshift(val);
  603. }
  604. else if (val !== undefined) {
  605. dest[name_1] = val; // if there were no objects, this value will be used
  606. break;
  607. }
  608. }
  609. // if the trailing values were objects, use the merged value
  610. if (complexObjs.length) {
  611. dest[name_1] = mergeProps(complexObjs);
  612. }
  613. }
  614. }
  615. // copy values into the destination, going from last to first
  616. for (var i = propObjs.length - 1; i >= 0; i -= 1) {
  617. var props = propObjs[i];
  618. for (var name_2 in props) {
  619. if (!(name_2 in dest)) { // if already assigned by previous props or complex props, don't reassign
  620. dest[name_2] = props[name_2];
  621. }
  622. }
  623. }
  624. return dest;
  625. }
  626. function filterHash(hash, func) {
  627. var filtered = {};
  628. for (var key in hash) {
  629. if (func(hash[key], key)) {
  630. filtered[key] = hash[key];
  631. }
  632. }
  633. return filtered;
  634. }
  635. function mapHash(hash, func) {
  636. var newHash = {};
  637. for (var key in hash) {
  638. newHash[key] = func(hash[key], key);
  639. }
  640. return newHash;
  641. }
  642. function arrayToHash(a) {
  643. var hash = {};
  644. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  645. var item = a_1[_i];
  646. hash[item] = true;
  647. }
  648. return hash;
  649. }
  650. function buildHashFromArray(a, func) {
  651. var hash = {};
  652. for (var i = 0; i < a.length; i += 1) {
  653. var tuple = func(a[i], i);
  654. hash[tuple[0]] = tuple[1];
  655. }
  656. return hash;
  657. }
  658. function hashValuesToArray(obj) {
  659. var a = [];
  660. for (var key in obj) {
  661. a.push(obj[key]);
  662. }
  663. return a;
  664. }
  665. function isPropsEqual(obj0, obj1) {
  666. if (obj0 === obj1) {
  667. return true;
  668. }
  669. for (var key in obj0) {
  670. if (hasOwnProperty.call(obj0, key)) {
  671. if (!(key in obj1)) {
  672. return false;
  673. }
  674. }
  675. }
  676. for (var key in obj1) {
  677. if (hasOwnProperty.call(obj1, key)) {
  678. if (obj0[key] !== obj1[key]) {
  679. return false;
  680. }
  681. }
  682. }
  683. return true;
  684. }
  685. function getUnequalProps(obj0, obj1) {
  686. var keys = [];
  687. for (var key in obj0) {
  688. if (hasOwnProperty.call(obj0, key)) {
  689. if (!(key in obj1)) {
  690. keys.push(key);
  691. }
  692. }
  693. }
  694. for (var key in obj1) {
  695. if (hasOwnProperty.call(obj1, key)) {
  696. if (obj0[key] !== obj1[key]) {
  697. keys.push(key);
  698. }
  699. }
  700. }
  701. return keys;
  702. }
  703. function compareObjs(oldProps, newProps, equalityFuncs) {
  704. if (equalityFuncs === void 0) { equalityFuncs = {}; }
  705. if (oldProps === newProps) {
  706. return true;
  707. }
  708. for (var key in newProps) {
  709. if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key])) ;
  710. else {
  711. return false;
  712. }
  713. }
  714. // check for props that were omitted in the new
  715. for (var key in oldProps) {
  716. if (!(key in newProps)) {
  717. return false;
  718. }
  719. }
  720. return true;
  721. }
  722. /*
  723. assumed "true" equality for handler names like "onReceiveSomething"
  724. */
  725. function isObjValsEqual(val0, val1, comparator) {
  726. if (val0 === val1 || comparator === true) {
  727. return true;
  728. }
  729. if (comparator) {
  730. return comparator(val0, val1);
  731. }
  732. return false;
  733. }
  734. function collectFromHash(hash, startIndex, endIndex, step) {
  735. if (startIndex === void 0) { startIndex = 0; }
  736. if (step === void 0) { step = 1; }
  737. var res = [];
  738. if (endIndex == null) {
  739. endIndex = Object.keys(hash).length;
  740. }
  741. for (var i = startIndex; i < endIndex; i += step) {
  742. var val = hash[i];
  743. if (val !== undefined) { // will disregard undefined for sparse arrays
  744. res.push(val);
  745. }
  746. }
  747. return res;
  748. }
  749. function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
  750. for (var i = 0; i < recurringTypes.length; i += 1) {
  751. var parsed = recurringTypes[i].parse(refined, dateEnv);
  752. if (parsed) {
  753. var allDay = refined.allDay;
  754. if (allDay == null) {
  755. allDay = defaultAllDay;
  756. if (allDay == null) {
  757. allDay = parsed.allDayGuess;
  758. if (allDay == null) {
  759. allDay = false;
  760. }
  761. }
  762. }
  763. return {
  764. allDay: allDay,
  765. duration: parsed.duration,
  766. typeData: parsed.typeData,
  767. typeId: i,
  768. };
  769. }
  770. }
  771. return null;
  772. }
  773. function expandRecurring(eventStore, framingRange, context) {
  774. var dateEnv = context.dateEnv, pluginHooks = context.pluginHooks, options = context.options;
  775. var defs = eventStore.defs, instances = eventStore.instances;
  776. // remove existing recurring instances
  777. // TODO: bad. always expand events as a second step
  778. instances = filterHash(instances, function (instance) { return !defs[instance.defId].recurringDef; });
  779. for (var defId in defs) {
  780. var def = defs[defId];
  781. if (def.recurringDef) {
  782. var duration = def.recurringDef.duration;
  783. if (!duration) {
  784. duration = def.allDay ?
  785. options.defaultAllDayEventDuration :
  786. options.defaultTimedEventDuration;
  787. }
  788. var starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
  789. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  790. var start = starts_1[_i];
  791. var instance = createEventInstance(defId, {
  792. start: start,
  793. end: dateEnv.add(start, duration),
  794. });
  795. instances[instance.instanceId] = instance;
  796. }
  797. }
  798. }
  799. return { defs: defs, instances: instances };
  800. }
  801. /*
  802. Event MUST have a recurringDef
  803. */
  804. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  805. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  806. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  807. start: dateEnv.subtract(framingRange.start, duration),
  808. end: framingRange.end,
  809. }, dateEnv);
  810. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  811. if (eventDef.allDay) {
  812. markers = markers.map(startOfDay);
  813. }
  814. return markers;
  815. }
  816. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  817. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  818. // Parsing and Creation
  819. function createDuration(input, unit) {
  820. var _a;
  821. if (typeof input === 'string') {
  822. return parseString(input);
  823. }
  824. if (typeof input === 'object' && input) { // non-null object
  825. return parseObject(input);
  826. }
  827. if (typeof input === 'number') {
  828. return parseObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  829. }
  830. return null;
  831. }
  832. function parseString(s) {
  833. var m = PARSE_RE.exec(s);
  834. if (m) {
  835. var sign = m[1] ? -1 : 1;
  836. return {
  837. years: 0,
  838. months: 0,
  839. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  840. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  841. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  842. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  843. (m[6] ? parseInt(m[6], 10) : 0) // ms
  844. ),
  845. };
  846. }
  847. return null;
  848. }
  849. function parseObject(obj) {
  850. var duration = {
  851. years: obj.years || obj.year || 0,
  852. months: obj.months || obj.month || 0,
  853. days: obj.days || obj.day || 0,
  854. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  855. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  856. (obj.seconds || obj.second || 0) * 1000 + // seconds
  857. (obj.milliseconds || obj.millisecond || obj.ms || 0),
  858. };
  859. var weeks = obj.weeks || obj.week;
  860. if (weeks) {
  861. duration.days += weeks * 7;
  862. duration.specifiedWeeks = true;
  863. }
  864. return duration;
  865. }
  866. // Equality
  867. function durationsEqual(d0, d1) {
  868. return d0.years === d1.years &&
  869. d0.months === d1.months &&
  870. d0.days === d1.days &&
  871. d0.milliseconds === d1.milliseconds;
  872. }
  873. function asCleanDays(dur) {
  874. if (!dur.years && !dur.months && !dur.milliseconds) {
  875. return dur.days;
  876. }
  877. return 0;
  878. }
  879. // Simple Math
  880. function addDurations(d0, d1) {
  881. return {
  882. years: d0.years + d1.years,
  883. months: d0.months + d1.months,
  884. days: d0.days + d1.days,
  885. milliseconds: d0.milliseconds + d1.milliseconds,
  886. };
  887. }
  888. function subtractDurations(d1, d0) {
  889. return {
  890. years: d1.years - d0.years,
  891. months: d1.months - d0.months,
  892. days: d1.days - d0.days,
  893. milliseconds: d1.milliseconds - d0.milliseconds,
  894. };
  895. }
  896. function multiplyDuration(d, n) {
  897. return {
  898. years: d.years * n,
  899. months: d.months * n,
  900. days: d.days * n,
  901. milliseconds: d.milliseconds * n,
  902. };
  903. }
  904. // Conversions
  905. // "Rough" because they are based on average-case Gregorian months/years
  906. function asRoughYears(dur) {
  907. return asRoughDays(dur) / 365;
  908. }
  909. function asRoughMonths(dur) {
  910. return asRoughDays(dur) / 30;
  911. }
  912. function asRoughDays(dur) {
  913. return asRoughMs(dur) / 864e5;
  914. }
  915. function asRoughMinutes(dur) {
  916. return asRoughMs(dur) / (1000 * 60);
  917. }
  918. function asRoughSeconds(dur) {
  919. return asRoughMs(dur) / 1000;
  920. }
  921. function asRoughMs(dur) {
  922. return dur.years * (365 * 864e5) +
  923. dur.months * (30 * 864e5) +
  924. dur.days * 864e5 +
  925. dur.milliseconds;
  926. }
  927. // Advanced Math
  928. function wholeDivideDurations(numerator, denominator) {
  929. var res = null;
  930. for (var i = 0; i < INTERNAL_UNITS.length; i += 1) {
  931. var unit = INTERNAL_UNITS[i];
  932. if (denominator[unit]) {
  933. var localRes = numerator[unit] / denominator[unit];
  934. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  935. return null;
  936. }
  937. res = localRes;
  938. }
  939. else if (numerator[unit]) {
  940. // needs to divide by something but can't!
  941. return null;
  942. }
  943. }
  944. return res;
  945. }
  946. function greatestDurationDenominator(dur) {
  947. var ms = dur.milliseconds;
  948. if (ms) {
  949. if (ms % 1000 !== 0) {
  950. return { unit: 'millisecond', value: ms };
  951. }
  952. if (ms % (1000 * 60) !== 0) {
  953. return { unit: 'second', value: ms / 1000 };
  954. }
  955. if (ms % (1000 * 60 * 60) !== 0) {
  956. return { unit: 'minute', value: ms / (1000 * 60) };
  957. }
  958. if (ms) {
  959. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  960. }
  961. }
  962. if (dur.days) {
  963. if (dur.specifiedWeeks && dur.days % 7 === 0) {
  964. return { unit: 'week', value: dur.days / 7 };
  965. }
  966. return { unit: 'day', value: dur.days };
  967. }
  968. if (dur.months) {
  969. return { unit: 'month', value: dur.months };
  970. }
  971. if (dur.years) {
  972. return { unit: 'year', value: dur.years };
  973. }
  974. return { unit: 'millisecond', value: 0 };
  975. }
  976. // timeZoneOffset is in minutes
  977. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  978. if (stripZeroTime === void 0) { stripZeroTime = false; }
  979. var s = marker.toISOString();
  980. s = s.replace('.000', '');
  981. if (stripZeroTime) {
  982. s = s.replace('T00:00:00Z', '');
  983. }
  984. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  985. if (timeZoneOffset == null) {
  986. s = s.replace('Z', '');
  987. }
  988. else if (timeZoneOffset !== 0) {
  989. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  990. }
  991. // otherwise, its UTC-0 and we want to keep the Z
  992. }
  993. return s;
  994. }
  995. // formats the date, but with no time part
  996. // TODO: somehow merge with buildIsoString and stripZeroTime
  997. // TODO: rename. omit "string"
  998. function formatDayString(marker) {
  999. return marker.toISOString().replace(/T.*$/, '');
  1000. }
  1001. // TODO: use Date::toISOString and use everything after the T?
  1002. function formatIsoTimeString(marker) {
  1003. return padStart(marker.getUTCHours(), 2) + ':' +
  1004. padStart(marker.getUTCMinutes(), 2) + ':' +
  1005. padStart(marker.getUTCSeconds(), 2);
  1006. }
  1007. function formatTimeZoneOffset(minutes, doIso) {
  1008. if (doIso === void 0) { doIso = false; }
  1009. var sign = minutes < 0 ? '-' : '+';
  1010. var abs = Math.abs(minutes);
  1011. var hours = Math.floor(abs / 60);
  1012. var mins = Math.round(abs % 60);
  1013. if (doIso) {
  1014. return sign + padStart(hours, 2) + ":" + padStart(mins, 2);
  1015. }
  1016. return "GMT" + sign + hours + (mins ? ":" + padStart(mins, 2) : '');
  1017. }
  1018. // TODO: new util arrayify?
  1019. function removeExact(array, exactVal) {
  1020. var removeCnt = 0;
  1021. var i = 0;
  1022. while (i < array.length) {
  1023. if (array[i] === exactVal) {
  1024. array.splice(i, 1);
  1025. removeCnt += 1;
  1026. }
  1027. else {
  1028. i += 1;
  1029. }
  1030. }
  1031. return removeCnt;
  1032. }
  1033. function isArraysEqual(a0, a1, equalityFunc) {
  1034. if (a0 === a1) {
  1035. return true;
  1036. }
  1037. var len = a0.length;
  1038. var i;
  1039. if (len !== a1.length) { // not array? or not same length?
  1040. return false;
  1041. }
  1042. for (i = 0; i < len; i += 1) {
  1043. if (!(equalityFunc ? equalityFunc(a0[i], a1[i]) : a0[i] === a1[i])) {
  1044. return false;
  1045. }
  1046. }
  1047. return true;
  1048. }
  1049. function memoize(workerFunc, resEquality, teardownFunc) {
  1050. var currentArgs;
  1051. var currentRes;
  1052. return function () {
  1053. var newArgs = [];
  1054. for (var _i = 0; _i < arguments.length; _i++) {
  1055. newArgs[_i] = arguments[_i];
  1056. }
  1057. if (!currentArgs) {
  1058. currentRes = workerFunc.apply(this, newArgs);
  1059. }
  1060. else if (!isArraysEqual(currentArgs, newArgs)) {
  1061. if (teardownFunc) {
  1062. teardownFunc(currentRes);
  1063. }
  1064. var res = workerFunc.apply(this, newArgs);
  1065. if (!resEquality || !resEquality(res, currentRes)) {
  1066. currentRes = res;
  1067. }
  1068. }
  1069. currentArgs = newArgs;
  1070. return currentRes;
  1071. };
  1072. }
  1073. function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
  1074. var _this = this;
  1075. var currentArg;
  1076. var currentRes;
  1077. return function (newArg) {
  1078. if (!currentArg) {
  1079. currentRes = workerFunc.call(_this, newArg);
  1080. }
  1081. else if (!isPropsEqual(currentArg, newArg)) {
  1082. if (teardownFunc) {
  1083. teardownFunc(currentRes);
  1084. }
  1085. var res = workerFunc.call(_this, newArg);
  1086. if (!resEquality || !resEquality(res, currentRes)) {
  1087. currentRes = res;
  1088. }
  1089. }
  1090. currentArg = newArg;
  1091. return currentRes;
  1092. };
  1093. }
  1094. function memoizeArraylike(// used at all?
  1095. workerFunc, resEquality, teardownFunc) {
  1096. var _this = this;
  1097. var currentArgSets = [];
  1098. var currentResults = [];
  1099. return function (newArgSets) {
  1100. var currentLen = currentArgSets.length;
  1101. var newLen = newArgSets.length;
  1102. var i = 0;
  1103. for (; i < currentLen; i += 1) {
  1104. if (!newArgSets[i]) { // one of the old sets no longer exists
  1105. if (teardownFunc) {
  1106. teardownFunc(currentResults[i]);
  1107. }
  1108. }
  1109. else if (!isArraysEqual(currentArgSets[i], newArgSets[i])) {
  1110. if (teardownFunc) {
  1111. teardownFunc(currentResults[i]);
  1112. }
  1113. var res = workerFunc.apply(_this, newArgSets[i]);
  1114. if (!resEquality || !resEquality(res, currentResults[i])) {
  1115. currentResults[i] = res;
  1116. }
  1117. }
  1118. }
  1119. for (; i < newLen; i += 1) {
  1120. currentResults[i] = workerFunc.apply(_this, newArgSets[i]);
  1121. }
  1122. currentArgSets = newArgSets;
  1123. currentResults.splice(newLen); // remove excess
  1124. return currentResults;
  1125. };
  1126. }
  1127. function memoizeHashlike(// used?
  1128. workerFunc, resEquality, teardownFunc) {
  1129. var _this = this;
  1130. var currentArgHash = {};
  1131. var currentResHash = {};
  1132. return function (newArgHash) {
  1133. var newResHash = {};
  1134. for (var key in newArgHash) {
  1135. if (!currentResHash[key]) {
  1136. newResHash[key] = workerFunc.apply(_this, newArgHash[key]);
  1137. }
  1138. else if (!isArraysEqual(currentArgHash[key], newArgHash[key])) {
  1139. if (teardownFunc) {
  1140. teardownFunc(currentResHash[key]);
  1141. }
  1142. var res = workerFunc.apply(_this, newArgHash[key]);
  1143. newResHash[key] = (resEquality && resEquality(res, currentResHash[key]))
  1144. ? currentResHash[key]
  1145. : res;
  1146. }
  1147. else {
  1148. newResHash[key] = currentResHash[key];
  1149. }
  1150. }
  1151. currentArgHash = newArgHash;
  1152. currentResHash = newResHash;
  1153. return newResHash;
  1154. };
  1155. }
  1156. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1157. week: 3,
  1158. separator: 0,
  1159. omitZeroMinute: 0,
  1160. meridiem: 0,
  1161. omitCommas: 0,
  1162. };
  1163. var STANDARD_DATE_PROP_SEVERITIES = {
  1164. timeZoneName: 7,
  1165. era: 6,
  1166. year: 5,
  1167. month: 4,
  1168. day: 2,
  1169. weekday: 2,
  1170. hour: 1,
  1171. minute: 1,
  1172. second: 1,
  1173. };
  1174. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1175. var COMMA_RE = /,/g; // we need re for globalness
  1176. var MULTI_SPACE_RE = /\s+/g;
  1177. var LTR_RE = /\u200e/g; // control character
  1178. var UTC_RE = /UTC|GMT/;
  1179. var NativeFormatter = /** @class */ (function () {
  1180. function NativeFormatter(formatSettings) {
  1181. var standardDateProps = {};
  1182. var extendedSettings = {};
  1183. var severity = 0;
  1184. for (var name_1 in formatSettings) {
  1185. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1186. extendedSettings[name_1] = formatSettings[name_1];
  1187. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1188. }
  1189. else {
  1190. standardDateProps[name_1] = formatSettings[name_1];
  1191. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) { // TODO: what about hour12? no severity
  1192. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1193. }
  1194. }
  1195. }
  1196. this.standardDateProps = standardDateProps;
  1197. this.extendedSettings = extendedSettings;
  1198. this.severity = severity;
  1199. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1200. }
  1201. NativeFormatter.prototype.format = function (date, context) {
  1202. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1203. };
  1204. NativeFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1205. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1206. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1207. if (!diffSeverity) {
  1208. return this.format(start, context);
  1209. }
  1210. var biggestUnitForPartial = diffSeverity;
  1211. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1212. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1213. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1214. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1215. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1216. }
  1217. var full0 = this.format(start, context);
  1218. var full1 = this.format(end, context);
  1219. if (full0 === full1) {
  1220. return full0;
  1221. }
  1222. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1223. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1224. var partial0 = partialFormattingFunc(start);
  1225. var partial1 = partialFormattingFunc(end);
  1226. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1227. var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || '';
  1228. if (insertion) {
  1229. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1230. }
  1231. return full0 + separator + full1;
  1232. };
  1233. NativeFormatter.prototype.getLargestUnit = function () {
  1234. switch (this.severity) {
  1235. case 7:
  1236. case 6:
  1237. case 5:
  1238. return 'year';
  1239. case 4:
  1240. return 'month';
  1241. case 3:
  1242. return 'week';
  1243. case 2:
  1244. return 'day';
  1245. default:
  1246. return 'time'; // really?
  1247. }
  1248. };
  1249. return NativeFormatter;
  1250. }());
  1251. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1252. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1253. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1254. return function (date) { return (formatTimeZoneOffset(date.timeZoneOffset)); };
  1255. }
  1256. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1257. return function (date) { return (formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.locale, extendedSettings.week)); };
  1258. }
  1259. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1260. }
  1261. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1262. standardDateProps = __assign({}, standardDateProps); // copy
  1263. extendedSettings = __assign({}, extendedSettings); // copy
  1264. sanitizeSettings(standardDateProps, extendedSettings);
  1265. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1266. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1267. var zeroFormat; // needed?
  1268. if (extendedSettings.omitZeroMinute) {
  1269. var zeroProps = __assign({}, standardDateProps);
  1270. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1271. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1272. }
  1273. return function (date) {
  1274. var marker = date.marker;
  1275. var format;
  1276. if (zeroFormat && !marker.getUTCMinutes()) {
  1277. format = zeroFormat;
  1278. }
  1279. else {
  1280. format = normalFormat;
  1281. }
  1282. var s = format.format(marker);
  1283. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1284. };
  1285. }
  1286. function sanitizeSettings(standardDateProps, extendedSettings) {
  1287. // deal with a browser inconsistency where formatting the timezone
  1288. // requires that the hour/minute be present.
  1289. if (standardDateProps.timeZoneName) {
  1290. if (!standardDateProps.hour) {
  1291. standardDateProps.hour = '2-digit';
  1292. }
  1293. if (!standardDateProps.minute) {
  1294. standardDateProps.minute = '2-digit';
  1295. }
  1296. }
  1297. // only support short timezone names
  1298. if (standardDateProps.timeZoneName === 'long') {
  1299. standardDateProps.timeZoneName = 'short';
  1300. }
  1301. // if requesting to display seconds, MUST display minutes
  1302. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1303. delete extendedSettings.omitZeroMinute;
  1304. }
  1305. }
  1306. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1307. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1308. if (standardDateProps.timeZoneName === 'short') {
  1309. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1310. 'UTC' : // important to normalize for IE, which does "GMT"
  1311. formatTimeZoneOffset(date.timeZoneOffset));
  1312. }
  1313. if (extendedSettings.omitCommas) {
  1314. s = s.replace(COMMA_RE, '').trim();
  1315. }
  1316. if (extendedSettings.omitZeroMinute) {
  1317. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1318. }
  1319. // ^ do anything that might create adjacent spaces before this point,
  1320. // because MERIDIEM_RE likes to eat up loading spaces
  1321. if (extendedSettings.meridiem === false) {
  1322. s = s.replace(MERIDIEM_RE, '').trim();
  1323. }
  1324. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1325. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase(); });
  1326. }
  1327. else if (extendedSettings.meridiem === 'short') { // am/pm
  1328. s = s.replace(MERIDIEM_RE, function (m0, m1) { return m1.toLocaleLowerCase() + "m"; });
  1329. }
  1330. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1331. s = s.replace(MERIDIEM_RE, function (m0) { return m0.toLocaleLowerCase(); });
  1332. }
  1333. s = s.replace(MULTI_SPACE_RE, ' ');
  1334. s = s.trim();
  1335. return s;
  1336. }
  1337. function injectTzoStr(s, tzoStr) {
  1338. var replaced = false;
  1339. s = s.replace(UTC_RE, function () {
  1340. replaced = true;
  1341. return tzoStr;
  1342. });
  1343. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1344. if (!replaced) {
  1345. s += " " + tzoStr;
  1346. }
  1347. return s;
  1348. }
  1349. function formatWeekNumber(num, weekText, locale, display) {
  1350. var parts = [];
  1351. if (display === 'narrow') {
  1352. parts.push(weekText);
  1353. }
  1354. else if (display === 'short') {
  1355. parts.push(weekText, ' ');
  1356. }
  1357. // otherwise, considered 'numeric'
  1358. parts.push(locale.simpleNumberFormat.format(num));
  1359. if (locale.options.direction === 'rtl') { // TODO: use control characters instead?
  1360. parts.reverse();
  1361. }
  1362. return parts.join('');
  1363. }
  1364. // Range Formatting Utils
  1365. // 0 = exactly the same
  1366. // 1 = different by time
  1367. // and bigger
  1368. function computeMarkerDiffSeverity(d0, d1, ca) {
  1369. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1370. return 5;
  1371. }
  1372. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1373. return 4;
  1374. }
  1375. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1376. return 2;
  1377. }
  1378. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1379. return 1;
  1380. }
  1381. return 0;
  1382. }
  1383. function computePartialFormattingOptions(options, biggestUnit) {
  1384. var partialOptions = {};
  1385. for (var name_2 in options) {
  1386. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1387. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1388. partialOptions[name_2] = options[name_2];
  1389. }
  1390. }
  1391. return partialOptions;
  1392. }
  1393. function findCommonInsertion(full0, partial0, full1, partial1) {
  1394. var i0 = 0;
  1395. while (i0 < full0.length) {
  1396. var found0 = full0.indexOf(partial0, i0);
  1397. if (found0 === -1) {
  1398. break;
  1399. }
  1400. var before0 = full0.substr(0, found0);
  1401. i0 = found0 + partial0.length;
  1402. var after0 = full0.substr(i0);
  1403. var i1 = 0;
  1404. while (i1 < full1.length) {
  1405. var found1 = full1.indexOf(partial1, i1);
  1406. if (found1 === -1) {
  1407. break;
  1408. }
  1409. var before1 = full1.substr(0, found1);
  1410. i1 = found1 + partial1.length;
  1411. var after1 = full1.substr(i1);
  1412. if (before0 === before1 && after0 === after1) {
  1413. return {
  1414. before: before0,
  1415. after: after0,
  1416. };
  1417. }
  1418. }
  1419. }
  1420. return null;
  1421. }
  1422. function expandZonedMarker(dateInfo, calendarSystem) {
  1423. var a = calendarSystem.markerToArray(dateInfo.marker);
  1424. return {
  1425. marker: dateInfo.marker,
  1426. timeZoneOffset: dateInfo.timeZoneOffset,
  1427. array: a,
  1428. year: a[0],
  1429. month: a[1],
  1430. day: a[2],
  1431. hour: a[3],
  1432. minute: a[4],
  1433. second: a[5],
  1434. millisecond: a[6],
  1435. };
  1436. }
  1437. function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
  1438. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1439. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1440. return {
  1441. date: startInfo,
  1442. start: startInfo,
  1443. end: endInfo,
  1444. timeZone: context.timeZone,
  1445. localeCodes: context.locale.codes,
  1446. defaultSeparator: betterDefaultSeparator || context.defaultSeparator,
  1447. };
  1448. }
  1449. /*
  1450. TODO: fix the terminology of "formatter" vs "formatting func"
  1451. */
  1452. /*
  1453. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1454. It receives this at the time of formatting, as a setting.
  1455. */
  1456. var CmdFormatter = /** @class */ (function () {
  1457. function CmdFormatter(cmdStr) {
  1458. this.cmdStr = cmdStr;
  1459. }
  1460. CmdFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1461. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1462. };
  1463. CmdFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1464. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1465. };
  1466. return CmdFormatter;
  1467. }());
  1468. var FuncFormatter = /** @class */ (function () {
  1469. function FuncFormatter(func) {
  1470. this.func = func;
  1471. }
  1472. FuncFormatter.prototype.format = function (date, context, betterDefaultSeparator) {
  1473. return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
  1474. };
  1475. FuncFormatter.prototype.formatRange = function (start, end, context, betterDefaultSeparator) {
  1476. return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
  1477. };
  1478. return FuncFormatter;
  1479. }());
  1480. function createFormatter(input) {
  1481. if (typeof input === 'object' && input) { // non-null object
  1482. return new NativeFormatter(input);
  1483. }
  1484. if (typeof input === 'string') {
  1485. return new CmdFormatter(input);
  1486. }
  1487. if (typeof input === 'function') {
  1488. return new FuncFormatter(input);
  1489. }
  1490. return null;
  1491. }
  1492. // base options
  1493. // ------------
  1494. var BASE_OPTION_REFINERS = {
  1495. navLinkDayClick: identity,
  1496. navLinkWeekClick: identity,
  1497. duration: createDuration,
  1498. bootstrapFontAwesome: identity,
  1499. buttonIcons: identity,
  1500. customButtons: identity,
  1501. defaultAllDayEventDuration: createDuration,
  1502. defaultTimedEventDuration: createDuration,
  1503. nextDayThreshold: createDuration,
  1504. scrollTime: createDuration,
  1505. slotMinTime: createDuration,
  1506. slotMaxTime: createDuration,
  1507. dayPopoverFormat: createFormatter,
  1508. slotDuration: createDuration,
  1509. snapDuration: createDuration,
  1510. headerToolbar: identity,
  1511. footerToolbar: identity,
  1512. defaultRangeSeparator: String,
  1513. titleRangeSeparator: String,
  1514. forceEventDuration: Boolean,
  1515. dayHeaders: Boolean,
  1516. dayHeaderFormat: createFormatter,
  1517. dayHeaderClassNames: identity,
  1518. dayHeaderContent: identity,
  1519. dayHeaderDidMount: identity,
  1520. dayHeaderWillUnmount: identity,
  1521. dayCellClassNames: identity,
  1522. dayCellContent: identity,
  1523. dayCellDidMount: identity,
  1524. dayCellWillUnmount: identity,
  1525. initialView: String,
  1526. aspectRatio: Number,
  1527. weekends: Boolean,
  1528. weekNumberCalculation: identity,
  1529. weekNumbers: Boolean,
  1530. weekNumberClassNames: identity,
  1531. weekNumberContent: identity,
  1532. weekNumberDidMount: identity,
  1533. weekNumberWillUnmount: identity,
  1534. editable: Boolean,
  1535. viewClassNames: identity,
  1536. viewDidMount: identity,
  1537. viewWillUnmount: identity,
  1538. nowIndicator: Boolean,
  1539. nowIndicatorClassNames: identity,
  1540. nowIndicatorContent: identity,
  1541. nowIndicatorDidMount: identity,
  1542. nowIndicatorWillUnmount: identity,
  1543. showNonCurrentDates: Boolean,
  1544. lazyFetching: Boolean,
  1545. startParam: String,
  1546. endParam: String,
  1547. timeZoneParam: String,
  1548. timeZone: String,
  1549. locales: identity,
  1550. locale: identity,
  1551. themeSystem: String,
  1552. dragRevertDuration: Number,
  1553. dragScroll: Boolean,
  1554. allDayMaintainDuration: Boolean,
  1555. unselectAuto: Boolean,
  1556. dropAccept: identity,
  1557. eventOrder: parseFieldSpecs,
  1558. handleWindowResize: Boolean,
  1559. windowResizeDelay: Number,
  1560. longPressDelay: Number,
  1561. eventDragMinDistance: Number,
  1562. expandRows: Boolean,
  1563. height: identity,
  1564. contentHeight: identity,
  1565. direction: String,
  1566. weekNumberFormat: createFormatter,
  1567. eventResizableFromStart: Boolean,
  1568. displayEventTime: Boolean,
  1569. displayEventEnd: Boolean,
  1570. weekText: String,
  1571. progressiveEventRendering: Boolean,
  1572. businessHours: identity,
  1573. initialDate: identity,
  1574. now: identity,
  1575. eventDataTransform: identity,
  1576. stickyHeaderDates: identity,
  1577. stickyFooterScrollbar: identity,
  1578. viewHeight: identity,
  1579. defaultAllDay: Boolean,
  1580. eventSourceFailure: identity,
  1581. eventSourceSuccess: identity,
  1582. eventDisplay: String,
  1583. eventStartEditable: Boolean,
  1584. eventDurationEditable: Boolean,
  1585. eventOverlap: identity,
  1586. eventConstraint: identity,
  1587. eventAllow: identity,
  1588. eventBackgroundColor: String,
  1589. eventBorderColor: String,
  1590. eventTextColor: String,
  1591. eventColor: String,
  1592. eventClassNames: identity,
  1593. eventContent: identity,
  1594. eventDidMount: identity,
  1595. eventWillUnmount: identity,
  1596. selectConstraint: identity,
  1597. selectOverlap: identity,
  1598. selectAllow: identity,
  1599. droppable: Boolean,
  1600. unselectCancel: String,
  1601. slotLabelFormat: identity,
  1602. slotLaneClassNames: identity,
  1603. slotLaneContent: identity,
  1604. slotLaneDidMount: identity,
  1605. slotLaneWillUnmount: identity,
  1606. slotLabelClassNames: identity,
  1607. slotLabelContent: identity,
  1608. slotLabelDidMount: identity,
  1609. slotLabelWillUnmount: identity,
  1610. dayMaxEvents: identity,
  1611. dayMaxEventRows: identity,
  1612. dayMinWidth: Number,
  1613. slotLabelInterval: createDuration,
  1614. allDayText: String,
  1615. allDayClassNames: identity,
  1616. allDayContent: identity,
  1617. allDayDidMount: identity,
  1618. allDayWillUnmount: identity,
  1619. slotMinWidth: Number,
  1620. navLinks: Boolean,
  1621. eventTimeFormat: createFormatter,
  1622. rerenderDelay: Number,
  1623. moreLinkText: identity,
  1624. selectMinDistance: Number,
  1625. selectable: Boolean,
  1626. selectLongPressDelay: Number,
  1627. eventLongPressDelay: Number,
  1628. selectMirror: Boolean,
  1629. eventMinHeight: Number,
  1630. slotEventOverlap: Boolean,
  1631. plugins: identity,
  1632. firstDay: Number,
  1633. dayCount: Number,
  1634. dateAlignment: String,
  1635. dateIncrement: createDuration,
  1636. hiddenDays: identity,
  1637. monthMode: Boolean,
  1638. fixedWeekCount: Boolean,
  1639. validRange: identity,
  1640. visibleRange: identity,
  1641. titleFormat: identity,
  1642. // only used by list-view, but languages define the value, so we need it in base options
  1643. noEventsText: String,
  1644. };
  1645. // do NOT give a type here. need `typeof BASE_OPTION_DEFAULTS` to give real results.
  1646. // raw values.
  1647. var BASE_OPTION_DEFAULTS = {
  1648. eventDisplay: 'auto',
  1649. defaultRangeSeparator: ' - ',
  1650. titleRangeSeparator: ' \u2013 ',
  1651. defaultTimedEventDuration: '01:00:00',
  1652. defaultAllDayEventDuration: { day: 1 },
  1653. forceEventDuration: false,
  1654. nextDayThreshold: '00:00:00',
  1655. dayHeaders: true,
  1656. initialView: '',
  1657. aspectRatio: 1.35,
  1658. headerToolbar: {
  1659. start: 'title',
  1660. center: '',
  1661. end: 'today prev,next',
  1662. },
  1663. weekends: true,
  1664. weekNumbers: false,
  1665. weekNumberCalculation: 'local',
  1666. editable: false,
  1667. nowIndicator: false,
  1668. scrollTime: '06:00:00',
  1669. slotMinTime: '00:00:00',
  1670. slotMaxTime: '24:00:00',
  1671. showNonCurrentDates: true,
  1672. lazyFetching: true,
  1673. startParam: 'start',
  1674. endParam: 'end',
  1675. timeZoneParam: 'timeZone',
  1676. timeZone: 'local',
  1677. locales: [],
  1678. locale: '',
  1679. themeSystem: 'standard',
  1680. dragRevertDuration: 500,
  1681. dragScroll: true,
  1682. allDayMaintainDuration: false,
  1683. unselectAuto: true,
  1684. dropAccept: '*',
  1685. eventOrder: 'start,-duration,allDay,title',
  1686. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  1687. handleWindowResize: true,
  1688. windowResizeDelay: 100,
  1689. longPressDelay: 1000,
  1690. eventDragMinDistance: 5,
  1691. expandRows: false,
  1692. navLinks: false,
  1693. selectable: false,
  1694. };
  1695. // calendar listeners
  1696. // ------------------
  1697. var CALENDAR_LISTENER_REFINERS = {
  1698. datesSet: identity,
  1699. eventsSet: identity,
  1700. eventAdd: identity,
  1701. eventChange: identity,
  1702. eventRemove: identity,
  1703. windowResize: identity,
  1704. eventClick: identity,
  1705. eventMouseEnter: identity,
  1706. eventMouseLeave: identity,
  1707. select: identity,
  1708. unselect: identity,
  1709. loading: identity,
  1710. // internal
  1711. _unmount: identity,
  1712. _beforeprint: identity,
  1713. _afterprint: identity,
  1714. _noEventDrop: identity,
  1715. _noEventResize: identity,
  1716. _resize: identity,
  1717. _scrollRequest: identity,
  1718. };
  1719. // calendar-specific options
  1720. // -------------------------
  1721. var CALENDAR_OPTION_REFINERS = {
  1722. buttonText: identity,
  1723. views: identity,
  1724. plugins: identity,
  1725. initialEvents: identity,
  1726. events: identity,
  1727. eventSources: identity,
  1728. };
  1729. var COMPLEX_OPTION_COMPARATORS = {
  1730. headerToolbar: isBoolComplexEqual,
  1731. footerToolbar: isBoolComplexEqual,
  1732. buttonText: isBoolComplexEqual,
  1733. buttonIcons: isBoolComplexEqual,
  1734. };
  1735. function isBoolComplexEqual(a, b) {
  1736. if (typeof a === 'object' && typeof b === 'object' && a && b) { // both non-null objects
  1737. return isPropsEqual(a, b);
  1738. }
  1739. return a === b;
  1740. }
  1741. // view-specific options
  1742. // ---------------------
  1743. var VIEW_OPTION_REFINERS = {
  1744. type: String,
  1745. component: identity,
  1746. buttonText: String,
  1747. buttonTextKey: String,
  1748. dateProfileGeneratorClass: identity,
  1749. usesMinMaxTime: Boolean,
  1750. classNames: identity,
  1751. content: identity,
  1752. didMount: identity,
  1753. willUnmount: identity,
  1754. };
  1755. // util funcs
  1756. // ----------------------------------------------------------------------------------------------------
  1757. function mergeRawOptions(optionSets) {
  1758. return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
  1759. }
  1760. function refineProps(input, refiners) {
  1761. var refined = {};
  1762. var extra = {};
  1763. for (var propName in refiners) {
  1764. if (propName in input) {
  1765. refined[propName] = refiners[propName](input[propName]);
  1766. }
  1767. }
  1768. for (var propName in input) {
  1769. if (!(propName in refiners)) {
  1770. extra[propName] = input[propName];
  1771. }
  1772. }
  1773. return { refined: refined, extra: extra };
  1774. }
  1775. function identity(raw) {
  1776. return raw;
  1777. }
  1778. function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
  1779. var eventStore = createEmptyEventStore();
  1780. var eventRefiners = buildEventRefiners(context);
  1781. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1782. var rawEvent = rawEvents_1[_i];
  1783. var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
  1784. if (tuple) {
  1785. eventTupleToStore(tuple, eventStore);
  1786. }
  1787. }
  1788. return eventStore;
  1789. }
  1790. function eventTupleToStore(tuple, eventStore) {
  1791. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1792. eventStore.defs[tuple.def.defId] = tuple.def;
  1793. if (tuple.instance) {
  1794. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1795. }
  1796. return eventStore;
  1797. }
  1798. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1799. // or they are the same as the instance.
  1800. // why might instanceId not be in the store? an event from another calendar?
  1801. function getRelevantEvents(eventStore, instanceId) {
  1802. var instance = eventStore.instances[instanceId];
  1803. if (instance) {
  1804. var def_1 = eventStore.defs[instance.defId];
  1805. // get events/instances with same group
  1806. var newStore = filterEventStoreDefs(eventStore, function (lookDef) { return isEventDefsGrouped(def_1, lookDef); });
  1807. // add the original
  1808. // TODO: wish we could use eventTupleToStore or something like it
  1809. newStore.defs[def_1.defId] = def_1;
  1810. newStore.instances[instance.instanceId] = instance;
  1811. return newStore;
  1812. }
  1813. return createEmptyEventStore();
  1814. }
  1815. function isEventDefsGrouped(def0, def1) {
  1816. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1817. }
  1818. function createEmptyEventStore() {
  1819. return { defs: {}, instances: {} };
  1820. }
  1821. function mergeEventStores(store0, store1) {
  1822. return {
  1823. defs: __assign(__assign({}, store0.defs), store1.defs),
  1824. instances: __assign(__assign({}, store0.instances), store1.instances),
  1825. };
  1826. }
  1827. function filterEventStoreDefs(eventStore, filterFunc) {
  1828. var defs = filterHash(eventStore.defs, filterFunc);
  1829. var instances = filterHash(eventStore.instances, function (instance) { return (defs[instance.defId] // still exists?
  1830. ); });
  1831. return { defs: defs, instances: instances };
  1832. }
  1833. function excludeSubEventStore(master, sub) {
  1834. var defs = master.defs, instances = master.instances;
  1835. var filteredDefs = {};
  1836. var filteredInstances = {};
  1837. for (var defId in defs) {
  1838. if (!sub.defs[defId]) { // not explicitly excluded
  1839. filteredDefs[defId] = defs[defId];
  1840. }
  1841. }
  1842. for (var instanceId in instances) {
  1843. if (!sub.instances[instanceId] && // not explicitly excluded
  1844. filteredDefs[instances[instanceId].defId] // def wasn't filtered away
  1845. ) {
  1846. filteredInstances[instanceId] = instances[instanceId];
  1847. }
  1848. }
  1849. return {
  1850. defs: filteredDefs,
  1851. instances: filteredInstances,
  1852. };
  1853. }
  1854. function normalizeConstraint(input, context) {
  1855. if (Array.isArray(input)) {
  1856. return parseEvents(input, null, context, true); // allowOpenRange=true
  1857. }
  1858. if (typeof input === 'object' && input) { // non-null object
  1859. return parseEvents([input], null, context, true); // allowOpenRange=true
  1860. }
  1861. if (input != null) {
  1862. return String(input);
  1863. }
  1864. return null;
  1865. }
  1866. function parseClassNames(raw) {
  1867. if (Array.isArray(raw)) {
  1868. return raw;
  1869. }
  1870. if (typeof raw === 'string') {
  1871. return raw.split(/\s+/);
  1872. }
  1873. return [];
  1874. }
  1875. // TODO: better called "EventSettings" or "EventConfig"
  1876. // TODO: move this file into structs
  1877. // TODO: separate constraint/overlap/allow, because selection uses only that, not other props
  1878. var EVENT_UI_REFINERS = {
  1879. display: String,
  1880. editable: Boolean,
  1881. startEditable: Boolean,
  1882. durationEditable: Boolean,
  1883. constraint: identity,
  1884. overlap: identity,
  1885. allow: identity,
  1886. className: parseClassNames,
  1887. classNames: parseClassNames,
  1888. color: String,
  1889. backgroundColor: String,
  1890. borderColor: String,
  1891. textColor: String,
  1892. };
  1893. var EMPTY_EVENT_UI = {
  1894. display: null,
  1895. startEditable: null,
  1896. durationEditable: null,
  1897. constraints: [],
  1898. overlap: null,
  1899. allows: [],
  1900. backgroundColor: '',
  1901. borderColor: '',
  1902. textColor: '',
  1903. classNames: [],
  1904. };
  1905. function createEventUi(refined, context) {
  1906. var constraint = normalizeConstraint(refined.constraint, context);
  1907. return {
  1908. display: refined.display || null,
  1909. startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
  1910. durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
  1911. constraints: constraint != null ? [constraint] : [],
  1912. overlap: refined.overlap != null ? refined.overlap : null,
  1913. allows: refined.allow != null ? [refined.allow] : [],
  1914. backgroundColor: refined.backgroundColor || refined.color || '',
  1915. borderColor: refined.borderColor || refined.color || '',
  1916. textColor: refined.textColor || '',
  1917. classNames: (refined.className || []).concat(refined.classNames || []),
  1918. };
  1919. }
  1920. // TODO: prevent against problems with <2 args!
  1921. function combineEventUis(uis) {
  1922. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  1923. }
  1924. function combineTwoEventUis(item0, item1) {
  1925. return {
  1926. display: item1.display != null ? item1.display : item0.display,
  1927. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  1928. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  1929. constraints: item0.constraints.concat(item1.constraints),
  1930. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  1931. allows: item0.allows.concat(item1.allows),
  1932. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  1933. borderColor: item1.borderColor || item0.borderColor,
  1934. textColor: item1.textColor || item0.textColor,
  1935. classNames: item0.classNames.concat(item1.classNames),
  1936. };
  1937. }
  1938. var EVENT_NON_DATE_REFINERS = {
  1939. id: String,
  1940. groupId: String,
  1941. title: String,
  1942. url: String,
  1943. };
  1944. var EVENT_DATE_REFINERS = {
  1945. start: identity,
  1946. end: identity,
  1947. date: identity,
  1948. allDay: Boolean,
  1949. };
  1950. var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
  1951. function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
  1952. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  1953. var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
  1954. var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
  1955. var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
  1956. if (recurringRes) {
  1957. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', recurringRes.allDay, Boolean(recurringRes.duration), context);
  1958. def.recurringDef = {
  1959. typeId: recurringRes.typeId,
  1960. typeData: recurringRes.typeData,
  1961. duration: recurringRes.duration,
  1962. };
  1963. return { def: def, instance: null };
  1964. }
  1965. var singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
  1966. if (singleRes) {
  1967. var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : '', singleRes.allDay, singleRes.hasEnd, context);
  1968. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  1969. return { def: def, instance: instance };
  1970. }
  1971. return null;
  1972. }
  1973. function refineEventDef(raw, context, refiners) {
  1974. if (refiners === void 0) { refiners = buildEventRefiners(context); }
  1975. return refineProps(raw, refiners);
  1976. }
  1977. function buildEventRefiners(context) {
  1978. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
  1979. }
  1980. /*
  1981. Will NOT populate extendedProps with the leftover properties.
  1982. Will NOT populate date-related props.
  1983. */
  1984. function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context) {
  1985. var def = {
  1986. title: refined.title || '',
  1987. groupId: refined.groupId || '',
  1988. publicId: refined.id || '',
  1989. url: refined.url || '',
  1990. recurringDef: null,
  1991. defId: guid(),
  1992. sourceId: sourceId,
  1993. allDay: allDay,
  1994. hasEnd: hasEnd,
  1995. ui: createEventUi(refined, context),
  1996. extendedProps: __assign(__assign({}, (refined.extendedProps || {})), extra),
  1997. };
  1998. for (var _i = 0, _a = context.pluginHooks.eventDefMemberAdders; _i < _a.length; _i++) {
  1999. var memberAdder = _a[_i];
  2000. __assign(def, memberAdder(refined));
  2001. }
  2002. // help out EventApi from having user modify props
  2003. Object.freeze(def.ui.classNames);
  2004. Object.freeze(def.extendedProps);
  2005. return def;
  2006. }
  2007. function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
  2008. var allDay = refined.allDay;
  2009. var startMeta;
  2010. var startMarker = null;
  2011. var hasEnd = false;
  2012. var endMeta;
  2013. var endMarker = null;
  2014. var startInput = refined.start != null ? refined.start : refined.date;
  2015. startMeta = context.dateEnv.createMarkerMeta(startInput);
  2016. if (startMeta) {
  2017. startMarker = startMeta.marker;
  2018. }
  2019. else if (!allowOpenRange) {
  2020. return null;
  2021. }
  2022. if (refined.end != null) {
  2023. endMeta = context.dateEnv.createMarkerMeta(refined.end);
  2024. }
  2025. if (allDay == null) {
  2026. if (defaultAllDay != null) {
  2027. allDay = defaultAllDay;
  2028. }
  2029. else {
  2030. // fall back to the date props LAST
  2031. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  2032. (!endMeta || endMeta.isTimeUnspecified);
  2033. }
  2034. }
  2035. if (allDay && startMarker) {
  2036. startMarker = startOfDay(startMarker);
  2037. }
  2038. if (endMeta) {
  2039. endMarker = endMeta.marker;
  2040. if (allDay) {
  2041. endMarker = startOfDay(endMarker);
  2042. }
  2043. if (startMarker && endMarker <= startMarker) {
  2044. endMarker = null;
  2045. }
  2046. }
  2047. if (endMarker) {
  2048. hasEnd = true;
  2049. }
  2050. else if (!allowOpenRange) {
  2051. hasEnd = context.options.forceEventDuration || false;
  2052. endMarker = context.dateEnv.add(startMarker, allDay ?
  2053. context.options.defaultAllDayEventDuration :
  2054. context.options.defaultTimedEventDuration);
  2055. }
  2056. return {
  2057. allDay: allDay,
  2058. hasEnd: hasEnd,
  2059. range: { start: startMarker, end: endMarker },
  2060. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  2061. forcedEndTzo: endMeta ? endMeta.forcedTzo : null,
  2062. };
  2063. }
  2064. function computeIsDefaultAllDay(eventSource, context) {
  2065. var res = null;
  2066. if (eventSource) {
  2067. res = eventSource.defaultAllDay;
  2068. }
  2069. if (res == null) {
  2070. res = context.options.defaultAllDay;
  2071. }
  2072. return res;
  2073. }
  2074. /* Date stuff that doesn't belong in datelib core
  2075. ----------------------------------------------------------------------------------------------------------------------*/
  2076. // given a timed range, computes an all-day range that has the same exact duration,
  2077. // but whose start time is aligned with the start of the day.
  2078. function computeAlignedDayRange(timedRange) {
  2079. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  2080. var start = startOfDay(timedRange.start);
  2081. var end = addDays(start, dayCnt);
  2082. return { start: start, end: end };
  2083. }
  2084. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  2085. // TODO: give nextDayThreshold a default arg
  2086. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  2087. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  2088. var startDay = null;
  2089. var endDay = null;
  2090. if (timedRange.end) {
  2091. endDay = startOfDay(timedRange.end);
  2092. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  2093. // If the end time is actually inclusively part of the next day and is equal to or
  2094. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  2095. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  2096. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  2097. endDay = addDays(endDay, 1);
  2098. }
  2099. }
  2100. if (timedRange.start) {
  2101. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  2102. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  2103. if (endDay && endDay <= startDay) {
  2104. endDay = addDays(startDay, 1);
  2105. }
  2106. }
  2107. return { start: startDay, end: endDay };
  2108. }
  2109. // spans from one day into another?
  2110. function isMultiDayRange(range) {
  2111. var visibleRange = computeVisibleDayRange(range);
  2112. return diffDays(visibleRange.start, visibleRange.end) > 1;
  2113. }
  2114. function diffDates(date0, date1, dateEnv, largeUnit) {
  2115. if (largeUnit === 'year') {
  2116. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  2117. }
  2118. if (largeUnit === 'month') {
  2119. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  2120. }
  2121. return diffDayAndTime(date0, date1); // returns a duration
  2122. }
  2123. function parseRange(input, dateEnv) {
  2124. var start = null;
  2125. var end = null;
  2126. if (input.start) {
  2127. start = dateEnv.createMarker(input.start);
  2128. }
  2129. if (input.end) {
  2130. end = dateEnv.createMarker(input.end);
  2131. }
  2132. if (!start && !end) {
  2133. return null;
  2134. }
  2135. if (start && end && end < start) {
  2136. return null;
  2137. }
  2138. return { start: start, end: end };
  2139. }
  2140. // SIDE-EFFECT: will mutate ranges.
  2141. // Will return a new array result.
  2142. function invertRanges(ranges, constraintRange) {
  2143. var invertedRanges = [];
  2144. var start = constraintRange.start; // the end of the previous range. the start of the new range
  2145. var i;
  2146. var dateRange;
  2147. // ranges need to be in order. required for our date-walking algorithm
  2148. ranges.sort(compareRanges);
  2149. for (i = 0; i < ranges.length; i += 1) {
  2150. dateRange = ranges[i];
  2151. // add the span of time before the event (if there is any)
  2152. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  2153. invertedRanges.push({ start: start, end: dateRange.start });
  2154. }
  2155. if (dateRange.end > start) {
  2156. start = dateRange.end;
  2157. }
  2158. }
  2159. // add the span of time after the last event (if there is any)
  2160. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  2161. invertedRanges.push({ start: start, end: constraintRange.end });
  2162. }
  2163. return invertedRanges;
  2164. }
  2165. function compareRanges(range0, range1) {
  2166. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  2167. }
  2168. function intersectRanges(range0, range1) {
  2169. var start = range0.start, end = range0.end;
  2170. var newRange = null;
  2171. if (range1.start !== null) {
  2172. if (start === null) {
  2173. start = range1.start;
  2174. }
  2175. else {
  2176. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  2177. }
  2178. }
  2179. if (range1.end != null) {
  2180. if (end === null) {
  2181. end = range1.end;
  2182. }
  2183. else {
  2184. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  2185. }
  2186. }
  2187. if (start === null || end === null || start < end) {
  2188. newRange = { start: start, end: end };
  2189. }
  2190. return newRange;
  2191. }
  2192. function rangesEqual(range0, range1) {
  2193. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  2194. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  2195. }
  2196. function rangesIntersect(range0, range1) {
  2197. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  2198. (range0.start === null || range1.end === null || range0.start < range1.end);
  2199. }
  2200. function rangeContainsRange(outerRange, innerRange) {
  2201. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  2202. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  2203. }
  2204. function rangeContainsMarker(range, date) {
  2205. return (range.start === null || date >= range.start) &&
  2206. (range.end === null || date < range.end);
  2207. }
  2208. // If the given date is not within the given range, move it inside.
  2209. // (If it's past the end, make it one millisecond before the end).
  2210. function constrainMarkerToRange(date, range) {
  2211. if (range.start != null && date < range.start) {
  2212. return range.start;
  2213. }
  2214. if (range.end != null && date >= range.end) {
  2215. return new Date(range.end.valueOf() - 1);
  2216. }
  2217. return date;
  2218. }
  2219. /*
  2220. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2221. */
  2222. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2223. var inverseBgByGroupId = {};
  2224. var inverseBgByDefId = {};
  2225. var defByGroupId = {};
  2226. var bgRanges = [];
  2227. var fgRanges = [];
  2228. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2229. for (var defId in eventStore.defs) {
  2230. var def = eventStore.defs[defId];
  2231. var ui = eventUis[def.defId];
  2232. if (ui.display === 'inverse-background') {
  2233. if (def.groupId) {
  2234. inverseBgByGroupId[def.groupId] = [];
  2235. if (!defByGroupId[def.groupId]) {
  2236. defByGroupId[def.groupId] = def;
  2237. }
  2238. }
  2239. else {
  2240. inverseBgByDefId[defId] = [];
  2241. }
  2242. }
  2243. }
  2244. for (var instanceId in eventStore.instances) {
  2245. var instance = eventStore.instances[instanceId];
  2246. var def = eventStore.defs[instance.defId];
  2247. var ui = eventUis[def.defId];
  2248. var origRange = instance.range;
  2249. var normalRange = (!def.allDay && nextDayThreshold) ?
  2250. computeVisibleDayRange(origRange, nextDayThreshold) :
  2251. origRange;
  2252. var slicedRange = intersectRanges(normalRange, framingRange);
  2253. if (slicedRange) {
  2254. if (ui.display === 'inverse-background') {
  2255. if (def.groupId) {
  2256. inverseBgByGroupId[def.groupId].push(slicedRange);
  2257. }
  2258. else {
  2259. inverseBgByDefId[instance.defId].push(slicedRange);
  2260. }
  2261. }
  2262. else if (ui.display !== 'none') {
  2263. (ui.display === 'background' ? bgRanges : fgRanges).push({
  2264. def: def,
  2265. ui: ui,
  2266. instance: instance,
  2267. range: slicedRange,
  2268. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2269. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf(),
  2270. });
  2271. }
  2272. }
  2273. }
  2274. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2275. var ranges = inverseBgByGroupId[groupId];
  2276. var invertedRanges = invertRanges(ranges, framingRange);
  2277. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2278. var invertedRange = invertedRanges_1[_i];
  2279. var def = defByGroupId[groupId];
  2280. var ui = eventUis[def.defId];
  2281. bgRanges.push({
  2282. def: def,
  2283. ui: ui,
  2284. instance: null,
  2285. range: invertedRange,
  2286. isStart: false,
  2287. isEnd: false,
  2288. });
  2289. }
  2290. }
  2291. for (var defId in inverseBgByDefId) {
  2292. var ranges = inverseBgByDefId[defId];
  2293. var invertedRanges = invertRanges(ranges, framingRange);
  2294. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2295. var invertedRange = invertedRanges_2[_a];
  2296. bgRanges.push({
  2297. def: eventStore.defs[defId],
  2298. ui: eventUis[defId],
  2299. instance: null,
  2300. range: invertedRange,
  2301. isStart: false,
  2302. isEnd: false,
  2303. });
  2304. }
  2305. }
  2306. return { bg: bgRanges, fg: fgRanges };
  2307. }
  2308. function hasBgRendering(def) {
  2309. return def.ui.display === 'background' || def.ui.display === 'inverse-background';
  2310. }
  2311. function setElSeg(el, seg) {
  2312. el.fcSeg = seg;
  2313. }
  2314. function getElSeg(el) {
  2315. return el.fcSeg ||
  2316. el.parentNode.fcSeg || // for the harness
  2317. null;
  2318. }
  2319. // event ui computation
  2320. function compileEventUis(eventDefs, eventUiBases) {
  2321. return mapHash(eventDefs, function (eventDef) { return compileEventUi(eventDef, eventUiBases); });
  2322. }
  2323. function compileEventUi(eventDef, eventUiBases) {
  2324. var uis = [];
  2325. if (eventUiBases['']) {
  2326. uis.push(eventUiBases['']);
  2327. }
  2328. if (eventUiBases[eventDef.defId]) {
  2329. uis.push(eventUiBases[eventDef.defId]);
  2330. }
  2331. uis.push(eventDef.ui);
  2332. return combineEventUis(uis);
  2333. }
  2334. function sortEventSegs(segs, eventOrderSpecs) {
  2335. var objs = segs.map(buildSegCompareObj);
  2336. objs.sort(function (obj0, obj1) { return compareByFieldSpecs(obj0, obj1, eventOrderSpecs); });
  2337. return objs.map(function (c) { return c._seg; });
  2338. }
  2339. // returns a object with all primitive props that can be compared
  2340. function buildSegCompareObj(seg) {
  2341. var eventRange = seg.eventRange;
  2342. var eventDef = eventRange.def;
  2343. var range = eventRange.instance ? eventRange.instance.range : eventRange.range;
  2344. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  2345. var end = range.end ? range.end.valueOf() : 0; // "
  2346. return __assign(__assign(__assign({}, eventDef.extendedProps), eventDef), { id: eventDef.publicId, start: start,
  2347. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg });
  2348. }
  2349. function computeSegDraggable(seg, context) {
  2350. var pluginHooks = context.pluginHooks;
  2351. var transformers = pluginHooks.isDraggableTransformers;
  2352. var _a = seg.eventRange, def = _a.def, ui = _a.ui;
  2353. var val = ui.startEditable;
  2354. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  2355. var transformer = transformers_1[_i];
  2356. val = transformer(val, def, ui, context);
  2357. }
  2358. return val;
  2359. }
  2360. function computeSegStartResizable(seg, context) {
  2361. return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
  2362. }
  2363. function computeSegEndResizable(seg, context) {
  2364. return seg.isEnd && seg.eventRange.ui.durationEditable;
  2365. }
  2366. function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, // defaults to true
  2367. defaultDisplayEventEnd, // defaults to true
  2368. startOverride, endOverride) {
  2369. var dateEnv = context.dateEnv, options = context.options;
  2370. var displayEventTime = options.displayEventTime, displayEventEnd = options.displayEventEnd;
  2371. var eventDef = seg.eventRange.def;
  2372. var eventInstance = seg.eventRange.instance;
  2373. if (displayEventTime == null) {
  2374. displayEventTime = defaultDisplayEventTime !== false;
  2375. }
  2376. if (displayEventEnd == null) {
  2377. displayEventEnd = defaultDisplayEventEnd !== false;
  2378. }
  2379. if (displayEventTime && !eventDef.allDay && (seg.isStart || seg.isEnd)) {
  2380. var segStart = startOverride || (seg.isStart ? eventInstance.range.start : (seg.start || seg.eventRange.range.start));
  2381. var segEnd = endOverride || (seg.isEnd ? eventInstance.range.end : (seg.end || seg.eventRange.range.end));
  2382. if (displayEventEnd && eventDef.hasEnd) {
  2383. return dateEnv.formatRange(segStart, segEnd, timeFormat, {
  2384. forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2385. forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo,
  2386. });
  2387. }
  2388. return dateEnv.format(segStart, timeFormat, {
  2389. forcedTzo: startOverride ? null : eventInstance.forcedStartTzo,
  2390. });
  2391. }
  2392. return '';
  2393. }
  2394. function getSegMeta(seg, todayRange, nowDate) {
  2395. var segRange = seg.eventRange.range;
  2396. return {
  2397. isPast: segRange.end < (nowDate || todayRange.start),
  2398. isFuture: segRange.start >= (nowDate || todayRange.end),
  2399. isToday: todayRange && rangeContainsMarker(todayRange, segRange.start),
  2400. };
  2401. }
  2402. function getEventClassNames(props) {
  2403. var classNames = ['fc-event'];
  2404. if (props.isMirror) {
  2405. classNames.push('fc-event-mirror');
  2406. }
  2407. if (props.isDraggable) {
  2408. classNames.push('fc-event-draggable');
  2409. }
  2410. if (props.isStartResizable || props.isEndResizable) {
  2411. classNames.push('fc-event-resizable');
  2412. }
  2413. if (props.isDragging) {
  2414. classNames.push('fc-event-dragging');
  2415. }
  2416. if (props.isResizing) {
  2417. classNames.push('fc-event-resizing');
  2418. }
  2419. if (props.isSelected) {
  2420. classNames.push('fc-event-selected');
  2421. }
  2422. if (props.isStart) {
  2423. classNames.push('fc-event-start');
  2424. }
  2425. if (props.isEnd) {
  2426. classNames.push('fc-event-end');
  2427. }
  2428. if (props.isPast) {
  2429. classNames.push('fc-event-past');
  2430. }
  2431. if (props.isToday) {
  2432. classNames.push('fc-event-today');
  2433. }
  2434. if (props.isFuture) {
  2435. classNames.push('fc-event-future');
  2436. }
  2437. return classNames;
  2438. }
  2439. function buildEventRangeKey(eventRange) {
  2440. return eventRange.instance
  2441. ? eventRange.instance.instanceId
  2442. : eventRange.def.defId + ":" + eventRange.range.start.toISOString();
  2443. // inverse-background events don't have specific instances. TODO: better solution
  2444. }
  2445. var STANDARD_PROPS = {
  2446. start: identity,
  2447. end: identity,
  2448. allDay: Boolean,
  2449. };
  2450. function parseDateSpan(raw, dateEnv, defaultDuration) {
  2451. var span = parseOpenDateSpan(raw, dateEnv);
  2452. var range = span.range;
  2453. if (!range.start) {
  2454. return null;
  2455. }
  2456. if (!range.end) {
  2457. if (defaultDuration == null) {
  2458. return null;
  2459. }
  2460. range.end = dateEnv.add(range.start, defaultDuration);
  2461. }
  2462. return span;
  2463. }
  2464. /*
  2465. TODO: somehow combine with parseRange?
  2466. Will return null if the start/end props were present but parsed invalidly.
  2467. */
  2468. function parseOpenDateSpan(raw, dateEnv) {
  2469. var _a = refineProps(raw, STANDARD_PROPS), standardProps = _a.refined, extra = _a.extra;
  2470. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  2471. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  2472. var allDay = standardProps.allDay;
  2473. if (allDay == null) {
  2474. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  2475. (!endMeta || endMeta.isTimeUnspecified);
  2476. }
  2477. return __assign({ range: {
  2478. start: startMeta ? startMeta.marker : null,
  2479. end: endMeta ? endMeta.marker : null,
  2480. }, allDay: allDay }, extra);
  2481. }
  2482. function isDateSpansEqual(span0, span1) {
  2483. return rangesEqual(span0.range, span1.range) &&
  2484. span0.allDay === span1.allDay &&
  2485. isSpanPropsEqual(span0, span1);
  2486. }
  2487. // the NON-DATE-RELATED props
  2488. function isSpanPropsEqual(span0, span1) {
  2489. for (var propName in span1) {
  2490. if (propName !== 'range' && propName !== 'allDay') {
  2491. if (span0[propName] !== span1[propName]) {
  2492. return false;
  2493. }
  2494. }
  2495. }
  2496. // are there any props that span0 has that span1 DOESN'T have?
  2497. // both have range/allDay, so no need to special-case.
  2498. for (var propName in span0) {
  2499. if (!(propName in span1)) {
  2500. return false;
  2501. }
  2502. }
  2503. return true;
  2504. }
  2505. function buildDateSpanApi(span, dateEnv) {
  2506. return __assign(__assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
  2507. }
  2508. function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
  2509. return __assign(__assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
  2510. }
  2511. function buildRangeApi(range, dateEnv, omitTime) {
  2512. return {
  2513. start: dateEnv.toDate(range.start),
  2514. end: dateEnv.toDate(range.end),
  2515. startStr: dateEnv.formatIso(range.start, { omitTime: omitTime }),
  2516. endStr: dateEnv.formatIso(range.end, { omitTime: omitTime }),
  2517. };
  2518. }
  2519. function fabricateEventRange(dateSpan, eventUiBases, context) {
  2520. var res = refineEventDef({ editable: false }, context);
  2521. var def = parseEventDef(res.refined, res.extra, '', // sourceId
  2522. dateSpan.allDay, true, // hasEnd
  2523. context);
  2524. return {
  2525. def: def,
  2526. ui: compileEventUi(def, eventUiBases),
  2527. instance: createEventInstance(def.defId, dateSpan.range),
  2528. range: dateSpan.range,
  2529. isStart: true,
  2530. isEnd: true,
  2531. };
  2532. }
  2533. function triggerDateSelect(selection, pev, context) {
  2534. context.emitter.trigger('select', __assign(__assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
  2535. }
  2536. function triggerDateUnselect(pev, context) {
  2537. context.emitter.trigger('unselect', {
  2538. jsEvent: pev ? pev.origEvent : null,
  2539. view: context.viewApi || context.calendarApi.view,
  2540. });
  2541. }
  2542. function buildDateSpanApiWithContext(dateSpan, context) {
  2543. var props = {};
  2544. for (var _i = 0, _a = context.pluginHooks.dateSpanTransforms; _i < _a.length; _i++) {
  2545. var transform = _a[_i];
  2546. __assign(props, transform(dateSpan, context));
  2547. }
  2548. __assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
  2549. return props;
  2550. }
  2551. // Given an event's allDay status and start date, return what its fallback end date should be.
  2552. // TODO: rename to computeDefaultEventEnd
  2553. function getDefaultEventEnd(allDay, marker, context) {
  2554. var dateEnv = context.dateEnv, options = context.options;
  2555. var end = marker;
  2556. if (allDay) {
  2557. end = startOfDay(end);
  2558. end = dateEnv.add(end, options.defaultAllDayEventDuration);
  2559. }
  2560. else {
  2561. end = dateEnv.add(end, options.defaultTimedEventDuration);
  2562. }
  2563. return end;
  2564. }
  2565. // applies the mutation to ALL defs/instances within the event store
  2566. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
  2567. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2568. var dest = createEmptyEventStore();
  2569. for (var defId in eventStore.defs) {
  2570. var def = eventStore.defs[defId];
  2571. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
  2572. }
  2573. for (var instanceId in eventStore.instances) {
  2574. var instance = eventStore.instances[instanceId];
  2575. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2576. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
  2577. }
  2578. return dest;
  2579. }
  2580. function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
  2581. var standardProps = mutation.standardProps || {};
  2582. // if hasEnd has not been specified, guess a good value based on deltas.
  2583. // if duration will change, there's no way the default duration will persist,
  2584. // and thus, we need to mark the event as having a real end
  2585. if (standardProps.hasEnd == null &&
  2586. eventConfig.durationEditable &&
  2587. (mutation.startDelta || mutation.endDelta)) {
  2588. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2589. }
  2590. var copy = __assign(__assign(__assign({}, eventDef), standardProps), { ui: __assign(__assign({}, eventDef.ui), standardProps.ui) });
  2591. if (mutation.extendedProps) {
  2592. copy.extendedProps = __assign(__assign({}, copy.extendedProps), mutation.extendedProps);
  2593. }
  2594. for (var _i = 0, _a = context.pluginHooks.eventDefMutationAppliers; _i < _a.length; _i++) {
  2595. var applier = _a[_i];
  2596. applier(copy, mutation, context);
  2597. }
  2598. if (!copy.hasEnd && context.options.forceEventDuration) {
  2599. copy.hasEnd = true;
  2600. }
  2601. return copy;
  2602. }
  2603. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2604. eventConfig, mutation, context) {
  2605. var dateEnv = context.dateEnv;
  2606. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2607. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2608. var copy = __assign({}, eventInstance);
  2609. if (forceAllDay) {
  2610. copy.range = computeAlignedDayRange(copy.range);
  2611. }
  2612. if (mutation.datesDelta && eventConfig.startEditable) {
  2613. copy.range = {
  2614. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2615. end: dateEnv.add(copy.range.end, mutation.datesDelta),
  2616. };
  2617. }
  2618. if (mutation.startDelta && eventConfig.durationEditable) {
  2619. copy.range = {
  2620. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2621. end: copy.range.end,
  2622. };
  2623. }
  2624. if (mutation.endDelta && eventConfig.durationEditable) {
  2625. copy.range = {
  2626. start: copy.range.start,
  2627. end: dateEnv.add(copy.range.end, mutation.endDelta),
  2628. };
  2629. }
  2630. if (clearEnd) {
  2631. copy.range = {
  2632. start: copy.range.start,
  2633. end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context),
  2634. };
  2635. }
  2636. // in case event was all-day but the supplied deltas were not
  2637. // better util for this?
  2638. if (eventDef.allDay) {
  2639. copy.range = {
  2640. start: startOfDay(copy.range.start),
  2641. end: startOfDay(copy.range.end),
  2642. };
  2643. }
  2644. // handle invalid durations
  2645. if (copy.range.end < copy.range.start) {
  2646. copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
  2647. }
  2648. return copy;
  2649. }
  2650. // no public types yet. when there are, export from:
  2651. // import {} from './api-type-deps'
  2652. var ViewApi = /** @class */ (function () {
  2653. function ViewApi(type, getCurrentData, dateEnv) {
  2654. this.type = type;
  2655. this.getCurrentData = getCurrentData;
  2656. this.dateEnv = dateEnv;
  2657. }
  2658. Object.defineProperty(ViewApi.prototype, "calendar", {
  2659. get: function () {
  2660. return this.getCurrentData().calendarApi;
  2661. },
  2662. enumerable: false,
  2663. configurable: true
  2664. });
  2665. Object.defineProperty(ViewApi.prototype, "title", {
  2666. get: function () {
  2667. return this.getCurrentData().viewTitle;
  2668. },
  2669. enumerable: false,
  2670. configurable: true
  2671. });
  2672. Object.defineProperty(ViewApi.prototype, "activeStart", {
  2673. get: function () {
  2674. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
  2675. },
  2676. enumerable: false,
  2677. configurable: true
  2678. });
  2679. Object.defineProperty(ViewApi.prototype, "activeEnd", {
  2680. get: function () {
  2681. return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
  2682. },
  2683. enumerable: false,
  2684. configurable: true
  2685. });
  2686. Object.defineProperty(ViewApi.prototype, "currentStart", {
  2687. get: function () {
  2688. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
  2689. },
  2690. enumerable: false,
  2691. configurable: true
  2692. });
  2693. Object.defineProperty(ViewApi.prototype, "currentEnd", {
  2694. get: function () {
  2695. return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
  2696. },
  2697. enumerable: false,
  2698. configurable: true
  2699. });
  2700. ViewApi.prototype.getOption = function (name) {
  2701. return this.getCurrentData().options[name]; // are the view-specific options
  2702. };
  2703. return ViewApi;
  2704. }());
  2705. var EVENT_SOURCE_REFINERS = {
  2706. id: String,
  2707. defaultAllDay: Boolean,
  2708. url: String,
  2709. events: identity,
  2710. eventDataTransform: identity,
  2711. // for any network-related sources
  2712. success: identity,
  2713. failure: identity,
  2714. };
  2715. function parseEventSource(raw, context, refiners) {
  2716. if (refiners === void 0) { refiners = buildEventSourceRefiners(context); }
  2717. var rawObj;
  2718. if (typeof raw === 'string') {
  2719. rawObj = { url: raw };
  2720. }
  2721. else if (typeof raw === 'function' || Array.isArray(raw)) {
  2722. rawObj = { events: raw };
  2723. }
  2724. else if (typeof raw === 'object' && raw) { // not null
  2725. rawObj = raw;
  2726. }
  2727. if (rawObj) {
  2728. var _a = refineProps(rawObj, refiners), refined = _a.refined, extra = _a.extra;
  2729. var metaRes = buildEventSourceMeta(refined, context);
  2730. if (metaRes) {
  2731. return {
  2732. _raw: raw,
  2733. isFetching: false,
  2734. latestFetchId: '',
  2735. fetchRange: null,
  2736. defaultAllDay: refined.defaultAllDay,
  2737. eventDataTransform: refined.eventDataTransform,
  2738. success: refined.success,
  2739. failure: refined.failure,
  2740. publicId: refined.id || '',
  2741. sourceId: guid(),
  2742. sourceDefId: metaRes.sourceDefId,
  2743. meta: metaRes.meta,
  2744. ui: createEventUi(refined, context),
  2745. extendedProps: extra,
  2746. };
  2747. }
  2748. }
  2749. return null;
  2750. }
  2751. function buildEventSourceRefiners(context) {
  2752. return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS), context.pluginHooks.eventSourceRefiners);
  2753. }
  2754. function buildEventSourceMeta(raw, context) {
  2755. var defs = context.pluginHooks.eventSourceDefs;
  2756. for (var i = defs.length - 1; i >= 0; i -= 1) { // later-added plugins take precedence
  2757. var def = defs[i];
  2758. var meta = def.parseMeta(raw);
  2759. if (meta) {
  2760. return { sourceDefId: i, meta: meta };
  2761. }
  2762. }
  2763. return null;
  2764. }
  2765. function reduceCurrentDate(currentDate, action) {
  2766. switch (action.type) {
  2767. case 'CHANGE_DATE':
  2768. return action.dateMarker;
  2769. default:
  2770. return currentDate;
  2771. }
  2772. }
  2773. function getInitialDate(options, dateEnv) {
  2774. var initialDateInput = options.initialDate;
  2775. // compute the initial ambig-timezone date
  2776. if (initialDateInput != null) {
  2777. return dateEnv.createMarker(initialDateInput);
  2778. }
  2779. return getNow(options.now, dateEnv); // getNow already returns unzoned
  2780. }
  2781. function getNow(nowInput, dateEnv) {
  2782. if (typeof nowInput === 'function') {
  2783. nowInput = nowInput();
  2784. }
  2785. if (nowInput == null) {
  2786. return dateEnv.createNowMarker();
  2787. }
  2788. return dateEnv.createMarker(nowInput);
  2789. }
  2790. var CalendarApi = /** @class */ (function () {
  2791. function CalendarApi() {
  2792. }
  2793. CalendarApi.prototype.getCurrentData = function () {
  2794. return this.currentDataManager.getCurrentData();
  2795. };
  2796. CalendarApi.prototype.dispatch = function (action) {
  2797. return this.currentDataManager.dispatch(action);
  2798. };
  2799. Object.defineProperty(CalendarApi.prototype, "view", {
  2800. get: function () { return this.getCurrentData().viewApi; } // for public API
  2801. ,
  2802. enumerable: false,
  2803. configurable: true
  2804. });
  2805. CalendarApi.prototype.batchRendering = function (callback) {
  2806. callback();
  2807. };
  2808. CalendarApi.prototype.updateSize = function () {
  2809. this.trigger('_resize', true);
  2810. };
  2811. // Options
  2812. // -----------------------------------------------------------------------------------------------------------------
  2813. CalendarApi.prototype.setOption = function (name, val) {
  2814. this.dispatch({
  2815. type: 'SET_OPTION',
  2816. optionName: name,
  2817. rawOptionValue: val,
  2818. });
  2819. };
  2820. CalendarApi.prototype.getOption = function (name) {
  2821. return this.currentDataManager.currentCalendarOptionsInput[name];
  2822. };
  2823. CalendarApi.prototype.getAvailableLocaleCodes = function () {
  2824. return Object.keys(this.getCurrentData().availableRawLocales);
  2825. };
  2826. // Trigger
  2827. // -----------------------------------------------------------------------------------------------------------------
  2828. CalendarApi.prototype.on = function (handlerName, handler) {
  2829. var currentDataManager = this.currentDataManager;
  2830. if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
  2831. currentDataManager.emitter.on(handlerName, handler);
  2832. }
  2833. else {
  2834. console.warn("Unknown listener name '" + handlerName + "'");
  2835. }
  2836. };
  2837. CalendarApi.prototype.off = function (handlerName, handler) {
  2838. this.currentDataManager.emitter.off(handlerName, handler);
  2839. };
  2840. // not meant for public use
  2841. CalendarApi.prototype.trigger = function (handlerName) {
  2842. var _a;
  2843. var args = [];
  2844. for (var _i = 1; _i < arguments.length; _i++) {
  2845. args[_i - 1] = arguments[_i];
  2846. }
  2847. (_a = this.currentDataManager.emitter).trigger.apply(_a, __spreadArrays([handlerName], args));
  2848. };
  2849. // View
  2850. // -----------------------------------------------------------------------------------------------------------------
  2851. CalendarApi.prototype.changeView = function (viewType, dateOrRange) {
  2852. var _this = this;
  2853. this.batchRendering(function () {
  2854. _this.unselect();
  2855. if (dateOrRange) {
  2856. if (dateOrRange.start && dateOrRange.end) { // a range
  2857. _this.dispatch({
  2858. type: 'CHANGE_VIEW_TYPE',
  2859. viewType: viewType,
  2860. });
  2861. _this.dispatch({
  2862. type: 'SET_OPTION',
  2863. optionName: 'visibleRange',
  2864. rawOptionValue: dateOrRange,
  2865. });
  2866. }
  2867. else {
  2868. var dateEnv = _this.getCurrentData().dateEnv;
  2869. _this.dispatch({
  2870. type: 'CHANGE_VIEW_TYPE',
  2871. viewType: viewType,
  2872. dateMarker: dateEnv.createMarker(dateOrRange),
  2873. });
  2874. }
  2875. }
  2876. else {
  2877. _this.dispatch({
  2878. type: 'CHANGE_VIEW_TYPE',
  2879. viewType: viewType,
  2880. });
  2881. }
  2882. });
  2883. };
  2884. // Forces navigation to a view for the given date.
  2885. // `viewType` can be a specific view name or a generic one like "week" or "day".
  2886. // needs to change
  2887. CalendarApi.prototype.zoomTo = function (dateMarker, viewType) {
  2888. var state = this.getCurrentData();
  2889. var spec;
  2890. viewType = viewType || 'day'; // day is default zoom
  2891. spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
  2892. this.unselect();
  2893. if (spec) {
  2894. this.dispatch({
  2895. type: 'CHANGE_VIEW_TYPE',
  2896. viewType: spec.type,
  2897. dateMarker: dateMarker,
  2898. });
  2899. }
  2900. else {
  2901. this.dispatch({
  2902. type: 'CHANGE_DATE',
  2903. dateMarker: dateMarker,
  2904. });
  2905. }
  2906. };
  2907. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  2908. // Preference is given to views that have corresponding buttons.
  2909. CalendarApi.prototype.getUnitViewSpec = function (unit) {
  2910. var _a = this.getCurrentData(), viewSpecs = _a.viewSpecs, toolbarConfig = _a.toolbarConfig;
  2911. var viewTypes = [].concat(toolbarConfig.viewsWithButtons);
  2912. var i;
  2913. var spec;
  2914. for (var viewType in viewSpecs) {
  2915. viewTypes.push(viewType);
  2916. }
  2917. for (i = 0; i < viewTypes.length; i += 1) {
  2918. spec = viewSpecs[viewTypes[i]];
  2919. if (spec) {
  2920. if (spec.singleUnit === unit) {
  2921. return spec;
  2922. }
  2923. }
  2924. }
  2925. return null;
  2926. };
  2927. // Current Date
  2928. // -----------------------------------------------------------------------------------------------------------------
  2929. CalendarApi.prototype.prev = function () {
  2930. this.unselect();
  2931. this.dispatch({ type: 'PREV' });
  2932. };
  2933. CalendarApi.prototype.next = function () {
  2934. this.unselect();
  2935. this.dispatch({ type: 'NEXT' });
  2936. };
  2937. CalendarApi.prototype.prevYear = function () {
  2938. var state = this.getCurrentData();
  2939. this.unselect();
  2940. this.dispatch({
  2941. type: 'CHANGE_DATE',
  2942. dateMarker: state.dateEnv.addYears(state.currentDate, -1),
  2943. });
  2944. };
  2945. CalendarApi.prototype.nextYear = function () {
  2946. var state = this.getCurrentData();
  2947. this.unselect();
  2948. this.dispatch({
  2949. type: 'CHANGE_DATE',
  2950. dateMarker: state.dateEnv.addYears(state.currentDate, 1),
  2951. });
  2952. };
  2953. CalendarApi.prototype.today = function () {
  2954. var state = this.getCurrentData();
  2955. this.unselect();
  2956. this.dispatch({
  2957. type: 'CHANGE_DATE',
  2958. dateMarker: getNow(state.calendarOptions.now, state.dateEnv),
  2959. });
  2960. };
  2961. CalendarApi.prototype.gotoDate = function (zonedDateInput) {
  2962. var state = this.getCurrentData();
  2963. this.unselect();
  2964. this.dispatch({
  2965. type: 'CHANGE_DATE',
  2966. dateMarker: state.dateEnv.createMarker(zonedDateInput),
  2967. });
  2968. };
  2969. CalendarApi.prototype.incrementDate = function (deltaInput) {
  2970. var state = this.getCurrentData();
  2971. var delta = createDuration(deltaInput);
  2972. if (delta) { // else, warn about invalid input?
  2973. this.unselect();
  2974. this.dispatch({
  2975. type: 'CHANGE_DATE',
  2976. dateMarker: state.dateEnv.add(state.currentDate, delta),
  2977. });
  2978. }
  2979. };
  2980. // for external API
  2981. CalendarApi.prototype.getDate = function () {
  2982. var state = this.getCurrentData();
  2983. return state.dateEnv.toDate(state.currentDate);
  2984. };
  2985. // Date Formatting Utils
  2986. // -----------------------------------------------------------------------------------------------------------------
  2987. CalendarApi.prototype.formatDate = function (d, formatter) {
  2988. var dateEnv = this.getCurrentData().dateEnv;
  2989. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  2990. };
  2991. // `settings` is for formatter AND isEndExclusive
  2992. CalendarApi.prototype.formatRange = function (d0, d1, settings) {
  2993. var dateEnv = this.getCurrentData().dateEnv;
  2994. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
  2995. };
  2996. CalendarApi.prototype.formatIso = function (d, omitTime) {
  2997. var dateEnv = this.getCurrentData().dateEnv;
  2998. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  2999. };
  3000. // Date Selection / Event Selection / DayClick
  3001. // -----------------------------------------------------------------------------------------------------------------
  3002. // this public method receives start/end dates in any format, with any timezone
  3003. // NOTE: args were changed from v3
  3004. CalendarApi.prototype.select = function (dateOrObj, endDate) {
  3005. var selectionInput;
  3006. if (endDate == null) {
  3007. if (dateOrObj.start != null) {
  3008. selectionInput = dateOrObj;
  3009. }
  3010. else {
  3011. selectionInput = {
  3012. start: dateOrObj,
  3013. end: null,
  3014. };
  3015. }
  3016. }
  3017. else {
  3018. selectionInput = {
  3019. start: dateOrObj,
  3020. end: endDate,
  3021. };
  3022. }
  3023. var state = this.getCurrentData();
  3024. var selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
  3025. if (selection) { // throw parse error otherwise?
  3026. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  3027. triggerDateSelect(selection, null, state);
  3028. }
  3029. };
  3030. // public method
  3031. CalendarApi.prototype.unselect = function (pev) {
  3032. var state = this.getCurrentData();
  3033. if (state.dateSelection) {
  3034. this.dispatch({ type: 'UNSELECT_DATES' });
  3035. triggerDateUnselect(pev, state);
  3036. }
  3037. };
  3038. // Public Events API
  3039. // -----------------------------------------------------------------------------------------------------------------
  3040. CalendarApi.prototype.addEvent = function (eventInput, sourceInput) {
  3041. if (eventInput instanceof EventApi) {
  3042. var def = eventInput._def;
  3043. var instance = eventInput._instance;
  3044. var currentData = this.getCurrentData();
  3045. // not already present? don't want to add an old snapshot
  3046. if (!currentData.eventStore.defs[def.defId]) {
  3047. this.dispatch({
  3048. type: 'ADD_EVENTS',
  3049. eventStore: eventTupleToStore({ def: def, instance: instance }),
  3050. });
  3051. this.triggerEventAdd(eventInput);
  3052. }
  3053. return eventInput;
  3054. }
  3055. var state = this.getCurrentData();
  3056. var eventSource;
  3057. if (sourceInput instanceof EventSourceApi) {
  3058. eventSource = sourceInput.internalEventSource;
  3059. }
  3060. else if (typeof sourceInput === 'boolean') {
  3061. if (sourceInput) { // true. part of the first event source
  3062. eventSource = hashValuesToArray(state.eventSources)[0];
  3063. }
  3064. }
  3065. else if (sourceInput != null) { // an ID. accepts a number too
  3066. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  3067. if (!sourceApi) {
  3068. console.warn("Could not find an event source with ID \"" + sourceInput + "\""); // TODO: test
  3069. return null;
  3070. }
  3071. eventSource = sourceApi.internalEventSource;
  3072. }
  3073. var tuple = parseEvent(eventInput, eventSource, state, false);
  3074. if (tuple) {
  3075. var newEventApi = new EventApi(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  3076. this.dispatch({
  3077. type: 'ADD_EVENTS',
  3078. eventStore: eventTupleToStore(tuple),
  3079. });
  3080. this.triggerEventAdd(newEventApi);
  3081. return newEventApi;
  3082. }
  3083. return null;
  3084. };
  3085. CalendarApi.prototype.triggerEventAdd = function (eventApi) {
  3086. var _this = this;
  3087. var emitter = this.getCurrentData().emitter;
  3088. emitter.trigger('eventAdd', {
  3089. event: eventApi,
  3090. relatedEvents: [],
  3091. revert: function () {
  3092. _this.dispatch({
  3093. type: 'REMOVE_EVENTS',
  3094. eventStore: eventApiToStore(eventApi),
  3095. });
  3096. },
  3097. });
  3098. };
  3099. // TODO: optimize
  3100. CalendarApi.prototype.getEventById = function (id) {
  3101. var state = this.getCurrentData();
  3102. var _a = state.eventStore, defs = _a.defs, instances = _a.instances;
  3103. id = String(id);
  3104. for (var defId in defs) {
  3105. var def = defs[defId];
  3106. if (def.publicId === id) {
  3107. if (def.recurringDef) {
  3108. return new EventApi(state, def, null);
  3109. }
  3110. for (var instanceId in instances) {
  3111. var instance = instances[instanceId];
  3112. if (instance.defId === def.defId) {
  3113. return new EventApi(state, def, instance);
  3114. }
  3115. }
  3116. }
  3117. }
  3118. return null;
  3119. };
  3120. CalendarApi.prototype.getEvents = function () {
  3121. var currentData = this.getCurrentData();
  3122. return buildEventApis(currentData.eventStore, currentData);
  3123. };
  3124. CalendarApi.prototype.removeAllEvents = function () {
  3125. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  3126. };
  3127. // Public Event Sources API
  3128. // -----------------------------------------------------------------------------------------------------------------
  3129. CalendarApi.prototype.getEventSources = function () {
  3130. var state = this.getCurrentData();
  3131. var sourceHash = state.eventSources;
  3132. var sourceApis = [];
  3133. for (var internalId in sourceHash) {
  3134. sourceApis.push(new EventSourceApi(state, sourceHash[internalId]));
  3135. }
  3136. return sourceApis;
  3137. };
  3138. CalendarApi.prototype.getEventSourceById = function (id) {
  3139. var state = this.getCurrentData();
  3140. var sourceHash = state.eventSources;
  3141. id = String(id);
  3142. for (var sourceId in sourceHash) {
  3143. if (sourceHash[sourceId].publicId === id) {
  3144. return new EventSourceApi(state, sourceHash[sourceId]);
  3145. }
  3146. }
  3147. return null;
  3148. };
  3149. CalendarApi.prototype.addEventSource = function (sourceInput) {
  3150. var state = this.getCurrentData();
  3151. if (sourceInput instanceof EventSourceApi) {
  3152. // not already present? don't want to add an old snapshot
  3153. if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
  3154. this.dispatch({
  3155. type: 'ADD_EVENT_SOURCES',
  3156. sources: [sourceInput.internalEventSource],
  3157. });
  3158. }
  3159. return sourceInput;
  3160. }
  3161. var eventSource = parseEventSource(sourceInput, state);
  3162. if (eventSource) { // TODO: error otherwise?
  3163. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  3164. return new EventSourceApi(state, eventSource);
  3165. }
  3166. return null;
  3167. };
  3168. CalendarApi.prototype.removeAllEventSources = function () {
  3169. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  3170. };
  3171. CalendarApi.prototype.refetchEvents = function () {
  3172. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  3173. };
  3174. // Scroll
  3175. // -----------------------------------------------------------------------------------------------------------------
  3176. CalendarApi.prototype.scrollToTime = function (timeInput) {
  3177. var time = createDuration(timeInput);
  3178. if (time) {
  3179. this.trigger('_scrollRequest', { time: time });
  3180. }
  3181. };
  3182. return CalendarApi;
  3183. }());
  3184. var EventApi = /** @class */ (function () {
  3185. // instance will be null if expressing a recurring event that has no current instances,
  3186. // OR if trying to validate an incoming external event that has no dates assigned
  3187. function EventApi(context, def, instance) {
  3188. this._context = context;
  3189. this._def = def;
  3190. this._instance = instance || null;
  3191. }
  3192. /*
  3193. TODO: make event struct more responsible for this
  3194. */
  3195. EventApi.prototype.setProp = function (name, val) {
  3196. var _a, _b;
  3197. if (name in EVENT_DATE_REFINERS) {
  3198. console.warn('Could not set date-related prop \'name\'. Use one of the date-related methods instead.');
  3199. }
  3200. else if (name in EVENT_NON_DATE_REFINERS) {
  3201. val = EVENT_NON_DATE_REFINERS[name](val);
  3202. this.mutate({
  3203. standardProps: (_a = {}, _a[name] = val, _a),
  3204. });
  3205. }
  3206. else if (name in EVENT_UI_REFINERS) {
  3207. var ui = EVENT_UI_REFINERS[name](val);
  3208. if (name === 'color') {
  3209. ui = { backgroundColor: val, borderColor: val };
  3210. }
  3211. else if (name === 'editable') {
  3212. ui = { startEditable: val, durationEditable: val };
  3213. }
  3214. else {
  3215. ui = (_b = {}, _b[name] = val, _b);
  3216. }
  3217. this.mutate({
  3218. standardProps: { ui: ui },
  3219. });
  3220. }
  3221. else {
  3222. console.warn("Could not set prop '" + name + "'. Use setExtendedProp instead.");
  3223. }
  3224. };
  3225. EventApi.prototype.setExtendedProp = function (name, val) {
  3226. var _a;
  3227. this.mutate({
  3228. extendedProps: (_a = {}, _a[name] = val, _a),
  3229. });
  3230. };
  3231. EventApi.prototype.setStart = function (startInput, options) {
  3232. if (options === void 0) { options = {}; }
  3233. var dateEnv = this._context.dateEnv;
  3234. var start = dateEnv.createMarker(startInput);
  3235. if (start && this._instance) { // TODO: warning if parsed bad
  3236. var instanceRange = this._instance.range;
  3237. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  3238. if (options.maintainDuration) {
  3239. this.mutate({ datesDelta: startDelta });
  3240. }
  3241. else {
  3242. this.mutate({ startDelta: startDelta });
  3243. }
  3244. }
  3245. };
  3246. EventApi.prototype.setEnd = function (endInput, options) {
  3247. if (options === void 0) { options = {}; }
  3248. var dateEnv = this._context.dateEnv;
  3249. var end;
  3250. if (endInput != null) {
  3251. end = dateEnv.createMarker(endInput);
  3252. if (!end) {
  3253. return; // TODO: warning if parsed bad
  3254. }
  3255. }
  3256. if (this._instance) {
  3257. if (end) {
  3258. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  3259. this.mutate({ endDelta: endDelta });
  3260. }
  3261. else {
  3262. this.mutate({ standardProps: { hasEnd: false } });
  3263. }
  3264. }
  3265. };
  3266. EventApi.prototype.setDates = function (startInput, endInput, options) {
  3267. if (options === void 0) { options = {}; }
  3268. var dateEnv = this._context.dateEnv;
  3269. var standardProps = { allDay: options.allDay };
  3270. var start = dateEnv.createMarker(startInput);
  3271. var end;
  3272. if (!start) {
  3273. return; // TODO: warning if parsed bad
  3274. }
  3275. if (endInput != null) {
  3276. end = dateEnv.createMarker(endInput);
  3277. if (!end) { // TODO: warning if parsed bad
  3278. return;
  3279. }
  3280. }
  3281. if (this._instance) {
  3282. var instanceRange = this._instance.range;
  3283. // when computing the diff for an event being converted to all-day,
  3284. // compute diff off of the all-day values the way event-mutation does.
  3285. if (options.allDay === true) {
  3286. instanceRange = computeAlignedDayRange(instanceRange);
  3287. }
  3288. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  3289. if (end) {
  3290. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  3291. if (durationsEqual(startDelta, endDelta)) {
  3292. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3293. }
  3294. else {
  3295. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  3296. }
  3297. }
  3298. else { // means "clear the end"
  3299. standardProps.hasEnd = false;
  3300. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  3301. }
  3302. }
  3303. };
  3304. EventApi.prototype.moveStart = function (deltaInput) {
  3305. var delta = createDuration(deltaInput);
  3306. if (delta) { // TODO: warning if parsed bad
  3307. this.mutate({ startDelta: delta });
  3308. }
  3309. };
  3310. EventApi.prototype.moveEnd = function (deltaInput) {
  3311. var delta = createDuration(deltaInput);
  3312. if (delta) { // TODO: warning if parsed bad
  3313. this.mutate({ endDelta: delta });
  3314. }
  3315. };
  3316. EventApi.prototype.moveDates = function (deltaInput) {
  3317. var delta = createDuration(deltaInput);
  3318. if (delta) { // TODO: warning if parsed bad
  3319. this.mutate({ datesDelta: delta });
  3320. }
  3321. };
  3322. EventApi.prototype.setAllDay = function (allDay, options) {
  3323. if (options === void 0) { options = {}; }
  3324. var standardProps = { allDay: allDay };
  3325. var maintainDuration = options.maintainDuration;
  3326. if (maintainDuration == null) {
  3327. maintainDuration = this._context.options.allDayMaintainDuration;
  3328. }
  3329. if (this._def.allDay !== allDay) {
  3330. standardProps.hasEnd = maintainDuration;
  3331. }
  3332. this.mutate({ standardProps: standardProps });
  3333. };
  3334. EventApi.prototype.formatRange = function (formatInput) {
  3335. var dateEnv = this._context.dateEnv;
  3336. var instance = this._instance;
  3337. var formatter = createFormatter(formatInput);
  3338. if (this._def.hasEnd) {
  3339. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  3340. forcedStartTzo: instance.forcedStartTzo,
  3341. forcedEndTzo: instance.forcedEndTzo,
  3342. });
  3343. }
  3344. return dateEnv.format(instance.range.start, formatter, {
  3345. forcedTzo: instance.forcedStartTzo,
  3346. });
  3347. };
  3348. EventApi.prototype.mutate = function (mutation) {
  3349. var instance = this._instance;
  3350. if (instance) {
  3351. var def = this._def;
  3352. var context_1 = this._context;
  3353. var eventStore = context_1.getCurrentData().eventStore;
  3354. var relevantEvents_1 = getRelevantEvents(eventStore, instance.instanceId);
  3355. var eventConfigBase = {
  3356. '': {
  3357. display: '',
  3358. startEditable: true,
  3359. durationEditable: true,
  3360. constraints: [],
  3361. overlap: null,
  3362. allows: [],
  3363. backgroundColor: '',
  3364. borderColor: '',
  3365. textColor: '',
  3366. classNames: [],
  3367. },
  3368. };
  3369. relevantEvents_1 = applyMutationToEventStore(relevantEvents_1, eventConfigBase, mutation, context_1);
  3370. var oldEvent = new EventApi(context_1, def, instance); // snapshot
  3371. this._def = relevantEvents_1.defs[def.defId];
  3372. this._instance = relevantEvents_1.instances[instance.instanceId];
  3373. context_1.dispatch({
  3374. type: 'MERGE_EVENTS',
  3375. eventStore: relevantEvents_1,
  3376. });
  3377. context_1.emitter.trigger('eventChange', {
  3378. oldEvent: oldEvent,
  3379. event: this,
  3380. relatedEvents: buildEventApis(relevantEvents_1, context_1, instance),
  3381. revert: function () {
  3382. context_1.dispatch({
  3383. type: 'REMOVE_EVENTS',
  3384. eventStore: relevantEvents_1,
  3385. });
  3386. },
  3387. });
  3388. }
  3389. };
  3390. EventApi.prototype.remove = function () {
  3391. var context = this._context;
  3392. var asStore = eventApiToStore(this);
  3393. context.dispatch({
  3394. type: 'REMOVE_EVENTS',
  3395. eventStore: asStore,
  3396. });
  3397. context.emitter.trigger('eventRemove', {
  3398. event: this,
  3399. relatedEvents: [],
  3400. revert: function () {
  3401. context.dispatch({
  3402. type: 'MERGE_EVENTS',
  3403. eventStore: asStore,
  3404. });
  3405. },
  3406. });
  3407. };
  3408. Object.defineProperty(EventApi.prototype, "source", {
  3409. get: function () {
  3410. var sourceId = this._def.sourceId;
  3411. if (sourceId) {
  3412. return new EventSourceApi(this._context, this._context.getCurrentData().eventSources[sourceId]);
  3413. }
  3414. return null;
  3415. },
  3416. enumerable: false,
  3417. configurable: true
  3418. });
  3419. Object.defineProperty(EventApi.prototype, "start", {
  3420. get: function () {
  3421. return this._instance ?
  3422. this._context.dateEnv.toDate(this._instance.range.start) :
  3423. null;
  3424. },
  3425. enumerable: false,
  3426. configurable: true
  3427. });
  3428. Object.defineProperty(EventApi.prototype, "end", {
  3429. get: function () {
  3430. return (this._instance && this._def.hasEnd) ?
  3431. this._context.dateEnv.toDate(this._instance.range.end) :
  3432. null;
  3433. },
  3434. enumerable: false,
  3435. configurable: true
  3436. });
  3437. Object.defineProperty(EventApi.prototype, "startStr", {
  3438. get: function () {
  3439. var instance = this._instance;
  3440. if (instance) {
  3441. return this._context.dateEnv.formatIso(instance.range.start, {
  3442. omitTime: this._def.allDay,
  3443. forcedTzo: instance.forcedStartTzo,
  3444. });
  3445. }
  3446. return '';
  3447. },
  3448. enumerable: false,
  3449. configurable: true
  3450. });
  3451. Object.defineProperty(EventApi.prototype, "endStr", {
  3452. get: function () {
  3453. var instance = this._instance;
  3454. if (instance && this._def.hasEnd) {
  3455. return this._context.dateEnv.formatIso(instance.range.end, {
  3456. omitTime: this._def.allDay,
  3457. forcedTzo: instance.forcedEndTzo,
  3458. });
  3459. }
  3460. return '';
  3461. },
  3462. enumerable: false,
  3463. configurable: true
  3464. });
  3465. Object.defineProperty(EventApi.prototype, "id", {
  3466. // computable props that all access the def
  3467. // TODO: find a TypeScript-compatible way to do this at scale
  3468. get: function () { return this._def.publicId; },
  3469. enumerable: false,
  3470. configurable: true
  3471. });
  3472. Object.defineProperty(EventApi.prototype, "groupId", {
  3473. get: function () { return this._def.groupId; },
  3474. enumerable: false,
  3475. configurable: true
  3476. });
  3477. Object.defineProperty(EventApi.prototype, "allDay", {
  3478. get: function () { return this._def.allDay; },
  3479. enumerable: false,
  3480. configurable: true
  3481. });
  3482. Object.defineProperty(EventApi.prototype, "title", {
  3483. get: function () { return this._def.title; },
  3484. enumerable: false,
  3485. configurable: true
  3486. });
  3487. Object.defineProperty(EventApi.prototype, "url", {
  3488. get: function () { return this._def.url; },
  3489. enumerable: false,
  3490. configurable: true
  3491. });
  3492. Object.defineProperty(EventApi.prototype, "display", {
  3493. get: function () { return this._def.ui.display || 'auto'; } // bad. just normalize the type earlier
  3494. ,
  3495. enumerable: false,
  3496. configurable: true
  3497. });
  3498. Object.defineProperty(EventApi.prototype, "startEditable", {
  3499. get: function () { return this._def.ui.startEditable; },
  3500. enumerable: false,
  3501. configurable: true
  3502. });
  3503. Object.defineProperty(EventApi.prototype, "durationEditable", {
  3504. get: function () { return this._def.ui.durationEditable; },
  3505. enumerable: false,
  3506. configurable: true
  3507. });
  3508. Object.defineProperty(EventApi.prototype, "constraint", {
  3509. get: function () { return this._def.ui.constraints[0] || null; },
  3510. enumerable: false,
  3511. configurable: true
  3512. });
  3513. Object.defineProperty(EventApi.prototype, "overlap", {
  3514. get: function () { return this._def.ui.overlap; },
  3515. enumerable: false,
  3516. configurable: true
  3517. });
  3518. Object.defineProperty(EventApi.prototype, "allow", {
  3519. get: function () { return this._def.ui.allows[0] || null; },
  3520. enumerable: false,
  3521. configurable: true
  3522. });
  3523. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  3524. get: function () { return this._def.ui.backgroundColor; },
  3525. enumerable: false,
  3526. configurable: true
  3527. });
  3528. Object.defineProperty(EventApi.prototype, "borderColor", {
  3529. get: function () { return this._def.ui.borderColor; },
  3530. enumerable: false,
  3531. configurable: true
  3532. });
  3533. Object.defineProperty(EventApi.prototype, "textColor", {
  3534. get: function () { return this._def.ui.textColor; },
  3535. enumerable: false,
  3536. configurable: true
  3537. });
  3538. Object.defineProperty(EventApi.prototype, "classNames", {
  3539. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  3540. get: function () { return this._def.ui.classNames; },
  3541. enumerable: false,
  3542. configurable: true
  3543. });
  3544. Object.defineProperty(EventApi.prototype, "extendedProps", {
  3545. get: function () { return this._def.extendedProps; },
  3546. enumerable: false,
  3547. configurable: true
  3548. });
  3549. EventApi.prototype.toPlainObject = function (settings) {
  3550. if (settings === void 0) { settings = {}; }
  3551. var def = this._def;
  3552. var ui = def.ui;
  3553. var _a = this, startStr = _a.startStr, endStr = _a.endStr;
  3554. var res = {};
  3555. if (def.title) {
  3556. res.title = def.title;
  3557. }
  3558. if (startStr) {
  3559. res.start = startStr;
  3560. }
  3561. if (endStr) {
  3562. res.end = endStr;
  3563. }
  3564. if (def.publicId) {
  3565. res.id = def.publicId;
  3566. }
  3567. if (def.groupId) {
  3568. res.groupId = def.groupId;
  3569. }
  3570. if (def.url) {
  3571. res.url = def.url;
  3572. }
  3573. if (ui.display && ui.display !== 'auto') {
  3574. res.display = ui.display;
  3575. }
  3576. // TODO: what about recurring-event properties???
  3577. // TODO: include startEditable/durationEditable/constraint/overlap/allow
  3578. if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
  3579. res.color = ui.backgroundColor;
  3580. }
  3581. else {
  3582. if (ui.backgroundColor) {
  3583. res.backgroundColor = ui.backgroundColor;
  3584. }
  3585. if (ui.borderColor) {
  3586. res.borderColor = ui.borderColor;
  3587. }
  3588. }
  3589. if (ui.textColor) {
  3590. res.textColor = ui.textColor;
  3591. }
  3592. if (ui.classNames.length) {
  3593. res.classNames = ui.classNames;
  3594. }
  3595. if (Object.keys(def.extendedProps).length) {
  3596. if (settings.collapseExtendedProps) {
  3597. __assign(res, def.extendedProps);
  3598. }
  3599. else {
  3600. res.extendedProps = def.extendedProps;
  3601. }
  3602. }
  3603. return res;
  3604. };
  3605. EventApi.prototype.toJSON = function () {
  3606. return this.toPlainObject();
  3607. };
  3608. return EventApi;
  3609. }());
  3610. function eventApiToStore(eventApi) {
  3611. var _a, _b;
  3612. var def = eventApi._def;
  3613. var instance = eventApi._instance;
  3614. return {
  3615. defs: (_a = {}, _a[def.defId] = def, _a),
  3616. instances: instance
  3617. ? (_b = {}, _b[instance.instanceId] = instance, _b) : {},
  3618. };
  3619. }
  3620. function buildEventApis(eventStore, context, excludeInstance) {
  3621. var defs = eventStore.defs, instances = eventStore.instances;
  3622. var eventApis = [];
  3623. var excludeInstanceId = excludeInstance ? excludeInstance.instanceId : '';
  3624. for (var id in instances) {
  3625. var instance = instances[id];
  3626. var def = defs[instance.defId];
  3627. if (instance.instanceId !== excludeInstanceId) {
  3628. eventApis.push(new EventApi(context, def, instance));
  3629. }
  3630. }
  3631. return eventApis;
  3632. }
  3633. var calendarSystemClassMap = {};
  3634. function registerCalendarSystem(name, theClass) {
  3635. calendarSystemClassMap[name] = theClass;
  3636. }
  3637. function createCalendarSystem(name) {
  3638. return new calendarSystemClassMap[name]();
  3639. }
  3640. var GregorianCalendarSystem = /** @class */ (function () {
  3641. function GregorianCalendarSystem() {
  3642. }
  3643. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  3644. return d.getUTCFullYear();
  3645. };
  3646. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  3647. return d.getUTCMonth();
  3648. };
  3649. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  3650. return d.getUTCDate();
  3651. };
  3652. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  3653. return arrayToUtcDate(arr);
  3654. };
  3655. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  3656. return dateToUtcArray(marker);
  3657. };
  3658. return GregorianCalendarSystem;
  3659. }());
  3660. registerCalendarSystem('gregory', GregorianCalendarSystem);
  3661. var ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  3662. function parse(str) {
  3663. var m = ISO_RE.exec(str);
  3664. if (m) {
  3665. 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));
  3666. if (isValidDate(marker)) {
  3667. var timeZoneOffset = null;
  3668. if (m[13]) {
  3669. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  3670. Number(m[18] || 0));
  3671. }
  3672. return {
  3673. marker: marker,
  3674. isTimeUnspecified: !m[6],
  3675. timeZoneOffset: timeZoneOffset,
  3676. };
  3677. }
  3678. }
  3679. return null;
  3680. }
  3681. var DateEnv = /** @class */ (function () {
  3682. function DateEnv(settings) {
  3683. var timeZone = this.timeZone = settings.timeZone;
  3684. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  3685. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  3686. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  3687. }
  3688. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  3689. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  3690. this.locale = settings.locale;
  3691. this.weekDow = settings.locale.week.dow;
  3692. this.weekDoy = settings.locale.week.doy;
  3693. if (settings.weekNumberCalculation === 'ISO') {
  3694. this.weekDow = 1;
  3695. this.weekDoy = 4;
  3696. }
  3697. if (typeof settings.firstDay === 'number') {
  3698. this.weekDow = settings.firstDay;
  3699. }
  3700. if (typeof settings.weekNumberCalculation === 'function') {
  3701. this.weekNumberFunc = settings.weekNumberCalculation;
  3702. }
  3703. this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
  3704. this.cmdFormatter = settings.cmdFormatter;
  3705. this.defaultSeparator = settings.defaultSeparator;
  3706. }
  3707. // Creating / Parsing
  3708. DateEnv.prototype.createMarker = function (input) {
  3709. var meta = this.createMarkerMeta(input);
  3710. if (meta === null) {
  3711. return null;
  3712. }
  3713. return meta.marker;
  3714. };
  3715. DateEnv.prototype.createNowMarker = function () {
  3716. if (this.canComputeOffset) {
  3717. return this.timestampToMarker(new Date().valueOf());
  3718. }
  3719. // if we can't compute the current date val for a timezone,
  3720. // better to give the current local date vals than UTC
  3721. return arrayToUtcDate(dateToLocalArray(new Date()));
  3722. };
  3723. DateEnv.prototype.createMarkerMeta = function (input) {
  3724. if (typeof input === 'string') {
  3725. return this.parse(input);
  3726. }
  3727. var marker = null;
  3728. if (typeof input === 'number') {
  3729. marker = this.timestampToMarker(input);
  3730. }
  3731. else if (input instanceof Date) {
  3732. input = input.valueOf();
  3733. if (!isNaN(input)) {
  3734. marker = this.timestampToMarker(input);
  3735. }
  3736. }
  3737. else if (Array.isArray(input)) {
  3738. marker = arrayToUtcDate(input);
  3739. }
  3740. if (marker === null || !isValidDate(marker)) {
  3741. return null;
  3742. }
  3743. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  3744. };
  3745. DateEnv.prototype.parse = function (s) {
  3746. var parts = parse(s);
  3747. if (parts === null) {
  3748. return null;
  3749. }
  3750. var marker = parts.marker;
  3751. var forcedTzo = null;
  3752. if (parts.timeZoneOffset !== null) {
  3753. if (this.canComputeOffset) {
  3754. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  3755. }
  3756. else {
  3757. forcedTzo = parts.timeZoneOffset;
  3758. }
  3759. }
  3760. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  3761. };
  3762. // Accessors
  3763. DateEnv.prototype.getYear = function (marker) {
  3764. return this.calendarSystem.getMarkerYear(marker);
  3765. };
  3766. DateEnv.prototype.getMonth = function (marker) {
  3767. return this.calendarSystem.getMarkerMonth(marker);
  3768. };
  3769. // Adding / Subtracting
  3770. DateEnv.prototype.add = function (marker, dur) {
  3771. var a = this.calendarSystem.markerToArray(marker);
  3772. a[0] += dur.years;
  3773. a[1] += dur.months;
  3774. a[2] += dur.days;
  3775. a[6] += dur.milliseconds;
  3776. return this.calendarSystem.arrayToMarker(a);
  3777. };
  3778. DateEnv.prototype.subtract = function (marker, dur) {
  3779. var a = this.calendarSystem.markerToArray(marker);
  3780. a[0] -= dur.years;
  3781. a[1] -= dur.months;
  3782. a[2] -= dur.days;
  3783. a[6] -= dur.milliseconds;
  3784. return this.calendarSystem.arrayToMarker(a);
  3785. };
  3786. DateEnv.prototype.addYears = function (marker, n) {
  3787. var a = this.calendarSystem.markerToArray(marker);
  3788. a[0] += n;
  3789. return this.calendarSystem.arrayToMarker(a);
  3790. };
  3791. DateEnv.prototype.addMonths = function (marker, n) {
  3792. var a = this.calendarSystem.markerToArray(marker);
  3793. a[1] += n;
  3794. return this.calendarSystem.arrayToMarker(a);
  3795. };
  3796. // Diffing Whole Units
  3797. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  3798. var calendarSystem = this.calendarSystem;
  3799. if (timeAsMs(m0) === timeAsMs(m1) &&
  3800. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  3801. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  3802. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  3803. }
  3804. return null;
  3805. };
  3806. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  3807. var calendarSystem = this.calendarSystem;
  3808. if (timeAsMs(m0) === timeAsMs(m1) &&
  3809. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  3810. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  3811. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  3812. }
  3813. return null;
  3814. };
  3815. // Range / Duration
  3816. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  3817. var n = this.diffWholeYears(m0, m1);
  3818. if (n !== null) {
  3819. return { unit: 'year', value: n };
  3820. }
  3821. n = this.diffWholeMonths(m0, m1);
  3822. if (n !== null) {
  3823. return { unit: 'month', value: n };
  3824. }
  3825. n = diffWholeWeeks(m0, m1);
  3826. if (n !== null) {
  3827. return { unit: 'week', value: n };
  3828. }
  3829. n = diffWholeDays(m0, m1);
  3830. if (n !== null) {
  3831. return { unit: 'day', value: n };
  3832. }
  3833. n = diffHours(m0, m1);
  3834. if (isInt(n)) {
  3835. return { unit: 'hour', value: n };
  3836. }
  3837. n = diffMinutes(m0, m1);
  3838. if (isInt(n)) {
  3839. return { unit: 'minute', value: n };
  3840. }
  3841. n = diffSeconds(m0, m1);
  3842. if (isInt(n)) {
  3843. return { unit: 'second', value: n };
  3844. }
  3845. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  3846. };
  3847. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  3848. // TODO: can use greatestWholeUnit
  3849. var diff;
  3850. if (d.years) {
  3851. diff = this.diffWholeYears(m0, m1);
  3852. if (diff !== null) {
  3853. return diff / asRoughYears(d);
  3854. }
  3855. }
  3856. if (d.months) {
  3857. diff = this.diffWholeMonths(m0, m1);
  3858. if (diff !== null) {
  3859. return diff / asRoughMonths(d);
  3860. }
  3861. }
  3862. if (d.days) {
  3863. diff = diffWholeDays(m0, m1);
  3864. if (diff !== null) {
  3865. return diff / asRoughDays(d);
  3866. }
  3867. }
  3868. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  3869. };
  3870. // Start-Of
  3871. // these DON'T return zoned-dates. only UTC start-of dates
  3872. DateEnv.prototype.startOf = function (m, unit) {
  3873. if (unit === 'year') {
  3874. return this.startOfYear(m);
  3875. }
  3876. if (unit === 'month') {
  3877. return this.startOfMonth(m);
  3878. }
  3879. if (unit === 'week') {
  3880. return this.startOfWeek(m);
  3881. }
  3882. if (unit === 'day') {
  3883. return startOfDay(m);
  3884. }
  3885. if (unit === 'hour') {
  3886. return startOfHour(m);
  3887. }
  3888. if (unit === 'minute') {
  3889. return startOfMinute(m);
  3890. }
  3891. if (unit === 'second') {
  3892. return startOfSecond(m);
  3893. }
  3894. return null;
  3895. };
  3896. DateEnv.prototype.startOfYear = function (m) {
  3897. return this.calendarSystem.arrayToMarker([
  3898. this.calendarSystem.getMarkerYear(m),
  3899. ]);
  3900. };
  3901. DateEnv.prototype.startOfMonth = function (m) {
  3902. return this.calendarSystem.arrayToMarker([
  3903. this.calendarSystem.getMarkerYear(m),
  3904. this.calendarSystem.getMarkerMonth(m),
  3905. ]);
  3906. };
  3907. DateEnv.prototype.startOfWeek = function (m) {
  3908. return this.calendarSystem.arrayToMarker([
  3909. this.calendarSystem.getMarkerYear(m),
  3910. this.calendarSystem.getMarkerMonth(m),
  3911. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7),
  3912. ]);
  3913. };
  3914. // Week Number
  3915. DateEnv.prototype.computeWeekNumber = function (marker) {
  3916. if (this.weekNumberFunc) {
  3917. return this.weekNumberFunc(this.toDate(marker));
  3918. }
  3919. return weekOfYear(marker, this.weekDow, this.weekDoy);
  3920. };
  3921. // TODO: choke on timeZoneName: long
  3922. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  3923. if (dateOptions === void 0) { dateOptions = {}; }
  3924. return formatter.format({
  3925. marker: marker,
  3926. timeZoneOffset: dateOptions.forcedTzo != null ?
  3927. dateOptions.forcedTzo :
  3928. this.offsetForMarker(marker),
  3929. }, this);
  3930. };
  3931. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  3932. if (dateOptions === void 0) { dateOptions = {}; }
  3933. if (dateOptions.isEndExclusive) {
  3934. end = addMs(end, -1);
  3935. }
  3936. return formatter.formatRange({
  3937. marker: start,
  3938. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  3939. dateOptions.forcedStartTzo :
  3940. this.offsetForMarker(start),
  3941. }, {
  3942. marker: end,
  3943. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  3944. dateOptions.forcedEndTzo :
  3945. this.offsetForMarker(end),
  3946. }, this, dateOptions.defaultSeparator);
  3947. };
  3948. /*
  3949. DUMB: the omitTime arg is dumb. if we omit the time, we want to omit the timezone offset. and if we do that,
  3950. might as well use buildIsoString or some other util directly
  3951. */
  3952. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  3953. if (extraOptions === void 0) { extraOptions = {}; }
  3954. var timeZoneOffset = null;
  3955. if (!extraOptions.omitTimeZoneOffset) {
  3956. if (extraOptions.forcedTzo != null) {
  3957. timeZoneOffset = extraOptions.forcedTzo;
  3958. }
  3959. else {
  3960. timeZoneOffset = this.offsetForMarker(marker);
  3961. }
  3962. }
  3963. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  3964. };
  3965. // TimeZone
  3966. DateEnv.prototype.timestampToMarker = function (ms) {
  3967. if (this.timeZone === 'local') {
  3968. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  3969. }
  3970. if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  3971. return new Date(ms);
  3972. }
  3973. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  3974. };
  3975. DateEnv.prototype.offsetForMarker = function (m) {
  3976. if (this.timeZone === 'local') {
  3977. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  3978. }
  3979. if (this.timeZone === 'UTC') {
  3980. return 0;
  3981. }
  3982. if (this.namedTimeZoneImpl) {
  3983. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  3984. }
  3985. return null;
  3986. };
  3987. // Conversion
  3988. DateEnv.prototype.toDate = function (m, forcedTzo) {
  3989. if (this.timeZone === 'local') {
  3990. return arrayToLocalDate(dateToUtcArray(m));
  3991. }
  3992. if (this.timeZone === 'UTC') {
  3993. return new Date(m.valueOf()); // make sure it's a copy
  3994. }
  3995. if (!this.namedTimeZoneImpl) {
  3996. return new Date(m.valueOf() - (forcedTzo || 0));
  3997. }
  3998. return new Date(m.valueOf() -
  3999. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60);
  4000. };
  4001. return DateEnv;
  4002. }());
  4003. var globalLocales = [];
  4004. var RAW_EN_LOCALE = {
  4005. code: 'en',
  4006. week: {
  4007. dow: 0,
  4008. doy: 4,
  4009. },
  4010. direction: 'ltr',
  4011. buttonText: {
  4012. prev: 'prev',
  4013. next: 'next',
  4014. prevYear: 'prev year',
  4015. nextYear: 'next year',
  4016. year: 'year',
  4017. today: 'today',
  4018. month: 'month',
  4019. week: 'week',
  4020. day: 'day',
  4021. list: 'list',
  4022. },
  4023. weekText: 'W',
  4024. allDayText: 'all-day',
  4025. moreLinkText: 'more',
  4026. noEventsText: 'No events to display',
  4027. };
  4028. function organizeRawLocales(explicitRawLocales) {
  4029. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4030. var allRawLocales = globalLocales.concat(explicitRawLocales);
  4031. var rawLocaleMap = {
  4032. en: RAW_EN_LOCALE,
  4033. };
  4034. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4035. var rawLocale = allRawLocales_1[_i];
  4036. rawLocaleMap[rawLocale.code] = rawLocale;
  4037. }
  4038. return {
  4039. map: rawLocaleMap,
  4040. defaultCode: defaultCode,
  4041. };
  4042. }
  4043. function buildLocale(inputSingular, available) {
  4044. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4045. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4046. }
  4047. return queryLocale(inputSingular, available);
  4048. }
  4049. function queryLocale(codeArg, available) {
  4050. var codes = [].concat(codeArg || []); // will convert to array
  4051. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4052. return parseLocale(codeArg, codes, raw);
  4053. }
  4054. function queryRawLocale(codes, available) {
  4055. for (var i = 0; i < codes.length; i += 1) {
  4056. var parts = codes[i].toLocaleLowerCase().split('-');
  4057. for (var j = parts.length; j > 0; j -= 1) {
  4058. var simpleId = parts.slice(0, j).join('-');
  4059. if (available[simpleId]) {
  4060. return available[simpleId];
  4061. }
  4062. }
  4063. }
  4064. return null;
  4065. }
  4066. function parseLocale(codeArg, codes, raw) {
  4067. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4068. delete merged.code; // don't want this part of the options
  4069. var week = merged.week;
  4070. delete merged.week;
  4071. return {
  4072. codeArg: codeArg,
  4073. codes: codes,
  4074. week: week,
  4075. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4076. options: merged,
  4077. };
  4078. }
  4079. function formatDate(dateInput, options) {
  4080. if (options === void 0) { options = {}; }
  4081. var dateEnv = buildDateEnv(options);
  4082. var formatter = createFormatter(options);
  4083. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  4084. if (!dateMeta) { // TODO: warning?
  4085. return '';
  4086. }
  4087. return dateEnv.format(dateMeta.marker, formatter, {
  4088. forcedTzo: dateMeta.forcedTzo,
  4089. });
  4090. }
  4091. function formatRange(startInput, endInput, options) {
  4092. var dateEnv = buildDateEnv(typeof options === 'object' && options ? options : {}); // pass in if non-null object
  4093. var formatter = createFormatter(options);
  4094. var startMeta = dateEnv.createMarkerMeta(startInput);
  4095. var endMeta = dateEnv.createMarkerMeta(endInput);
  4096. if (!startMeta || !endMeta) { // TODO: warning?
  4097. return '';
  4098. }
  4099. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  4100. forcedStartTzo: startMeta.forcedTzo,
  4101. forcedEndTzo: endMeta.forcedTzo,
  4102. isEndExclusive: options.isEndExclusive,
  4103. defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator,
  4104. });
  4105. }
  4106. // TODO: more DRY and optimized
  4107. function buildDateEnv(settings) {
  4108. var locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  4109. return new DateEnv(__assign(__assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale: locale }));
  4110. }
  4111. var DEF_DEFAULTS = {
  4112. startTime: '09:00',
  4113. endTime: '17:00',
  4114. daysOfWeek: [1, 2, 3, 4, 5],
  4115. display: 'inverse-background',
  4116. classNames: 'fc-non-business',
  4117. groupId: '_businessHours',
  4118. };
  4119. /*
  4120. TODO: pass around as EventDefHash!!!
  4121. */
  4122. function parseBusinessHours(input, context) {
  4123. return parseEvents(refineInputs(input), null, context);
  4124. }
  4125. function refineInputs(input) {
  4126. var rawDefs;
  4127. if (input === true) {
  4128. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  4129. }
  4130. else if (Array.isArray(input)) {
  4131. // if specifying an array, every sub-definition NEEDS a day-of-week
  4132. rawDefs = input.filter(function (rawDef) { return rawDef.daysOfWeek; });
  4133. }
  4134. else if (typeof input === 'object' && input) { // non-null object
  4135. rawDefs = [input];
  4136. }
  4137. else { // is probably false
  4138. rawDefs = [];
  4139. }
  4140. rawDefs = rawDefs.map(function (rawDef) { return (__assign(__assign({}, DEF_DEFAULTS), rawDef)); });
  4141. return rawDefs;
  4142. }
  4143. function pointInsideRect(point, rect) {
  4144. return point.left >= rect.left &&
  4145. point.left < rect.right &&
  4146. point.top >= rect.top &&
  4147. point.top < rect.bottom;
  4148. }
  4149. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  4150. function intersectRects(rect1, rect2) {
  4151. var res = {
  4152. left: Math.max(rect1.left, rect2.left),
  4153. right: Math.min(rect1.right, rect2.right),
  4154. top: Math.max(rect1.top, rect2.top),
  4155. bottom: Math.min(rect1.bottom, rect2.bottom),
  4156. };
  4157. if (res.left < res.right && res.top < res.bottom) {
  4158. return res;
  4159. }
  4160. return false;
  4161. }
  4162. function translateRect(rect, deltaX, deltaY) {
  4163. return {
  4164. left: rect.left + deltaX,
  4165. right: rect.right + deltaX,
  4166. top: rect.top + deltaY,
  4167. bottom: rect.bottom + deltaY,
  4168. };
  4169. }
  4170. // Returns a new point that will have been moved to reside within the given rectangle
  4171. function constrainPoint(point, rect) {
  4172. return {
  4173. left: Math.min(Math.max(point.left, rect.left), rect.right),
  4174. top: Math.min(Math.max(point.top, rect.top), rect.bottom),
  4175. };
  4176. }
  4177. // Returns a point that is the center of the given rectangle
  4178. function getRectCenter(rect) {
  4179. return {
  4180. left: (rect.left + rect.right) / 2,
  4181. top: (rect.top + rect.bottom) / 2,
  4182. };
  4183. }
  4184. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  4185. function diffPoints(point1, point2) {
  4186. return {
  4187. left: point1.left - point2.left,
  4188. top: point1.top - point2.top,
  4189. };
  4190. }
  4191. var canVGrowWithinCell;
  4192. function getCanVGrowWithinCell() {
  4193. if (canVGrowWithinCell == null) {
  4194. canVGrowWithinCell = computeCanVGrowWithinCell();
  4195. }
  4196. return canVGrowWithinCell;
  4197. }
  4198. function computeCanVGrowWithinCell() {
  4199. // for SSR, because this function is call immediately at top-level
  4200. // TODO: just make this logic execute top-level, immediately, instead of doing lazily
  4201. if (typeof document === 'undefined') {
  4202. return true;
  4203. }
  4204. var el = document.createElement('div');
  4205. el.style.position = 'absolute';
  4206. el.style.top = '0px';
  4207. el.style.left = '0px';
  4208. el.innerHTML = '<table><tr><td><div></div></td></tr></table>';
  4209. el.querySelector('table').style.height = '100px';
  4210. el.querySelector('div').style.height = '100%';
  4211. document.body.appendChild(el);
  4212. var div = el.querySelector('div');
  4213. var possible = div.offsetHeight > 0;
  4214. document.body.removeChild(el);
  4215. return possible;
  4216. }
  4217. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  4218. var Splitter = /** @class */ (function () {
  4219. function Splitter() {
  4220. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  4221. this.splitDateSelection = memoize(this._splitDateSpan);
  4222. this.splitEventStore = memoize(this._splitEventStore);
  4223. this.splitIndividualUi = memoize(this._splitIndividualUi);
  4224. this.splitEventDrag = memoize(this._splitInteraction);
  4225. this.splitEventResize = memoize(this._splitInteraction);
  4226. this.eventUiBuilders = {}; // TODO: typescript protection
  4227. }
  4228. Splitter.prototype.splitProps = function (props) {
  4229. var _this = this;
  4230. var keyInfos = this.getKeyInfo(props);
  4231. var defKeys = this.getKeysForEventDefs(props.eventStore);
  4232. var dateSelections = this.splitDateSelection(props.dateSelection);
  4233. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  4234. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  4235. var eventDrags = this.splitEventDrag(props.eventDrag);
  4236. var eventResizes = this.splitEventResize(props.eventResize);
  4237. var splitProps = {};
  4238. this.eventUiBuilders = mapHash(keyInfos, function (info, key) { return _this.eventUiBuilders[key] || memoize(buildEventUiForKey); });
  4239. for (var key in keyInfos) {
  4240. var keyInfo = keyInfos[key];
  4241. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  4242. var buildEventUi = this.eventUiBuilders[key];
  4243. splitProps[key] = {
  4244. businessHours: keyInfo.businessHours || props.businessHours,
  4245. dateSelection: dateSelections[key] || null,
  4246. eventStore: eventStore,
  4247. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  4248. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  4249. eventDrag: eventDrags[key] || null,
  4250. eventResize: eventResizes[key] || null,
  4251. };
  4252. }
  4253. return splitProps;
  4254. };
  4255. Splitter.prototype._splitDateSpan = function (dateSpan) {
  4256. var dateSpans = {};
  4257. if (dateSpan) {
  4258. var keys = this.getKeysForDateSpan(dateSpan);
  4259. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  4260. var key = keys_1[_i];
  4261. dateSpans[key] = dateSpan;
  4262. }
  4263. }
  4264. return dateSpans;
  4265. };
  4266. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  4267. var _this = this;
  4268. return mapHash(eventStore.defs, function (eventDef) { return _this.getKeysForEventDef(eventDef); });
  4269. };
  4270. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  4271. var defs = eventStore.defs, instances = eventStore.instances;
  4272. var splitStores = {};
  4273. for (var defId in defs) {
  4274. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4275. var key = _a[_i];
  4276. if (!splitStores[key]) {
  4277. splitStores[key] = createEmptyEventStore();
  4278. }
  4279. splitStores[key].defs[defId] = defs[defId];
  4280. }
  4281. }
  4282. for (var instanceId in instances) {
  4283. var instance = instances[instanceId];
  4284. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  4285. var key = _c[_b];
  4286. if (splitStores[key]) { // must have already been created
  4287. splitStores[key].instances[instanceId] = instance;
  4288. }
  4289. }
  4290. }
  4291. return splitStores;
  4292. };
  4293. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  4294. var splitHashes = {};
  4295. for (var defId in eventUiBases) {
  4296. if (defId) { // not the '' key
  4297. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  4298. var key = _a[_i];
  4299. if (!splitHashes[key]) {
  4300. splitHashes[key] = {};
  4301. }
  4302. splitHashes[key][defId] = eventUiBases[defId];
  4303. }
  4304. }
  4305. }
  4306. return splitHashes;
  4307. };
  4308. Splitter.prototype._splitInteraction = function (interaction) {
  4309. var splitStates = {};
  4310. if (interaction) {
  4311. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
  4312. // can't rely on defKeys because event data is mutated
  4313. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  4314. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  4315. var populate = function (key) {
  4316. if (!splitStates[key]) {
  4317. splitStates[key] = {
  4318. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  4319. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  4320. isEvent: interaction.isEvent,
  4321. };
  4322. }
  4323. };
  4324. for (var key in affectedStores_1) {
  4325. populate(key);
  4326. }
  4327. for (var key in mutatedStores_1) {
  4328. populate(key);
  4329. }
  4330. }
  4331. return splitStates;
  4332. };
  4333. return Splitter;
  4334. }());
  4335. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  4336. var baseParts = [];
  4337. if (allUi) {
  4338. baseParts.push(allUi);
  4339. }
  4340. if (eventUiForKey) {
  4341. baseParts.push(eventUiForKey);
  4342. }
  4343. var stuff = {
  4344. '': combineEventUis(baseParts),
  4345. };
  4346. if (individualUi) {
  4347. __assign(stuff, individualUi);
  4348. }
  4349. return stuff;
  4350. }
  4351. function getDateMeta(date, todayRange, nowDate, dateProfile) {
  4352. return {
  4353. dow: date.getUTCDay(),
  4354. isDisabled: Boolean(dateProfile && !rangeContainsMarker(dateProfile.activeRange, date)),
  4355. isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
  4356. isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
  4357. isPast: Boolean(nowDate ? (date < nowDate) : todayRange ? (date < todayRange.start) : false),
  4358. isFuture: Boolean(nowDate ? (date > nowDate) : todayRange ? (date >= todayRange.end) : false),
  4359. };
  4360. }
  4361. function getDayClassNames(meta, theme) {
  4362. var classNames = [
  4363. 'fc-day',
  4364. "fc-day-" + DAY_IDS[meta.dow],
  4365. ];
  4366. if (meta.isDisabled) {
  4367. classNames.push('fc-day-disabled');
  4368. }
  4369. else {
  4370. if (meta.isToday) {
  4371. classNames.push('fc-day-today');
  4372. classNames.push(theme.getClass('today'));
  4373. }
  4374. if (meta.isPast) {
  4375. classNames.push('fc-day-past');
  4376. }
  4377. if (meta.isFuture) {
  4378. classNames.push('fc-day-future');
  4379. }
  4380. if (meta.isOther) {
  4381. classNames.push('fc-day-other');
  4382. }
  4383. }
  4384. return classNames;
  4385. }
  4386. function getSlotClassNames(meta, theme) {
  4387. var classNames = [
  4388. 'fc-slot',
  4389. "fc-slot-" + DAY_IDS[meta.dow],
  4390. ];
  4391. if (meta.isDisabled) {
  4392. classNames.push('fc-slot-disabled');
  4393. }
  4394. else {
  4395. if (meta.isToday) {
  4396. classNames.push('fc-slot-today');
  4397. classNames.push(theme.getClass('today'));
  4398. }
  4399. if (meta.isPast) {
  4400. classNames.push('fc-slot-past');
  4401. }
  4402. if (meta.isFuture) {
  4403. classNames.push('fc-slot-future');
  4404. }
  4405. }
  4406. return classNames;
  4407. }
  4408. function buildNavLinkData(date, type) {
  4409. if (type === void 0) { type = 'day'; }
  4410. return JSON.stringify({
  4411. date: formatDayString(date),
  4412. type: type,
  4413. });
  4414. }
  4415. var _isRtlScrollbarOnLeft = null;
  4416. function getIsRtlScrollbarOnLeft() {
  4417. if (_isRtlScrollbarOnLeft === null) {
  4418. _isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  4419. }
  4420. return _isRtlScrollbarOnLeft;
  4421. }
  4422. function computeIsRtlScrollbarOnLeft() {
  4423. var outerEl = document.createElement('div');
  4424. applyStyle(outerEl, {
  4425. position: 'absolute',
  4426. top: -1000,
  4427. left: 0,
  4428. border: 0,
  4429. padding: 0,
  4430. overflow: 'scroll',
  4431. direction: 'rtl',
  4432. });
  4433. outerEl.innerHTML = '<div></div>';
  4434. document.body.appendChild(outerEl);
  4435. var innerEl = outerEl.firstChild;
  4436. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  4437. removeElement(outerEl);
  4438. return res;
  4439. }
  4440. var _scrollbarWidths;
  4441. function getScrollbarWidths() {
  4442. if (!_scrollbarWidths) {
  4443. _scrollbarWidths = computeScrollbarWidths();
  4444. }
  4445. return _scrollbarWidths;
  4446. }
  4447. function computeScrollbarWidths() {
  4448. var el = document.createElement('div');
  4449. el.style.overflow = 'scroll';
  4450. document.body.appendChild(el);
  4451. var res = computeScrollbarWidthsForEl(el);
  4452. document.body.removeChild(el);
  4453. return res;
  4454. }
  4455. // WARNING: will include border
  4456. function computeScrollbarWidthsForEl(el) {
  4457. return {
  4458. x: el.offsetHeight - el.clientHeight,
  4459. y: el.offsetWidth - el.clientWidth,
  4460. };
  4461. }
  4462. function computeEdges(el, getPadding) {
  4463. if (getPadding === void 0) { getPadding = false; }
  4464. var computedStyle = window.getComputedStyle(el);
  4465. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  4466. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  4467. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  4468. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  4469. var badScrollbarWidths = computeScrollbarWidthsForEl(el); // includes border!
  4470. var scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
  4471. var scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
  4472. var res = {
  4473. borderLeft: borderLeft,
  4474. borderRight: borderRight,
  4475. borderTop: borderTop,
  4476. borderBottom: borderBottom,
  4477. scrollbarBottom: scrollbarBottom,
  4478. scrollbarLeft: 0,
  4479. scrollbarRight: 0,
  4480. };
  4481. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  4482. res.scrollbarLeft = scrollbarLeftRight;
  4483. }
  4484. else {
  4485. res.scrollbarRight = scrollbarLeftRight;
  4486. }
  4487. if (getPadding) {
  4488. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  4489. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  4490. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  4491. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  4492. }
  4493. return res;
  4494. }
  4495. function computeInnerRect(el, goWithinPadding, doFromWindowViewport) {
  4496. if (goWithinPadding === void 0) { goWithinPadding = false; }
  4497. var outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
  4498. var edges = computeEdges(el, goWithinPadding);
  4499. var res = {
  4500. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  4501. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  4502. top: outerRect.top + edges.borderTop,
  4503. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom,
  4504. };
  4505. if (goWithinPadding) {
  4506. res.left += edges.paddingLeft;
  4507. res.right -= edges.paddingRight;
  4508. res.top += edges.paddingTop;
  4509. res.bottom -= edges.paddingBottom;
  4510. }
  4511. return res;
  4512. }
  4513. function computeRect(el) {
  4514. var rect = el.getBoundingClientRect();
  4515. return {
  4516. left: rect.left + window.pageXOffset,
  4517. top: rect.top + window.pageYOffset,
  4518. right: rect.right + window.pageXOffset,
  4519. bottom: rect.bottom + window.pageYOffset,
  4520. };
  4521. }
  4522. function computeHeightAndMargins(el) {
  4523. return el.getBoundingClientRect().height + computeVMargins(el);
  4524. }
  4525. function computeVMargins(el) {
  4526. var computed = window.getComputedStyle(el);
  4527. return parseInt(computed.marginTop, 10) +
  4528. parseInt(computed.marginBottom, 10);
  4529. }
  4530. // does not return window
  4531. function getClippingParents(el) {
  4532. var parents = [];
  4533. while (el instanceof HTMLElement) { // will stop when gets to document or null
  4534. var computedStyle = window.getComputedStyle(el);
  4535. if (computedStyle.position === 'fixed') {
  4536. break;
  4537. }
  4538. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  4539. parents.push(el);
  4540. }
  4541. el = el.parentNode;
  4542. }
  4543. return parents;
  4544. }
  4545. // given a function that resolves a result asynchronously.
  4546. // the function can either call passed-in success and failure callbacks,
  4547. // or it can return a promise.
  4548. // if you need to pass additional params to func, bind them first.
  4549. function unpromisify(func, success, failure) {
  4550. // guard against success/failure callbacks being called more than once
  4551. // and guard against a promise AND callback being used together.
  4552. var isResolved = false;
  4553. var wrappedSuccess = function () {
  4554. if (!isResolved) {
  4555. isResolved = true;
  4556. success.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4557. }
  4558. };
  4559. var wrappedFailure = function () {
  4560. if (!isResolved) {
  4561. isResolved = true;
  4562. if (failure) {
  4563. failure.apply(this, arguments); // eslint-disable-line prefer-rest-params
  4564. }
  4565. }
  4566. };
  4567. var res = func(wrappedSuccess, wrappedFailure);
  4568. if (res && typeof res.then === 'function') {
  4569. res.then(wrappedSuccess, wrappedFailure);
  4570. }
  4571. }
  4572. var Emitter = /** @class */ (function () {
  4573. function Emitter() {
  4574. this.handlers = {};
  4575. this.thisContext = null;
  4576. }
  4577. Emitter.prototype.setThisContext = function (thisContext) {
  4578. this.thisContext = thisContext;
  4579. };
  4580. Emitter.prototype.setOptions = function (options) {
  4581. this.options = options;
  4582. };
  4583. Emitter.prototype.on = function (type, handler) {
  4584. addToHash(this.handlers, type, handler);
  4585. };
  4586. Emitter.prototype.off = function (type, handler) {
  4587. removeFromHash(this.handlers, type, handler);
  4588. };
  4589. Emitter.prototype.trigger = function (type) {
  4590. var args = [];
  4591. for (var _i = 1; _i < arguments.length; _i++) {
  4592. args[_i - 1] = arguments[_i];
  4593. }
  4594. var attachedHandlers = this.handlers[type] || [];
  4595. var optionHandler = this.options && this.options[type];
  4596. var handlers = [].concat(optionHandler || [], attachedHandlers);
  4597. for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
  4598. var handler = handlers_1[_a];
  4599. handler.apply(this.thisContext, args);
  4600. }
  4601. };
  4602. Emitter.prototype.hasHandlers = function (type) {
  4603. return (this.handlers[type] && this.handlers[type].length) ||
  4604. (this.options && this.options[type]);
  4605. };
  4606. return Emitter;
  4607. }());
  4608. function addToHash(hash, type, handler) {
  4609. (hash[type] || (hash[type] = []))
  4610. .push(handler);
  4611. }
  4612. function removeFromHash(hash, type, handler) {
  4613. if (handler) {
  4614. if (hash[type]) {
  4615. hash[type] = hash[type].filter(function (func) { return func !== handler; });
  4616. }
  4617. }
  4618. else {
  4619. delete hash[type]; // remove all handler funcs for this type
  4620. }
  4621. }
  4622. /*
  4623. Records offset information for a set of elements, relative to an origin element.
  4624. Can record the left/right OR the top/bottom OR both.
  4625. Provides methods for querying the cache by position.
  4626. */
  4627. var PositionCache = /** @class */ (function () {
  4628. function PositionCache(originEl, els, isHorizontal, isVertical) {
  4629. this.els = els;
  4630. var originClientRect = this.originClientRect = originEl.getBoundingClientRect(); // relative to viewport top-left
  4631. if (isHorizontal) {
  4632. this.buildElHorizontals(originClientRect.left);
  4633. }
  4634. if (isVertical) {
  4635. this.buildElVerticals(originClientRect.top);
  4636. }
  4637. }
  4638. // Populates the left/right internal coordinate arrays
  4639. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  4640. var lefts = [];
  4641. var rights = [];
  4642. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4643. var el = _a[_i];
  4644. var rect = el.getBoundingClientRect();
  4645. lefts.push(rect.left - originClientLeft);
  4646. rights.push(rect.right - originClientLeft);
  4647. }
  4648. this.lefts = lefts;
  4649. this.rights = rights;
  4650. };
  4651. // Populates the top/bottom internal coordinate arrays
  4652. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  4653. var tops = [];
  4654. var bottoms = [];
  4655. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  4656. var el = _a[_i];
  4657. var rect = el.getBoundingClientRect();
  4658. tops.push(rect.top - originClientTop);
  4659. bottoms.push(rect.bottom - originClientTop);
  4660. }
  4661. this.tops = tops;
  4662. this.bottoms = bottoms;
  4663. };
  4664. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  4665. // If no intersection is made, returns undefined.
  4666. PositionCache.prototype.leftToIndex = function (leftPosition) {
  4667. var _a = this, lefts = _a.lefts, rights = _a.rights;
  4668. var len = lefts.length;
  4669. var i;
  4670. for (i = 0; i < len; i += 1) {
  4671. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  4672. return i;
  4673. }
  4674. }
  4675. return undefined; // TODO: better
  4676. };
  4677. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  4678. // If no intersection is made, returns undefined.
  4679. PositionCache.prototype.topToIndex = function (topPosition) {
  4680. var _a = this, tops = _a.tops, bottoms = _a.bottoms;
  4681. var len = tops.length;
  4682. var i;
  4683. for (i = 0; i < len; i += 1) {
  4684. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  4685. return i;
  4686. }
  4687. }
  4688. return undefined; // TODO: better
  4689. };
  4690. // Gets the width of the element at the given index
  4691. PositionCache.prototype.getWidth = function (leftIndex) {
  4692. return this.rights[leftIndex] - this.lefts[leftIndex];
  4693. };
  4694. // Gets the height of the element at the given index
  4695. PositionCache.prototype.getHeight = function (topIndex) {
  4696. return this.bottoms[topIndex] - this.tops[topIndex];
  4697. };
  4698. return PositionCache;
  4699. }());
  4700. /* eslint max-classes-per-file: "off" */
  4701. /*
  4702. An object for getting/setting scroll-related information for an element.
  4703. Internally, this is done very differently for window versus DOM element,
  4704. so this object serves as a common interface.
  4705. */
  4706. var ScrollController = /** @class */ (function () {
  4707. function ScrollController() {
  4708. }
  4709. ScrollController.prototype.getMaxScrollTop = function () {
  4710. return this.getScrollHeight() - this.getClientHeight();
  4711. };
  4712. ScrollController.prototype.getMaxScrollLeft = function () {
  4713. return this.getScrollWidth() - this.getClientWidth();
  4714. };
  4715. ScrollController.prototype.canScrollVertically = function () {
  4716. return this.getMaxScrollTop() > 0;
  4717. };
  4718. ScrollController.prototype.canScrollHorizontally = function () {
  4719. return this.getMaxScrollLeft() > 0;
  4720. };
  4721. ScrollController.prototype.canScrollUp = function () {
  4722. return this.getScrollTop() > 0;
  4723. };
  4724. ScrollController.prototype.canScrollDown = function () {
  4725. return this.getScrollTop() < this.getMaxScrollTop();
  4726. };
  4727. ScrollController.prototype.canScrollLeft = function () {
  4728. return this.getScrollLeft() > 0;
  4729. };
  4730. ScrollController.prototype.canScrollRight = function () {
  4731. return this.getScrollLeft() < this.getMaxScrollLeft();
  4732. };
  4733. return ScrollController;
  4734. }());
  4735. var ElementScrollController = /** @class */ (function (_super) {
  4736. __extends(ElementScrollController, _super);
  4737. function ElementScrollController(el) {
  4738. var _this = _super.call(this) || this;
  4739. _this.el = el;
  4740. return _this;
  4741. }
  4742. ElementScrollController.prototype.getScrollTop = function () {
  4743. return this.el.scrollTop;
  4744. };
  4745. ElementScrollController.prototype.getScrollLeft = function () {
  4746. return this.el.scrollLeft;
  4747. };
  4748. ElementScrollController.prototype.setScrollTop = function (top) {
  4749. this.el.scrollTop = top;
  4750. };
  4751. ElementScrollController.prototype.setScrollLeft = function (left) {
  4752. this.el.scrollLeft = left;
  4753. };
  4754. ElementScrollController.prototype.getScrollWidth = function () {
  4755. return this.el.scrollWidth;
  4756. };
  4757. ElementScrollController.prototype.getScrollHeight = function () {
  4758. return this.el.scrollHeight;
  4759. };
  4760. ElementScrollController.prototype.getClientHeight = function () {
  4761. return this.el.clientHeight;
  4762. };
  4763. ElementScrollController.prototype.getClientWidth = function () {
  4764. return this.el.clientWidth;
  4765. };
  4766. return ElementScrollController;
  4767. }(ScrollController));
  4768. var WindowScrollController = /** @class */ (function (_super) {
  4769. __extends(WindowScrollController, _super);
  4770. function WindowScrollController() {
  4771. return _super !== null && _super.apply(this, arguments) || this;
  4772. }
  4773. WindowScrollController.prototype.getScrollTop = function () {
  4774. return window.pageYOffset;
  4775. };
  4776. WindowScrollController.prototype.getScrollLeft = function () {
  4777. return window.pageXOffset;
  4778. };
  4779. WindowScrollController.prototype.setScrollTop = function (n) {
  4780. window.scroll(window.pageXOffset, n);
  4781. };
  4782. WindowScrollController.prototype.setScrollLeft = function (n) {
  4783. window.scroll(n, window.pageYOffset);
  4784. };
  4785. WindowScrollController.prototype.getScrollWidth = function () {
  4786. return document.documentElement.scrollWidth;
  4787. };
  4788. WindowScrollController.prototype.getScrollHeight = function () {
  4789. return document.documentElement.scrollHeight;
  4790. };
  4791. WindowScrollController.prototype.getClientHeight = function () {
  4792. return document.documentElement.clientHeight;
  4793. };
  4794. WindowScrollController.prototype.getClientWidth = function () {
  4795. return document.documentElement.clientWidth;
  4796. };
  4797. return WindowScrollController;
  4798. }(ScrollController));
  4799. var Theme = /** @class */ (function () {
  4800. function Theme(calendarOptions) {
  4801. if (this.iconOverrideOption) {
  4802. this.setIconOverride(calendarOptions[this.iconOverrideOption]);
  4803. }
  4804. }
  4805. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  4806. var iconClassesCopy;
  4807. var buttonName;
  4808. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  4809. iconClassesCopy = __assign({}, this.iconClasses);
  4810. for (buttonName in iconOverrideHash) {
  4811. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  4812. }
  4813. this.iconClasses = iconClassesCopy;
  4814. }
  4815. else if (iconOverrideHash === false) {
  4816. this.iconClasses = {};
  4817. }
  4818. };
  4819. Theme.prototype.applyIconOverridePrefix = function (className) {
  4820. var prefix = this.iconOverridePrefix;
  4821. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  4822. className = prefix + className;
  4823. }
  4824. return className;
  4825. };
  4826. Theme.prototype.getClass = function (key) {
  4827. return this.classes[key] || '';
  4828. };
  4829. Theme.prototype.getIconClass = function (buttonName, isRtl) {
  4830. var className;
  4831. if (isRtl && this.rtlIconClasses) {
  4832. className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
  4833. }
  4834. else {
  4835. className = this.iconClasses[buttonName];
  4836. }
  4837. if (className) {
  4838. return this.baseIconClass + " " + className;
  4839. }
  4840. return '';
  4841. };
  4842. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  4843. var className;
  4844. if (this.iconOverrideCustomButtonOption) {
  4845. className = customButtonProps[this.iconOverrideCustomButtonOption];
  4846. if (className) {
  4847. return this.baseIconClass + " " + this.applyIconOverridePrefix(className);
  4848. }
  4849. }
  4850. return '';
  4851. };
  4852. return Theme;
  4853. }());
  4854. Theme.prototype.classes = {};
  4855. Theme.prototype.iconClasses = {};
  4856. Theme.prototype.baseIconClass = '';
  4857. Theme.prototype.iconOverridePrefix = '';
  4858. /// <reference types="@fullcalendar/core-preact" />
  4859. if (typeof FullCalendarVDom === 'undefined') {
  4860. throw new Error('Please import the top-level fullcalendar lib before attempting to import a plugin.');
  4861. }
  4862. var Component = FullCalendarVDom.Component;
  4863. var createElement = FullCalendarVDom.createElement;
  4864. var render = FullCalendarVDom.render;
  4865. var createRef = FullCalendarVDom.createRef;
  4866. var Fragment = FullCalendarVDom.Fragment;
  4867. var createContext$1 = FullCalendarVDom.createContext;
  4868. var flushToDom$1 = FullCalendarVDom.flushToDom;
  4869. var unmountComponentAtNode$1 = FullCalendarVDom.unmountComponentAtNode;
  4870. var ScrollResponder = /** @class */ (function () {
  4871. function ScrollResponder(execFunc, emitter, scrollTime) {
  4872. var _this = this;
  4873. this.execFunc = execFunc;
  4874. this.emitter = emitter;
  4875. this.scrollTime = scrollTime;
  4876. this.handleScrollRequest = function (request) {
  4877. _this.queuedRequest = __assign({}, _this.queuedRequest || {}, request);
  4878. _this.drain();
  4879. };
  4880. emitter.on('_scrollRequest', this.handleScrollRequest);
  4881. this.fireInitialScroll();
  4882. }
  4883. ScrollResponder.prototype.detach = function () {
  4884. this.emitter.off('_scrollRequest', this.handleScrollRequest);
  4885. };
  4886. ScrollResponder.prototype.update = function (isDatesNew) {
  4887. if (isDatesNew) {
  4888. this.fireInitialScroll(); // will drain
  4889. }
  4890. else {
  4891. this.drain();
  4892. }
  4893. };
  4894. ScrollResponder.prototype.fireInitialScroll = function () {
  4895. this.handleScrollRequest({
  4896. time: this.scrollTime,
  4897. });
  4898. };
  4899. ScrollResponder.prototype.drain = function () {
  4900. if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
  4901. this.queuedRequest = null;
  4902. }
  4903. };
  4904. return ScrollResponder;
  4905. }());
  4906. var ViewContextType = createContext$1({}); // for Components
  4907. function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
  4908. return {
  4909. dateEnv: dateEnv,
  4910. options: viewOptions,
  4911. pluginHooks: pluginHooks,
  4912. emitter: emitter,
  4913. dispatch: dispatch,
  4914. getCurrentData: getCurrentData,
  4915. calendarApi: calendarApi,
  4916. viewSpec: viewSpec,
  4917. viewApi: viewApi,
  4918. dateProfileGenerator: dateProfileGenerator,
  4919. theme: theme,
  4920. isRtl: viewOptions.direction === 'rtl',
  4921. addResizeHandler: function (handler) {
  4922. emitter.on('_resize', handler);
  4923. },
  4924. removeResizeHandler: function (handler) {
  4925. emitter.off('_resize', handler);
  4926. },
  4927. createScrollResponder: function (execFunc) {
  4928. return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime));
  4929. },
  4930. registerInteractiveComponent: registerInteractiveComponent,
  4931. unregisterInteractiveComponent: unregisterInteractiveComponent,
  4932. };
  4933. }
  4934. /* eslint max-classes-per-file: off */
  4935. var PureComponent = /** @class */ (function (_super) {
  4936. __extends(PureComponent, _super);
  4937. function PureComponent() {
  4938. return _super !== null && _super.apply(this, arguments) || this;
  4939. }
  4940. PureComponent.prototype.shouldComponentUpdate = function (nextProps, nextState) {
  4941. if (this.debug) {
  4942. // eslint-disable-next-line no-console
  4943. console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
  4944. }
  4945. return !compareObjs(this.props, nextProps, this.propEquality) ||
  4946. !compareObjs(this.state, nextState, this.stateEquality);
  4947. };
  4948. PureComponent.addPropsEquality = addPropsEquality;
  4949. PureComponent.addStateEquality = addStateEquality;
  4950. PureComponent.contextType = ViewContextType;
  4951. return PureComponent;
  4952. }(Component));
  4953. PureComponent.prototype.propEquality = {};
  4954. PureComponent.prototype.stateEquality = {};
  4955. var BaseComponent = /** @class */ (function (_super) {
  4956. __extends(BaseComponent, _super);
  4957. function BaseComponent() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. BaseComponent.contextType = ViewContextType;
  4961. return BaseComponent;
  4962. }(PureComponent));
  4963. function addPropsEquality(propEquality) {
  4964. var hash = Object.create(this.prototype.propEquality);
  4965. __assign(hash, propEquality);
  4966. this.prototype.propEquality = hash;
  4967. }
  4968. function addStateEquality(stateEquality) {
  4969. var hash = Object.create(this.prototype.stateEquality);
  4970. __assign(hash, stateEquality);
  4971. this.prototype.stateEquality = hash;
  4972. }
  4973. // use other one
  4974. function setRef(ref, current) {
  4975. if (typeof ref === 'function') {
  4976. ref(current);
  4977. }
  4978. else if (ref) {
  4979. // see https://github.com/facebook/react/issues/13029
  4980. ref.current = current;
  4981. }
  4982. }
  4983. function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
  4984. switch (action.type) {
  4985. case 'RECEIVE_EVENTS': // raw
  4986. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
  4987. case 'ADD_EVENTS': // already parsed, but not expanded
  4988. return addEvent(eventStore, action.eventStore, // new ones
  4989. dateProfile ? dateProfile.activeRange : null, context);
  4990. case 'MERGE_EVENTS': // already parsed and expanded
  4991. return mergeEventStores(eventStore, action.eventStore);
  4992. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  4993. case 'NEXT':
  4994. case 'CHANGE_DATE':
  4995. case 'CHANGE_VIEW_TYPE':
  4996. if (dateProfile) {
  4997. return expandRecurring(eventStore, dateProfile.activeRange, context);
  4998. }
  4999. return eventStore;
  5000. case 'REMOVE_EVENTS':
  5001. return excludeSubEventStore(eventStore, action.eventStore);
  5002. case 'REMOVE_EVENT_SOURCE':
  5003. return excludeEventsBySourceId(eventStore, action.sourceId);
  5004. case 'REMOVE_ALL_EVENT_SOURCES':
  5005. return filterEventStoreDefs(eventStore, function (eventDef) { return (!eventDef.sourceId // only keep events with no source id
  5006. ); });
  5007. case 'REMOVE_ALL_EVENTS':
  5008. return createEmptyEventStore();
  5009. default:
  5010. return eventStore;
  5011. }
  5012. }
  5013. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
  5014. if (eventSource && // not already removed
  5015. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  5016. ) {
  5017. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
  5018. if (fetchRange) {
  5019. subset = expandRecurring(subset, fetchRange, context);
  5020. }
  5021. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  5022. }
  5023. return eventStore;
  5024. }
  5025. function transformRawEvents(rawEvents, eventSource, context) {
  5026. var calEachTransform = context.options.eventDataTransform;
  5027. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  5028. if (sourceEachTransform) {
  5029. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  5030. }
  5031. if (calEachTransform) {
  5032. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  5033. }
  5034. return rawEvents;
  5035. }
  5036. function transformEachRawEvent(rawEvents, func) {
  5037. var refinedEvents;
  5038. if (!func) {
  5039. refinedEvents = rawEvents;
  5040. }
  5041. else {
  5042. refinedEvents = [];
  5043. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  5044. var rawEvent = rawEvents_1[_i];
  5045. var refinedEvent = func(rawEvent);
  5046. if (refinedEvent) {
  5047. refinedEvents.push(refinedEvent);
  5048. }
  5049. else if (refinedEvent == null) {
  5050. refinedEvents.push(rawEvent);
  5051. } // if a different falsy value, do nothing
  5052. }
  5053. }
  5054. return refinedEvents;
  5055. }
  5056. function addEvent(eventStore, subset, expandRange, context) {
  5057. if (expandRange) {
  5058. subset = expandRecurring(subset, expandRange, context);
  5059. }
  5060. return mergeEventStores(eventStore, subset);
  5061. }
  5062. function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
  5063. var defs = eventStore.defs;
  5064. var instances = mapHash(eventStore.instances, function (instance) {
  5065. var def = defs[instance.defId];
  5066. if (def.allDay || def.recurringDef) {
  5067. return instance; // isn't dependent on timezone
  5068. }
  5069. return __assign(__assign({}, instance), { range: {
  5070. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  5071. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo)),
  5072. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  5073. });
  5074. return { defs: defs, instances: instances };
  5075. }
  5076. function excludeEventsBySourceId(eventStore, sourceId) {
  5077. return filterEventStoreDefs(eventStore, function (eventDef) { return eventDef.sourceId !== sourceId; });
  5078. }
  5079. // QUESTION: why not just return instances? do a general object-property-exclusion util
  5080. function excludeInstances(eventStore, removals) {
  5081. return {
  5082. defs: eventStore.defs,
  5083. instances: filterHash(eventStore.instances, function (instance) { return !removals[instance.instanceId]; }),
  5084. };
  5085. }
  5086. // high-level segmenting-aware tester functions
  5087. // ------------------------------------------------------------------------------------------------------------------------
  5088. function isInteractionValid(interaction, context) {
  5089. return isNewPropsValid({ eventDrag: interaction }, context); // HACK: the eventDrag props is used for ALL interactions
  5090. }
  5091. function isDateSelectionValid(dateSelection, context) {
  5092. return isNewPropsValid({ dateSelection: dateSelection }, context);
  5093. }
  5094. function isNewPropsValid(newProps, context) {
  5095. var calendarState = context.getCurrentData();
  5096. var props = __assign({ businessHours: calendarState.businessHours, dateSelection: '', eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  5097. return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
  5098. }
  5099. function isPropsValid(state, context, dateSpanMeta, filterConfig) {
  5100. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  5101. if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  5102. return false;
  5103. }
  5104. if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
  5105. return false;
  5106. }
  5107. return true;
  5108. }
  5109. // Moving Event Validation
  5110. // ------------------------------------------------------------------------------------------------------------------------
  5111. function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
  5112. var currentState = context.getCurrentData();
  5113. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  5114. var subjectEventStore = interaction.mutatedEvents;
  5115. var subjectDefs = subjectEventStore.defs;
  5116. var subjectInstances = subjectEventStore.instances;
  5117. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  5118. state.eventUiBases :
  5119. { '': currentState.selectionConfig });
  5120. if (filterConfig) {
  5121. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  5122. }
  5123. // exclude the subject events. TODO: exclude defs too?
  5124. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
  5125. var otherDefs = otherEventStore.defs;
  5126. var otherInstances = otherEventStore.instances;
  5127. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  5128. for (var subjectInstanceId in subjectInstances) {
  5129. var subjectInstance = subjectInstances[subjectInstanceId];
  5130. var subjectRange = subjectInstance.range;
  5131. var subjectConfig = subjectConfigs[subjectInstance.defId];
  5132. var subjectDef = subjectDefs[subjectInstance.defId];
  5133. // constraint
  5134. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
  5135. return false;
  5136. }
  5137. // overlap
  5138. var eventOverlap = context.options.eventOverlap;
  5139. var eventOverlapFunc = typeof eventOverlap === 'function' ? eventOverlap : null;
  5140. for (var otherInstanceId in otherInstances) {
  5141. var otherInstance = otherInstances[otherInstanceId];
  5142. // intersect! evaluate
  5143. if (rangesIntersect(subjectRange, otherInstance.range)) {
  5144. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  5145. // consider the other event's overlap. only do this if the subject event is a "real" event
  5146. if (otherOverlap === false && interaction.isEvent) {
  5147. return false;
  5148. }
  5149. if (subjectConfig.overlap === false) {
  5150. return false;
  5151. }
  5152. if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), // still event
  5153. new EventApi(context, subjectDef, subjectInstance))) {
  5154. return false;
  5155. }
  5156. }
  5157. }
  5158. // allow (a function)
  5159. var calendarEventStore = currentState.eventStore; // need global-to-calendar, not local to component (splittable)state
  5160. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  5161. var subjectAllow = _a[_i];
  5162. var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
  5163. var origDef = calendarEventStore.defs[subjectDef.defId];
  5164. var origInstance = calendarEventStore.instances[subjectInstanceId];
  5165. var eventApi = void 0;
  5166. if (origDef) { // was previously in the calendar
  5167. eventApi = new EventApi(context, origDef, origInstance);
  5168. }
  5169. else { // was an external event
  5170. eventApi = new EventApi(context, subjectDef); // no instance, because had no dates
  5171. }
  5172. if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
  5173. return false;
  5174. }
  5175. }
  5176. }
  5177. return true;
  5178. }
  5179. // Date Selection Validation
  5180. // ------------------------------------------------------------------------------------------------------------------------
  5181. function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
  5182. var relevantEventStore = state.eventStore;
  5183. var relevantDefs = relevantEventStore.defs;
  5184. var relevantInstances = relevantEventStore.instances;
  5185. var selection = state.dateSelection;
  5186. var selectionRange = selection.range;
  5187. var selectionConfig = context.getCurrentData().selectionConfig;
  5188. if (filterConfig) {
  5189. selectionConfig = filterConfig(selectionConfig);
  5190. }
  5191. // constraint
  5192. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
  5193. return false;
  5194. }
  5195. // overlap
  5196. var selectOverlap = context.options.selectOverlap;
  5197. var selectOverlapFunc = typeof selectOverlap === 'function' ? selectOverlap : null;
  5198. for (var relevantInstanceId in relevantInstances) {
  5199. var relevantInstance = relevantInstances[relevantInstanceId];
  5200. // intersect! evaluate
  5201. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  5202. if (selectionConfig.overlap === false) {
  5203. return false;
  5204. }
  5205. if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
  5206. return false;
  5207. }
  5208. }
  5209. }
  5210. // allow (a function)
  5211. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  5212. var selectionAllow = _a[_i];
  5213. var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
  5214. if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
  5215. return false;
  5216. }
  5217. }
  5218. return true;
  5219. }
  5220. // Constraint Utils
  5221. // ------------------------------------------------------------------------------------------------------------------------
  5222. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
  5223. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  5224. var constraint = constraints_1[_i];
  5225. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
  5226. return false;
  5227. }
  5228. }
  5229. return true;
  5230. }
  5231. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  5232. otherEventStore, // for if constraint is an even group ID
  5233. businessHoursUnexpanded, // for if constraint is 'businessHours'
  5234. context) {
  5235. if (constraint === 'businessHours') {
  5236. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
  5237. }
  5238. if (typeof constraint === 'string') { // an group ID
  5239. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) { return eventDef.groupId === constraint; }));
  5240. }
  5241. if (typeof constraint === 'object' && constraint) { // non-null object
  5242. return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
  5243. }
  5244. return []; // if it's false
  5245. }
  5246. // TODO: move to event-store file?
  5247. function eventStoreToRanges(eventStore) {
  5248. var instances = eventStore.instances;
  5249. var ranges = [];
  5250. for (var instanceId in instances) {
  5251. ranges.push(instances[instanceId].range);
  5252. }
  5253. return ranges;
  5254. }
  5255. // TODO: move to geom file?
  5256. function anyRangesContainRange(outerRanges, innerRange) {
  5257. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  5258. var outerRange = outerRanges_1[_i];
  5259. if (rangeContainsRange(outerRange, innerRange)) {
  5260. return true;
  5261. }
  5262. }
  5263. return false;
  5264. }
  5265. /*
  5266. an INTERACTABLE date component
  5267. PURPOSES:
  5268. - hook up to fg, fill, and mirror renderers
  5269. - interface for dragging and hits
  5270. */
  5271. var DateComponent = /** @class */ (function (_super) {
  5272. __extends(DateComponent, _super);
  5273. function DateComponent() {
  5274. var _this = _super !== null && _super.apply(this, arguments) || this;
  5275. _this.uid = guid();
  5276. return _this;
  5277. }
  5278. // Hit System
  5279. // -----------------------------------------------------------------------------------------------------------------
  5280. DateComponent.prototype.prepareHits = function () {
  5281. };
  5282. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  5283. return null; // this should be abstract
  5284. };
  5285. // Validation
  5286. // -----------------------------------------------------------------------------------------------------------------
  5287. DateComponent.prototype.isInteractionValid = function (interaction) {
  5288. var dateProfile = this.props.dateProfile; // HACK
  5289. var instances = interaction.mutatedEvents.instances;
  5290. if (dateProfile) { // HACK for MorePopover
  5291. for (var instanceId in instances) {
  5292. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  5293. return false;
  5294. }
  5295. }
  5296. }
  5297. return isInteractionValid(interaction, this.context);
  5298. };
  5299. DateComponent.prototype.isDateSelectionValid = function (selection) {
  5300. var dateProfile = this.props.dateProfile; // HACK
  5301. if (dateProfile && // HACK for MorePopover
  5302. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  5303. return false;
  5304. }
  5305. return isDateSelectionValid(selection, this.context);
  5306. };
  5307. // Pointer Interaction Utils
  5308. // -----------------------------------------------------------------------------------------------------------------
  5309. DateComponent.prototype.isValidSegDownEl = function (el) {
  5310. return !this.props.eventDrag && // HACK
  5311. !this.props.eventResize && // HACK
  5312. !elementClosest(el, '.fc-event-mirror') &&
  5313. (this.isPopover() || !this.isInPopover(el));
  5314. // ^above line ensures we don't detect a seg interaction within a nested component.
  5315. // it's a HACK because it only supports a popover as the nested component.
  5316. };
  5317. DateComponent.prototype.isValidDateDownEl = function (el) {
  5318. return !elementClosest(el, '.fc-event:not(.fc-bg-event)') &&
  5319. !elementClosest(el, '.fc-daygrid-more-link') && // a "more.." link
  5320. !elementClosest(el, 'a[data-navlink]') && // a clickable nav link
  5321. !this.isInPopover(el);
  5322. };
  5323. DateComponent.prototype.isPopover = function () {
  5324. return false;
  5325. };
  5326. DateComponent.prototype.isInPopover = function (el) {
  5327. return Boolean(elementClosest(el, '.fc-popover'));
  5328. };
  5329. return DateComponent;
  5330. }(BaseComponent));
  5331. // TODO: easier way to add new hooks? need to update a million things
  5332. function createPlugin(input) {
  5333. return {
  5334. id: guid(),
  5335. deps: input.deps || [],
  5336. reducers: input.reducers || [],
  5337. contextInit: [].concat(input.contextInit || []),
  5338. eventRefiners: input.eventRefiners || {},
  5339. eventDefMemberAdders: input.eventDefMemberAdders || [],
  5340. eventSourceRefiners: input.eventSourceRefiners || {},
  5341. isDraggableTransformers: input.isDraggableTransformers || [],
  5342. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  5343. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  5344. dateSelectionTransformers: input.dateSelectionTransformers || [],
  5345. datePointTransforms: input.datePointTransforms || [],
  5346. dateSpanTransforms: input.dateSpanTransforms || [],
  5347. views: input.views || {},
  5348. viewPropsTransformers: input.viewPropsTransformers || [],
  5349. isPropsValid: input.isPropsValid || null,
  5350. externalDefTransforms: input.externalDefTransforms || [],
  5351. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  5352. viewContainerAppends: input.viewContainerAppends || [],
  5353. eventDropTransformers: input.eventDropTransformers || [],
  5354. componentInteractions: input.componentInteractions || [],
  5355. calendarInteractions: input.calendarInteractions || [],
  5356. themeClasses: input.themeClasses || {},
  5357. eventSourceDefs: input.eventSourceDefs || [],
  5358. cmdFormatter: input.cmdFormatter,
  5359. recurringTypes: input.recurringTypes || [],
  5360. namedTimeZonedImpl: input.namedTimeZonedImpl,
  5361. initialView: input.initialView || '',
  5362. elementDraggingImpl: input.elementDraggingImpl,
  5363. optionChangeHandlers: input.optionChangeHandlers || {},
  5364. scrollGridImpl: input.scrollGridImpl || null,
  5365. contentTypeHandlers: input.contentTypeHandlers || {},
  5366. listenerRefiners: input.listenerRefiners || {},
  5367. optionRefiners: input.optionRefiners || {},
  5368. propSetHandlers: input.propSetHandlers || {},
  5369. };
  5370. }
  5371. function buildPluginHooks(pluginDefs, globalDefs) {
  5372. var isAdded = {};
  5373. var hooks = {
  5374. reducers: [],
  5375. contextInit: [],
  5376. eventRefiners: {},
  5377. eventDefMemberAdders: [],
  5378. eventSourceRefiners: {},
  5379. isDraggableTransformers: [],
  5380. eventDragMutationMassagers: [],
  5381. eventDefMutationAppliers: [],
  5382. dateSelectionTransformers: [],
  5383. datePointTransforms: [],
  5384. dateSpanTransforms: [],
  5385. views: {},
  5386. viewPropsTransformers: [],
  5387. isPropsValid: null,
  5388. externalDefTransforms: [],
  5389. eventResizeJoinTransforms: [],
  5390. viewContainerAppends: [],
  5391. eventDropTransformers: [],
  5392. componentInteractions: [],
  5393. calendarInteractions: [],
  5394. themeClasses: {},
  5395. eventSourceDefs: [],
  5396. cmdFormatter: null,
  5397. recurringTypes: [],
  5398. namedTimeZonedImpl: null,
  5399. initialView: '',
  5400. elementDraggingImpl: null,
  5401. optionChangeHandlers: {},
  5402. scrollGridImpl: null,
  5403. contentTypeHandlers: {},
  5404. listenerRefiners: {},
  5405. optionRefiners: {},
  5406. propSetHandlers: {},
  5407. };
  5408. function addDefs(defs) {
  5409. for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
  5410. var def = defs_1[_i];
  5411. if (!isAdded[def.id]) {
  5412. isAdded[def.id] = true;
  5413. addDefs(def.deps);
  5414. hooks = combineHooks(hooks, def);
  5415. }
  5416. }
  5417. }
  5418. if (pluginDefs) {
  5419. addDefs(pluginDefs);
  5420. }
  5421. addDefs(globalDefs);
  5422. return hooks;
  5423. }
  5424. function buildBuildPluginHooks() {
  5425. var currentOverrideDefs = [];
  5426. var currentGlobalDefs = [];
  5427. var currentHooks;
  5428. return function (overrideDefs, globalDefs) {
  5429. if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
  5430. currentHooks = buildPluginHooks(overrideDefs, globalDefs);
  5431. }
  5432. currentOverrideDefs = overrideDefs;
  5433. currentGlobalDefs = globalDefs;
  5434. return currentHooks;
  5435. };
  5436. }
  5437. function combineHooks(hooks0, hooks1) {
  5438. return {
  5439. reducers: hooks0.reducers.concat(hooks1.reducers),
  5440. contextInit: hooks0.contextInit.concat(hooks1.contextInit),
  5441. eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
  5442. eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
  5443. eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
  5444. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  5445. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  5446. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  5447. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  5448. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  5449. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  5450. views: __assign(__assign({}, hooks0.views), hooks1.views),
  5451. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  5452. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  5453. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  5454. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  5455. viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
  5456. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  5457. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  5458. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  5459. themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
  5460. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  5461. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  5462. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  5463. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  5464. initialView: hooks0.initialView || hooks1.initialView,
  5465. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  5466. optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
  5467. scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
  5468. contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
  5469. listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
  5470. optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
  5471. propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
  5472. };
  5473. }
  5474. var StandardTheme = /** @class */ (function (_super) {
  5475. __extends(StandardTheme, _super);
  5476. function StandardTheme() {
  5477. return _super !== null && _super.apply(this, arguments) || this;
  5478. }
  5479. return StandardTheme;
  5480. }(Theme));
  5481. StandardTheme.prototype.classes = {
  5482. root: 'fc-theme-standard',
  5483. tableCellShaded: 'fc-cell-shaded',
  5484. buttonGroup: 'fc-button-group',
  5485. button: 'fc-button fc-button-primary',
  5486. buttonActive: 'fc-button-active',
  5487. };
  5488. StandardTheme.prototype.baseIconClass = 'fc-icon';
  5489. StandardTheme.prototype.iconClasses = {
  5490. close: 'fc-icon-x',
  5491. prev: 'fc-icon-chevron-left',
  5492. next: 'fc-icon-chevron-right',
  5493. prevYear: 'fc-icon-chevrons-left',
  5494. nextYear: 'fc-icon-chevrons-right',
  5495. };
  5496. StandardTheme.prototype.rtlIconClasses = {
  5497. prev: 'fc-icon-chevron-right',
  5498. next: 'fc-icon-chevron-left',
  5499. prevYear: 'fc-icon-chevrons-right',
  5500. nextYear: 'fc-icon-chevrons-left',
  5501. };
  5502. StandardTheme.prototype.iconOverrideOption = 'buttonIcons'; // TODO: make TS-friendly
  5503. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  5504. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  5505. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5506. var hash = {};
  5507. var viewType;
  5508. for (viewType in defaultConfigs) {
  5509. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5510. }
  5511. for (viewType in overrideConfigs) {
  5512. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5513. }
  5514. return hash;
  5515. }
  5516. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5517. if (hash[viewType]) {
  5518. return hash[viewType];
  5519. }
  5520. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5521. if (viewDef) {
  5522. hash[viewType] = viewDef;
  5523. }
  5524. return viewDef;
  5525. }
  5526. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5527. var defaultConfig = defaultConfigs[viewType];
  5528. var overrideConfig = overrideConfigs[viewType];
  5529. var queryProp = function (name) { return ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5530. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null)); };
  5531. var theComponent = queryProp('component');
  5532. var superType = queryProp('superType');
  5533. var superDef = null;
  5534. if (superType) {
  5535. if (superType === viewType) {
  5536. throw new Error('Can\'t have a custom view type that references itself');
  5537. }
  5538. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5539. }
  5540. if (!theComponent && superDef) {
  5541. theComponent = superDef.component;
  5542. }
  5543. if (!theComponent) {
  5544. return null; // don't throw a warning, might be settings for a single-unit view
  5545. }
  5546. return {
  5547. type: viewType,
  5548. component: theComponent,
  5549. defaults: __assign(__assign({}, (superDef ? superDef.defaults : {})), (defaultConfig ? defaultConfig.rawOptions : {})),
  5550. overrides: __assign(__assign({}, (superDef ? superDef.overrides : {})), (overrideConfig ? overrideConfig.rawOptions : {})),
  5551. };
  5552. }
  5553. /* eslint max-classes-per-file: off */
  5554. // NOTE: in JSX, you should always use this class with <HookProps> arg. otherwise, will default to any???
  5555. var RenderHook = /** @class */ (function (_super) {
  5556. __extends(RenderHook, _super);
  5557. function RenderHook() {
  5558. var _this = _super !== null && _super.apply(this, arguments) || this;
  5559. _this.rootElRef = createRef();
  5560. _this.handleRootEl = function (el) {
  5561. setRef(_this.rootElRef, el);
  5562. if (_this.props.elRef) {
  5563. setRef(_this.props.elRef, el);
  5564. }
  5565. };
  5566. return _this;
  5567. }
  5568. RenderHook.prototype.render = function () {
  5569. var _this = this;
  5570. var props = this.props;
  5571. var hookProps = props.hookProps;
  5572. 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); })); }));
  5573. };
  5574. return RenderHook;
  5575. }(BaseComponent));
  5576. // TODO: rename to be about function, not default. use in above type
  5577. // for forcing rerender of components that use the ContentHook
  5578. var CustomContentRenderContext = createContext$1(0);
  5579. function ContentHook(props) {
  5580. return (createElement(CustomContentRenderContext.Consumer, null, function (renderId) { return (createElement(ContentHookInner, __assign({ renderId: renderId }, props))); }));
  5581. }
  5582. var ContentHookInner = /** @class */ (function (_super) {
  5583. __extends(ContentHookInner, _super);
  5584. function ContentHookInner() {
  5585. var _this = _super !== null && _super.apply(this, arguments) || this;
  5586. _this.innerElRef = createRef();
  5587. return _this;
  5588. }
  5589. ContentHookInner.prototype.render = function () {
  5590. return this.props.children(this.innerElRef, this.renderInnerContent());
  5591. };
  5592. ContentHookInner.prototype.componentDidMount = function () {
  5593. this.updateCustomContent();
  5594. };
  5595. ContentHookInner.prototype.componentDidUpdate = function () {
  5596. this.updateCustomContent();
  5597. };
  5598. ContentHookInner.prototype.componentWillUnmount = function () {
  5599. if (this.customContentInfo && this.customContentInfo.destroy) {
  5600. this.customContentInfo.destroy();
  5601. }
  5602. };
  5603. ContentHookInner.prototype.renderInnerContent = function () {
  5604. var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
  5605. var _a = this, props = _a.props, customContentInfo = _a.customContentInfo;
  5606. var rawVal = props.content;
  5607. var innerContent = normalizeContent(rawVal, props.hookProps);
  5608. var innerContentVDom = null;
  5609. if (innerContent === undefined) { // use the default
  5610. innerContent = normalizeContent(props.defaultContent, props.hookProps);
  5611. }
  5612. if (innerContent !== undefined) { // we allow custom content handlers to return nothing
  5613. if (customContentInfo) {
  5614. customContentInfo.contentVal = innerContent[customContentInfo.contentKey];
  5615. }
  5616. else if (typeof innerContent === 'object') {
  5617. // look for a prop that would indicate a custom content handler is needed
  5618. for (var contentKey in contentTypeHandlers) {
  5619. if (innerContent[contentKey] !== undefined) {
  5620. var stuff = contentTypeHandlers[contentKey]();
  5621. customContentInfo = this.customContentInfo = __assign({ contentKey: contentKey, contentVal: innerContent[contentKey] }, stuff);
  5622. break;
  5623. }
  5624. }
  5625. }
  5626. if (customContentInfo) {
  5627. innerContentVDom = []; // signal that something was specified
  5628. }
  5629. else {
  5630. innerContentVDom = innerContent; // assume a [p]react vdom node. use it
  5631. }
  5632. }
  5633. return innerContentVDom;
  5634. };
  5635. ContentHookInner.prototype.updateCustomContent = function () {
  5636. if (this.customContentInfo) {
  5637. this.customContentInfo.render(this.innerElRef.current || this.props.backupElRef.current, // the element to render into
  5638. this.customContentInfo.contentVal);
  5639. }
  5640. };
  5641. return ContentHookInner;
  5642. }(BaseComponent));
  5643. var MountHook = /** @class */ (function (_super) {
  5644. __extends(MountHook, _super);
  5645. function MountHook() {
  5646. var _this = _super !== null && _super.apply(this, arguments) || this;
  5647. _this.handleRootEl = function (rootEl) {
  5648. _this.rootEl = rootEl;
  5649. if (_this.props.elRef) {
  5650. setRef(_this.props.elRef, rootEl);
  5651. }
  5652. };
  5653. return _this;
  5654. }
  5655. MountHook.prototype.render = function () {
  5656. return this.props.children(this.handleRootEl);
  5657. };
  5658. MountHook.prototype.componentDidMount = function () {
  5659. var callback = this.props.didMount;
  5660. if (callback) {
  5661. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5662. }
  5663. };
  5664. MountHook.prototype.componentWillUnmount = function () {
  5665. var callback = this.props.willUnmount;
  5666. if (callback) {
  5667. callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
  5668. }
  5669. };
  5670. return MountHook;
  5671. }(BaseComponent));
  5672. function buildClassNameNormalizer() {
  5673. var currentGenerator;
  5674. var currentHookProps;
  5675. var currentClassNames = [];
  5676. return function (generator, hookProps) {
  5677. if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
  5678. currentGenerator = generator;
  5679. currentHookProps = hookProps;
  5680. currentClassNames = normalizeClassNames(generator, hookProps);
  5681. }
  5682. return currentClassNames;
  5683. };
  5684. }
  5685. function normalizeClassNames(classNames, hookProps) {
  5686. if (typeof classNames === 'function') {
  5687. classNames = classNames(hookProps);
  5688. }
  5689. return parseClassNames(classNames);
  5690. }
  5691. function normalizeContent(input, hookProps) {
  5692. if (typeof input === 'function') {
  5693. return input(hookProps, createElement); // give the function the vdom-creation func
  5694. }
  5695. return input;
  5696. }
  5697. var ViewRoot = /** @class */ (function (_super) {
  5698. __extends(ViewRoot, _super);
  5699. function ViewRoot() {
  5700. var _this = _super !== null && _super.apply(this, arguments) || this;
  5701. _this.normalizeClassNames = buildClassNameNormalizer();
  5702. return _this;
  5703. }
  5704. ViewRoot.prototype.render = function () {
  5705. var _a = this, props = _a.props, context = _a.context;
  5706. var options = context.options;
  5707. var hookProps = { view: context.viewApi };
  5708. var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
  5709. 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)); }));
  5710. };
  5711. return ViewRoot;
  5712. }(BaseComponent));
  5713. function parseViewConfigs(inputs) {
  5714. return mapHash(inputs, parseViewConfig);
  5715. }
  5716. function parseViewConfig(input) {
  5717. var rawOptions = typeof input === 'function' ?
  5718. { component: input } :
  5719. input;
  5720. var component = rawOptions.component;
  5721. if (rawOptions.content) {
  5722. component = createViewHookComponent(rawOptions);
  5723. // TODO: remove content/classNames/didMount/etc from options?
  5724. }
  5725. return {
  5726. superType: rawOptions.type,
  5727. component: component,
  5728. rawOptions: rawOptions,
  5729. };
  5730. }
  5731. function createViewHookComponent(options) {
  5732. return function (viewProps) { return (createElement(ViewContextType.Consumer, null, function (context) { return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (viewElRef, viewClassNames) {
  5733. var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
  5734. 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)); }));
  5735. })); })); };
  5736. }
  5737. function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5738. var defaultConfigs = parseViewConfigs(defaultInputs);
  5739. var overrideConfigs = parseViewConfigs(optionOverrides.views);
  5740. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5741. return mapHash(viewDefs, function (viewDef) { return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults); });
  5742. }
  5743. function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
  5744. var durationInput = viewDef.overrides.duration ||
  5745. viewDef.defaults.duration ||
  5746. dynamicOptionOverrides.duration ||
  5747. optionOverrides.duration;
  5748. var duration = null;
  5749. var durationUnit = '';
  5750. var singleUnit = '';
  5751. var singleUnitOverrides = {};
  5752. if (durationInput) {
  5753. duration = createDurationCached(durationInput);
  5754. if (duration) { // valid?
  5755. var denom = greatestDurationDenominator(duration);
  5756. durationUnit = denom.unit;
  5757. if (denom.value === 1) {
  5758. singleUnit = durationUnit;
  5759. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
  5760. }
  5761. }
  5762. }
  5763. var queryButtonText = function (optionsSubset) {
  5764. var buttonTextMap = optionsSubset.buttonText || {};
  5765. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5766. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5767. return buttonTextMap[buttonTextKey];
  5768. }
  5769. if (buttonTextMap[viewDef.type] != null) {
  5770. return buttonTextMap[viewDef.type];
  5771. }
  5772. if (buttonTextMap[singleUnit] != null) {
  5773. return buttonTextMap[singleUnit];
  5774. }
  5775. return null;
  5776. };
  5777. return {
  5778. type: viewDef.type,
  5779. component: viewDef.component,
  5780. duration: duration,
  5781. durationUnit: durationUnit,
  5782. singleUnit: singleUnit,
  5783. optionDefaults: viewDef.defaults,
  5784. optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
  5785. buttonTextOverride: queryButtonText(dynamicOptionOverrides) ||
  5786. queryButtonText(optionOverrides) || // constructor-specified buttonText lookup hash takes precedence
  5787. viewDef.overrides.buttonText,
  5788. buttonTextDefault: queryButtonText(localeDefaults) ||
  5789. viewDef.defaults.buttonText ||
  5790. queryButtonText(BASE_OPTION_DEFAULTS) ||
  5791. viewDef.type,
  5792. };
  5793. }
  5794. // hack to get memoization working
  5795. var durationInputMap = {};
  5796. function createDurationCached(durationInput) {
  5797. var json = JSON.stringify(durationInput);
  5798. var res = durationInputMap[json];
  5799. if (res === undefined) {
  5800. res = createDuration(durationInput);
  5801. durationInputMap[json] = res;
  5802. }
  5803. return res;
  5804. }
  5805. var DateProfileGenerator = /** @class */ (function () {
  5806. function DateProfileGenerator(props) {
  5807. this.props = props;
  5808. this.nowDate = getNow(props.nowInput, props.dateEnv);
  5809. this.initHiddenDays();
  5810. }
  5811. /* Date Range Computation
  5812. ------------------------------------------------------------------------------------------------------------------*/
  5813. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5814. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate, forceToValid) {
  5815. var dateEnv = this.props.dateEnv;
  5816. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5817. currentDateProfile.dateIncrement);
  5818. return this.build(prevDate, -1, forceToValid);
  5819. };
  5820. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5821. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate, forceToValid) {
  5822. var dateEnv = this.props.dateEnv;
  5823. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5824. currentDateProfile.dateIncrement);
  5825. return this.build(nextDate, 1, forceToValid);
  5826. };
  5827. // Builds a structure holding dates/ranges for rendering around the given date.
  5828. // Optional direction param indicates whether the date is being incremented/decremented
  5829. // from its previous value. decremented = -1, incremented = 1 (default).
  5830. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5831. if (forceToValid === void 0) { forceToValid = true; }
  5832. var props = this.props;
  5833. var validRange;
  5834. var currentInfo;
  5835. var isRangeAllDay;
  5836. var renderRange;
  5837. var activeRange;
  5838. var isValid;
  5839. validRange = this.buildValidRange();
  5840. validRange = this.trimHiddenDays(validRange);
  5841. if (forceToValid) {
  5842. currentDate = constrainMarkerToRange(currentDate, validRange);
  5843. }
  5844. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5845. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5846. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5847. renderRange = this.trimHiddenDays(renderRange);
  5848. activeRange = renderRange;
  5849. if (!props.showNonCurrentDates) {
  5850. activeRange = intersectRanges(activeRange, currentInfo.range);
  5851. }
  5852. activeRange = this.adjustActiveRange(activeRange);
  5853. activeRange = intersectRanges(activeRange, validRange); // might return null
  5854. // it's invalid if the originally requested date is not contained,
  5855. // or if the range is completely outside of the valid range.
  5856. isValid = rangesIntersect(currentInfo.range, validRange);
  5857. return {
  5858. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5859. // an object with optional start and end properties.
  5860. validRange: validRange,
  5861. // range the view is formally responsible for.
  5862. // for example, a month view might have 1st-31st, excluding padded dates
  5863. currentRange: currentInfo.range,
  5864. // name of largest unit being displayed, like "month" or "week"
  5865. currentRangeUnit: currentInfo.unit,
  5866. isRangeAllDay: isRangeAllDay,
  5867. // dates that display events and accept drag-n-drop
  5868. // will be `null` if no dates accept events
  5869. activeRange: activeRange,
  5870. // date range with a rendered skeleton
  5871. // includes not-active days that need some sort of DOM
  5872. renderRange: renderRange,
  5873. // Duration object that denotes the first visible time of any given day
  5874. slotMinTime: props.slotMinTime,
  5875. // Duration object that denotes the exclusive visible end time of any given day
  5876. slotMaxTime: props.slotMaxTime,
  5877. isValid: isValid,
  5878. // how far the current date will move for a prev/next operation
  5879. dateIncrement: this.buildDateIncrement(currentInfo.duration),
  5880. };
  5881. };
  5882. // Builds an object with optional start/end properties.
  5883. // Indicates the minimum/maximum dates to display.
  5884. // not responsible for trimming hidden days.
  5885. DateProfileGenerator.prototype.buildValidRange = function () {
  5886. var input = this.props.validRangeInput;
  5887. var simpleInput = typeof input === 'function'
  5888. ? input.call(this.props.calendarApi, this.nowDate)
  5889. : input;
  5890. return this.refineRange(simpleInput) ||
  5891. { start: null, end: null }; // completely open-ended
  5892. };
  5893. // Builds a structure with info about the "current" range, the range that is
  5894. // highlighted as being the current month for example.
  5895. // See build() for a description of `direction`.
  5896. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5897. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5898. var props = this.props;
  5899. var duration = null;
  5900. var unit = null;
  5901. var range = null;
  5902. var dayCount;
  5903. if (props.duration) {
  5904. duration = props.duration;
  5905. unit = props.durationUnit;
  5906. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5907. }
  5908. else if ((dayCount = this.props.dayCount)) {
  5909. unit = 'day';
  5910. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5911. }
  5912. else if ((range = this.buildCustomVisibleRange(date))) {
  5913. unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5914. }
  5915. else {
  5916. duration = this.getFallbackDuration();
  5917. unit = greatestDurationDenominator(duration).unit;
  5918. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5919. }
  5920. return { duration: duration, unit: unit, range: range };
  5921. };
  5922. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5923. return createDuration({ day: 1 });
  5924. };
  5925. // Returns a new activeRange to have time values (un-ambiguate)
  5926. // slotMinTime or slotMaxTime causes the range to expand.
  5927. DateProfileGenerator.prototype.adjustActiveRange = function (range) {
  5928. var _a = this.props, dateEnv = _a.dateEnv, usesMinMaxTime = _a.usesMinMaxTime, slotMinTime = _a.slotMinTime, slotMaxTime = _a.slotMaxTime;
  5929. var start = range.start, end = range.end;
  5930. if (usesMinMaxTime) {
  5931. // expand active range if slotMinTime is negative (why not when positive?)
  5932. if (asRoughDays(slotMinTime) < 0) {
  5933. start = startOfDay(start); // necessary?
  5934. start = dateEnv.add(start, slotMinTime);
  5935. }
  5936. // expand active range if slotMaxTime is beyond one day (why not when negative?)
  5937. if (asRoughDays(slotMaxTime) > 1) {
  5938. end = startOfDay(end); // necessary?
  5939. end = addDays(end, -1);
  5940. end = dateEnv.add(end, slotMaxTime);
  5941. }
  5942. }
  5943. return { start: start, end: end };
  5944. };
  5945. // Builds the "current" range when it is specified as an explicit duration.
  5946. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5947. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5948. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5949. var start;
  5950. var end;
  5951. var res;
  5952. // compute what the alignment should be
  5953. if (!dateAlignment) {
  5954. var dateIncrement = this.props.dateIncrement;
  5955. if (dateIncrement) {
  5956. // use the smaller of the two units
  5957. if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
  5958. dateAlignment = greatestDurationDenominator(dateIncrement).unit;
  5959. }
  5960. else {
  5961. dateAlignment = unit;
  5962. }
  5963. }
  5964. else {
  5965. dateAlignment = unit;
  5966. }
  5967. }
  5968. // if the view displays a single day or smaller
  5969. if (asRoughDays(duration) <= 1) {
  5970. if (this.isHiddenDay(start)) {
  5971. start = this.skipHiddenDays(start, direction);
  5972. start = startOfDay(start);
  5973. }
  5974. }
  5975. function computeRes() {
  5976. start = dateEnv.startOf(date, dateAlignment);
  5977. end = dateEnv.add(start, duration);
  5978. res = { start: start, end: end };
  5979. }
  5980. computeRes();
  5981. // if range is completely enveloped by hidden days, go past the hidden days
  5982. if (!this.trimHiddenDays(res)) {
  5983. date = this.skipHiddenDays(date, direction);
  5984. computeRes();
  5985. }
  5986. return res;
  5987. };
  5988. // Builds the "current" range when a dayCount is specified.
  5989. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5990. var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
  5991. var runningCount = 0;
  5992. var start = date;
  5993. var end;
  5994. if (dateAlignment) {
  5995. start = dateEnv.startOf(start, dateAlignment);
  5996. }
  5997. start = startOfDay(start);
  5998. start = this.skipHiddenDays(start, direction);
  5999. end = start;
  6000. do {
  6001. end = addDays(end, 1);
  6002. if (!this.isHiddenDay(end)) {
  6003. runningCount += 1;
  6004. }
  6005. } while (runningCount < dayCount);
  6006. return { start: start, end: end };
  6007. };
  6008. // Builds a normalized range object for the "visible" range,
  6009. // which is a way to define the currentRange and activeRange at the same time.
  6010. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  6011. var props = this.props;
  6012. var input = props.visibleRangeInput;
  6013. var simpleInput = typeof input === 'function'
  6014. ? input.call(props.calendarApi, props.dateEnv.toDate(date))
  6015. : input;
  6016. var range = this.refineRange(simpleInput);
  6017. if (range && (range.start == null || range.end == null)) {
  6018. return null;
  6019. }
  6020. return range;
  6021. };
  6022. // Computes the range that will represent the element/cells for *rendering*,
  6023. // but which may have voided days/times.
  6024. // not responsible for trimming hidden days.
  6025. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  6026. return currentRange;
  6027. };
  6028. // Compute the duration value that should be added/substracted to the current date
  6029. // when a prev/next operation happens.
  6030. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  6031. var dateIncrement = this.props.dateIncrement;
  6032. var customAlignment;
  6033. if (dateIncrement) {
  6034. return dateIncrement;
  6035. }
  6036. if ((customAlignment = this.props.dateAlignment)) {
  6037. return createDuration(1, customAlignment);
  6038. }
  6039. if (fallback) {
  6040. return fallback;
  6041. }
  6042. return createDuration({ days: 1 });
  6043. };
  6044. DateProfileGenerator.prototype.refineRange = function (rangeInput) {
  6045. if (rangeInput) {
  6046. var range = parseRange(rangeInput, this.props.dateEnv);
  6047. if (range) {
  6048. range = computeVisibleDayRange(range);
  6049. }
  6050. return range;
  6051. }
  6052. return null;
  6053. };
  6054. /* Hidden Days
  6055. ------------------------------------------------------------------------------------------------------------------*/
  6056. // Initializes internal variables related to calculating hidden days-of-week
  6057. DateProfileGenerator.prototype.initHiddenDays = function () {
  6058. var hiddenDays = this.props.hiddenDays || []; // array of day-of-week indices that are hidden
  6059. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  6060. var dayCnt = 0;
  6061. var i;
  6062. if (this.props.weekends === false) {
  6063. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  6064. }
  6065. for (i = 0; i < 7; i += 1) {
  6066. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  6067. dayCnt += 1;
  6068. }
  6069. }
  6070. if (!dayCnt) {
  6071. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  6072. }
  6073. this.isHiddenDayHash = isHiddenDayHash;
  6074. };
  6075. // Remove days from the beginning and end of the range that are computed as hidden.
  6076. // If the whole range is trimmed off, returns null
  6077. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  6078. var start = range.start, end = range.end;
  6079. if (start) {
  6080. start = this.skipHiddenDays(start);
  6081. }
  6082. if (end) {
  6083. end = this.skipHiddenDays(end, -1, true);
  6084. }
  6085. if (start == null || end == null || start < end) {
  6086. return { start: start, end: end };
  6087. }
  6088. return null;
  6089. };
  6090. // Is the current day hidden?
  6091. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  6092. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  6093. if (day instanceof Date) {
  6094. day = day.getUTCDay();
  6095. }
  6096. return this.isHiddenDayHash[day];
  6097. };
  6098. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  6099. // DOES NOT CONSIDER validRange!
  6100. // If the initial value of `date` is not a hidden day, don't do anything.
  6101. // Pass `isExclusive` as `true` if you are dealing with an end date.
  6102. // `inc` defaults to `1` (increment one day forward each time)
  6103. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  6104. if (inc === void 0) { inc = 1; }
  6105. if (isExclusive === void 0) { isExclusive = false; }
  6106. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  6107. date = addDays(date, inc);
  6108. }
  6109. return date;
  6110. };
  6111. return DateProfileGenerator;
  6112. }());
  6113. function reduceViewType(viewType, action) {
  6114. switch (action.type) {
  6115. case 'CHANGE_VIEW_TYPE':
  6116. viewType = action.viewType;
  6117. }
  6118. return viewType;
  6119. }
  6120. function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
  6121. var _a;
  6122. switch (action.type) {
  6123. case 'SET_OPTION':
  6124. return __assign(__assign({}, dynamicOptionOverrides), (_a = {}, _a[action.optionName] = action.rawOptionValue, _a));
  6125. default:
  6126. return dynamicOptionOverrides;
  6127. }
  6128. }
  6129. function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
  6130. var dp;
  6131. switch (action.type) {
  6132. case 'CHANGE_VIEW_TYPE':
  6133. return dateProfileGenerator.build(action.dateMarker || currentDate);
  6134. case 'CHANGE_DATE':
  6135. if (!currentDateProfile.activeRange ||
  6136. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker) // don't move if date already in view
  6137. ) {
  6138. return dateProfileGenerator.build(action.dateMarker);
  6139. }
  6140. break;
  6141. case 'PREV':
  6142. dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
  6143. if (dp.isValid) {
  6144. return dp;
  6145. }
  6146. break;
  6147. case 'NEXT':
  6148. dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
  6149. if (dp.isValid) {
  6150. return dp;
  6151. }
  6152. break;
  6153. }
  6154. return currentDateProfile;
  6155. }
  6156. function initEventSources(calendarOptions, dateProfile, context) {
  6157. var activeRange = dateProfile ? dateProfile.activeRange : null;
  6158. return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
  6159. }
  6160. function reduceEventSources(eventSources, action, dateProfile, context) {
  6161. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6162. switch (action.type) {
  6163. case 'ADD_EVENT_SOURCES': // already parsed
  6164. return addSources(eventSources, action.sources, activeRange, context);
  6165. case 'REMOVE_EVENT_SOURCE':
  6166. return removeSource(eventSources, action.sourceId);
  6167. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  6168. case 'NEXT':
  6169. case 'CHANGE_DATE':
  6170. case 'CHANGE_VIEW_TYPE':
  6171. if (dateProfile) {
  6172. return fetchDirtySources(eventSources, activeRange, context);
  6173. }
  6174. return eventSources;
  6175. case 'FETCH_EVENT_SOURCES':
  6176. return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
  6177. arrayToHash(action.sourceIds) :
  6178. excludeStaticSources(eventSources, context), activeRange, context);
  6179. case 'RECEIVE_EVENTS':
  6180. case 'RECEIVE_EVENT_ERROR':
  6181. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  6182. case 'REMOVE_ALL_EVENT_SOURCES':
  6183. return {};
  6184. default:
  6185. return eventSources;
  6186. }
  6187. }
  6188. function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
  6189. var activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
  6190. return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, context);
  6191. }
  6192. function computeEventSourceLoadingLevel(eventSources) {
  6193. var cnt = 0;
  6194. for (var sourceId in eventSources) {
  6195. if (eventSources[sourceId].isFetching) {
  6196. cnt += 1;
  6197. }
  6198. }
  6199. return cnt;
  6200. }
  6201. function addSources(eventSourceHash, sources, fetchRange, context) {
  6202. var hash = {};
  6203. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  6204. var source = sources_1[_i];
  6205. hash[source.sourceId] = source;
  6206. }
  6207. if (fetchRange) {
  6208. hash = fetchDirtySources(hash, fetchRange, context);
  6209. }
  6210. return __assign(__assign({}, eventSourceHash), hash);
  6211. }
  6212. function removeSource(eventSourceHash, sourceId) {
  6213. return filterHash(eventSourceHash, function (eventSource) { return eventSource.sourceId !== sourceId; });
  6214. }
  6215. function fetchDirtySources(sourceHash, fetchRange, context) {
  6216. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) { return isSourceDirty(eventSource, fetchRange, context); }), fetchRange, context);
  6217. }
  6218. function isSourceDirty(eventSource, fetchRange, context) {
  6219. if (!doesSourceNeedRange(eventSource, context)) {
  6220. return !eventSource.latestFetchId;
  6221. }
  6222. return !context.options.lazyFetching ||
  6223. !eventSource.fetchRange ||
  6224. eventSource.isFetching || // always cancel outdated in-progress fetches
  6225. fetchRange.start < eventSource.fetchRange.start ||
  6226. fetchRange.end > eventSource.fetchRange.end;
  6227. }
  6228. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, context) {
  6229. var nextSources = {};
  6230. for (var sourceId in prevSources) {
  6231. var source = prevSources[sourceId];
  6232. if (sourceIdHash[sourceId]) {
  6233. nextSources[sourceId] = fetchSource(source, fetchRange, context);
  6234. }
  6235. else {
  6236. nextSources[sourceId] = source;
  6237. }
  6238. }
  6239. return nextSources;
  6240. }
  6241. function fetchSource(eventSource, fetchRange, context) {
  6242. var options = context.options, calendarApi = context.calendarApi;
  6243. var sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
  6244. var fetchId = guid();
  6245. sourceDef.fetch({
  6246. eventSource: eventSource,
  6247. range: fetchRange,
  6248. context: context,
  6249. }, function (res) {
  6250. var rawEvents = res.rawEvents;
  6251. if (options.eventSourceSuccess) {
  6252. rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6253. }
  6254. if (eventSource.success) {
  6255. rawEvents = eventSource.success.call(calendarApi, rawEvents, res.xhr) || rawEvents;
  6256. }
  6257. context.dispatch({
  6258. type: 'RECEIVE_EVENTS',
  6259. sourceId: eventSource.sourceId,
  6260. fetchId: fetchId,
  6261. fetchRange: fetchRange,
  6262. rawEvents: rawEvents,
  6263. });
  6264. }, function (error) {
  6265. console.warn(error.message, error);
  6266. if (options.eventSourceFailure) {
  6267. options.eventSourceFailure.call(calendarApi, error);
  6268. }
  6269. if (eventSource.failure) {
  6270. eventSource.failure(error);
  6271. }
  6272. context.dispatch({
  6273. type: 'RECEIVE_EVENT_ERROR',
  6274. sourceId: eventSource.sourceId,
  6275. fetchId: fetchId,
  6276. fetchRange: fetchRange,
  6277. error: error,
  6278. });
  6279. });
  6280. return __assign(__assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
  6281. }
  6282. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  6283. var _a;
  6284. var eventSource = sourceHash[sourceId];
  6285. if (eventSource && // not already removed
  6286. fetchId === eventSource.latestFetchId) {
  6287. return __assign(__assign({}, sourceHash), (_a = {}, _a[sourceId] = __assign(__assign({}, eventSource), { isFetching: false, fetchRange: fetchRange }), _a));
  6288. }
  6289. return sourceHash;
  6290. }
  6291. function excludeStaticSources(eventSources, context) {
  6292. return filterHash(eventSources, function (eventSource) { return doesSourceNeedRange(eventSource, context); });
  6293. }
  6294. function parseInitialSources(rawOptions, context) {
  6295. var refiners = buildEventSourceRefiners(context);
  6296. var rawSources = [].concat(rawOptions.eventSources || []);
  6297. var sources = []; // parsed
  6298. if (rawOptions.initialEvents) {
  6299. rawSources.unshift(rawOptions.initialEvents);
  6300. }
  6301. if (rawOptions.events) {
  6302. rawSources.unshift(rawOptions.events);
  6303. }
  6304. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6305. var rawSource = rawSources_1[_i];
  6306. var source = parseEventSource(rawSource, context, refiners);
  6307. if (source) {
  6308. sources.push(source);
  6309. }
  6310. }
  6311. return sources;
  6312. }
  6313. function doesSourceNeedRange(eventSource, context) {
  6314. var defs = context.pluginHooks.eventSourceDefs;
  6315. return !defs[eventSource.sourceDefId].ignoreRange;
  6316. }
  6317. function reduceDateSelection(currentSelection, action) {
  6318. switch (action.type) {
  6319. case 'UNSELECT_DATES':
  6320. return null;
  6321. case 'SELECT_DATES':
  6322. return action.selection;
  6323. default:
  6324. return currentSelection;
  6325. }
  6326. }
  6327. function reduceSelectedEvent(currentInstanceId, action) {
  6328. switch (action.type) {
  6329. case 'UNSELECT_EVENT':
  6330. return '';
  6331. case 'SELECT_EVENT':
  6332. return action.eventInstanceId;
  6333. default:
  6334. return currentInstanceId;
  6335. }
  6336. }
  6337. function reduceEventDrag(currentDrag, action) {
  6338. var newDrag;
  6339. switch (action.type) {
  6340. case 'UNSET_EVENT_DRAG':
  6341. return null;
  6342. case 'SET_EVENT_DRAG':
  6343. newDrag = action.state;
  6344. return {
  6345. affectedEvents: newDrag.affectedEvents,
  6346. mutatedEvents: newDrag.mutatedEvents,
  6347. isEvent: newDrag.isEvent,
  6348. };
  6349. default:
  6350. return currentDrag;
  6351. }
  6352. }
  6353. function reduceEventResize(currentResize, action) {
  6354. var newResize;
  6355. switch (action.type) {
  6356. case 'UNSET_EVENT_RESIZE':
  6357. return null;
  6358. case 'SET_EVENT_RESIZE':
  6359. newResize = action.state;
  6360. return {
  6361. affectedEvents: newResize.affectedEvents,
  6362. mutatedEvents: newResize.mutatedEvents,
  6363. isEvent: newResize.isEvent,
  6364. };
  6365. default:
  6366. return currentResize;
  6367. }
  6368. }
  6369. function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
  6370. var viewsWithButtons = [];
  6371. var headerToolbar = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) : null;
  6372. var footerToolbar = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) : null;
  6373. return { headerToolbar: headerToolbar, footerToolbar: footerToolbar, viewsWithButtons: viewsWithButtons };
  6374. }
  6375. function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) {
  6376. return mapHash(sectionStrHash, function (sectionStr) { return parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons); });
  6377. }
  6378. /*
  6379. BAD: querying icons and text here. should be done at render time
  6380. */
  6381. function parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi, viewsWithButtons) {
  6382. var isRtl = calendarOptions.direction === 'rtl';
  6383. var calendarCustomButtons = calendarOptions.customButtons || {};
  6384. var calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
  6385. var calendarButtonText = calendarOptions.buttonText || {};
  6386. var sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
  6387. return sectionSubstrs.map(function (buttonGroupStr) { return (buttonGroupStr.split(',').map(function (buttonName) {
  6388. if (buttonName === 'title') {
  6389. return { buttonName: buttonName };
  6390. }
  6391. var customButtonProps;
  6392. var viewSpec;
  6393. var buttonClick;
  6394. var buttonIcon; // only one of these will be set
  6395. var buttonText; // "
  6396. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  6397. buttonClick = function (ev) {
  6398. if (customButtonProps.click) {
  6399. customButtonProps.click.call(ev.target, ev, ev.target);
  6400. }
  6401. };
  6402. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  6403. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6404. (buttonText = customButtonProps.text);
  6405. }
  6406. else if ((viewSpec = viewSpecs[buttonName])) {
  6407. viewsWithButtons.push(buttonName);
  6408. buttonClick = function () {
  6409. calendarApi.changeView(buttonName);
  6410. };
  6411. (buttonText = viewSpec.buttonTextOverride) ||
  6412. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6413. (buttonText = viewSpec.buttonTextDefault);
  6414. }
  6415. else if (calendarApi[buttonName]) { // a calendarApi method
  6416. buttonClick = function () {
  6417. calendarApi[buttonName]();
  6418. };
  6419. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6420. (buttonIcon = theme.getIconClass(buttonName, isRtl)) ||
  6421. (buttonText = calendarButtonText[buttonName]);
  6422. // ^ everything else is considered default
  6423. }
  6424. return { buttonName: buttonName, buttonClick: buttonClick, buttonIcon: buttonIcon, buttonText: buttonText };
  6425. })); });
  6426. }
  6427. var eventSourceDef = {
  6428. ignoreRange: true,
  6429. parseMeta: function (refined) {
  6430. if (Array.isArray(refined.events)) {
  6431. return refined.events;
  6432. }
  6433. return null;
  6434. },
  6435. fetch: function (arg, success) {
  6436. success({
  6437. rawEvents: arg.eventSource.meta,
  6438. });
  6439. },
  6440. };
  6441. var arrayEventSourcePlugin = createPlugin({
  6442. eventSourceDefs: [eventSourceDef],
  6443. });
  6444. var eventSourceDef$1 = {
  6445. parseMeta: function (refined) {
  6446. if (typeof refined.events === 'function') {
  6447. return refined.events;
  6448. }
  6449. return null;
  6450. },
  6451. fetch: function (arg, success, failure) {
  6452. var dateEnv = arg.context.dateEnv;
  6453. var func = arg.eventSource.meta;
  6454. unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), function (rawEvents) {
  6455. success({ rawEvents: rawEvents }); // needs an object response
  6456. }, failure);
  6457. },
  6458. };
  6459. var funcEventSourcePlugin = createPlugin({
  6460. eventSourceDefs: [eventSourceDef$1],
  6461. });
  6462. function requestJson(method, url, params, successCallback, failureCallback) {
  6463. method = method.toUpperCase();
  6464. var body = null;
  6465. if (method === 'GET') {
  6466. url = injectQueryStringParams(url, params);
  6467. }
  6468. else {
  6469. body = encodeParams(params);
  6470. }
  6471. var xhr = new XMLHttpRequest();
  6472. xhr.open(method, url, true);
  6473. if (method !== 'GET') {
  6474. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  6475. }
  6476. xhr.onload = function () {
  6477. if (xhr.status >= 200 && xhr.status < 400) {
  6478. var parsed = false;
  6479. var res = void 0;
  6480. try {
  6481. res = JSON.parse(xhr.responseText);
  6482. parsed = true;
  6483. }
  6484. catch (err) {
  6485. // will handle parsed=false
  6486. }
  6487. if (parsed) {
  6488. successCallback(res, xhr);
  6489. }
  6490. else {
  6491. failureCallback('Failure parsing JSON', xhr);
  6492. }
  6493. }
  6494. else {
  6495. failureCallback('Request failed', xhr);
  6496. }
  6497. };
  6498. xhr.onerror = function () {
  6499. failureCallback('Request failed', xhr);
  6500. };
  6501. xhr.send(body);
  6502. }
  6503. function injectQueryStringParams(url, params) {
  6504. return url +
  6505. (url.indexOf('?') === -1 ? '?' : '&') +
  6506. encodeParams(params);
  6507. }
  6508. function encodeParams(params) {
  6509. var parts = [];
  6510. for (var key in params) {
  6511. parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
  6512. }
  6513. return parts.join('&');
  6514. }
  6515. var JSON_FEED_EVENT_SOURCE_REFINERS = {
  6516. method: String,
  6517. extraParams: identity,
  6518. startParam: String,
  6519. endParam: String,
  6520. timeZoneParam: String,
  6521. };
  6522. var eventSourceDef$2 = {
  6523. parseMeta: function (refined) {
  6524. if (refined.url) {
  6525. return {
  6526. url: refined.url,
  6527. method: (refined.method || 'GET').toUpperCase(),
  6528. extraParams: refined.extraParams,
  6529. startParam: refined.startParam,
  6530. endParam: refined.endParam,
  6531. timeZoneParam: refined.timeZoneParam,
  6532. };
  6533. }
  6534. return null;
  6535. },
  6536. fetch: function (arg, success, failure) {
  6537. var meta = arg.eventSource.meta;
  6538. var requestParams = buildRequestParams(meta, arg.range, arg.context);
  6539. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  6540. success({ rawEvents: rawEvents, xhr: xhr });
  6541. }, function (errorMessage, xhr) {
  6542. failure({ message: errorMessage, xhr: xhr });
  6543. });
  6544. },
  6545. };
  6546. var jsonFeedEventSourcePlugin = createPlugin({
  6547. eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
  6548. eventSourceDefs: [eventSourceDef$2],
  6549. });
  6550. function buildRequestParams(meta, range, context) {
  6551. var dateEnv = context.dateEnv, options = context.options;
  6552. var startParam;
  6553. var endParam;
  6554. var timeZoneParam;
  6555. var customRequestParams;
  6556. var params = {};
  6557. startParam = meta.startParam;
  6558. if (startParam == null) {
  6559. startParam = options.startParam;
  6560. }
  6561. endParam = meta.endParam;
  6562. if (endParam == null) {
  6563. endParam = options.endParam;
  6564. }
  6565. timeZoneParam = meta.timeZoneParam;
  6566. if (timeZoneParam == null) {
  6567. timeZoneParam = options.timeZoneParam;
  6568. }
  6569. // retrieve any outbound GET/POST data from the options
  6570. if (typeof meta.extraParams === 'function') {
  6571. // supplied as a function that returns a key/value object
  6572. customRequestParams = meta.extraParams();
  6573. }
  6574. else {
  6575. // probably supplied as a straight key/value object
  6576. customRequestParams = meta.extraParams || {};
  6577. }
  6578. __assign(params, customRequestParams);
  6579. params[startParam] = dateEnv.formatIso(range.start);
  6580. params[endParam] = dateEnv.formatIso(range.end);
  6581. if (dateEnv.timeZone !== 'local') {
  6582. params[timeZoneParam] = dateEnv.timeZone;
  6583. }
  6584. return params;
  6585. }
  6586. var SIMPLE_RECURRING_REFINERS = {
  6587. daysOfWeek: identity,
  6588. startTime: createDuration,
  6589. endTime: createDuration,
  6590. duration: createDuration,
  6591. startRecur: identity,
  6592. endRecur: identity,
  6593. };
  6594. var recurring = {
  6595. parse: function (refined, dateEnv) {
  6596. if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
  6597. var recurringData = {
  6598. daysOfWeek: refined.daysOfWeek || null,
  6599. startTime: refined.startTime || null,
  6600. endTime: refined.endTime || null,
  6601. startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
  6602. endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
  6603. };
  6604. var duration = void 0;
  6605. if (refined.duration) {
  6606. duration = refined.duration;
  6607. }
  6608. if (!duration && refined.startTime && refined.endTime) {
  6609. duration = subtractDurations(refined.endTime, refined.startTime);
  6610. }
  6611. return {
  6612. allDayGuess: Boolean(!refined.startTime && !refined.endTime),
  6613. duration: duration,
  6614. typeData: recurringData,
  6615. };
  6616. }
  6617. return null;
  6618. },
  6619. expand: function (typeData, framingRange, dateEnv) {
  6620. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  6621. if (clippedFramingRange) {
  6622. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  6623. }
  6624. return [];
  6625. },
  6626. };
  6627. var simpleRecurringEventsPlugin = createPlugin({
  6628. recurringTypes: [recurring],
  6629. eventRefiners: SIMPLE_RECURRING_REFINERS,
  6630. });
  6631. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  6632. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  6633. var dayMarker = startOfDay(framingRange.start);
  6634. var endMarker = framingRange.end;
  6635. var instanceStarts = [];
  6636. while (dayMarker < endMarker) {
  6637. var instanceStart
  6638. // if everyday, or this particular day-of-week
  6639. = void 0;
  6640. // if everyday, or this particular day-of-week
  6641. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  6642. if (startTime) {
  6643. instanceStart = dateEnv.add(dayMarker, startTime);
  6644. }
  6645. else {
  6646. instanceStart = dayMarker;
  6647. }
  6648. instanceStarts.push(instanceStart);
  6649. }
  6650. dayMarker = addDays(dayMarker, 1);
  6651. }
  6652. return instanceStarts;
  6653. }
  6654. var changeHandlerPlugin = createPlugin({
  6655. optionChangeHandlers: {
  6656. events: function (events, context) {
  6657. handleEventSources([events], context);
  6658. },
  6659. eventSources: handleEventSources,
  6660. },
  6661. });
  6662. /*
  6663. BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
  6664. */
  6665. function handleEventSources(inputs, context) {
  6666. var unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
  6667. var newInputs = [];
  6668. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  6669. var input = inputs_1[_i];
  6670. var inputFound = false;
  6671. for (var i = 0; i < unfoundSources.length; i += 1) {
  6672. if (unfoundSources[i]._raw === input) {
  6673. unfoundSources.splice(i, 1); // delete
  6674. inputFound = true;
  6675. break;
  6676. }
  6677. }
  6678. if (!inputFound) {
  6679. newInputs.push(input);
  6680. }
  6681. }
  6682. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  6683. var unfoundSource = unfoundSources_1[_a];
  6684. context.dispatch({
  6685. type: 'REMOVE_EVENT_SOURCE',
  6686. sourceId: unfoundSource.sourceId,
  6687. });
  6688. }
  6689. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  6690. var newInput = newInputs_1[_b];
  6691. context.calendarApi.addEventSource(newInput);
  6692. }
  6693. }
  6694. function handleDateProfile(dateProfile, context) {
  6695. context.emitter.trigger('datesSet', __assign(__assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
  6696. }
  6697. function handleEventStore(eventStore, context) {
  6698. var emitter = context.emitter;
  6699. if (emitter.hasHandlers('eventsSet')) {
  6700. emitter.trigger('eventsSet', buildEventApis(eventStore, context));
  6701. }
  6702. }
  6703. /*
  6704. this array is exposed on the root namespace so that UMD plugins can add to it.
  6705. see the rollup-bundles script.
  6706. */
  6707. var globalPlugins = [
  6708. arrayEventSourcePlugin,
  6709. funcEventSourcePlugin,
  6710. jsonFeedEventSourcePlugin,
  6711. simpleRecurringEventsPlugin,
  6712. changeHandlerPlugin,
  6713. createPlugin({
  6714. contentTypeHandlers: {
  6715. html: function () { return ({ render: injectHtml }); },
  6716. domNodes: function () { return ({ render: injectDomNodes }); },
  6717. },
  6718. propSetHandlers: {
  6719. dateProfile: handleDateProfile,
  6720. eventStore: handleEventStore,
  6721. },
  6722. }),
  6723. ];
  6724. function injectHtml(el, html) {
  6725. el.innerHTML = html;
  6726. }
  6727. function injectDomNodes(el, domNodes) {
  6728. var oldNodes = Array.prototype.slice.call(el.childNodes); // TODO: use array util
  6729. var newNodes = Array.prototype.slice.call(domNodes); // TODO: use array util
  6730. if (!isArraysEqual(oldNodes, newNodes)) {
  6731. for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) {
  6732. var newNode = newNodes_1[_i];
  6733. el.appendChild(newNode);
  6734. }
  6735. oldNodes.forEach(removeElement);
  6736. }
  6737. }
  6738. var DelayedRunner = /** @class */ (function () {
  6739. function DelayedRunner(drainedOption) {
  6740. this.drainedOption = drainedOption;
  6741. this.isRunning = false;
  6742. this.isDirty = false;
  6743. this.pauseDepths = {};
  6744. this.timeoutId = 0;
  6745. }
  6746. DelayedRunner.prototype.request = function (delay) {
  6747. this.isDirty = true;
  6748. if (!this.isPaused()) {
  6749. this.clearTimeout();
  6750. if (delay == null) {
  6751. this.tryDrain();
  6752. }
  6753. else {
  6754. this.timeoutId = setTimeout(// NOT OPTIMAL! TODO: look at debounce
  6755. this.tryDrain.bind(this), delay);
  6756. }
  6757. }
  6758. };
  6759. DelayedRunner.prototype.pause = function (scope) {
  6760. if (scope === void 0) { scope = ''; }
  6761. var pauseDepths = this.pauseDepths;
  6762. pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
  6763. this.clearTimeout();
  6764. };
  6765. DelayedRunner.prototype.resume = function (scope, force) {
  6766. if (scope === void 0) { scope = ''; }
  6767. var pauseDepths = this.pauseDepths;
  6768. if (scope in pauseDepths) {
  6769. if (force) {
  6770. delete pauseDepths[scope];
  6771. }
  6772. else {
  6773. pauseDepths[scope] -= 1;
  6774. var depth = pauseDepths[scope];
  6775. if (depth <= 0) {
  6776. delete pauseDepths[scope];
  6777. }
  6778. }
  6779. this.tryDrain();
  6780. }
  6781. };
  6782. DelayedRunner.prototype.isPaused = function () {
  6783. return Object.keys(this.pauseDepths).length;
  6784. };
  6785. DelayedRunner.prototype.tryDrain = function () {
  6786. if (!this.isRunning && !this.isPaused()) {
  6787. this.isRunning = true;
  6788. while (this.isDirty) {
  6789. this.isDirty = false;
  6790. this.drained(); // might set isDirty to true again
  6791. }
  6792. this.isRunning = false;
  6793. }
  6794. };
  6795. DelayedRunner.prototype.clear = function () {
  6796. this.clearTimeout();
  6797. this.isDirty = false;
  6798. this.pauseDepths = {};
  6799. };
  6800. DelayedRunner.prototype.clearTimeout = function () {
  6801. if (this.timeoutId) {
  6802. clearTimeout(this.timeoutId);
  6803. this.timeoutId = 0;
  6804. }
  6805. };
  6806. DelayedRunner.prototype.drained = function () {
  6807. if (this.drainedOption) {
  6808. this.drainedOption();
  6809. }
  6810. };
  6811. return DelayedRunner;
  6812. }());
  6813. var TaskRunner = /** @class */ (function () {
  6814. function TaskRunner(runTaskOption, drainedOption) {
  6815. this.runTaskOption = runTaskOption;
  6816. this.drainedOption = drainedOption;
  6817. this.queue = [];
  6818. this.delayedRunner = new DelayedRunner(this.drain.bind(this));
  6819. }
  6820. TaskRunner.prototype.request = function (task, delay) {
  6821. this.queue.push(task);
  6822. this.delayedRunner.request(delay);
  6823. };
  6824. TaskRunner.prototype.pause = function (scope) {
  6825. this.delayedRunner.pause(scope);
  6826. };
  6827. TaskRunner.prototype.resume = function (scope, force) {
  6828. this.delayedRunner.resume(scope, force);
  6829. };
  6830. TaskRunner.prototype.drain = function () {
  6831. var queue = this.queue;
  6832. while (queue.length) {
  6833. var completedTasks = [];
  6834. var task = void 0;
  6835. while ((task = queue.shift())) {
  6836. this.runTask(task);
  6837. completedTasks.push(task);
  6838. }
  6839. this.drained(completedTasks);
  6840. } // keep going, in case new tasks were added in the drained handler
  6841. };
  6842. TaskRunner.prototype.runTask = function (task) {
  6843. if (this.runTaskOption) {
  6844. this.runTaskOption(task);
  6845. }
  6846. };
  6847. TaskRunner.prototype.drained = function (completedTasks) {
  6848. if (this.drainedOption) {
  6849. this.drainedOption(completedTasks);
  6850. }
  6851. };
  6852. return TaskRunner;
  6853. }());
  6854. // Computes what the title at the top of the calendarApi should be for this view
  6855. function buildTitle(dateProfile, viewOptions, dateEnv) {
  6856. var range;
  6857. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6858. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6859. range = dateProfile.currentRange;
  6860. }
  6861. else { // for day units or smaller, use the actual day range
  6862. range = dateProfile.activeRange;
  6863. }
  6864. return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
  6865. isEndExclusive: dateProfile.isRangeAllDay,
  6866. defaultSeparator: viewOptions.titleRangeSeparator,
  6867. });
  6868. }
  6869. // Generates the format string that should be used to generate the title for the current date range.
  6870. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6871. function buildTitleFormat(dateProfile) {
  6872. var currentRangeUnit = dateProfile.currentRangeUnit;
  6873. if (currentRangeUnit === 'year') {
  6874. return { year: 'numeric' };
  6875. }
  6876. if (currentRangeUnit === 'month') {
  6877. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6878. }
  6879. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6880. if (days !== null && days > 1) {
  6881. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6882. return { year: 'numeric', month: 'short', day: 'numeric' };
  6883. }
  6884. // one day. longer, like "September 9 2014"
  6885. return { year: 'numeric', month: 'long', day: 'numeric' };
  6886. }
  6887. // in future refactor, do the redux-style function(state=initial) for initial-state
  6888. // also, whatever is happening in constructor, have it happen in action queue too
  6889. var CalendarDataManager = /** @class */ (function () {
  6890. function CalendarDataManager(props) {
  6891. var _this = this;
  6892. this.computeOptionsData = memoize(this._computeOptionsData);
  6893. this.computeCurrentViewData = memoize(this._computeCurrentViewData);
  6894. this.organizeRawLocales = memoize(organizeRawLocales);
  6895. this.buildLocale = memoize(buildLocale);
  6896. this.buildPluginHooks = buildBuildPluginHooks();
  6897. this.buildDateEnv = memoize(buildDateEnv$1);
  6898. this.buildTheme = memoize(buildTheme);
  6899. this.parseToolbars = memoize(parseToolbars);
  6900. this.buildViewSpecs = memoize(buildViewSpecs);
  6901. this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
  6902. this.buildViewApi = memoize(buildViewApi);
  6903. this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
  6904. this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
  6905. this.buildEventUiBases = memoize(buildEventUiBases);
  6906. this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
  6907. this.buildTitle = memoize(buildTitle);
  6908. this.emitter = new Emitter();
  6909. this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
  6910. this.currentCalendarOptionsInput = {};
  6911. this.currentCalendarOptionsRefined = {};
  6912. this.currentViewOptionsInput = {};
  6913. this.currentViewOptionsRefined = {};
  6914. this.currentCalendarOptionsRefiners = {};
  6915. this.getCurrentData = function () { return _this.data; };
  6916. this.dispatch = function (action) {
  6917. _this.actionRunner.request(action); // protects against recursive calls to _handleAction
  6918. };
  6919. this.props = props;
  6920. this.actionRunner.pause();
  6921. var dynamicOptionOverrides = {};
  6922. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  6923. var currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
  6924. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  6925. // wire things up
  6926. // TODO: not DRY
  6927. props.calendarApi.currentDataManager = this;
  6928. this.emitter.setThisContext(props.calendarApi);
  6929. this.emitter.setOptions(currentViewData.options);
  6930. var currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
  6931. var dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  6932. if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
  6933. currentDate = dateProfile.currentRange.start;
  6934. }
  6935. var calendarContext = {
  6936. dateEnv: optionsData.dateEnv,
  6937. options: optionsData.calendarOptions,
  6938. pluginHooks: optionsData.pluginHooks,
  6939. calendarApi: props.calendarApi,
  6940. dispatch: this.dispatch,
  6941. emitter: this.emitter,
  6942. getCurrentData: this.getCurrentData,
  6943. };
  6944. // needs to be after setThisContext
  6945. for (var _i = 0, _a = optionsData.pluginHooks.contextInit; _i < _a.length; _i++) {
  6946. var callback = _a[_i];
  6947. callback(calendarContext);
  6948. }
  6949. // NOT DRY
  6950. var eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
  6951. var initialState = {
  6952. dynamicOptionOverrides: dynamicOptionOverrides,
  6953. currentViewType: currentViewType,
  6954. currentDate: currentDate,
  6955. dateProfile: dateProfile,
  6956. businessHours: this.parseContextBusinessHours(calendarContext),
  6957. eventSources: eventSources,
  6958. eventUiBases: {},
  6959. loadingLevel: computeEventSourceLoadingLevel(eventSources),
  6960. eventStore: createEmptyEventStore(),
  6961. renderableEventStore: createEmptyEventStore(),
  6962. dateSelection: null,
  6963. eventSelection: '',
  6964. eventDrag: null,
  6965. eventResize: null,
  6966. selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
  6967. };
  6968. var contextAndState = __assign(__assign({}, calendarContext), initialState);
  6969. for (var _b = 0, _c = optionsData.pluginHooks.reducers; _b < _c.length; _b++) {
  6970. var reducer = _c[_b];
  6971. __assign(initialState, reducer(null, null, contextAndState));
  6972. }
  6973. if (initialState.loadingLevel) {
  6974. this.emitter.trigger('loading', true); // NOT DRY
  6975. }
  6976. this.state = initialState;
  6977. this.updateData();
  6978. this.actionRunner.resume();
  6979. }
  6980. CalendarDataManager.prototype.resetOptions = function (optionOverrides, append) {
  6981. var props = this.props;
  6982. props.optionOverrides = append
  6983. ? __assign(__assign({}, props.optionOverrides), optionOverrides) : optionOverrides;
  6984. this.actionRunner.request({
  6985. type: 'NOTHING',
  6986. });
  6987. };
  6988. CalendarDataManager.prototype._handleAction = function (action) {
  6989. var _a = this, props = _a.props, state = _a.state, emitter = _a.emitter;
  6990. var dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
  6991. var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
  6992. var currentViewType = reduceViewType(state.currentViewType, action);
  6993. var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
  6994. // wire things up
  6995. // TODO: not DRY
  6996. props.calendarApi.currentDataManager = this;
  6997. emitter.setThisContext(props.calendarApi);
  6998. emitter.setOptions(currentViewData.options);
  6999. var calendarContext = {
  7000. dateEnv: optionsData.dateEnv,
  7001. options: optionsData.calendarOptions,
  7002. pluginHooks: optionsData.pluginHooks,
  7003. calendarApi: props.calendarApi,
  7004. dispatch: this.dispatch,
  7005. emitter: emitter,
  7006. getCurrentData: this.getCurrentData,
  7007. };
  7008. var currentDate = state.currentDate, dateProfile = state.dateProfile;
  7009. if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
  7010. dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
  7011. }
  7012. currentDate = reduceCurrentDate(currentDate, action);
  7013. dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
  7014. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  7015. currentDate = dateProfile.currentRange.start;
  7016. }
  7017. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
  7018. var eventSourceLoadingLevel = computeEventSourceLoadingLevel(eventSources);
  7019. var eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
  7020. var renderableEventStore = (eventSourceLoadingLevel && !currentViewData.options.progressiveEventRendering) ?
  7021. (state.renderableEventStore || eventStore) : // try from previous state
  7022. eventStore;
  7023. var _b = this.buildViewUiProps(calendarContext), eventUiSingleBase = _b.eventUiSingleBase, selectionConfig = _b.selectionConfig; // will memoize obj
  7024. var eventUiBySource = this.buildEventUiBySource(eventSources);
  7025. var eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  7026. var prevLoadingLevel = state.loadingLevel || 0;
  7027. var loadingLevel = eventSourceLoadingLevel;
  7028. var newState = {
  7029. dynamicOptionOverrides: dynamicOptionOverrides,
  7030. currentViewType: currentViewType,
  7031. currentDate: currentDate,
  7032. dateProfile: dateProfile,
  7033. eventSources: eventSources,
  7034. eventStore: eventStore,
  7035. renderableEventStore: renderableEventStore,
  7036. selectionConfig: selectionConfig,
  7037. eventUiBases: eventUiBases,
  7038. loadingLevel: loadingLevel,
  7039. businessHours: this.parseContextBusinessHours(calendarContext),
  7040. dateSelection: reduceDateSelection(state.dateSelection, action),
  7041. eventSelection: reduceSelectedEvent(state.eventSelection, action),
  7042. eventDrag: reduceEventDrag(state.eventDrag, action),
  7043. eventResize: reduceEventResize(state.eventResize, action),
  7044. };
  7045. var contextAndState = __assign(__assign({}, calendarContext), newState);
  7046. for (var _i = 0, _c = optionsData.pluginHooks.reducers; _i < _c.length; _i++) {
  7047. var reducer = _c[_i];
  7048. __assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
  7049. }
  7050. // TODO: use propSetHandlers in plugin system
  7051. if (!prevLoadingLevel && loadingLevel) {
  7052. emitter.trigger('loading', true);
  7053. }
  7054. else if (prevLoadingLevel && !loadingLevel) {
  7055. emitter.trigger('loading', false);
  7056. }
  7057. this.state = newState;
  7058. if (props.onAction) {
  7059. props.onAction(action);
  7060. }
  7061. };
  7062. CalendarDataManager.prototype.updateData = function () {
  7063. var _a = this, props = _a.props, state = _a.state;
  7064. var oldData = this.data;
  7065. var optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
  7066. var currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
  7067. 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);
  7068. var changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
  7069. var oldCalendarOptions = oldData && oldData.calendarOptions;
  7070. var newCalendarOptions = optionsData.calendarOptions;
  7071. if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
  7072. if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
  7073. // hack
  7074. state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
  7075. state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
  7076. }
  7077. for (var optionName in changeHandlers) {
  7078. if (oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
  7079. changeHandlers[optionName](newCalendarOptions[optionName], data);
  7080. }
  7081. }
  7082. }
  7083. if (props.onData) {
  7084. props.onData(data);
  7085. }
  7086. };
  7087. CalendarDataManager.prototype._computeOptionsData = function (optionOverrides, dynamicOptionOverrides, calendarApi) {
  7088. // TODO: blacklist options that are handled by optionChangeHandlers
  7089. var _a = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, pluginHooks = _a.pluginHooks, localeDefaults = _a.localeDefaults, availableLocaleData = _a.availableLocaleData, extra = _a.extra;
  7090. warnUnknownOptions(extra);
  7091. var dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
  7092. var viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides, localeDefaults);
  7093. var theme = this.buildTheme(refinedOptions, pluginHooks);
  7094. var toolbarConfig = this.parseToolbars(refinedOptions, optionOverrides, theme, viewSpecs, calendarApi);
  7095. return {
  7096. calendarOptions: refinedOptions,
  7097. pluginHooks: pluginHooks,
  7098. dateEnv: dateEnv,
  7099. viewSpecs: viewSpecs,
  7100. theme: theme,
  7101. toolbarConfig: toolbarConfig,
  7102. localeDefaults: localeDefaults,
  7103. availableRawLocales: availableLocaleData.map,
  7104. };
  7105. };
  7106. // always called from behind a memoizer
  7107. CalendarDataManager.prototype.processRawCalendarOptions = function (optionOverrides, dynamicOptionOverrides) {
  7108. var _a = mergeRawOptions([
  7109. BASE_OPTION_DEFAULTS,
  7110. optionOverrides,
  7111. dynamicOptionOverrides,
  7112. ]), locales = _a.locales, locale = _a.locale;
  7113. var availableLocaleData = this.organizeRawLocales(locales);
  7114. var availableRawLocales = availableLocaleData.map;
  7115. var localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
  7116. var pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
  7117. var refiners = this.currentCalendarOptionsRefiners = __assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7118. var extra = {};
  7119. var raw = mergeRawOptions([
  7120. BASE_OPTION_DEFAULTS,
  7121. localeDefaults,
  7122. optionOverrides,
  7123. dynamicOptionOverrides,
  7124. ]);
  7125. var refined = {};
  7126. var currentRaw = this.currentCalendarOptionsInput;
  7127. var currentRefined = this.currentCalendarOptionsRefined;
  7128. var anyChanges = false;
  7129. for (var optionName in raw) {
  7130. if (optionName !== 'plugins') { // because plugins is special-cased
  7131. if (raw[optionName] === currentRaw[optionName] ||
  7132. (COMPLEX_OPTION_COMPARATORS[optionName] &&
  7133. (optionName in currentRaw) &&
  7134. COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName]))) {
  7135. refined[optionName] = currentRefined[optionName];
  7136. }
  7137. else if (refiners[optionName]) {
  7138. refined[optionName] = refiners[optionName](raw[optionName]);
  7139. anyChanges = true;
  7140. }
  7141. else {
  7142. extra[optionName] = currentRaw[optionName];
  7143. }
  7144. }
  7145. }
  7146. if (anyChanges) {
  7147. this.currentCalendarOptionsInput = raw;
  7148. this.currentCalendarOptionsRefined = refined;
  7149. }
  7150. return {
  7151. rawOptions: this.currentCalendarOptionsInput,
  7152. refinedOptions: this.currentCalendarOptionsRefined,
  7153. pluginHooks: pluginHooks,
  7154. availableLocaleData: availableLocaleData,
  7155. localeDefaults: localeDefaults,
  7156. extra: extra,
  7157. };
  7158. };
  7159. CalendarDataManager.prototype._computeCurrentViewData = function (viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
  7160. var viewSpec = optionsData.viewSpecs[viewType];
  7161. if (!viewSpec) {
  7162. throw new Error("viewType \"" + viewType + "\" is not available. Please make sure you've loaded all neccessary plugins");
  7163. }
  7164. var _a = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, extra = _a.extra;
  7165. warnUnknownOptions(extra);
  7166. var dateProfileGenerator = this.buildDateProfileGenerator({
  7167. dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
  7168. duration: viewSpec.duration,
  7169. durationUnit: viewSpec.durationUnit,
  7170. usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
  7171. dateEnv: optionsData.dateEnv,
  7172. calendarApi: this.props.calendarApi,
  7173. slotMinTime: refinedOptions.slotMinTime,
  7174. slotMaxTime: refinedOptions.slotMaxTime,
  7175. showNonCurrentDates: refinedOptions.showNonCurrentDates,
  7176. dayCount: refinedOptions.dayCount,
  7177. dateAlignment: refinedOptions.dateAlignment,
  7178. dateIncrement: refinedOptions.dateIncrement,
  7179. hiddenDays: refinedOptions.hiddenDays,
  7180. weekends: refinedOptions.weekends,
  7181. nowInput: refinedOptions.now,
  7182. validRangeInput: refinedOptions.validRange,
  7183. visibleRangeInput: refinedOptions.visibleRange,
  7184. monthMode: refinedOptions.monthMode,
  7185. fixedWeekCount: refinedOptions.fixedWeekCount,
  7186. });
  7187. var viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
  7188. return { viewSpec: viewSpec, options: refinedOptions, dateProfileGenerator: dateProfileGenerator, viewApi: viewApi };
  7189. };
  7190. CalendarDataManager.prototype.processRawViewOptions = function (viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
  7191. var raw = mergeRawOptions([
  7192. BASE_OPTION_DEFAULTS,
  7193. viewSpec.optionDefaults,
  7194. localeDefaults,
  7195. optionOverrides,
  7196. viewSpec.optionOverrides,
  7197. dynamicOptionOverrides,
  7198. ]);
  7199. var refiners = __assign(__assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
  7200. var refined = {};
  7201. var currentRaw = this.currentViewOptionsInput;
  7202. var currentRefined = this.currentViewOptionsRefined;
  7203. var anyChanges = false;
  7204. var extra = {};
  7205. for (var optionName in raw) {
  7206. if (raw[optionName] === currentRaw[optionName]) {
  7207. refined[optionName] = currentRefined[optionName];
  7208. }
  7209. else {
  7210. if (raw[optionName] === this.currentCalendarOptionsInput[optionName]) {
  7211. if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
  7212. refined[optionName] = this.currentCalendarOptionsRefined[optionName];
  7213. }
  7214. }
  7215. else if (refiners[optionName]) {
  7216. refined[optionName] = refiners[optionName](raw[optionName]);
  7217. }
  7218. else {
  7219. extra[optionName] = raw[optionName];
  7220. }
  7221. anyChanges = true;
  7222. }
  7223. }
  7224. if (anyChanges) {
  7225. this.currentViewOptionsInput = raw;
  7226. this.currentViewOptionsRefined = refined;
  7227. }
  7228. return {
  7229. rawOptions: this.currentViewOptionsInput,
  7230. refinedOptions: this.currentViewOptionsRefined,
  7231. extra: extra,
  7232. };
  7233. };
  7234. return CalendarDataManager;
  7235. }());
  7236. function buildDateEnv$1(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
  7237. var locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
  7238. return new DateEnv({
  7239. calendarSystem: 'gregory',
  7240. timeZone: timeZone,
  7241. namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
  7242. locale: locale,
  7243. weekNumberCalculation: weekNumberCalculation,
  7244. firstDay: firstDay,
  7245. weekText: weekText,
  7246. cmdFormatter: pluginHooks.cmdFormatter,
  7247. defaultSeparator: defaultSeparator,
  7248. });
  7249. }
  7250. function buildTheme(options, pluginHooks) {
  7251. var ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
  7252. return new ThemeClass(options);
  7253. }
  7254. function buildDateProfileGenerator(props) {
  7255. var DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
  7256. return new DateProfileGeneratorClass(props);
  7257. }
  7258. function buildViewApi(type, getCurrentData, dateEnv) {
  7259. return new ViewApi(type, getCurrentData, dateEnv);
  7260. }
  7261. function buildEventUiBySource(eventSources) {
  7262. return mapHash(eventSources, function (eventSource) { return eventSource.ui; });
  7263. }
  7264. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7265. var eventUiBases = { '': eventUiSingleBase };
  7266. for (var defId in eventDefs) {
  7267. var def = eventDefs[defId];
  7268. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7269. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7270. }
  7271. }
  7272. return eventUiBases;
  7273. }
  7274. function buildViewUiProps(calendarContext) {
  7275. var options = calendarContext.options;
  7276. return {
  7277. eventUiSingleBase: createEventUi({
  7278. display: options.eventDisplay,
  7279. editable: options.editable,
  7280. startEditable: options.eventStartEditable,
  7281. durationEditable: options.eventDurationEditable,
  7282. constraint: options.eventConstraint,
  7283. overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
  7284. allow: options.eventAllow,
  7285. backgroundColor: options.eventBackgroundColor,
  7286. borderColor: options.eventBorderColor,
  7287. textColor: options.eventTextColor,
  7288. color: options.eventColor,
  7289. }, calendarContext),
  7290. selectionConfig: createEventUi({
  7291. constraint: options.selectConstraint,
  7292. overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
  7293. allow: options.selectAllow,
  7294. }, calendarContext),
  7295. };
  7296. }
  7297. function parseContextBusinessHours(calendarContext) {
  7298. return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
  7299. }
  7300. function warnUnknownOptions(options, viewName) {
  7301. for (var optionName in options) {
  7302. console.warn("Unknown option '" + optionName + "'" +
  7303. (viewName ? " for view '" + viewName + "'" : ''));
  7304. }
  7305. }
  7306. // TODO: move this to react plugin?
  7307. var CalendarDataProvider = /** @class */ (function (_super) {
  7308. __extends(CalendarDataProvider, _super);
  7309. function CalendarDataProvider(props) {
  7310. var _this = _super.call(this, props) || this;
  7311. _this.handleData = function (data) {
  7312. if (!_this.dataManager) { // still within initial run, before assignment in constructor
  7313. // eslint-disable-next-line react/no-direct-mutation-state
  7314. _this.state = data; // can't use setState yet
  7315. }
  7316. else {
  7317. _this.setState(data);
  7318. }
  7319. };
  7320. _this.dataManager = new CalendarDataManager({
  7321. optionOverrides: props.optionOverrides,
  7322. calendarApi: props.calendarApi,
  7323. onData: _this.handleData,
  7324. });
  7325. return _this;
  7326. }
  7327. CalendarDataProvider.prototype.render = function () {
  7328. return this.props.children(this.state);
  7329. };
  7330. CalendarDataProvider.prototype.componentDidUpdate = function (prevProps) {
  7331. var newOptionOverrides = this.props.optionOverrides;
  7332. if (newOptionOverrides !== prevProps.optionOverrides) { // prevent recursive handleData
  7333. this.dataManager.resetOptions(newOptionOverrides);
  7334. }
  7335. };
  7336. return CalendarDataProvider;
  7337. }(Component));
  7338. // HELPERS
  7339. /*
  7340. if nextDayThreshold is specified, slicing is done in an all-day fashion.
  7341. you can get nextDayThreshold from context.nextDayThreshold
  7342. */
  7343. function sliceEvents(props, allDay) {
  7344. return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
  7345. }
  7346. var NamedTimeZoneImpl = /** @class */ (function () {
  7347. function NamedTimeZoneImpl(timeZoneName) {
  7348. this.timeZoneName = timeZoneName;
  7349. }
  7350. return NamedTimeZoneImpl;
  7351. }());
  7352. var Interaction = /** @class */ (function () {
  7353. function Interaction(settings) {
  7354. this.component = settings.component;
  7355. }
  7356. Interaction.prototype.destroy = function () {
  7357. };
  7358. return Interaction;
  7359. }());
  7360. function parseInteractionSettings(component, input) {
  7361. return {
  7362. component: component,
  7363. el: input.el,
  7364. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
  7365. };
  7366. }
  7367. function interactionSettingsToStore(settings) {
  7368. var _a;
  7369. return _a = {},
  7370. _a[settings.component.uid] = settings,
  7371. _a;
  7372. }
  7373. // global state
  7374. var interactionSettingsStore = {};
  7375. /*
  7376. An abstraction for a dragging interaction originating on an event.
  7377. Does higher-level things than PointerDragger, such as possibly:
  7378. - a "mirror" that moves with the pointer
  7379. - a minimum number of pixels or other criteria for a true drag to begin
  7380. subclasses must emit:
  7381. - pointerdown
  7382. - dragstart
  7383. - dragmove
  7384. - pointerup
  7385. - dragend
  7386. */
  7387. var ElementDragging = /** @class */ (function () {
  7388. function ElementDragging(el, selector) {
  7389. this.emitter = new Emitter();
  7390. }
  7391. ElementDragging.prototype.destroy = function () {
  7392. };
  7393. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  7394. // optional if subclass doesn't want to support a mirror
  7395. };
  7396. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  7397. // optional if subclass doesn't want to support a mirror
  7398. };
  7399. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  7400. // optional
  7401. };
  7402. return ElementDragging;
  7403. }());
  7404. // TODO: get rid of this in favor of options system,
  7405. // tho it's really easy to access this globally rather than pass thru options.
  7406. var config = {};
  7407. /*
  7408. Information about what will happen when an external element is dragged-and-dropped
  7409. onto a calendar. Contains information for creating an event.
  7410. */
  7411. var DRAG_META_REFINERS = {
  7412. startTime: createDuration,
  7413. duration: createDuration,
  7414. create: Boolean,
  7415. sourceId: String,
  7416. };
  7417. function parseDragMeta(raw) {
  7418. var _a = refineProps(raw, DRAG_META_REFINERS), refined = _a.refined, extra = _a.extra;
  7419. return {
  7420. startTime: refined.startTime || null,
  7421. duration: refined.duration || null,
  7422. create: refined.create != null ? refined.create : true,
  7423. sourceId: refined.sourceId,
  7424. leftoverProps: extra,
  7425. };
  7426. }
  7427. var ToolbarSection = /** @class */ (function (_super) {
  7428. __extends(ToolbarSection, _super);
  7429. function ToolbarSection() {
  7430. return _super !== null && _super.apply(this, arguments) || this;
  7431. }
  7432. ToolbarSection.prototype.render = function () {
  7433. var _this = this;
  7434. var children = this.props.widgetGroups.map(function (widgetGroup) { return _this.renderWidgetGroup(widgetGroup); });
  7435. return createElement.apply(void 0, __spreadArrays(['div', { className: 'fc-toolbar-chunk' }], children));
  7436. };
  7437. ToolbarSection.prototype.renderWidgetGroup = function (widgetGroup) {
  7438. var props = this.props;
  7439. var theme = this.context.theme;
  7440. var children = [];
  7441. var isOnlyButtons = true;
  7442. for (var _i = 0, widgetGroup_1 = widgetGroup; _i < widgetGroup_1.length; _i++) {
  7443. var widget = widgetGroup_1[_i];
  7444. var buttonName = widget.buttonName, buttonClick = widget.buttonClick, buttonText = widget.buttonText, buttonIcon = widget.buttonIcon;
  7445. if (buttonName === 'title') {
  7446. isOnlyButtons = false;
  7447. children.push(createElement("h2", { className: "fc-toolbar-title" }, props.title));
  7448. }
  7449. else {
  7450. var ariaAttrs = buttonIcon ? { 'aria-label': buttonName } : {};
  7451. var buttonClasses = ["fc-" + buttonName + "-button", theme.getClass('button')];
  7452. if (buttonName === props.activeButton) {
  7453. buttonClasses.push(theme.getClass('buttonActive'));
  7454. }
  7455. var isDisabled = (!props.isTodayEnabled && buttonName === 'today') ||
  7456. (!props.isPrevEnabled && buttonName === 'prev') ||
  7457. (!props.isNextEnabled && buttonName === 'next');
  7458. children.push(createElement("button", __assign({ disabled: isDisabled, className: buttonClasses.join(' '), onClick: buttonClick, type: "button" }, ariaAttrs), buttonText || (buttonIcon ? createElement("span", { className: buttonIcon }) : '')));
  7459. }
  7460. }
  7461. if (children.length > 1) {
  7462. var groupClassName = (isOnlyButtons && theme.getClass('buttonGroup')) || '';
  7463. return createElement.apply(void 0, __spreadArrays(['div', { className: groupClassName }], children));
  7464. }
  7465. return children[0];
  7466. };
  7467. return ToolbarSection;
  7468. }(BaseComponent));
  7469. var Toolbar = /** @class */ (function (_super) {
  7470. __extends(Toolbar, _super);
  7471. function Toolbar() {
  7472. return _super !== null && _super.apply(this, arguments) || this;
  7473. }
  7474. Toolbar.prototype.render = function () {
  7475. var _a = this.props, model = _a.model, extraClassName = _a.extraClassName;
  7476. var forceLtr = false;
  7477. var startContent;
  7478. var endContent;
  7479. var centerContent = model.center;
  7480. if (model.left) {
  7481. forceLtr = true;
  7482. startContent = model.left;
  7483. }
  7484. else {
  7485. startContent = model.start;
  7486. }
  7487. if (model.right) {
  7488. forceLtr = true;
  7489. endContent = model.right;
  7490. }
  7491. else {
  7492. endContent = model.end;
  7493. }
  7494. var classNames = [
  7495. extraClassName || '',
  7496. 'fc-toolbar',
  7497. forceLtr ? 'fc-toolbar-ltr' : '',
  7498. ];
  7499. return (createElement("div", { className: classNames.join(' ') },
  7500. this.renderSection('start', startContent || []),
  7501. this.renderSection('center', centerContent || []),
  7502. this.renderSection('end', endContent || [])));
  7503. };
  7504. Toolbar.prototype.renderSection = function (key, widgetGroups) {
  7505. var props = this.props;
  7506. return (createElement(ToolbarSection, { key: key, widgetGroups: widgetGroups, title: props.title, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled }));
  7507. };
  7508. return Toolbar;
  7509. }(BaseComponent));
  7510. // TODO: do function component?
  7511. var ViewContainer = /** @class */ (function (_super) {
  7512. __extends(ViewContainer, _super);
  7513. function ViewContainer() {
  7514. var _this = _super !== null && _super.apply(this, arguments) || this;
  7515. _this.state = {
  7516. availableWidth: null,
  7517. };
  7518. _this.handleEl = function (el) {
  7519. _this.el = el;
  7520. setRef(_this.props.elRef, el);
  7521. _this.updateAvailableWidth();
  7522. };
  7523. _this.handleResize = function () {
  7524. _this.updateAvailableWidth();
  7525. };
  7526. return _this;
  7527. }
  7528. ViewContainer.prototype.render = function () {
  7529. var _a = this, props = _a.props, state = _a.state;
  7530. var aspectRatio = props.aspectRatio;
  7531. var classNames = [
  7532. 'fc-view-harness',
  7533. (aspectRatio || props.liquid || props.height)
  7534. ? 'fc-view-harness-active' // harness controls the height
  7535. : 'fc-view-harness-passive',
  7536. ];
  7537. var height = '';
  7538. var paddingBottom = '';
  7539. if (aspectRatio) {
  7540. if (state.availableWidth !== null) {
  7541. height = state.availableWidth / aspectRatio;
  7542. }
  7543. else {
  7544. // while waiting to know availableWidth, we can't set height to *zero*
  7545. // because will cause lots of unnecessary scrollbars within scrollgrid.
  7546. // BETTER: don't start rendering ANYTHING yet until we know container width
  7547. // NOTE: why not always use paddingBottom? Causes height oscillation (issue 5606)
  7548. paddingBottom = (1 / aspectRatio) * 100 + "%";
  7549. }
  7550. }
  7551. else {
  7552. height = props.height || '';
  7553. }
  7554. return (createElement("div", { ref: this.handleEl, onClick: props.onClick, className: classNames.join(' '), style: { height: height, paddingBottom: paddingBottom } }, props.children));
  7555. };
  7556. ViewContainer.prototype.componentDidMount = function () {
  7557. this.context.addResizeHandler(this.handleResize);
  7558. };
  7559. ViewContainer.prototype.componentWillUnmount = function () {
  7560. this.context.removeResizeHandler(this.handleResize);
  7561. };
  7562. ViewContainer.prototype.updateAvailableWidth = function () {
  7563. if (this.el && // needed. but why?
  7564. this.props.aspectRatio // aspectRatio is the only height setting that needs availableWidth
  7565. ) {
  7566. this.setState({ availableWidth: this.el.offsetWidth });
  7567. }
  7568. };
  7569. return ViewContainer;
  7570. }(BaseComponent));
  7571. /*
  7572. Detects when the user clicks on an event within a DateComponent
  7573. */
  7574. var EventClicking = /** @class */ (function (_super) {
  7575. __extends(EventClicking, _super);
  7576. function EventClicking(settings) {
  7577. var _this = _super.call(this, settings) || this;
  7578. _this.handleSegClick = function (ev, segEl) {
  7579. var component = _this.component;
  7580. var context = component.context;
  7581. var seg = getElSeg(segEl);
  7582. if (seg && // might be the <div> surrounding the more link
  7583. component.isValidSegDownEl(ev.target)) {
  7584. // our way to simulate a link click for elements that can't be <a> tags
  7585. // grab before trigger fired in case trigger trashes DOM thru rerendering
  7586. var hasUrlContainer = elementClosest(ev.target, '.fc-event-forced-url');
  7587. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  7588. context.emitter.trigger('eventClick', {
  7589. el: segEl,
  7590. event: new EventApi(component.context, seg.eventRange.def, seg.eventRange.instance),
  7591. jsEvent: ev,
  7592. view: context.viewApi,
  7593. });
  7594. if (url && !ev.defaultPrevented) {
  7595. window.location.href = url;
  7596. }
  7597. }
  7598. };
  7599. _this.destroy = listenBySelector(settings.el, 'click', '.fc-event', // on both fg and bg events
  7600. _this.handleSegClick);
  7601. return _this;
  7602. }
  7603. return EventClicking;
  7604. }(Interaction));
  7605. /*
  7606. Triggers events and adds/removes core classNames when the user's pointer
  7607. enters/leaves event-elements of a component.
  7608. */
  7609. var EventHovering = /** @class */ (function (_super) {
  7610. __extends(EventHovering, _super);
  7611. function EventHovering(settings) {
  7612. var _this = _super.call(this, settings) || this;
  7613. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  7614. _this.handleEventElRemove = function (el) {
  7615. if (el === _this.currentSegEl) {
  7616. _this.handleSegLeave(null, _this.currentSegEl);
  7617. }
  7618. };
  7619. _this.handleSegEnter = function (ev, segEl) {
  7620. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  7621. _this.currentSegEl = segEl;
  7622. _this.triggerEvent('eventMouseEnter', ev, segEl);
  7623. }
  7624. };
  7625. _this.handleSegLeave = function (ev, segEl) {
  7626. if (_this.currentSegEl) {
  7627. _this.currentSegEl = null;
  7628. _this.triggerEvent('eventMouseLeave', ev, segEl);
  7629. }
  7630. };
  7631. _this.removeHoverListeners = listenToHoverBySelector(settings.el, '.fc-event', // on both fg and bg events
  7632. _this.handleSegEnter, _this.handleSegLeave);
  7633. return _this;
  7634. }
  7635. EventHovering.prototype.destroy = function () {
  7636. this.removeHoverListeners();
  7637. };
  7638. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  7639. var component = this.component;
  7640. var context = component.context;
  7641. var seg = getElSeg(segEl);
  7642. if (!ev || component.isValidSegDownEl(ev.target)) {
  7643. context.emitter.trigger(publicEvName, {
  7644. el: segEl,
  7645. event: new EventApi(context, seg.eventRange.def, seg.eventRange.instance),
  7646. jsEvent: ev,
  7647. view: context.viewApi,
  7648. });
  7649. }
  7650. };
  7651. return EventHovering;
  7652. }(Interaction));
  7653. var CalendarContent = /** @class */ (function (_super) {
  7654. __extends(CalendarContent, _super);
  7655. function CalendarContent() {
  7656. var _this = _super !== null && _super.apply(this, arguments) || this;
  7657. _this.buildViewContext = memoize(buildViewContext);
  7658. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  7659. _this.buildToolbarProps = memoize(buildToolbarProps);
  7660. _this.handleNavLinkClick = buildDelegationHandler('a[data-navlink]', _this._handleNavLinkClick.bind(_this));
  7661. _this.headerRef = createRef();
  7662. _this.footerRef = createRef();
  7663. _this.interactionsStore = {};
  7664. // Component Registration
  7665. // -----------------------------------------------------------------------------------------------------------------
  7666. _this.registerInteractiveComponent = function (component, settingsInput) {
  7667. var settings = parseInteractionSettings(component, settingsInput);
  7668. var DEFAULT_INTERACTIONS = [
  7669. EventClicking,
  7670. EventHovering,
  7671. ];
  7672. var interactionClasses = DEFAULT_INTERACTIONS.concat(_this.props.pluginHooks.componentInteractions);
  7673. var interactions = interactionClasses.map(function (TheInteractionClass) { return new TheInteractionClass(settings); });
  7674. _this.interactionsStore[component.uid] = interactions;
  7675. interactionSettingsStore[component.uid] = settings;
  7676. };
  7677. _this.unregisterInteractiveComponent = function (component) {
  7678. for (var _i = 0, _a = _this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7679. var listener = _a[_i];
  7680. listener.destroy();
  7681. }
  7682. delete _this.interactionsStore[component.uid];
  7683. delete interactionSettingsStore[component.uid];
  7684. };
  7685. // Resizing
  7686. // -----------------------------------------------------------------------------------------------------------------
  7687. _this.resizeRunner = new DelayedRunner(function () {
  7688. _this.props.emitter.trigger('_resize', true); // should window resizes be considered "forced" ?
  7689. _this.props.emitter.trigger('windowResize', { view: _this.props.viewApi });
  7690. });
  7691. _this.handleWindowResize = function (ev) {
  7692. var options = _this.props.options;
  7693. if (options.handleWindowResize &&
  7694. ev.target === window // avoid jqui events
  7695. ) {
  7696. _this.resizeRunner.request(options.windowResizeDelay);
  7697. }
  7698. };
  7699. return _this;
  7700. }
  7701. /*
  7702. renders INSIDE of an outer div
  7703. */
  7704. CalendarContent.prototype.render = function () {
  7705. var props = this.props;
  7706. var toolbarConfig = props.toolbarConfig, options = props.options;
  7707. var toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, getNow(props.options.now, props.dateEnv), // TODO: use NowTimer????
  7708. props.viewTitle);
  7709. var viewVGrow = false;
  7710. var viewHeight = '';
  7711. var viewAspectRatio;
  7712. if (props.isHeightAuto || props.forPrint) {
  7713. viewHeight = '';
  7714. }
  7715. else if (options.height != null) {
  7716. viewVGrow = true;
  7717. }
  7718. else if (options.contentHeight != null) {
  7719. viewHeight = options.contentHeight;
  7720. }
  7721. else {
  7722. viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
  7723. }
  7724. 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);
  7725. return (createElement(ViewContextType.Provider, { value: viewContext },
  7726. toolbarConfig.headerToolbar && (createElement(Toolbar, __assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.headerToolbar }, toolbarProps))),
  7727. createElement(ViewContainer, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, onClick: this.handleNavLinkClick },
  7728. this.renderView(props),
  7729. this.buildAppendContent()),
  7730. toolbarConfig.footerToolbar && (createElement(Toolbar, __assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footerToolbar }, toolbarProps)))));
  7731. };
  7732. CalendarContent.prototype.componentDidMount = function () {
  7733. var props = this.props;
  7734. this.calendarInteractions = props.pluginHooks.calendarInteractions
  7735. .map(function (CalendarInteractionClass) { return new CalendarInteractionClass(props); });
  7736. window.addEventListener('resize', this.handleWindowResize);
  7737. var propSetHandlers = props.pluginHooks.propSetHandlers;
  7738. for (var propName in propSetHandlers) {
  7739. propSetHandlers[propName](props[propName], props);
  7740. }
  7741. };
  7742. CalendarContent.prototype.componentDidUpdate = function (prevProps) {
  7743. var props = this.props;
  7744. var propSetHandlers = props.pluginHooks.propSetHandlers;
  7745. for (var propName in propSetHandlers) {
  7746. if (props[propName] !== prevProps[propName]) {
  7747. propSetHandlers[propName](props[propName], props);
  7748. }
  7749. }
  7750. };
  7751. CalendarContent.prototype.componentWillUnmount = function () {
  7752. window.removeEventListener('resize', this.handleWindowResize);
  7753. this.resizeRunner.clear();
  7754. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  7755. var interaction = _a[_i];
  7756. interaction.destroy();
  7757. }
  7758. this.props.emitter.trigger('_unmount');
  7759. };
  7760. CalendarContent.prototype._handleNavLinkClick = function (ev, anchorEl) {
  7761. var _a = this.props, dateEnv = _a.dateEnv, options = _a.options, calendarApi = _a.calendarApi;
  7762. var navLinkOptions = anchorEl.getAttribute('data-navlink');
  7763. navLinkOptions = navLinkOptions ? JSON.parse(navLinkOptions) : {};
  7764. var dateMarker = dateEnv.createMarker(navLinkOptions.date);
  7765. var viewType = navLinkOptions.type;
  7766. var customAction = viewType === 'day' ? options.navLinkDayClick :
  7767. viewType === 'week' ? options.navLinkWeekClick : null;
  7768. if (typeof customAction === 'function') {
  7769. customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
  7770. }
  7771. else {
  7772. if (typeof customAction === 'string') {
  7773. viewType = customAction;
  7774. }
  7775. calendarApi.zoomTo(dateMarker, viewType);
  7776. }
  7777. };
  7778. CalendarContent.prototype.buildAppendContent = function () {
  7779. var props = this.props;
  7780. var children = props.pluginHooks.viewContainerAppends.map(function (buildAppendContent) { return buildAppendContent(props); });
  7781. return createElement.apply(void 0, __spreadArrays([Fragment, {}], children));
  7782. };
  7783. CalendarContent.prototype.renderView = function (props) {
  7784. var pluginHooks = props.pluginHooks;
  7785. var viewSpec = props.viewSpec;
  7786. var viewProps = {
  7787. dateProfile: props.dateProfile,
  7788. businessHours: props.businessHours,
  7789. eventStore: props.renderableEventStore,
  7790. eventUiBases: props.eventUiBases,
  7791. dateSelection: props.dateSelection,
  7792. eventSelection: props.eventSelection,
  7793. eventDrag: props.eventDrag,
  7794. eventResize: props.eventResize,
  7795. isHeightAuto: props.isHeightAuto,
  7796. forPrint: props.forPrint,
  7797. };
  7798. var transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
  7799. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  7800. var transformer = transformers_1[_i];
  7801. __assign(viewProps, transformer.transform(viewProps, props));
  7802. }
  7803. var ViewComponent = viewSpec.component;
  7804. return (createElement(ViewComponent, __assign({}, viewProps)));
  7805. };
  7806. return CalendarContent;
  7807. }(PureComponent));
  7808. function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
  7809. // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
  7810. var todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
  7811. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
  7812. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
  7813. return {
  7814. title: title,
  7815. activeButton: viewSpec.type,
  7816. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  7817. isPrevEnabled: prevInfo.isValid,
  7818. isNextEnabled: nextInfo.isValid,
  7819. };
  7820. }
  7821. // Plugin
  7822. // -----------------------------------------------------------------------------------------------------------------
  7823. function buildViewPropTransformers(theClasses) {
  7824. return theClasses.map(function (TheClass) { return new TheClass(); });
  7825. }
  7826. var CalendarRoot = /** @class */ (function (_super) {
  7827. __extends(CalendarRoot, _super);
  7828. function CalendarRoot() {
  7829. var _this = _super !== null && _super.apply(this, arguments) || this;
  7830. _this.state = {
  7831. forPrint: false,
  7832. };
  7833. _this.handleBeforePrint = function () {
  7834. _this.setState({ forPrint: true });
  7835. };
  7836. _this.handleAfterPrint = function () {
  7837. _this.setState({ forPrint: false });
  7838. };
  7839. return _this;
  7840. }
  7841. CalendarRoot.prototype.render = function () {
  7842. var props = this.props;
  7843. var options = props.options;
  7844. var forPrint = this.state.forPrint;
  7845. var isHeightAuto = forPrint || options.height === 'auto' || options.contentHeight === 'auto';
  7846. var height = (!isHeightAuto && options.height != null) ? options.height : '';
  7847. var classNames = [
  7848. 'fc',
  7849. forPrint ? 'fc-media-print' : 'fc-media-screen',
  7850. "fc-direction-" + options.direction,
  7851. props.theme.getClass('root'),
  7852. ];
  7853. if (!getCanVGrowWithinCell()) {
  7854. classNames.push('fc-liquid-hack');
  7855. }
  7856. return props.children(classNames, height, isHeightAuto, forPrint);
  7857. };
  7858. CalendarRoot.prototype.componentDidMount = function () {
  7859. var emitter = this.props.emitter;
  7860. emitter.on('_beforeprint', this.handleBeforePrint);
  7861. emitter.on('_afterprint', this.handleAfterPrint);
  7862. };
  7863. CalendarRoot.prototype.componentWillUnmount = function () {
  7864. var emitter = this.props.emitter;
  7865. emitter.off('_beforeprint', this.handleBeforePrint);
  7866. emitter.off('_afterprint', this.handleAfterPrint);
  7867. };
  7868. return CalendarRoot;
  7869. }(BaseComponent));
  7870. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  7871. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  7872. // if more than one week row, or if there are a lot of columns with not much space,
  7873. // put just the day numbers will be in each cell
  7874. if (!datesRepDistinctDays || dayCnt > 10) {
  7875. return createFormatter({ weekday: 'short' }); // "Sat"
  7876. }
  7877. if (dayCnt > 1) {
  7878. return createFormatter({ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }); // "Sat 11/12"
  7879. }
  7880. return createFormatter({ weekday: 'long' }); // "Saturday"
  7881. }
  7882. var CLASS_NAME = 'fc-col-header-cell'; // do the cushion too? no
  7883. function renderInner(hookProps) {
  7884. return hookProps.text;
  7885. }
  7886. var TableDateCell = /** @class */ (function (_super) {
  7887. __extends(TableDateCell, _super);
  7888. function TableDateCell() {
  7889. return _super !== null && _super.apply(this, arguments) || this;
  7890. }
  7891. TableDateCell.prototype.render = function () {
  7892. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options, theme = _a.theme, viewApi = _a.viewApi;
  7893. var props = this.props;
  7894. var date = props.date, dateProfile = props.dateProfile;
  7895. var dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
  7896. var classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
  7897. var text = dateEnv.format(date, props.dayHeaderFormat);
  7898. // if colCnt is 1, we are already in a day-view and don't need a navlink
  7899. var navLinkAttrs = (options.navLinks && !dayMeta.isDisabled && props.colCnt > 1)
  7900. ? { 'data-navlink': buildNavLinkData(date), tabIndex: 0 }
  7901. : {};
  7902. var hookProps = __assign(__assign(__assign({ date: dateEnv.toDate(date), view: viewApi }, props.extraHookProps), { text: text }), dayMeta);
  7903. 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),
  7904. createElement("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && (createElement("a", __assign({ ref: innerElRef, className: [
  7905. 'fc-col-header-cell-cushion',
  7906. props.isSticky ? 'fc-sticky' : '',
  7907. ].join(' ') }, navLinkAttrs), innerContent))))); }));
  7908. };
  7909. return TableDateCell;
  7910. }(BaseComponent));
  7911. var TableDowCell = /** @class */ (function (_super) {
  7912. __extends(TableDowCell, _super);
  7913. function TableDowCell() {
  7914. return _super !== null && _super.apply(this, arguments) || this;
  7915. }
  7916. TableDowCell.prototype.render = function () {
  7917. var props = this.props;
  7918. var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, viewApi = _a.viewApi, options = _a.options;
  7919. var date = addDays(new Date(259200000), props.dow); // start with Sun, 04 Jan 1970 00:00:00 GMT
  7920. var dateMeta = {
  7921. dow: props.dow,
  7922. isDisabled: false,
  7923. isFuture: false,
  7924. isPast: false,
  7925. isToday: false,
  7926. isOther: false,
  7927. };
  7928. var classNames = [CLASS_NAME].concat(getDayClassNames(dateMeta, theme), props.extraClassNames || []);
  7929. var text = dateEnv.format(date, props.dayHeaderFormat);
  7930. var hookProps = __assign(__assign(__assign(__assign({ // TODO: make this public?
  7931. date: date }, dateMeta), { view: viewApi }), props.extraHookProps), { text: text });
  7932. 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),
  7933. createElement("div", { className: "fc-scrollgrid-sync-inner" },
  7934. createElement("a", { className: [
  7935. 'fc-col-header-cell-cushion',
  7936. props.isSticky ? 'fc-sticky' : '',
  7937. ].join(' '), ref: innerElRef }, innerContent)))); }));
  7938. };
  7939. return TableDowCell;
  7940. }(BaseComponent));
  7941. var NowTimer = /** @class */ (function (_super) {
  7942. __extends(NowTimer, _super);
  7943. function NowTimer(props, context) {
  7944. var _this = _super.call(this, props, context) || this;
  7945. _this.initialNowDate = getNow(context.options.now, context.dateEnv);
  7946. _this.initialNowQueriedMs = new Date().valueOf();
  7947. _this.state = _this.computeTiming().currentState;
  7948. return _this;
  7949. }
  7950. NowTimer.prototype.render = function () {
  7951. var _a = this, props = _a.props, state = _a.state;
  7952. return props.children(state.nowDate, state.todayRange);
  7953. };
  7954. NowTimer.prototype.componentDidMount = function () {
  7955. this.setTimeout();
  7956. };
  7957. NowTimer.prototype.componentDidUpdate = function (prevProps) {
  7958. if (prevProps.unit !== this.props.unit) {
  7959. this.clearTimeout();
  7960. this.setTimeout();
  7961. }
  7962. };
  7963. NowTimer.prototype.componentWillUnmount = function () {
  7964. this.clearTimeout();
  7965. };
  7966. NowTimer.prototype.computeTiming = function () {
  7967. var _a = this, props = _a.props, context = _a.context;
  7968. var unroundedNow = addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs);
  7969. var currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
  7970. var nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
  7971. var waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
  7972. return {
  7973. currentState: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
  7974. nextState: { nowDate: nextUnitStart, todayRange: buildDayRange(nextUnitStart) },
  7975. waitMs: waitMs,
  7976. };
  7977. };
  7978. NowTimer.prototype.setTimeout = function () {
  7979. var _this = this;
  7980. var _a = this.computeTiming(), nextState = _a.nextState, waitMs = _a.waitMs;
  7981. this.timeoutId = setTimeout(function () {
  7982. _this.setState(nextState, function () {
  7983. _this.setTimeout();
  7984. });
  7985. }, waitMs);
  7986. };
  7987. NowTimer.prototype.clearTimeout = function () {
  7988. if (this.timeoutId) {
  7989. clearTimeout(this.timeoutId);
  7990. }
  7991. };
  7992. NowTimer.contextType = ViewContextType;
  7993. return NowTimer;
  7994. }(Component));
  7995. function buildDayRange(date) {
  7996. var start = startOfDay(date);
  7997. var end = addDays(start, 1);
  7998. return { start: start, end: end };
  7999. }
  8000. var DayHeader = /** @class */ (function (_super) {
  8001. __extends(DayHeader, _super);
  8002. function DayHeader() {
  8003. var _this = _super !== null && _super.apply(this, arguments) || this;
  8004. _this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
  8005. return _this;
  8006. }
  8007. DayHeader.prototype.render = function () {
  8008. var context = this.context;
  8009. var _a = this.props, dates = _a.dates, dateProfile = _a.dateProfile, datesRepDistinctDays = _a.datesRepDistinctDays, renderIntro = _a.renderIntro;
  8010. var dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
  8011. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement("tr", null,
  8012. renderIntro && renderIntro(),
  8013. 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 }))); }))); }));
  8014. };
  8015. return DayHeader;
  8016. }(BaseComponent));
  8017. function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
  8018. return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
  8019. }
  8020. var DaySeriesModel = /** @class */ (function () {
  8021. function DaySeriesModel(range, dateProfileGenerator) {
  8022. var date = range.start;
  8023. var end = range.end;
  8024. var indices = [];
  8025. var dates = [];
  8026. var dayIndex = -1;
  8027. while (date < end) { // loop each day from start to end
  8028. if (dateProfileGenerator.isHiddenDay(date)) {
  8029. indices.push(dayIndex + 0.5); // mark that it's between indices
  8030. }
  8031. else {
  8032. dayIndex += 1;
  8033. indices.push(dayIndex);
  8034. dates.push(date);
  8035. }
  8036. date = addDays(date, 1);
  8037. }
  8038. this.dates = dates;
  8039. this.indices = indices;
  8040. this.cnt = dates.length;
  8041. }
  8042. DaySeriesModel.prototype.sliceRange = function (range) {
  8043. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8044. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8045. var clippedFirstIndex = Math.max(0, firstIndex);
  8046. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8047. // deal with in-between indices
  8048. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8049. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8050. if (clippedFirstIndex <= clippedLastIndex) {
  8051. return {
  8052. firstIndex: clippedFirstIndex,
  8053. lastIndex: clippedLastIndex,
  8054. isStart: firstIndex === clippedFirstIndex,
  8055. isEnd: lastIndex === clippedLastIndex,
  8056. };
  8057. }
  8058. return null;
  8059. };
  8060. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8061. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8062. // If before the first offset, returns a negative number.
  8063. // If after the last offset, returns an offset past the last cell offset.
  8064. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8065. DaySeriesModel.prototype.getDateDayIndex = function (date) {
  8066. var indices = this.indices;
  8067. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8068. if (dayOffset < 0) {
  8069. return indices[0] - 1;
  8070. }
  8071. if (dayOffset >= indices.length) {
  8072. return indices[indices.length - 1] + 1;
  8073. }
  8074. return indices[dayOffset];
  8075. };
  8076. return DaySeriesModel;
  8077. }());
  8078. var DayTableModel = /** @class */ (function () {
  8079. function DayTableModel(daySeries, breakOnWeeks) {
  8080. var dates = daySeries.dates;
  8081. var daysPerRow;
  8082. var firstDay;
  8083. var rowCnt;
  8084. if (breakOnWeeks) {
  8085. // count columns until the day-of-week repeats
  8086. firstDay = dates[0].getUTCDay();
  8087. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
  8088. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8089. break;
  8090. }
  8091. }
  8092. rowCnt = Math.ceil(dates.length / daysPerRow);
  8093. }
  8094. else {
  8095. rowCnt = 1;
  8096. daysPerRow = dates.length;
  8097. }
  8098. this.rowCnt = rowCnt;
  8099. this.colCnt = daysPerRow;
  8100. this.daySeries = daySeries;
  8101. this.cells = this.buildCells();
  8102. this.headerDates = this.buildHeaderDates();
  8103. }
  8104. DayTableModel.prototype.buildCells = function () {
  8105. var rows = [];
  8106. for (var row = 0; row < this.rowCnt; row += 1) {
  8107. var cells = [];
  8108. for (var col = 0; col < this.colCnt; col += 1) {
  8109. cells.push(this.buildCell(row, col));
  8110. }
  8111. rows.push(cells);
  8112. }
  8113. return rows;
  8114. };
  8115. DayTableModel.prototype.buildCell = function (row, col) {
  8116. var date = this.daySeries.dates[row * this.colCnt + col];
  8117. return {
  8118. key: date.toISOString(),
  8119. date: date,
  8120. };
  8121. };
  8122. DayTableModel.prototype.buildHeaderDates = function () {
  8123. var dates = [];
  8124. for (var col = 0; col < this.colCnt; col += 1) {
  8125. dates.push(this.cells[0][col].date);
  8126. }
  8127. return dates;
  8128. };
  8129. DayTableModel.prototype.sliceRange = function (range) {
  8130. var colCnt = this.colCnt;
  8131. var seriesSeg = this.daySeries.sliceRange(range);
  8132. var segs = [];
  8133. if (seriesSeg) {
  8134. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8135. var index = firstIndex;
  8136. while (index <= lastIndex) {
  8137. var row = Math.floor(index / colCnt);
  8138. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8139. segs.push({
  8140. row: row,
  8141. firstCol: index % colCnt,
  8142. lastCol: (nextIndex - 1) % colCnt,
  8143. isStart: seriesSeg.isStart && index === firstIndex,
  8144. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex,
  8145. });
  8146. index = nextIndex;
  8147. }
  8148. }
  8149. return segs;
  8150. };
  8151. return DayTableModel;
  8152. }());
  8153. var Slicer = /** @class */ (function () {
  8154. function Slicer() {
  8155. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8156. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8157. this.sliceEventStore = memoize(this._sliceEventStore);
  8158. this.sliceEventDrag = memoize(this._sliceInteraction);
  8159. this.sliceEventResize = memoize(this._sliceInteraction);
  8160. this.forceDayIfListItem = false; // hack
  8161. }
  8162. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, context) {
  8163. var extraArgs = [];
  8164. for (var _i = 4; _i < arguments.length; _i++) {
  8165. extraArgs[_i - 4] = arguments[_i];
  8166. }
  8167. var eventUiBases = props.eventUiBases;
  8168. var eventSegs = this.sliceEventStore.apply(this, __spreadArrays([props.eventStore, eventUiBases, dateProfile, nextDayThreshold], extraArgs));
  8169. return {
  8170. dateSelectionSegs: this.sliceDateSelection.apply(this, __spreadArrays([props.dateSelection, eventUiBases, context], extraArgs)),
  8171. businessHourSegs: this.sliceBusinessHours.apply(this, __spreadArrays([props.businessHours, dateProfile, nextDayThreshold, context], extraArgs)),
  8172. fgEventSegs: eventSegs.fg,
  8173. bgEventSegs: eventSegs.bg,
  8174. eventDrag: this.sliceEventDrag.apply(this, __spreadArrays([props.eventDrag, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8175. eventResize: this.sliceEventResize.apply(this, __spreadArrays([props.eventResize, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
  8176. eventSelection: props.eventSelection,
  8177. }; // TODO: give interactionSegs?
  8178. };
  8179. Slicer.prototype.sliceNowDate = function (// does not memoize
  8180. date, context) {
  8181. var extraArgs = [];
  8182. for (var _i = 2; _i < arguments.length; _i++) {
  8183. extraArgs[_i - 2] = arguments[_i];
  8184. }
  8185. return this._sliceDateSpan.apply(this, __spreadArrays([{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8186. {},
  8187. context], extraArgs));
  8188. };
  8189. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, context) {
  8190. var extraArgs = [];
  8191. for (var _i = 4; _i < arguments.length; _i++) {
  8192. extraArgs[_i - 4] = arguments[_i];
  8193. }
  8194. if (!businessHours) {
  8195. return [];
  8196. }
  8197. return this._sliceEventStore.apply(this, __spreadArrays([expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context),
  8198. {},
  8199. dateProfile,
  8200. nextDayThreshold], extraArgs)).bg;
  8201. };
  8202. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold) {
  8203. var extraArgs = [];
  8204. for (var _i = 4; _i < arguments.length; _i++) {
  8205. extraArgs[_i - 4] = arguments[_i];
  8206. }
  8207. if (eventStore) {
  8208. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8209. return {
  8210. bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
  8211. fg: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8212. };
  8213. }
  8214. return { bg: [], fg: [] };
  8215. };
  8216. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold) {
  8217. var extraArgs = [];
  8218. for (var _i = 4; _i < arguments.length; _i++) {
  8219. extraArgs[_i - 4] = arguments[_i];
  8220. }
  8221. if (!interaction) {
  8222. return null;
  8223. }
  8224. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8225. return {
  8226. segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
  8227. affectedInstances: interaction.affectedEvents.instances,
  8228. isEvent: interaction.isEvent,
  8229. };
  8230. };
  8231. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, context) {
  8232. var extraArgs = [];
  8233. for (var _i = 3; _i < arguments.length; _i++) {
  8234. extraArgs[_i - 3] = arguments[_i];
  8235. }
  8236. if (!dateSpan) {
  8237. return [];
  8238. }
  8239. var eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
  8240. var segs = this.sliceRange.apply(this, __spreadArrays([dateSpan.range], extraArgs));
  8241. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8242. var seg = segs_1[_a];
  8243. seg.eventRange = eventRange;
  8244. }
  8245. return segs;
  8246. };
  8247. /*
  8248. "complete" seg means it has component and eventRange
  8249. */
  8250. Slicer.prototype.sliceEventRanges = function (eventRanges, extraArgs) {
  8251. var segs = [];
  8252. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8253. var eventRange = eventRanges_1[_i];
  8254. segs.push.apply(segs, this.sliceEventRange(eventRange, extraArgs));
  8255. }
  8256. return segs;
  8257. };
  8258. /*
  8259. "complete" seg means it has component and eventRange
  8260. */
  8261. Slicer.prototype.sliceEventRange = function (eventRange, extraArgs) {
  8262. var dateRange = eventRange.range;
  8263. // hack to make multi-day events that are being force-displayed as list-items to take up only one day
  8264. if (this.forceDayIfListItem && eventRange.ui.display === 'list-item') {
  8265. dateRange = {
  8266. start: dateRange.start,
  8267. end: addDays(dateRange.start, 1),
  8268. };
  8269. }
  8270. var segs = this.sliceRange.apply(this, __spreadArrays([dateRange], extraArgs));
  8271. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8272. var seg = segs_2[_i];
  8273. seg.eventRange = eventRange;
  8274. seg.isStart = eventRange.isStart && seg.isStart;
  8275. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8276. }
  8277. return segs;
  8278. };
  8279. return Slicer;
  8280. }());
  8281. /*
  8282. for incorporating slotMinTime/slotMaxTime if appropriate
  8283. TODO: should be part of DateProfile!
  8284. TimelineDateProfile already does this btw
  8285. */
  8286. function computeActiveRange(dateProfile, isComponentAllDay) {
  8287. var range = dateProfile.activeRange;
  8288. if (isComponentAllDay) {
  8289. return range;
  8290. }
  8291. return {
  8292. start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
  8293. end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5),
  8294. };
  8295. }
  8296. var VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
  8297. var Scroller = /** @class */ (function (_super) {
  8298. __extends(Scroller, _super);
  8299. function Scroller() {
  8300. var _this = _super !== null && _super.apply(this, arguments) || this;
  8301. _this.handleEl = function (el) {
  8302. _this.el = el;
  8303. setRef(_this.props.elRef, el);
  8304. };
  8305. return _this;
  8306. }
  8307. Scroller.prototype.render = function () {
  8308. var props = this.props;
  8309. var liquid = props.liquid, liquidIsAbsolute = props.liquidIsAbsolute;
  8310. var isAbsolute = liquid && liquidIsAbsolute;
  8311. var className = ['fc-scroller'];
  8312. if (liquid) {
  8313. if (liquidIsAbsolute) {
  8314. className.push('fc-scroller-liquid-absolute');
  8315. }
  8316. else {
  8317. className.push('fc-scroller-liquid');
  8318. }
  8319. }
  8320. return (createElement("div", { ref: this.handleEl, className: className.join(' '), style: {
  8321. overflowX: props.overflowX,
  8322. overflowY: props.overflowY,
  8323. left: (isAbsolute && -(props.overcomeLeft || 0)) || '',
  8324. right: (isAbsolute && -(props.overcomeRight || 0)) || '',
  8325. bottom: (isAbsolute && -(props.overcomeBottom || 0)) || '',
  8326. marginLeft: (!isAbsolute && -(props.overcomeLeft || 0)) || '',
  8327. marginRight: (!isAbsolute && -(props.overcomeRight || 0)) || '',
  8328. marginBottom: (!isAbsolute && -(props.overcomeBottom || 0)) || '',
  8329. maxHeight: props.maxHeight || '',
  8330. } }, props.children));
  8331. };
  8332. Scroller.prototype.needsXScrolling = function () {
  8333. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8334. return false;
  8335. }
  8336. // testing scrollWidth>clientWidth is unreliable cross-browser when pixel heights aren't integers.
  8337. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8338. // inner-child margins and absolute positioning
  8339. var el = this.el;
  8340. var realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
  8341. var children = el.children;
  8342. for (var i = 0; i < children.length; i += 1) {
  8343. var childEl = children[i];
  8344. if (childEl.getBoundingClientRect().width > realClientWidth) {
  8345. return true;
  8346. }
  8347. }
  8348. return false;
  8349. };
  8350. Scroller.prototype.needsYScrolling = function () {
  8351. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8352. return false;
  8353. }
  8354. // testing scrollHeight>clientHeight is unreliable cross-browser when pixel heights aren't integers.
  8355. // much more reliable to see if children are taller than the scroller, even tho doesn't account for
  8356. // inner-child margins and absolute positioning
  8357. var el = this.el;
  8358. var realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
  8359. var children = el.children;
  8360. for (var i = 0; i < children.length; i += 1) {
  8361. var childEl = children[i];
  8362. if (childEl.getBoundingClientRect().height > realClientHeight) {
  8363. return true;
  8364. }
  8365. }
  8366. return false;
  8367. };
  8368. Scroller.prototype.getXScrollbarWidth = function () {
  8369. if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
  8370. return 0;
  8371. }
  8372. return this.el.offsetHeight - this.el.clientHeight; // only works because we guarantee no borders. TODO: add to CSS with important?
  8373. };
  8374. Scroller.prototype.getYScrollbarWidth = function () {
  8375. if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
  8376. return 0;
  8377. }
  8378. return this.el.offsetWidth - this.el.clientWidth; // only works because we guarantee no borders. TODO: add to CSS with important?
  8379. };
  8380. return Scroller;
  8381. }(BaseComponent));
  8382. /*
  8383. TODO: somehow infer OtherArgs from masterCallback?
  8384. TODO: infer RefType from masterCallback if provided
  8385. */
  8386. var RefMap = /** @class */ (function () {
  8387. function RefMap(masterCallback) {
  8388. var _this = this;
  8389. this.masterCallback = masterCallback;
  8390. this.currentMap = {};
  8391. this.depths = {};
  8392. this.callbackMap = {};
  8393. this.handleValue = function (val, key) {
  8394. var _a = _this, depths = _a.depths, currentMap = _a.currentMap;
  8395. var removed = false;
  8396. var added = false;
  8397. if (val !== null) {
  8398. // for bug... ACTUALLY: can probably do away with this now that callers don't share numeric indices anymore
  8399. removed = (key in currentMap);
  8400. currentMap[key] = val;
  8401. depths[key] = (depths[key] || 0) + 1;
  8402. added = true;
  8403. }
  8404. else {
  8405. depths[key] -= 1;
  8406. if (!depths[key]) {
  8407. delete currentMap[key];
  8408. delete _this.callbackMap[key];
  8409. removed = true;
  8410. }
  8411. }
  8412. if (_this.masterCallback) {
  8413. if (removed) {
  8414. _this.masterCallback(null, String(key));
  8415. }
  8416. if (added) {
  8417. _this.masterCallback(val, String(key));
  8418. }
  8419. }
  8420. };
  8421. }
  8422. RefMap.prototype.createRef = function (key) {
  8423. var _this = this;
  8424. var refCallback = this.callbackMap[key];
  8425. if (!refCallback) {
  8426. refCallback = this.callbackMap[key] = function (val) {
  8427. _this.handleValue(val, String(key));
  8428. };
  8429. }
  8430. return refCallback;
  8431. };
  8432. // TODO: check callers that don't care about order. should use getAll instead
  8433. // NOTE: this method has become less valuable now that we are encouraged to map order by some other index
  8434. // TODO: provide ONE array-export function, buildArray, which fails on non-numeric indexes. caller can manipulate and "collect"
  8435. RefMap.prototype.collect = function (startIndex, endIndex, step) {
  8436. return collectFromHash(this.currentMap, startIndex, endIndex, step);
  8437. };
  8438. RefMap.prototype.getAll = function () {
  8439. return hashValuesToArray(this.currentMap);
  8440. };
  8441. return RefMap;
  8442. }());
  8443. function computeShrinkWidth(chunkEls) {
  8444. var shrinkCells = findElements(chunkEls, '.fc-scrollgrid-shrink');
  8445. var largestWidth = 0;
  8446. for (var _i = 0, shrinkCells_1 = shrinkCells; _i < shrinkCells_1.length; _i++) {
  8447. var shrinkCell = shrinkCells_1[_i];
  8448. largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
  8449. }
  8450. return Math.ceil(largestWidth); // <table> elements work best with integers. round up to ensure contents fits
  8451. }
  8452. function getSectionHasLiquidHeight(props, sectionConfig) {
  8453. return props.liquid && sectionConfig.liquid; // does the section do liquid-height? (need to have whole scrollgrid liquid-height as well)
  8454. }
  8455. function getAllowYScrolling(props, sectionConfig) {
  8456. return sectionConfig.maxHeight != null || // if its possible for the height to max out, we might need scrollbars
  8457. getSectionHasLiquidHeight(props, sectionConfig); // if the section is liquid height, it might condense enough to require scrollbars
  8458. }
  8459. // TODO: ONLY use `arg`. force out internal function to use same API
  8460. function renderChunkContent(sectionConfig, chunkConfig, arg) {
  8461. var expandRows = arg.expandRows;
  8462. var content = typeof chunkConfig.content === 'function' ?
  8463. chunkConfig.content(arg) :
  8464. createElement('table', {
  8465. className: [
  8466. chunkConfig.tableClassName,
  8467. sectionConfig.syncRowHeights ? 'fc-scrollgrid-sync-table' : '',
  8468. ].join(' '),
  8469. style: {
  8470. minWidth: arg.tableMinWidth,
  8471. width: arg.clientWidth,
  8472. height: expandRows ? arg.clientHeight : '',
  8473. },
  8474. }, arg.tableColGroupNode, createElement('tbody', {}, typeof chunkConfig.rowContent === 'function' ? chunkConfig.rowContent(arg) : chunkConfig.rowContent));
  8475. return content;
  8476. }
  8477. function isColPropsEqual(cols0, cols1) {
  8478. return isArraysEqual(cols0, cols1, isPropsEqual);
  8479. }
  8480. function renderMicroColGroup(cols, shrinkWidth) {
  8481. var colNodes = [];
  8482. /*
  8483. for ColProps with spans, it would have been great to make a single <col span="">
  8484. HOWEVER, Chrome was getting messing up distributing the width to <td>/<th> elements with colspans.
  8485. SOLUTION: making individual <col> elements makes Chrome behave.
  8486. */
  8487. for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
  8488. var colProps = cols_1[_i];
  8489. var span = colProps.span || 1;
  8490. for (var i = 0; i < span; i += 1) {
  8491. colNodes.push(createElement("col", { style: {
  8492. width: colProps.width === 'shrink' ? sanitizeShrinkWidth(shrinkWidth) : (colProps.width || ''),
  8493. minWidth: colProps.minWidth || '',
  8494. } }));
  8495. }
  8496. }
  8497. return createElement.apply(void 0, __spreadArrays(['colgroup', {}], colNodes));
  8498. }
  8499. function sanitizeShrinkWidth(shrinkWidth) {
  8500. /* why 4? if we do 0, it will kill any border, which are needed for computeSmallestCellWidth
  8501. 4 accounts for 2 2-pixel borders. TODO: better solution? */
  8502. return shrinkWidth == null ? 4 : shrinkWidth;
  8503. }
  8504. function hasShrinkWidth(cols) {
  8505. for (var _i = 0, cols_2 = cols; _i < cols_2.length; _i++) {
  8506. var col = cols_2[_i];
  8507. if (col.width === 'shrink') {
  8508. return true;
  8509. }
  8510. }
  8511. return false;
  8512. }
  8513. function getScrollGridClassNames(liquid, context) {
  8514. var classNames = [
  8515. 'fc-scrollgrid',
  8516. context.theme.getClass('table'),
  8517. ];
  8518. if (liquid) {
  8519. classNames.push('fc-scrollgrid-liquid');
  8520. }
  8521. return classNames;
  8522. }
  8523. function getSectionClassNames(sectionConfig, wholeTableVGrow) {
  8524. var classNames = [
  8525. 'fc-scrollgrid-section',
  8526. "fc-scrollgrid-section-" + sectionConfig.type,
  8527. sectionConfig.className,
  8528. ];
  8529. if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
  8530. classNames.push('fc-scrollgrid-section-liquid');
  8531. }
  8532. if (sectionConfig.isSticky) {
  8533. classNames.push('fc-scrollgrid-section-sticky');
  8534. }
  8535. return classNames;
  8536. }
  8537. function renderScrollShim(arg) {
  8538. return (createElement("div", { className: "fc-scrollgrid-sticky-shim", style: {
  8539. width: arg.clientWidth,
  8540. minWidth: arg.tableMinWidth,
  8541. } }));
  8542. }
  8543. function getStickyHeaderDates(options) {
  8544. var stickyHeaderDates = options.stickyHeaderDates;
  8545. if (stickyHeaderDates == null || stickyHeaderDates === 'auto') {
  8546. stickyHeaderDates = options.height === 'auto' || options.viewHeight === 'auto';
  8547. }
  8548. return stickyHeaderDates;
  8549. }
  8550. function getStickyFooterScrollbar(options) {
  8551. var stickyFooterScrollbar = options.stickyFooterScrollbar;
  8552. if (stickyFooterScrollbar == null || stickyFooterScrollbar === 'auto') {
  8553. stickyFooterScrollbar = options.height === 'auto' || options.viewHeight === 'auto';
  8554. }
  8555. return stickyFooterScrollbar;
  8556. }
  8557. var SimpleScrollGrid = /** @class */ (function (_super) {
  8558. __extends(SimpleScrollGrid, _super);
  8559. function SimpleScrollGrid() {
  8560. var _this = _super !== null && _super.apply(this, arguments) || this;
  8561. _this.processCols = memoize(function (a) { return a; }, isColPropsEqual); // so we get same `cols` props every time
  8562. // yucky to memoize VNodes, but much more efficient for consumers
  8563. _this.renderMicroColGroup = memoize(renderMicroColGroup);
  8564. _this.scrollerRefs = new RefMap();
  8565. _this.scrollerElRefs = new RefMap(_this._handleScrollerEl.bind(_this));
  8566. _this.state = {
  8567. shrinkWidth: null,
  8568. forceYScrollbars: false,
  8569. scrollerClientWidths: {},
  8570. scrollerClientHeights: {},
  8571. };
  8572. // TODO: can do a really simple print-view. dont need to join rows
  8573. _this.handleSizing = function () {
  8574. _this.setState(__assign({ shrinkWidth: _this.computeShrinkWidth() }, _this.computeScrollerDims()));
  8575. };
  8576. return _this;
  8577. }
  8578. SimpleScrollGrid.prototype.render = function () {
  8579. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  8580. var sectionConfigs = props.sections || [];
  8581. var cols = this.processCols(props.cols);
  8582. var microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
  8583. var classNames = getScrollGridClassNames(props.liquid, context);
  8584. // TODO: make DRY
  8585. var configCnt = sectionConfigs.length;
  8586. var configI = 0;
  8587. var currentConfig;
  8588. var headSectionNodes = [];
  8589. var bodySectionNodes = [];
  8590. var footSectionNodes = [];
  8591. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'header') {
  8592. headSectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8593. configI += 1;
  8594. }
  8595. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'body') {
  8596. bodySectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8597. configI += 1;
  8598. }
  8599. while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === 'footer') {
  8600. footSectionNodes.push(this.renderSection(currentConfig, configI, microColGroupNode));
  8601. configI += 1;
  8602. }
  8603. // firefox bug: when setting height on table and there is a thead or tfoot,
  8604. // the necessary height:100% on the liquid-height body section forces the *whole* table to be taller. (bug #5524)
  8605. // use getCanVGrowWithinCell as a way to detect table-stupid firefox.
  8606. // if so, use a simpler dom structure, jam everything into a lone tbody.
  8607. var isBuggy = !getCanVGrowWithinCell();
  8608. return createElement('table', {
  8609. className: classNames.join(' '),
  8610. style: { height: props.height },
  8611. }, 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)));
  8612. };
  8613. SimpleScrollGrid.prototype.renderSection = function (sectionConfig, sectionI, microColGroupNode) {
  8614. if ('outerContent' in sectionConfig) {
  8615. return (createElement(Fragment, { key: sectionConfig.key }, sectionConfig.outerContent));
  8616. }
  8617. return (createElement("tr", { key: sectionConfig.key, className: getSectionClassNames(sectionConfig, this.props.liquid).join(' ') }, this.renderChunkTd(sectionConfig, sectionI, microColGroupNode, sectionConfig.chunk)));
  8618. };
  8619. SimpleScrollGrid.prototype.renderChunkTd = function (sectionConfig, sectionI, microColGroupNode, chunkConfig) {
  8620. if ('outerContent' in chunkConfig) {
  8621. return chunkConfig.outerContent;
  8622. }
  8623. var props = this.props;
  8624. var _a = this.state, forceYScrollbars = _a.forceYScrollbars, scrollerClientWidths = _a.scrollerClientWidths, scrollerClientHeights = _a.scrollerClientHeights;
  8625. var needsYScrolling = getAllowYScrolling(props, sectionConfig); // TODO: do lazily. do in section config?
  8626. var isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
  8627. // for `!props.liquid` - is WHOLE scrollgrid natural height?
  8628. // TODO: do same thing in advanced scrollgrid? prolly not b/c always has horizontal scrollbars
  8629. var overflowY = !props.liquid ? 'visible' :
  8630. forceYScrollbars ? 'scroll' :
  8631. !needsYScrolling ? 'hidden' :
  8632. 'auto';
  8633. var content = renderChunkContent(sectionConfig, chunkConfig, {
  8634. tableColGroupNode: microColGroupNode,
  8635. tableMinWidth: '',
  8636. clientWidth: scrollerClientWidths[sectionI] !== undefined ? scrollerClientWidths[sectionI] : null,
  8637. clientHeight: scrollerClientHeights[sectionI] !== undefined ? scrollerClientHeights[sectionI] : null,
  8638. expandRows: sectionConfig.expandRows,
  8639. syncRowHeights: false,
  8640. rowSyncHeights: [],
  8641. reportRowHeightChange: function () { },
  8642. });
  8643. return (createElement("td", { ref: chunkConfig.elRef },
  8644. createElement("div", { className: "fc-scroller-harness" + (isLiquid ? ' fc-scroller-harness-liquid' : '') },
  8645. 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
  8646. : true }, content))));
  8647. };
  8648. SimpleScrollGrid.prototype._handleScrollerEl = function (scrollerEl, key) {
  8649. var sectionI = parseInt(key, 10);
  8650. var chunkConfig = this.props.sections[sectionI].chunk;
  8651. setRef(chunkConfig.scrollerElRef, scrollerEl);
  8652. };
  8653. SimpleScrollGrid.prototype.componentDidMount = function () {
  8654. this.handleSizing();
  8655. this.context.addResizeHandler(this.handleSizing);
  8656. };
  8657. SimpleScrollGrid.prototype.componentDidUpdate = function () {
  8658. // TODO: need better solution when state contains non-sizing things
  8659. this.handleSizing();
  8660. };
  8661. SimpleScrollGrid.prototype.componentWillUnmount = function () {
  8662. this.context.removeResizeHandler(this.handleSizing);
  8663. };
  8664. SimpleScrollGrid.prototype.computeShrinkWidth = function () {
  8665. return hasShrinkWidth(this.props.cols)
  8666. ? computeShrinkWidth(this.scrollerElRefs.getAll())
  8667. : 0;
  8668. };
  8669. SimpleScrollGrid.prototype.computeScrollerDims = function () {
  8670. var scrollbarWidth = getScrollbarWidths();
  8671. var sectionCnt = this.props.sections.length;
  8672. var _a = this, scrollerRefs = _a.scrollerRefs, scrollerElRefs = _a.scrollerElRefs;
  8673. var forceYScrollbars = false;
  8674. var scrollerClientWidths = {};
  8675. var scrollerClientHeights = {};
  8676. for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) { // along edge
  8677. var scroller = scrollerRefs.currentMap[sectionI];
  8678. if (scroller && scroller.needsYScrolling()) {
  8679. forceYScrollbars = true;
  8680. break;
  8681. }
  8682. }
  8683. for (var sectionI = 0; sectionI < sectionCnt; sectionI += 1) { // along edge
  8684. var scrollerEl = scrollerElRefs.currentMap[sectionI];
  8685. if (scrollerEl) {
  8686. var harnessEl = scrollerEl.parentNode; // TODO: weird way to get this. need harness b/c doesn't include table borders
  8687. scrollerClientWidths[sectionI] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars
  8688. ? scrollbarWidth.y // use global because scroller might not have scrollbars yet but will need them in future
  8689. : 0));
  8690. scrollerClientHeights[sectionI] = Math.floor(harnessEl.getBoundingClientRect().height);
  8691. }
  8692. }
  8693. return { forceYScrollbars: forceYScrollbars, scrollerClientWidths: scrollerClientWidths, scrollerClientHeights: scrollerClientHeights };
  8694. };
  8695. return SimpleScrollGrid;
  8696. }(BaseComponent));
  8697. SimpleScrollGrid.addStateEquality({
  8698. scrollerClientWidths: isPropsEqual,
  8699. scrollerClientHeights: isPropsEqual,
  8700. });
  8701. var EventRoot = /** @class */ (function (_super) {
  8702. __extends(EventRoot, _super);
  8703. function EventRoot() {
  8704. var _this = _super !== null && _super.apply(this, arguments) || this;
  8705. _this.elRef = createRef();
  8706. return _this;
  8707. }
  8708. EventRoot.prototype.render = function () {
  8709. var _a = this, props = _a.props, context = _a.context;
  8710. var options = context.options;
  8711. var seg = props.seg;
  8712. var eventRange = seg.eventRange;
  8713. var ui = eventRange.ui;
  8714. var hookProps = {
  8715. event: new EventApi(context, eventRange.def, eventRange.instance),
  8716. view: context.viewApi,
  8717. timeText: props.timeText,
  8718. textColor: ui.textColor,
  8719. backgroundColor: ui.backgroundColor,
  8720. borderColor: ui.borderColor,
  8721. isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
  8722. isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
  8723. isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
  8724. isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
  8725. isStart: Boolean(seg.isStart),
  8726. isEnd: Boolean(seg.isEnd),
  8727. isPast: Boolean(props.isPast),
  8728. isFuture: Boolean(props.isFuture),
  8729. isToday: Boolean(props.isToday),
  8730. isSelected: Boolean(props.isSelected),
  8731. isDragging: Boolean(props.isDragging),
  8732. isResizing: Boolean(props.isResizing),
  8733. };
  8734. var standardClassNames = getEventClassNames(hookProps).concat(ui.classNames);
  8735. 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); }));
  8736. };
  8737. EventRoot.prototype.componentDidMount = function () {
  8738. setElSeg(this.elRef.current, this.props.seg);
  8739. };
  8740. /*
  8741. need to re-assign seg to the element if seg changes, even if the element is the same
  8742. */
  8743. EventRoot.prototype.componentDidUpdate = function (prevProps) {
  8744. var seg = this.props.seg;
  8745. if (seg !== prevProps.seg) {
  8746. setElSeg(this.elRef.current, seg);
  8747. }
  8748. };
  8749. return EventRoot;
  8750. }(BaseComponent));
  8751. // should not be a purecomponent
  8752. var StandardEvent = /** @class */ (function (_super) {
  8753. __extends(StandardEvent, _super);
  8754. function StandardEvent() {
  8755. return _super !== null && _super.apply(this, arguments) || this;
  8756. }
  8757. StandardEvent.prototype.render = function () {
  8758. var _a = this, props = _a.props, context = _a.context;
  8759. var seg = props.seg;
  8760. var timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat;
  8761. var timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
  8762. 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: {
  8763. borderColor: hookProps.borderColor,
  8764. backgroundColor: hookProps.backgroundColor,
  8765. }, ref: rootElRef }, getSegAnchorAttrs(seg)),
  8766. createElement("div", { className: "fc-event-main", ref: innerElRef, style: { color: hookProps.textColor } }, innerContent),
  8767. hookProps.isStartResizable &&
  8768. createElement("div", { className: "fc-event-resizer fc-event-resizer-start" }),
  8769. hookProps.isEndResizable &&
  8770. createElement("div", { className: "fc-event-resizer fc-event-resizer-end" }))); }));
  8771. };
  8772. return StandardEvent;
  8773. }(BaseComponent));
  8774. function renderInnerContent(innerProps) {
  8775. return (createElement("div", { className: "fc-event-main-frame" },
  8776. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  8777. createElement("div", { className: "fc-event-title-container" },
  8778. createElement("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || createElement(Fragment, null, "\u00A0")))));
  8779. }
  8780. function getSegAnchorAttrs(seg) {
  8781. var url = seg.eventRange.def.url;
  8782. return url ? { href: url } : {};
  8783. }
  8784. var NowIndicatorRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  8785. var options = context.options;
  8786. var hookProps = {
  8787. isAxis: props.isAxis,
  8788. date: context.dateEnv.toDate(props.date),
  8789. view: context.viewApi,
  8790. };
  8791. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.nowIndicatorClassNames, content: options.nowIndicatorContent, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children));
  8792. })); };
  8793. var DAY_NUM_FORMAT = createFormatter({ day: 'numeric' });
  8794. var DayCellContent = /** @class */ (function (_super) {
  8795. __extends(DayCellContent, _super);
  8796. function DayCellContent() {
  8797. return _super !== null && _super.apply(this, arguments) || this;
  8798. }
  8799. DayCellContent.prototype.render = function () {
  8800. var _a = this, props = _a.props, context = _a.context;
  8801. var options = context.options;
  8802. var hookProps = refineDayCellHookProps({
  8803. date: props.date,
  8804. dateProfile: props.dateProfile,
  8805. todayRange: props.todayRange,
  8806. showDayNumber: props.showDayNumber,
  8807. extraProps: props.extraHookProps,
  8808. viewApi: context.viewApi,
  8809. dateEnv: context.dateEnv,
  8810. });
  8811. return (createElement(ContentHook, { hookProps: hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children));
  8812. };
  8813. return DayCellContent;
  8814. }(BaseComponent));
  8815. function refineDayCellHookProps(raw) {
  8816. var date = raw.date, dateEnv = raw.dateEnv;
  8817. var dayMeta = getDateMeta(date, raw.todayRange, null, raw.dateProfile);
  8818. return __assign(__assign(__assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { dayNumberText: raw.showDayNumber ? dateEnv.format(date, DAY_NUM_FORMAT) : '' }), raw.extraProps);
  8819. }
  8820. var DayCellRoot = /** @class */ (function (_super) {
  8821. __extends(DayCellRoot, _super);
  8822. function DayCellRoot() {
  8823. var _this = _super !== null && _super.apply(this, arguments) || this;
  8824. _this.refineHookProps = memoizeObjArg(refineDayCellHookProps);
  8825. _this.normalizeClassNames = buildClassNameNormalizer();
  8826. return _this;
  8827. }
  8828. DayCellRoot.prototype.render = function () {
  8829. var _a = this, props = _a.props, context = _a.context;
  8830. var options = context.options;
  8831. var hookProps = this.refineHookProps({
  8832. date: props.date,
  8833. dateProfile: props.dateProfile,
  8834. todayRange: props.todayRange,
  8835. showDayNumber: props.showDayNumber,
  8836. extraProps: props.extraHookProps,
  8837. viewApi: context.viewApi,
  8838. dateEnv: context.dateEnv,
  8839. });
  8840. var classNames = getDayClassNames(hookProps, context.theme).concat(hookProps.isDisabled
  8841. ? [] // don't use custom classNames if disabled
  8842. : this.normalizeClassNames(options.dayCellClassNames, hookProps));
  8843. var dataAttrs = hookProps.isDisabled ? {} : {
  8844. 'data-date': formatDayString(props.date),
  8845. };
  8846. return (createElement(MountHook, { hookProps: hookProps, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount, elRef: props.elRef }, function (rootElRef) { return props.children(rootElRef, classNames, dataAttrs, hookProps.isDisabled); }));
  8847. };
  8848. return DayCellRoot;
  8849. }(BaseComponent));
  8850. function renderFill(fillType) {
  8851. return (createElement("div", { className: "fc-" + fillType }));
  8852. }
  8853. 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: {
  8854. backgroundColor: hookProps.backgroundColor,
  8855. } }, innerContent)); })); };
  8856. function renderInnerContent$1(props) {
  8857. var title = props.event.title;
  8858. return title && (createElement("div", { className: "fc-event-title" }, props.event.title));
  8859. }
  8860. var WeekNumberRoot = function (props) { return (createElement(ViewContextType.Consumer, null, function (context) {
  8861. var dateEnv = context.dateEnv, options = context.options;
  8862. var date = props.date;
  8863. var format = options.weekNumberFormat || props.defaultFormat;
  8864. var num = dateEnv.computeWeekNumber(date); // TODO: somehow use for formatting as well?
  8865. var text = dateEnv.format(date, format);
  8866. var hookProps = { num: num, text: text, date: date };
  8867. return (createElement(RenderHook, { hookProps: hookProps, classNames: options.weekNumberClassNames, content: options.weekNumberContent, defaultContent: renderInner$1, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children));
  8868. })); };
  8869. function renderInner$1(innerProps) {
  8870. return innerProps.text;
  8871. }
  8872. // exports
  8873. // --------------------------------------------------------------------------------------------------
  8874. var version = '5.3.2'; // important to type it, so .d.ts has generic string
  8875. var Calendar = /** @class */ (function (_super) {
  8876. __extends(Calendar, _super);
  8877. function Calendar(el, optionOverrides) {
  8878. if (optionOverrides === void 0) { optionOverrides = {}; }
  8879. var _this = _super.call(this) || this;
  8880. _this.isRendering = false;
  8881. _this.isRendered = false;
  8882. _this.currentClassNames = [];
  8883. _this.customContentRenderId = 0; // will affect custom generated classNames?
  8884. _this.handleAction = function (action) {
  8885. // actions we know we want to render immediately
  8886. switch (action.type) {
  8887. case 'SET_EVENT_DRAG':
  8888. case 'SET_EVENT_RESIZE':
  8889. _this.renderRunner.tryDrain();
  8890. }
  8891. };
  8892. _this.handleData = function (data) {
  8893. _this.currentData = data;
  8894. _this.renderRunner.request(data.calendarOptions.rerenderDelay);
  8895. };
  8896. _this.handleRenderRequest = function () {
  8897. if (_this.isRendering) {
  8898. _this.isRendered = true;
  8899. var currentData_1 = _this.currentData;
  8900. render(createElement(CalendarRoot, { options: currentData_1.calendarOptions, theme: currentData_1.theme, emitter: currentData_1.emitter }, function (classNames, height, isHeightAuto, forPrint) {
  8901. _this.setClassNames(classNames);
  8902. _this.setHeight(height);
  8903. return (createElement(CustomContentRenderContext.Provider, { value: _this.customContentRenderId },
  8904. createElement(CalendarContent, __assign({ isHeightAuto: isHeightAuto, forPrint: forPrint }, currentData_1))));
  8905. }), _this.el);
  8906. }
  8907. else if (_this.isRendered) {
  8908. _this.isRendered = false;
  8909. unmountComponentAtNode$1(_this.el);
  8910. _this.setClassNames([]);
  8911. _this.setHeight('');
  8912. }
  8913. flushToDom$1();
  8914. };
  8915. _this.el = el;
  8916. _this.renderRunner = new DelayedRunner(_this.handleRenderRequest);
  8917. new CalendarDataManager({
  8918. optionOverrides: optionOverrides,
  8919. calendarApi: _this,
  8920. onAction: _this.handleAction,
  8921. onData: _this.handleData,
  8922. });
  8923. return _this;
  8924. }
  8925. Object.defineProperty(Calendar.prototype, "view", {
  8926. get: function () { return this.currentData.viewApi; } // for public API
  8927. ,
  8928. enumerable: false,
  8929. configurable: true
  8930. });
  8931. Calendar.prototype.render = function () {
  8932. var wasRendering = this.isRendering;
  8933. if (!wasRendering) {
  8934. this.isRendering = true;
  8935. }
  8936. else {
  8937. this.customContentRenderId += 1;
  8938. }
  8939. this.renderRunner.request();
  8940. if (wasRendering) {
  8941. this.updateSize();
  8942. }
  8943. };
  8944. Calendar.prototype.destroy = function () {
  8945. if (this.isRendering) {
  8946. this.isRendering = false;
  8947. this.renderRunner.request();
  8948. }
  8949. };
  8950. Calendar.prototype.updateSize = function () {
  8951. _super.prototype.updateSize.call(this);
  8952. flushToDom$1();
  8953. };
  8954. Calendar.prototype.batchRendering = function (func) {
  8955. this.renderRunner.pause('batchRendering');
  8956. func();
  8957. this.renderRunner.resume('batchRendering');
  8958. };
  8959. Calendar.prototype.pauseRendering = function () {
  8960. this.renderRunner.pause('pauseRendering');
  8961. };
  8962. Calendar.prototype.resumeRendering = function () {
  8963. this.renderRunner.resume('pauseRendering', true);
  8964. };
  8965. Calendar.prototype.resetOptions = function (optionOverrides, append) {
  8966. this.currentDataManager.resetOptions(optionOverrides, append);
  8967. };
  8968. Calendar.prototype.setClassNames = function (classNames) {
  8969. if (!isArraysEqual(classNames, this.currentClassNames)) {
  8970. var classList = this.el.classList;
  8971. for (var _i = 0, _a = this.currentClassNames; _i < _a.length; _i++) {
  8972. var className = _a[_i];
  8973. classList.remove(className);
  8974. }
  8975. for (var _b = 0, classNames_1 = classNames; _b < classNames_1.length; _b++) {
  8976. var className = classNames_1[_b];
  8977. classList.add(className);
  8978. }
  8979. this.currentClassNames = classNames;
  8980. }
  8981. };
  8982. Calendar.prototype.setHeight = function (height) {
  8983. applyStyleProp(this.el, 'height', height);
  8984. };
  8985. return Calendar;
  8986. }(CalendarApi));
  8987. config.touchMouseIgnoreWait = 500;
  8988. var ignoreMouseDepth = 0;
  8989. var listenerCnt = 0;
  8990. var isWindowTouchMoveCancelled = false;
  8991. /*
  8992. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  8993. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  8994. Also, tracks if there was touch-scrolling.
  8995. Also, can prevent touch-scrolling from happening.
  8996. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  8997. emits:
  8998. - pointerdown
  8999. - pointermove
  9000. - pointerup
  9001. */
  9002. var PointerDragging = /** @class */ (function () {
  9003. function PointerDragging(containerEl) {
  9004. var _this = this;
  9005. this.subjectEl = null;
  9006. // options that can be directly assigned by caller
  9007. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  9008. this.handleSelector = '';
  9009. this.shouldIgnoreMove = false;
  9010. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  9011. // internal states
  9012. this.isDragging = false;
  9013. this.isTouchDragging = false;
  9014. this.wasTouchScroll = false;
  9015. // Mouse
  9016. // ----------------------------------------------------------------------------------------------------
  9017. this.handleMouseDown = function (ev) {
  9018. if (!_this.shouldIgnoreMouse() &&
  9019. isPrimaryMouseButton(ev) &&
  9020. _this.tryStart(ev)) {
  9021. var pev = _this.createEventFromMouse(ev, true);
  9022. _this.emitter.trigger('pointerdown', pev);
  9023. _this.initScrollWatch(pev);
  9024. if (!_this.shouldIgnoreMove) {
  9025. document.addEventListener('mousemove', _this.handleMouseMove);
  9026. }
  9027. document.addEventListener('mouseup', _this.handleMouseUp);
  9028. }
  9029. };
  9030. this.handleMouseMove = function (ev) {
  9031. var pev = _this.createEventFromMouse(ev);
  9032. _this.recordCoords(pev);
  9033. _this.emitter.trigger('pointermove', pev);
  9034. };
  9035. this.handleMouseUp = function (ev) {
  9036. document.removeEventListener('mousemove', _this.handleMouseMove);
  9037. document.removeEventListener('mouseup', _this.handleMouseUp);
  9038. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  9039. _this.cleanup(); // call last so that pointerup has access to props
  9040. };
  9041. // Touch
  9042. // ----------------------------------------------------------------------------------------------------
  9043. this.handleTouchStart = function (ev) {
  9044. if (_this.tryStart(ev)) {
  9045. _this.isTouchDragging = true;
  9046. var pev = _this.createEventFromTouch(ev, true);
  9047. _this.emitter.trigger('pointerdown', pev);
  9048. _this.initScrollWatch(pev);
  9049. // unlike mouse, need to attach to target, not document
  9050. // https://stackoverflow.com/a/45760014
  9051. var targetEl = ev.target;
  9052. if (!_this.shouldIgnoreMove) {
  9053. targetEl.addEventListener('touchmove', _this.handleTouchMove);
  9054. }
  9055. targetEl.addEventListener('touchend', _this.handleTouchEnd);
  9056. targetEl.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  9057. // attach a handler to get called when ANY scroll action happens on the page.
  9058. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  9059. // http://stackoverflow.com/a/32954565/96342
  9060. window.addEventListener('scroll', _this.handleTouchScroll, true);
  9061. }
  9062. };
  9063. this.handleTouchMove = function (ev) {
  9064. var pev = _this.createEventFromTouch(ev);
  9065. _this.recordCoords(pev);
  9066. _this.emitter.trigger('pointermove', pev);
  9067. };
  9068. this.handleTouchEnd = function (ev) {
  9069. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  9070. var targetEl = ev.target;
  9071. targetEl.removeEventListener('touchmove', _this.handleTouchMove);
  9072. targetEl.removeEventListener('touchend', _this.handleTouchEnd);
  9073. targetEl.removeEventListener('touchcancel', _this.handleTouchEnd);
  9074. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  9075. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  9076. _this.cleanup(); // call last so that pointerup has access to props
  9077. _this.isTouchDragging = false;
  9078. startIgnoringMouse();
  9079. }
  9080. };
  9081. this.handleTouchScroll = function () {
  9082. _this.wasTouchScroll = true;
  9083. };
  9084. this.handleScroll = function (ev) {
  9085. if (!_this.shouldIgnoreMove) {
  9086. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  9087. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  9088. _this.emitter.trigger('pointermove', {
  9089. origEvent: ev,
  9090. isTouch: _this.isTouchDragging,
  9091. subjectEl: _this.subjectEl,
  9092. pageX: pageX,
  9093. pageY: pageY,
  9094. deltaX: pageX - _this.origPageX,
  9095. deltaY: pageY - _this.origPageY,
  9096. });
  9097. }
  9098. };
  9099. this.containerEl = containerEl;
  9100. this.emitter = new Emitter();
  9101. containerEl.addEventListener('mousedown', this.handleMouseDown);
  9102. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  9103. listenerCreated();
  9104. }
  9105. PointerDragging.prototype.destroy = function () {
  9106. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  9107. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  9108. listenerDestroyed();
  9109. };
  9110. PointerDragging.prototype.tryStart = function (ev) {
  9111. var subjectEl = this.querySubjectEl(ev);
  9112. var downEl = ev.target;
  9113. if (subjectEl &&
  9114. (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
  9115. this.subjectEl = subjectEl;
  9116. this.isDragging = true; // do this first so cancelTouchScroll will work
  9117. this.wasTouchScroll = false;
  9118. return true;
  9119. }
  9120. return false;
  9121. };
  9122. PointerDragging.prototype.cleanup = function () {
  9123. isWindowTouchMoveCancelled = false;
  9124. this.isDragging = false;
  9125. this.subjectEl = null;
  9126. // keep wasTouchScroll around for later access
  9127. this.destroyScrollWatch();
  9128. };
  9129. PointerDragging.prototype.querySubjectEl = function (ev) {
  9130. if (this.selector) {
  9131. return elementClosest(ev.target, this.selector);
  9132. }
  9133. return this.containerEl;
  9134. };
  9135. PointerDragging.prototype.shouldIgnoreMouse = function () {
  9136. return ignoreMouseDepth || this.isTouchDragging;
  9137. };
  9138. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  9139. PointerDragging.prototype.cancelTouchScroll = function () {
  9140. if (this.isDragging) {
  9141. isWindowTouchMoveCancelled = true;
  9142. }
  9143. };
  9144. // Scrolling that simulates pointermoves
  9145. // ----------------------------------------------------------------------------------------------------
  9146. PointerDragging.prototype.initScrollWatch = function (ev) {
  9147. if (this.shouldWatchScroll) {
  9148. this.recordCoords(ev);
  9149. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  9150. }
  9151. };
  9152. PointerDragging.prototype.recordCoords = function (ev) {
  9153. if (this.shouldWatchScroll) {
  9154. this.prevPageX = ev.pageX;
  9155. this.prevPageY = ev.pageY;
  9156. this.prevScrollX = window.pageXOffset;
  9157. this.prevScrollY = window.pageYOffset;
  9158. }
  9159. };
  9160. PointerDragging.prototype.destroyScrollWatch = function () {
  9161. if (this.shouldWatchScroll) {
  9162. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  9163. }
  9164. };
  9165. // Event Normalization
  9166. // ----------------------------------------------------------------------------------------------------
  9167. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  9168. var deltaX = 0;
  9169. var deltaY = 0;
  9170. // TODO: repeat code
  9171. if (isFirst) {
  9172. this.origPageX = ev.pageX;
  9173. this.origPageY = ev.pageY;
  9174. }
  9175. else {
  9176. deltaX = ev.pageX - this.origPageX;
  9177. deltaY = ev.pageY - this.origPageY;
  9178. }
  9179. return {
  9180. origEvent: ev,
  9181. isTouch: false,
  9182. subjectEl: this.subjectEl,
  9183. pageX: ev.pageX,
  9184. pageY: ev.pageY,
  9185. deltaX: deltaX,
  9186. deltaY: deltaY,
  9187. };
  9188. };
  9189. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  9190. var touches = ev.touches;
  9191. var pageX;
  9192. var pageY;
  9193. var deltaX = 0;
  9194. var deltaY = 0;
  9195. // if touch coords available, prefer,
  9196. // because FF would give bad ev.pageX ev.pageY
  9197. if (touches && touches.length) {
  9198. pageX = touches[0].pageX;
  9199. pageY = touches[0].pageY;
  9200. }
  9201. else {
  9202. pageX = ev.pageX;
  9203. pageY = ev.pageY;
  9204. }
  9205. // TODO: repeat code
  9206. if (isFirst) {
  9207. this.origPageX = pageX;
  9208. this.origPageY = pageY;
  9209. }
  9210. else {
  9211. deltaX = pageX - this.origPageX;
  9212. deltaY = pageY - this.origPageY;
  9213. }
  9214. return {
  9215. origEvent: ev,
  9216. isTouch: true,
  9217. subjectEl: this.subjectEl,
  9218. pageX: pageX,
  9219. pageY: pageY,
  9220. deltaX: deltaX,
  9221. deltaY: deltaY,
  9222. };
  9223. };
  9224. return PointerDragging;
  9225. }());
  9226. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  9227. function isPrimaryMouseButton(ev) {
  9228. return ev.button === 0 && !ev.ctrlKey;
  9229. }
  9230. // Ignoring fake mouse events generated by touch
  9231. // ----------------------------------------------------------------------------------------------------
  9232. function startIgnoringMouse() {
  9233. ignoreMouseDepth += 1;
  9234. setTimeout(function () {
  9235. ignoreMouseDepth -= 1;
  9236. }, config.touchMouseIgnoreWait);
  9237. }
  9238. // We want to attach touchmove as early as possible for Safari
  9239. // ----------------------------------------------------------------------------------------------------
  9240. function listenerCreated() {
  9241. listenerCnt += 1;
  9242. if (listenerCnt === 1) {
  9243. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  9244. }
  9245. }
  9246. function listenerDestroyed() {
  9247. listenerCnt -= 1;
  9248. if (!listenerCnt) {
  9249. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  9250. }
  9251. }
  9252. function onWindowTouchMove(ev) {
  9253. if (isWindowTouchMoveCancelled) {
  9254. ev.preventDefault();
  9255. }
  9256. }
  9257. /*
  9258. An effect in which an element follows the movement of a pointer across the screen.
  9259. The moving element is a clone of some other element.
  9260. Must call start + handleMove + stop.
  9261. */
  9262. var ElementMirror = /** @class */ (function () {
  9263. function ElementMirror() {
  9264. this.isVisible = false; // must be explicitly enabled
  9265. this.sourceEl = null;
  9266. this.mirrorEl = null;
  9267. this.sourceElRect = null; // screen coords relative to viewport
  9268. // options that can be set directly by caller
  9269. this.parentNode = document.body;
  9270. this.zIndex = 9999;
  9271. this.revertDuration = 0;
  9272. }
  9273. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  9274. this.sourceEl = sourceEl;
  9275. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  9276. this.origScreenX = pageX - window.pageXOffset;
  9277. this.origScreenY = pageY - window.pageYOffset;
  9278. this.deltaX = 0;
  9279. this.deltaY = 0;
  9280. this.updateElPosition();
  9281. };
  9282. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  9283. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  9284. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  9285. this.updateElPosition();
  9286. };
  9287. // can be called before start
  9288. ElementMirror.prototype.setIsVisible = function (bool) {
  9289. if (bool) {
  9290. if (!this.isVisible) {
  9291. if (this.mirrorEl) {
  9292. this.mirrorEl.style.display = '';
  9293. }
  9294. this.isVisible = bool; // needs to happen before updateElPosition
  9295. this.updateElPosition(); // because was not updating the position while invisible
  9296. }
  9297. }
  9298. else if (this.isVisible) {
  9299. if (this.mirrorEl) {
  9300. this.mirrorEl.style.display = 'none';
  9301. }
  9302. this.isVisible = bool;
  9303. }
  9304. };
  9305. // always async
  9306. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  9307. var _this = this;
  9308. var done = function () {
  9309. _this.cleanup();
  9310. callback();
  9311. };
  9312. if (needsRevertAnimation &&
  9313. this.mirrorEl &&
  9314. this.isVisible &&
  9315. this.revertDuration && // if 0, transition won't work
  9316. (this.deltaX || this.deltaY) // if same coords, transition won't work
  9317. ) {
  9318. this.doRevertAnimation(done, this.revertDuration);
  9319. }
  9320. else {
  9321. setTimeout(done, 0);
  9322. }
  9323. };
  9324. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  9325. var mirrorEl = this.mirrorEl;
  9326. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  9327. mirrorEl.style.transition =
  9328. 'top ' + revertDuration + 'ms,' +
  9329. 'left ' + revertDuration + 'ms';
  9330. applyStyle(mirrorEl, {
  9331. left: finalSourceElRect.left,
  9332. top: finalSourceElRect.top,
  9333. });
  9334. whenTransitionDone(mirrorEl, function () {
  9335. mirrorEl.style.transition = '';
  9336. callback();
  9337. });
  9338. };
  9339. ElementMirror.prototype.cleanup = function () {
  9340. if (this.mirrorEl) {
  9341. removeElement(this.mirrorEl);
  9342. this.mirrorEl = null;
  9343. }
  9344. this.sourceEl = null;
  9345. };
  9346. ElementMirror.prototype.updateElPosition = function () {
  9347. if (this.sourceEl && this.isVisible) {
  9348. applyStyle(this.getMirrorEl(), {
  9349. left: this.sourceElRect.left + this.deltaX,
  9350. top: this.sourceElRect.top + this.deltaY,
  9351. });
  9352. }
  9353. };
  9354. ElementMirror.prototype.getMirrorEl = function () {
  9355. var sourceElRect = this.sourceElRect;
  9356. var mirrorEl = this.mirrorEl;
  9357. if (!mirrorEl) {
  9358. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  9359. // we don't want long taps or any mouse interaction causing selection/menus.
  9360. // would use preventSelection(), but that prevents selectstart, causing problems.
  9361. mirrorEl.classList.add('fc-unselectable');
  9362. mirrorEl.classList.add('fc-event-dragging');
  9363. applyStyle(mirrorEl, {
  9364. position: 'fixed',
  9365. zIndex: this.zIndex,
  9366. visibility: '',
  9367. boxSizing: 'border-box',
  9368. width: sourceElRect.right - sourceElRect.left,
  9369. height: sourceElRect.bottom - sourceElRect.top,
  9370. right: 'auto',
  9371. bottom: 'auto',
  9372. margin: 0,
  9373. });
  9374. this.parentNode.appendChild(mirrorEl);
  9375. }
  9376. return mirrorEl;
  9377. };
  9378. return ElementMirror;
  9379. }());
  9380. /*
  9381. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  9382. in addition the "client rectangle" of the element.. the area within the scrollbars.
  9383. The cache can be in one of two modes:
  9384. - doesListening:false - ignores when the container is scrolled by someone else
  9385. - doesListening:true - watch for scrolling and update the cache
  9386. */
  9387. var ScrollGeomCache = /** @class */ (function (_super) {
  9388. __extends(ScrollGeomCache, _super);
  9389. function ScrollGeomCache(scrollController, doesListening) {
  9390. var _this = _super.call(this) || this;
  9391. _this.handleScroll = function () {
  9392. _this.scrollTop = _this.scrollController.getScrollTop();
  9393. _this.scrollLeft = _this.scrollController.getScrollLeft();
  9394. _this.handleScrollChange();
  9395. };
  9396. _this.scrollController = scrollController;
  9397. _this.doesListening = doesListening;
  9398. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  9399. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  9400. _this.scrollWidth = scrollController.getScrollWidth();
  9401. _this.scrollHeight = scrollController.getScrollHeight();
  9402. _this.clientWidth = scrollController.getClientWidth();
  9403. _this.clientHeight = scrollController.getClientHeight();
  9404. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  9405. if (_this.doesListening) {
  9406. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  9407. }
  9408. return _this;
  9409. }
  9410. ScrollGeomCache.prototype.destroy = function () {
  9411. if (this.doesListening) {
  9412. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  9413. }
  9414. };
  9415. ScrollGeomCache.prototype.getScrollTop = function () {
  9416. return this.scrollTop;
  9417. };
  9418. ScrollGeomCache.prototype.getScrollLeft = function () {
  9419. return this.scrollLeft;
  9420. };
  9421. ScrollGeomCache.prototype.setScrollTop = function (top) {
  9422. this.scrollController.setScrollTop(top);
  9423. if (!this.doesListening) {
  9424. // we are not relying on the element to normalize out-of-bounds scroll values
  9425. // so we need to sanitize ourselves
  9426. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  9427. this.handleScrollChange();
  9428. }
  9429. };
  9430. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  9431. this.scrollController.setScrollLeft(top);
  9432. if (!this.doesListening) {
  9433. // we are not relying on the element to normalize out-of-bounds scroll values
  9434. // so we need to sanitize ourselves
  9435. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  9436. this.handleScrollChange();
  9437. }
  9438. };
  9439. ScrollGeomCache.prototype.getClientWidth = function () {
  9440. return this.clientWidth;
  9441. };
  9442. ScrollGeomCache.prototype.getClientHeight = function () {
  9443. return this.clientHeight;
  9444. };
  9445. ScrollGeomCache.prototype.getScrollWidth = function () {
  9446. return this.scrollWidth;
  9447. };
  9448. ScrollGeomCache.prototype.getScrollHeight = function () {
  9449. return this.scrollHeight;
  9450. };
  9451. ScrollGeomCache.prototype.handleScrollChange = function () {
  9452. };
  9453. return ScrollGeomCache;
  9454. }(ScrollController));
  9455. var ElementScrollGeomCache = /** @class */ (function (_super) {
  9456. __extends(ElementScrollGeomCache, _super);
  9457. function ElementScrollGeomCache(el, doesListening) {
  9458. return _super.call(this, new ElementScrollController(el), doesListening) || this;
  9459. }
  9460. ElementScrollGeomCache.prototype.getEventTarget = function () {
  9461. return this.scrollController.el;
  9462. };
  9463. ElementScrollGeomCache.prototype.computeClientRect = function () {
  9464. return computeInnerRect(this.scrollController.el);
  9465. };
  9466. return ElementScrollGeomCache;
  9467. }(ScrollGeomCache));
  9468. var WindowScrollGeomCache = /** @class */ (function (_super) {
  9469. __extends(WindowScrollGeomCache, _super);
  9470. function WindowScrollGeomCache(doesListening) {
  9471. return _super.call(this, new WindowScrollController(), doesListening) || this;
  9472. }
  9473. WindowScrollGeomCache.prototype.getEventTarget = function () {
  9474. return window;
  9475. };
  9476. WindowScrollGeomCache.prototype.computeClientRect = function () {
  9477. return {
  9478. left: this.scrollLeft,
  9479. right: this.scrollLeft + this.clientWidth,
  9480. top: this.scrollTop,
  9481. bottom: this.scrollTop + this.clientHeight,
  9482. };
  9483. };
  9484. // the window is the only scroll object that changes it's rectangle relative
  9485. // to the document's topleft as it scrolls
  9486. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  9487. this.clientRect = this.computeClientRect();
  9488. };
  9489. return WindowScrollGeomCache;
  9490. }(ScrollGeomCache));
  9491. // If available we are using native "performance" API instead of "Date"
  9492. // Read more about it on MDN:
  9493. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  9494. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  9495. /*
  9496. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  9497. approaches the edge.
  9498. The caller must call start + handleMove + stop.
  9499. */
  9500. var AutoScroller = /** @class */ (function () {
  9501. function AutoScroller() {
  9502. var _this = this;
  9503. // options that can be set by caller
  9504. this.isEnabled = true;
  9505. this.scrollQuery = [window, '.fc-scroller'];
  9506. this.edgeThreshold = 50; // pixels
  9507. this.maxVelocity = 300; // pixels per second
  9508. // internal state
  9509. this.pointerScreenX = null;
  9510. this.pointerScreenY = null;
  9511. this.isAnimating = false;
  9512. this.scrollCaches = null;
  9513. // protect against the initial pointerdown being too close to an edge and starting the scroll
  9514. this.everMovedUp = false;
  9515. this.everMovedDown = false;
  9516. this.everMovedLeft = false;
  9517. this.everMovedRight = false;
  9518. this.animate = function () {
  9519. if (_this.isAnimating) { // wasn't cancelled between animation calls
  9520. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  9521. if (edge) {
  9522. var now = getTime();
  9523. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  9524. _this.requestAnimation(now);
  9525. }
  9526. else {
  9527. _this.isAnimating = false; // will stop animation
  9528. }
  9529. }
  9530. };
  9531. }
  9532. AutoScroller.prototype.start = function (pageX, pageY) {
  9533. if (this.isEnabled) {
  9534. this.scrollCaches = this.buildCaches();
  9535. this.pointerScreenX = null;
  9536. this.pointerScreenY = null;
  9537. this.everMovedUp = false;
  9538. this.everMovedDown = false;
  9539. this.everMovedLeft = false;
  9540. this.everMovedRight = false;
  9541. this.handleMove(pageX, pageY);
  9542. }
  9543. };
  9544. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  9545. if (this.isEnabled) {
  9546. var pointerScreenX = pageX - window.pageXOffset;
  9547. var pointerScreenY = pageY - window.pageYOffset;
  9548. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  9549. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  9550. if (yDelta < 0) {
  9551. this.everMovedUp = true;
  9552. }
  9553. else if (yDelta > 0) {
  9554. this.everMovedDown = true;
  9555. }
  9556. if (xDelta < 0) {
  9557. this.everMovedLeft = true;
  9558. }
  9559. else if (xDelta > 0) {
  9560. this.everMovedRight = true;
  9561. }
  9562. this.pointerScreenX = pointerScreenX;
  9563. this.pointerScreenY = pointerScreenY;
  9564. if (!this.isAnimating) {
  9565. this.isAnimating = true;
  9566. this.requestAnimation(getTime());
  9567. }
  9568. }
  9569. };
  9570. AutoScroller.prototype.stop = function () {
  9571. if (this.isEnabled) {
  9572. this.isAnimating = false; // will stop animation
  9573. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9574. var scrollCache = _a[_i];
  9575. scrollCache.destroy();
  9576. }
  9577. this.scrollCaches = null;
  9578. }
  9579. };
  9580. AutoScroller.prototype.requestAnimation = function (now) {
  9581. this.msSinceRequest = now;
  9582. requestAnimationFrame(this.animate);
  9583. };
  9584. AutoScroller.prototype.handleSide = function (edge, seconds) {
  9585. var scrollCache = edge.scrollCache;
  9586. var edgeThreshold = this.edgeThreshold;
  9587. var invDistance = edgeThreshold - edge.distance;
  9588. var velocity = // the closer to the edge, the faster we scroll
  9589. ((invDistance * invDistance) / (edgeThreshold * edgeThreshold)) * // quadratic
  9590. this.maxVelocity * seconds;
  9591. var sign = 1;
  9592. switch (edge.name) {
  9593. case 'left':
  9594. sign = -1;
  9595. // falls through
  9596. case 'right':
  9597. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  9598. break;
  9599. case 'top':
  9600. sign = -1;
  9601. // falls through
  9602. case 'bottom':
  9603. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  9604. break;
  9605. }
  9606. };
  9607. // left/top are relative to document topleft
  9608. AutoScroller.prototype.computeBestEdge = function (left, top) {
  9609. var edgeThreshold = this.edgeThreshold;
  9610. var bestSide = null;
  9611. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9612. var scrollCache = _a[_i];
  9613. var rect = scrollCache.clientRect;
  9614. var leftDist = left - rect.left;
  9615. var rightDist = rect.right - left;
  9616. var topDist = top - rect.top;
  9617. var bottomDist = rect.bottom - top;
  9618. // completely within the rect?
  9619. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  9620. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  9621. (!bestSide || bestSide.distance > topDist)) {
  9622. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  9623. }
  9624. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  9625. (!bestSide || bestSide.distance > bottomDist)) {
  9626. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  9627. }
  9628. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  9629. (!bestSide || bestSide.distance > leftDist)) {
  9630. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  9631. }
  9632. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  9633. (!bestSide || bestSide.distance > rightDist)) {
  9634. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  9635. }
  9636. }
  9637. }
  9638. return bestSide;
  9639. };
  9640. AutoScroller.prototype.buildCaches = function () {
  9641. return this.queryScrollEls().map(function (el) {
  9642. if (el === window) {
  9643. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  9644. }
  9645. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  9646. });
  9647. };
  9648. AutoScroller.prototype.queryScrollEls = function () {
  9649. var els = [];
  9650. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  9651. var query = _a[_i];
  9652. if (typeof query === 'object') {
  9653. els.push(query);
  9654. }
  9655. else {
  9656. els.push.apply(els, Array.prototype.slice.call(document.querySelectorAll(query)));
  9657. }
  9658. }
  9659. return els;
  9660. };
  9661. return AutoScroller;
  9662. }());
  9663. /*
  9664. Monitors dragging on an element. Has a number of high-level features:
  9665. - minimum distance required before dragging
  9666. - minimum wait time ("delay") before dragging
  9667. - a mirror element that follows the pointer
  9668. */
  9669. var FeaturefulElementDragging = /** @class */ (function (_super) {
  9670. __extends(FeaturefulElementDragging, _super);
  9671. function FeaturefulElementDragging(containerEl, selector) {
  9672. var _this = _super.call(this, containerEl) || this;
  9673. // options that can be directly set by caller
  9674. // the caller can also set the PointerDragging's options as well
  9675. _this.delay = null;
  9676. _this.minDistance = 0;
  9677. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  9678. _this.mirrorNeedsRevert = false;
  9679. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  9680. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  9681. _this.isDelayEnded = false;
  9682. _this.isDistanceSurpassed = false;
  9683. _this.delayTimeoutId = null;
  9684. _this.onPointerDown = function (ev) {
  9685. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  9686. _this.isInteracting = true;
  9687. _this.isDelayEnded = false;
  9688. _this.isDistanceSurpassed = false;
  9689. preventSelection(document.body);
  9690. preventContextMenu(document.body);
  9691. // prevent links from being visited if there's an eventual drag.
  9692. // also prevents selection in older browsers (maybe?).
  9693. // not necessary for touch, besides, browser would complain about passiveness.
  9694. if (!ev.isTouch) {
  9695. ev.origEvent.preventDefault();
  9696. }
  9697. _this.emitter.trigger('pointerdown', ev);
  9698. if (_this.isInteracting && // not destroyed via pointerdown handler
  9699. !_this.pointer.shouldIgnoreMove) {
  9700. // actions related to initiating dragstart+dragmove+dragend...
  9701. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  9702. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  9703. _this.startDelay(ev);
  9704. if (!_this.minDistance) {
  9705. _this.handleDistanceSurpassed(ev);
  9706. }
  9707. }
  9708. }
  9709. };
  9710. _this.onPointerMove = function (ev) {
  9711. if (_this.isInteracting) {
  9712. _this.emitter.trigger('pointermove', ev);
  9713. if (!_this.isDistanceSurpassed) {
  9714. var minDistance = _this.minDistance;
  9715. var distanceSq = void 0; // current distance from the origin, squared
  9716. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  9717. distanceSq = deltaX * deltaX + deltaY * deltaY;
  9718. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  9719. _this.handleDistanceSurpassed(ev);
  9720. }
  9721. }
  9722. if (_this.isDragging) {
  9723. // a real pointer move? (not one simulated by scrolling)
  9724. if (ev.origEvent.type !== 'scroll') {
  9725. _this.mirror.handleMove(ev.pageX, ev.pageY);
  9726. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  9727. }
  9728. _this.emitter.trigger('dragmove', ev);
  9729. }
  9730. }
  9731. };
  9732. _this.onPointerUp = function (ev) {
  9733. if (_this.isInteracting) {
  9734. _this.isInteracting = false;
  9735. allowSelection(document.body);
  9736. allowContextMenu(document.body);
  9737. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  9738. if (_this.isDragging) {
  9739. _this.autoScroller.stop();
  9740. _this.tryStopDrag(ev); // which will stop the mirror
  9741. }
  9742. if (_this.delayTimeoutId) {
  9743. clearTimeout(_this.delayTimeoutId);
  9744. _this.delayTimeoutId = null;
  9745. }
  9746. }
  9747. };
  9748. var pointer = _this.pointer = new PointerDragging(containerEl);
  9749. pointer.emitter.on('pointerdown', _this.onPointerDown);
  9750. pointer.emitter.on('pointermove', _this.onPointerMove);
  9751. pointer.emitter.on('pointerup', _this.onPointerUp);
  9752. if (selector) {
  9753. pointer.selector = selector;
  9754. }
  9755. _this.mirror = new ElementMirror();
  9756. _this.autoScroller = new AutoScroller();
  9757. return _this;
  9758. }
  9759. FeaturefulElementDragging.prototype.destroy = function () {
  9760. this.pointer.destroy();
  9761. // HACK: simulate a pointer-up to end the current drag
  9762. // TODO: fire 'dragend' directly and stop interaction. discourage use of pointerup event (b/c might not fire)
  9763. this.onPointerUp({});
  9764. };
  9765. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  9766. var _this = this;
  9767. if (typeof this.delay === 'number') {
  9768. this.delayTimeoutId = setTimeout(function () {
  9769. _this.delayTimeoutId = null;
  9770. _this.handleDelayEnd(ev);
  9771. }, this.delay); // not assignable to number!
  9772. }
  9773. else {
  9774. this.handleDelayEnd(ev);
  9775. }
  9776. };
  9777. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  9778. this.isDelayEnded = true;
  9779. this.tryStartDrag(ev);
  9780. };
  9781. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  9782. this.isDistanceSurpassed = true;
  9783. this.tryStartDrag(ev);
  9784. };
  9785. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  9786. if (this.isDelayEnded && this.isDistanceSurpassed) {
  9787. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  9788. this.isDragging = true;
  9789. this.mirrorNeedsRevert = false;
  9790. this.autoScroller.start(ev.pageX, ev.pageY);
  9791. this.emitter.trigger('dragstart', ev);
  9792. if (this.touchScrollAllowed === false) {
  9793. this.pointer.cancelTouchScroll();
  9794. }
  9795. }
  9796. }
  9797. };
  9798. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  9799. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  9800. // that come from the document to fire beforehand. much more convenient this way.
  9801. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
  9802. };
  9803. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  9804. this.isDragging = false;
  9805. this.emitter.trigger('dragend', ev);
  9806. };
  9807. // fill in the implementations...
  9808. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  9809. this.pointer.shouldIgnoreMove = bool;
  9810. };
  9811. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  9812. this.mirror.setIsVisible(bool);
  9813. };
  9814. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  9815. this.mirrorNeedsRevert = bool;
  9816. };
  9817. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  9818. this.autoScroller.isEnabled = bool;
  9819. };
  9820. return FeaturefulElementDragging;
  9821. }(ElementDragging));
  9822. /*
  9823. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  9824. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  9825. Does not access the DOM after instantiation, so highly performant.
  9826. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  9827. and an determine if a given point is inside the combined clipping rectangle.
  9828. */
  9829. var OffsetTracker = /** @class */ (function () {
  9830. function OffsetTracker(el) {
  9831. this.origRect = computeRect(el);
  9832. // will work fine for divs that have overflow:hidden
  9833. this.scrollCaches = getClippingParents(el).map(function (scrollEl) { return new ElementScrollGeomCache(scrollEl, true); });
  9834. }
  9835. OffsetTracker.prototype.destroy = function () {
  9836. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9837. var scrollCache = _a[_i];
  9838. scrollCache.destroy();
  9839. }
  9840. };
  9841. OffsetTracker.prototype.computeLeft = function () {
  9842. var left = this.origRect.left;
  9843. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9844. var scrollCache = _a[_i];
  9845. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  9846. }
  9847. return left;
  9848. };
  9849. OffsetTracker.prototype.computeTop = function () {
  9850. var top = this.origRect.top;
  9851. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9852. var scrollCache = _a[_i];
  9853. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  9854. }
  9855. return top;
  9856. };
  9857. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  9858. var point = { left: pageX, top: pageY };
  9859. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  9860. var scrollCache = _a[_i];
  9861. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  9862. !pointInsideRect(point, scrollCache.clientRect)) {
  9863. return false;
  9864. }
  9865. }
  9866. return true;
  9867. };
  9868. return OffsetTracker;
  9869. }());
  9870. // certain clipping containers should never constrain interactions, like <html> and <body>
  9871. // https://github.com/fullcalendar/fullcalendar/issues/3615
  9872. function isIgnoredClipping(node) {
  9873. var tagName = node.tagName;
  9874. return tagName === 'HTML' || tagName === 'BODY';
  9875. }
  9876. /*
  9877. Tracks movement over multiple droppable areas (aka "hits")
  9878. that exist in one or more DateComponents.
  9879. Relies on an existing draggable.
  9880. emits:
  9881. - pointerdown
  9882. - dragstart
  9883. - hitchange - fires initially, even if not over a hit
  9884. - pointerup
  9885. - (hitchange - again, to null, if ended over a hit)
  9886. - dragend
  9887. */
  9888. var HitDragging = /** @class */ (function () {
  9889. function HitDragging(dragging, droppableStore) {
  9890. var _this = this;
  9891. // options that can be set by caller
  9892. this.useSubjectCenter = false;
  9893. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  9894. this.initialHit = null;
  9895. this.movingHit = null;
  9896. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  9897. this.handlePointerDown = function (ev) {
  9898. var dragging = _this.dragging;
  9899. _this.initialHit = null;
  9900. _this.movingHit = null;
  9901. _this.finalHit = null;
  9902. _this.prepareHits();
  9903. _this.processFirstCoord(ev);
  9904. if (_this.initialHit || !_this.requireInitial) {
  9905. dragging.setIgnoreMove(false);
  9906. // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  9907. _this.emitter.trigger('pointerdown', ev);
  9908. }
  9909. else {
  9910. dragging.setIgnoreMove(true);
  9911. }
  9912. };
  9913. this.handleDragStart = function (ev) {
  9914. _this.emitter.trigger('dragstart', ev);
  9915. _this.handleMove(ev, true); // force = fire even if initially null
  9916. };
  9917. this.handleDragMove = function (ev) {
  9918. _this.emitter.trigger('dragmove', ev);
  9919. _this.handleMove(ev);
  9920. };
  9921. this.handlePointerUp = function (ev) {
  9922. _this.releaseHits();
  9923. _this.emitter.trigger('pointerup', ev);
  9924. };
  9925. this.handleDragEnd = function (ev) {
  9926. if (_this.movingHit) {
  9927. _this.emitter.trigger('hitupdate', null, true, ev);
  9928. }
  9929. _this.finalHit = _this.movingHit;
  9930. _this.movingHit = null;
  9931. _this.emitter.trigger('dragend', ev);
  9932. };
  9933. this.droppableStore = droppableStore;
  9934. dragging.emitter.on('pointerdown', this.handlePointerDown);
  9935. dragging.emitter.on('dragstart', this.handleDragStart);
  9936. dragging.emitter.on('dragmove', this.handleDragMove);
  9937. dragging.emitter.on('pointerup', this.handlePointerUp);
  9938. dragging.emitter.on('dragend', this.handleDragEnd);
  9939. this.dragging = dragging;
  9940. this.emitter = new Emitter();
  9941. }
  9942. // sets initialHit
  9943. // sets coordAdjust
  9944. HitDragging.prototype.processFirstCoord = function (ev) {
  9945. var origPoint = { left: ev.pageX, top: ev.pageY };
  9946. var adjustedPoint = origPoint;
  9947. var subjectEl = ev.subjectEl;
  9948. var subjectRect;
  9949. if (subjectEl !== document) {
  9950. subjectRect = computeRect(subjectEl);
  9951. adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
  9952. }
  9953. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  9954. if (initialHit) {
  9955. if (this.useSubjectCenter && subjectRect) {
  9956. var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
  9957. if (slicedSubjectRect) {
  9958. adjustedPoint = getRectCenter(slicedSubjectRect);
  9959. }
  9960. }
  9961. this.coordAdjust = diffPoints(adjustedPoint, origPoint);
  9962. }
  9963. else {
  9964. this.coordAdjust = { left: 0, top: 0 };
  9965. }
  9966. };
  9967. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  9968. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  9969. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  9970. this.movingHit = hit;
  9971. this.emitter.trigger('hitupdate', hit, false, ev);
  9972. }
  9973. };
  9974. HitDragging.prototype.prepareHits = function () {
  9975. this.offsetTrackers = mapHash(this.droppableStore, function (interactionSettings) {
  9976. interactionSettings.component.prepareHits();
  9977. return new OffsetTracker(interactionSettings.el);
  9978. });
  9979. };
  9980. HitDragging.prototype.releaseHits = function () {
  9981. var offsetTrackers = this.offsetTrackers;
  9982. for (var id in offsetTrackers) {
  9983. offsetTrackers[id].destroy();
  9984. }
  9985. this.offsetTrackers = {};
  9986. };
  9987. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  9988. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  9989. var bestHit = null;
  9990. for (var id in droppableStore) {
  9991. var component = droppableStore[id].component;
  9992. var offsetTracker = offsetTrackers[id];
  9993. if (offsetTracker && // wasn't destroyed mid-drag
  9994. offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  9995. var originLeft = offsetTracker.computeLeft();
  9996. var originTop = offsetTracker.computeTop();
  9997. var positionLeft = offsetLeft - originLeft;
  9998. var positionTop = offsetTop - originTop;
  9999. var origRect = offsetTracker.origRect;
  10000. var width = origRect.right - origRect.left;
  10001. var height = origRect.bottom - origRect.top;
  10002. if (
  10003. // must be within the element's bounds
  10004. positionLeft >= 0 && positionLeft < width &&
  10005. positionTop >= 0 && positionTop < height) {
  10006. var hit = component.queryHit(positionLeft, positionTop, width, height);
  10007. var dateProfile = component.context.getCurrentData().dateProfile;
  10008. if (hit &&
  10009. (
  10010. // make sure the hit is within activeRange, meaning it's not a deal cell
  10011. rangeContainsRange(dateProfile.activeRange, hit.dateSpan.range)) &&
  10012. (!bestHit || hit.layer > bestHit.layer)) {
  10013. // TODO: better way to re-orient rectangle
  10014. hit.rect.left += originLeft;
  10015. hit.rect.right += originLeft;
  10016. hit.rect.top += originTop;
  10017. hit.rect.bottom += originTop;
  10018. bestHit = hit;
  10019. }
  10020. }
  10021. }
  10022. }
  10023. return bestHit;
  10024. };
  10025. return HitDragging;
  10026. }());
  10027. function isHitsEqual(hit0, hit1) {
  10028. if (!hit0 && !hit1) {
  10029. return true;
  10030. }
  10031. if (Boolean(hit0) !== Boolean(hit1)) {
  10032. return false;
  10033. }
  10034. return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  10035. }
  10036. function buildDatePointApiWithContext(dateSpan, context) {
  10037. var props = {};
  10038. for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
  10039. var transform = _a[_i];
  10040. __assign(props, transform(dateSpan, context));
  10041. }
  10042. __assign(props, buildDatePointApi(dateSpan, context.dateEnv));
  10043. return props;
  10044. }
  10045. function buildDatePointApi(span, dateEnv) {
  10046. return {
  10047. date: dateEnv.toDate(span.range.start),
  10048. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  10049. allDay: span.allDay,
  10050. };
  10051. }
  10052. /*
  10053. Monitors when the user clicks on a specific date/time of a component.
  10054. A pointerdown+pointerup on the same "hit" constitutes a click.
  10055. */
  10056. var DateClicking = /** @class */ (function (_super) {
  10057. __extends(DateClicking, _super);
  10058. function DateClicking(settings) {
  10059. var _this = _super.call(this, settings) || this;
  10060. _this.handlePointerDown = function (pev) {
  10061. var dragging = _this.dragging;
  10062. var downEl = pev.origEvent.target;
  10063. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  10064. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(downEl));
  10065. };
  10066. // won't even fire if moving was ignored
  10067. _this.handleDragEnd = function (ev) {
  10068. var component = _this.component;
  10069. var pointer = _this.dragging.pointer;
  10070. if (!pointer.wasTouchScroll) {
  10071. var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
  10072. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  10073. var context = component.context;
  10074. var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
  10075. context.emitter.trigger('dateClick', arg);
  10076. }
  10077. }
  10078. };
  10079. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  10080. _this.dragging = new FeaturefulElementDragging(settings.el);
  10081. _this.dragging.autoScroller.isEnabled = false;
  10082. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10083. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10084. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10085. return _this;
  10086. }
  10087. DateClicking.prototype.destroy = function () {
  10088. this.dragging.destroy();
  10089. };
  10090. return DateClicking;
  10091. }(Interaction));
  10092. /*
  10093. Tracks when the user selects a portion of time of a component,
  10094. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  10095. */
  10096. var DateSelecting = /** @class */ (function (_super) {
  10097. __extends(DateSelecting, _super);
  10098. function DateSelecting(settings) {
  10099. var _this = _super.call(this, settings) || this;
  10100. _this.dragSelection = null;
  10101. _this.handlePointerDown = function (ev) {
  10102. var _a = _this, component = _a.component, dragging = _a.dragging;
  10103. var options = component.context.options;
  10104. var canSelect = options.selectable &&
  10105. component.isValidDateDownEl(ev.origEvent.target);
  10106. // don't bother to watch expensive moves if component won't do selection
  10107. dragging.setIgnoreMove(!canSelect);
  10108. // if touch, require user to hold down
  10109. dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
  10110. };
  10111. _this.handleDragStart = function (ev) {
  10112. _this.component.context.calendarApi.unselect(ev); // unselect previous selections
  10113. };
  10114. _this.handleHitUpdate = function (hit, isFinal) {
  10115. var context = _this.component.context;
  10116. var dragSelection = null;
  10117. var isInvalid = false;
  10118. if (hit) {
  10119. dragSelection = joinHitsIntoSelection(_this.hitDragging.initialHit, hit, context.pluginHooks.dateSelectionTransformers);
  10120. if (!dragSelection || !_this.component.isDateSelectionValid(dragSelection)) {
  10121. isInvalid = true;
  10122. dragSelection = null;
  10123. }
  10124. }
  10125. if (dragSelection) {
  10126. context.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  10127. }
  10128. else if (!isFinal) { // only unselect if moved away while dragging
  10129. context.dispatch({ type: 'UNSELECT_DATES' });
  10130. }
  10131. if (!isInvalid) {
  10132. enableCursor();
  10133. }
  10134. else {
  10135. disableCursor();
  10136. }
  10137. if (!isFinal) {
  10138. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  10139. }
  10140. };
  10141. _this.handlePointerUp = function (pev) {
  10142. if (_this.dragSelection) {
  10143. // selection is already rendered, so just need to report selection
  10144. triggerDateSelect(_this.dragSelection, pev, _this.component.context);
  10145. _this.dragSelection = null;
  10146. }
  10147. };
  10148. var component = settings.component;
  10149. var options = component.context.options;
  10150. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10151. dragging.touchScrollAllowed = false;
  10152. dragging.minDistance = options.selectMinDistance || 0;
  10153. dragging.autoScroller.isEnabled = options.dragScroll;
  10154. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10155. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10156. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10157. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10158. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10159. return _this;
  10160. }
  10161. DateSelecting.prototype.destroy = function () {
  10162. this.dragging.destroy();
  10163. };
  10164. return DateSelecting;
  10165. }(Interaction));
  10166. function getComponentTouchDelay(component) {
  10167. var options = component.context.options;
  10168. var delay = options.selectLongPressDelay;
  10169. if (delay == null) {
  10170. delay = options.longPressDelay;
  10171. }
  10172. return delay;
  10173. }
  10174. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  10175. var dateSpan0 = hit0.dateSpan;
  10176. var dateSpan1 = hit1.dateSpan;
  10177. var ms = [
  10178. dateSpan0.range.start,
  10179. dateSpan0.range.end,
  10180. dateSpan1.range.start,
  10181. dateSpan1.range.end,
  10182. ];
  10183. ms.sort(compareNumbers);
  10184. var props = {};
  10185. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  10186. var transformer = dateSelectionTransformers_1[_i];
  10187. var res = transformer(hit0, hit1);
  10188. if (res === false) {
  10189. return null;
  10190. }
  10191. if (res) {
  10192. __assign(props, res);
  10193. }
  10194. }
  10195. props.range = { start: ms[0], end: ms[3] };
  10196. props.allDay = dateSpan0.allDay;
  10197. return props;
  10198. }
  10199. var EventDragging = /** @class */ (function (_super) {
  10200. __extends(EventDragging, _super);
  10201. function EventDragging(settings) {
  10202. var _this = _super.call(this, settings) || this;
  10203. // internal state
  10204. _this.subjectEl = null;
  10205. _this.subjectSeg = null; // the seg being selected/dragged
  10206. _this.isDragging = false;
  10207. _this.eventRange = null;
  10208. _this.relevantEvents = null; // the events being dragged
  10209. _this.receivingContext = null;
  10210. _this.validMutation = null;
  10211. _this.mutatedRelevantEvents = null;
  10212. _this.handlePointerDown = function (ev) {
  10213. var origTarget = ev.origEvent.target;
  10214. var _a = _this, component = _a.component, dragging = _a.dragging;
  10215. var mirror = dragging.mirror;
  10216. var options = component.context.options;
  10217. var initialContext = component.context;
  10218. _this.subjectEl = ev.subjectEl;
  10219. var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
  10220. var eventRange = _this.eventRange = subjectSeg.eventRange;
  10221. var eventInstanceId = eventRange.instance.instanceId;
  10222. _this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
  10223. dragging.minDistance = ev.isTouch ? 0 : options.eventDragMinDistance;
  10224. dragging.delay =
  10225. // only do a touch delay if touch and this event hasn't been selected yet
  10226. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  10227. getComponentTouchDelay$1(component) :
  10228. null;
  10229. if (options.fixedMirrorParent) {
  10230. mirror.parentNode = options.fixedMirrorParent;
  10231. }
  10232. else {
  10233. mirror.parentNode = elementClosest(origTarget, '.fc');
  10234. }
  10235. mirror.revertDuration = options.dragRevertDuration;
  10236. var isValid = component.isValidSegDownEl(origTarget) &&
  10237. !elementClosest(origTarget, '.fc-event-resizer'); // NOT on a resizer
  10238. dragging.setIgnoreMove(!isValid);
  10239. // disable dragging for elements that are resizable (ie, selectable)
  10240. // but are not draggable
  10241. _this.isDragging = isValid &&
  10242. ev.subjectEl.classList.contains('fc-event-draggable');
  10243. };
  10244. _this.handleDragStart = function (ev) {
  10245. var initialContext = _this.component.context;
  10246. var eventRange = _this.eventRange;
  10247. var eventInstanceId = eventRange.instance.instanceId;
  10248. if (ev.isTouch) {
  10249. // need to select a different event?
  10250. if (eventInstanceId !== _this.component.props.eventSelection) {
  10251. initialContext.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  10252. }
  10253. }
  10254. else {
  10255. // if now using mouse, but was previous touch interaction, clear selected event
  10256. initialContext.dispatch({ type: 'UNSELECT_EVENT' });
  10257. }
  10258. if (_this.isDragging) {
  10259. initialContext.calendarApi.unselect(ev); // unselect *date* selection
  10260. initialContext.emitter.trigger('eventDragStart', {
  10261. el: _this.subjectEl,
  10262. event: new EventApi(initialContext, eventRange.def, eventRange.instance),
  10263. jsEvent: ev.origEvent,
  10264. view: initialContext.viewApi,
  10265. });
  10266. }
  10267. };
  10268. _this.handleHitUpdate = function (hit, isFinal) {
  10269. if (!_this.isDragging) {
  10270. return;
  10271. }
  10272. var relevantEvents = _this.relevantEvents;
  10273. var initialHit = _this.hitDragging.initialHit;
  10274. var initialContext = _this.component.context;
  10275. // states based on new hit
  10276. var receivingContext = null;
  10277. var mutation = null;
  10278. var mutatedRelevantEvents = null;
  10279. var isInvalid = false;
  10280. var interaction = {
  10281. affectedEvents: relevantEvents,
  10282. mutatedEvents: createEmptyEventStore(),
  10283. isEvent: true,
  10284. };
  10285. if (hit) {
  10286. var receivingComponent = hit.component;
  10287. receivingContext = receivingComponent.context;
  10288. var receivingOptions = receivingContext.options;
  10289. if (initialContext === receivingContext ||
  10290. (receivingOptions.editable && receivingOptions.droppable)) {
  10291. mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
  10292. if (mutation) {
  10293. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
  10294. interaction.mutatedEvents = mutatedRelevantEvents;
  10295. if (!receivingComponent.isInteractionValid(interaction)) {
  10296. isInvalid = true;
  10297. mutation = null;
  10298. mutatedRelevantEvents = null;
  10299. interaction.mutatedEvents = createEmptyEventStore();
  10300. }
  10301. }
  10302. }
  10303. else {
  10304. receivingContext = null;
  10305. }
  10306. }
  10307. _this.displayDrag(receivingContext, interaction);
  10308. if (!isInvalid) {
  10309. enableCursor();
  10310. }
  10311. else {
  10312. disableCursor();
  10313. }
  10314. if (!isFinal) {
  10315. if (initialContext === receivingContext && // TODO: write test for this
  10316. isHitsEqual(initialHit, hit)) {
  10317. mutation = null;
  10318. }
  10319. _this.dragging.setMirrorNeedsRevert(!mutation);
  10320. // render the mirror if no already-rendered mirror
  10321. // TODO: wish we could somehow wait for dispatch to guarantee render
  10322. _this.dragging.setMirrorIsVisible(!hit || !document.querySelector('.fc-event-mirror'));
  10323. // assign states based on new hit
  10324. _this.receivingContext = receivingContext;
  10325. _this.validMutation = mutation;
  10326. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  10327. }
  10328. };
  10329. _this.handlePointerUp = function () {
  10330. if (!_this.isDragging) {
  10331. _this.cleanup(); // because handleDragEnd won't fire
  10332. }
  10333. };
  10334. _this.handleDragEnd = function (ev) {
  10335. if (_this.isDragging) {
  10336. var initialContext_1 = _this.component.context;
  10337. var initialView = initialContext_1.viewApi;
  10338. var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
  10339. var eventDef = _this.eventRange.def;
  10340. var eventInstance = _this.eventRange.instance;
  10341. var eventApi = new EventApi(initialContext_1, eventDef, eventInstance);
  10342. var relevantEvents_1 = _this.relevantEvents;
  10343. var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
  10344. var finalHit = _this.hitDragging.finalHit;
  10345. _this.clearDrag(); // must happen after revert animation
  10346. initialContext_1.emitter.trigger('eventDragStop', {
  10347. el: _this.subjectEl,
  10348. event: eventApi,
  10349. jsEvent: ev.origEvent,
  10350. view: initialView,
  10351. });
  10352. if (validMutation) {
  10353. // dropped within same calendar
  10354. if (receivingContext_1 === initialContext_1) {
  10355. var updatedEventApi = new EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
  10356. initialContext_1.dispatch({
  10357. type: 'MERGE_EVENTS',
  10358. eventStore: mutatedRelevantEvents_1,
  10359. });
  10360. var eventChangeArg = {
  10361. oldEvent: eventApi,
  10362. event: updatedEventApi,
  10363. relatedEvents: buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
  10364. revert: function () {
  10365. initialContext_1.dispatch({
  10366. type: 'MERGE_EVENTS',
  10367. eventStore: relevantEvents_1,
  10368. });
  10369. },
  10370. };
  10371. var transformed = {};
  10372. for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
  10373. var transformer = _b[_i];
  10374. __assign(transformed, transformer(validMutation, initialContext_1));
  10375. }
  10376. initialContext_1.emitter.trigger('eventDrop', __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
  10377. initialContext_1.emitter.trigger('eventChange', eventChangeArg);
  10378. // dropped in different calendar
  10379. }
  10380. else if (receivingContext_1) {
  10381. var eventRemoveArg = {
  10382. event: eventApi,
  10383. relatedEvents: buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
  10384. revert: function () {
  10385. initialContext_1.dispatch({
  10386. type: 'MERGE_EVENTS',
  10387. eventStore: relevantEvents_1,
  10388. });
  10389. },
  10390. };
  10391. initialContext_1.emitter.trigger('eventLeave', __assign(__assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
  10392. initialContext_1.dispatch({
  10393. type: 'REMOVE_EVENTS',
  10394. eventStore: relevantEvents_1,
  10395. });
  10396. initialContext_1.emitter.trigger('eventRemove', eventRemoveArg);
  10397. var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
  10398. var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
  10399. var addedEventApi = new EventApi(receivingContext_1, addedEventDef, addedEventInstance);
  10400. receivingContext_1.dispatch({
  10401. type: 'MERGE_EVENTS',
  10402. eventStore: mutatedRelevantEvents_1,
  10403. });
  10404. var eventAddArg = {
  10405. event: addedEventApi,
  10406. relatedEvents: buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
  10407. revert: function () {
  10408. receivingContext_1.dispatch({
  10409. type: 'REMOVE_EVENTS',
  10410. eventStore: mutatedRelevantEvents_1,
  10411. });
  10412. },
  10413. };
  10414. receivingContext_1.emitter.trigger('eventAdd', eventAddArg);
  10415. if (ev.isTouch) {
  10416. receivingContext_1.dispatch({
  10417. type: 'SELECT_EVENT',
  10418. eventInstanceId: eventInstance.instanceId,
  10419. });
  10420. }
  10421. receivingContext_1.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component.context.viewApi }));
  10422. receivingContext_1.emitter.trigger('eventReceive', __assign(__assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.component.context.viewApi }));
  10423. }
  10424. }
  10425. else {
  10426. initialContext_1.emitter.trigger('_noEventDrop');
  10427. }
  10428. }
  10429. _this.cleanup();
  10430. };
  10431. var component = _this.component;
  10432. var options = component.context.options;
  10433. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10434. dragging.pointer.selector = EventDragging.SELECTOR;
  10435. dragging.touchScrollAllowed = false;
  10436. dragging.autoScroller.isEnabled = options.dragScroll;
  10437. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
  10438. hitDragging.useSubjectCenter = settings.useEventCenter;
  10439. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10440. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10441. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10442. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  10443. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10444. return _this;
  10445. }
  10446. EventDragging.prototype.destroy = function () {
  10447. this.dragging.destroy();
  10448. };
  10449. // render a drag state on the next receivingCalendar
  10450. EventDragging.prototype.displayDrag = function (nextContext, state) {
  10451. var initialContext = this.component.context;
  10452. var prevContext = this.receivingContext;
  10453. // does the previous calendar need to be cleared?
  10454. if (prevContext && prevContext !== nextContext) {
  10455. // does the initial calendar need to be cleared?
  10456. // if so, don't clear all the way. we still need to to hide the affectedEvents
  10457. if (prevContext === initialContext) {
  10458. prevContext.dispatch({
  10459. type: 'SET_EVENT_DRAG',
  10460. state: {
  10461. affectedEvents: state.affectedEvents,
  10462. mutatedEvents: createEmptyEventStore(),
  10463. isEvent: true,
  10464. },
  10465. });
  10466. // completely clear the old calendar if it wasn't the initial
  10467. }
  10468. else {
  10469. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10470. }
  10471. }
  10472. if (nextContext) {
  10473. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  10474. }
  10475. };
  10476. EventDragging.prototype.clearDrag = function () {
  10477. var initialCalendar = this.component.context;
  10478. var receivingContext = this.receivingContext;
  10479. if (receivingContext) {
  10480. receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10481. }
  10482. // the initial calendar might have an dummy drag state from displayDrag
  10483. if (initialCalendar !== receivingContext) {
  10484. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10485. }
  10486. };
  10487. EventDragging.prototype.cleanup = function () {
  10488. this.subjectSeg = null;
  10489. this.isDragging = false;
  10490. this.eventRange = null;
  10491. this.relevantEvents = null;
  10492. this.receivingContext = null;
  10493. this.validMutation = null;
  10494. this.mutatedRelevantEvents = null;
  10495. };
  10496. // TODO: test this in IE11
  10497. // QUESTION: why do we need it on the resizable???
  10498. EventDragging.SELECTOR = '.fc-event-draggable, .fc-event-resizable';
  10499. return EventDragging;
  10500. }(Interaction));
  10501. function computeEventMutation(hit0, hit1, massagers) {
  10502. var dateSpan0 = hit0.dateSpan;
  10503. var dateSpan1 = hit1.dateSpan;
  10504. var date0 = dateSpan0.range.start;
  10505. var date1 = dateSpan1.range.start;
  10506. var standardProps = {};
  10507. if (dateSpan0.allDay !== dateSpan1.allDay) {
  10508. standardProps.allDay = dateSpan1.allDay;
  10509. standardProps.hasEnd = hit1.component.context.options.allDayMaintainDuration;
  10510. if (dateSpan1.allDay) {
  10511. // means date1 is already start-of-day,
  10512. // but date0 needs to be converted
  10513. date0 = startOfDay(date0);
  10514. }
  10515. }
  10516. var delta = diffDates(date0, date1, hit0.component.context.dateEnv, hit0.component === hit1.component ?
  10517. hit0.component.largeUnit :
  10518. null);
  10519. if (delta.milliseconds) { // has hours/minutes/seconds
  10520. standardProps.allDay = false;
  10521. }
  10522. var mutation = {
  10523. datesDelta: delta,
  10524. standardProps: standardProps,
  10525. };
  10526. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  10527. var massager = massagers_1[_i];
  10528. massager(mutation, hit0, hit1);
  10529. }
  10530. return mutation;
  10531. }
  10532. function getComponentTouchDelay$1(component) {
  10533. var options = component.context.options;
  10534. var delay = options.eventLongPressDelay;
  10535. if (delay == null) {
  10536. delay = options.longPressDelay;
  10537. }
  10538. return delay;
  10539. }
  10540. var EventResizing = /** @class */ (function (_super) {
  10541. __extends(EventResizing, _super);
  10542. function EventResizing(settings) {
  10543. var _this = _super.call(this, settings) || this;
  10544. // internal state
  10545. _this.draggingSegEl = null;
  10546. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  10547. _this.eventRange = null;
  10548. _this.relevantEvents = null;
  10549. _this.validMutation = null;
  10550. _this.mutatedRelevantEvents = null;
  10551. _this.handlePointerDown = function (ev) {
  10552. var component = _this.component;
  10553. var segEl = _this.querySegEl(ev);
  10554. var seg = getElSeg(segEl);
  10555. var eventRange = _this.eventRange = seg.eventRange;
  10556. _this.dragging.minDistance = component.context.options.eventDragMinDistance;
  10557. // if touch, need to be working with a selected event
  10558. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  10559. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  10560. };
  10561. _this.handleDragStart = function (ev) {
  10562. var context = _this.component.context;
  10563. var eventRange = _this.eventRange;
  10564. _this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
  10565. var segEl = _this.querySegEl(ev);
  10566. _this.draggingSegEl = segEl;
  10567. _this.draggingSeg = getElSeg(segEl);
  10568. context.calendarApi.unselect();
  10569. context.emitter.trigger('eventResizeStart', {
  10570. el: segEl,
  10571. event: new EventApi(context, eventRange.def, eventRange.instance),
  10572. jsEvent: ev.origEvent,
  10573. view: context.viewApi,
  10574. });
  10575. };
  10576. _this.handleHitUpdate = function (hit, isFinal, ev) {
  10577. var context = _this.component.context;
  10578. var relevantEvents = _this.relevantEvents;
  10579. var initialHit = _this.hitDragging.initialHit;
  10580. var eventInstance = _this.eventRange.instance;
  10581. var mutation = null;
  10582. var mutatedRelevantEvents = null;
  10583. var isInvalid = false;
  10584. var interaction = {
  10585. affectedEvents: relevantEvents,
  10586. mutatedEvents: createEmptyEventStore(),
  10587. isEvent: true,
  10588. };
  10589. if (hit) {
  10590. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-event-resizer-start'), eventInstance.range, context.pluginHooks.eventResizeJoinTransforms);
  10591. }
  10592. if (mutation) {
  10593. mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
  10594. interaction.mutatedEvents = mutatedRelevantEvents;
  10595. if (!_this.component.isInteractionValid(interaction)) {
  10596. isInvalid = true;
  10597. mutation = null;
  10598. mutatedRelevantEvents = null;
  10599. interaction.mutatedEvents = null;
  10600. }
  10601. }
  10602. if (mutatedRelevantEvents) {
  10603. context.dispatch({
  10604. type: 'SET_EVENT_RESIZE',
  10605. state: interaction,
  10606. });
  10607. }
  10608. else {
  10609. context.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  10610. }
  10611. if (!isInvalid) {
  10612. enableCursor();
  10613. }
  10614. else {
  10615. disableCursor();
  10616. }
  10617. if (!isFinal) {
  10618. if (mutation && isHitsEqual(initialHit, hit)) {
  10619. mutation = null;
  10620. }
  10621. _this.validMutation = mutation;
  10622. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  10623. }
  10624. };
  10625. _this.handleDragEnd = function (ev) {
  10626. var context = _this.component.context;
  10627. var eventDef = _this.eventRange.def;
  10628. var eventInstance = _this.eventRange.instance;
  10629. var eventApi = new EventApi(context, eventDef, eventInstance);
  10630. var relevantEvents = _this.relevantEvents;
  10631. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  10632. context.emitter.trigger('eventResizeStop', {
  10633. el: _this.draggingSegEl,
  10634. event: eventApi,
  10635. jsEvent: ev.origEvent,
  10636. view: context.viewApi,
  10637. });
  10638. if (_this.validMutation) {
  10639. var updatedEventApi = new EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
  10640. context.dispatch({
  10641. type: 'MERGE_EVENTS',
  10642. eventStore: mutatedRelevantEvents,
  10643. });
  10644. var eventChangeArg = {
  10645. oldEvent: eventApi,
  10646. event: updatedEventApi,
  10647. relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
  10648. revert: function () {
  10649. context.dispatch({
  10650. type: 'MERGE_EVENTS',
  10651. eventStore: relevantEvents,
  10652. });
  10653. },
  10654. };
  10655. 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 }));
  10656. context.emitter.trigger('eventChange', eventChangeArg);
  10657. }
  10658. else {
  10659. context.emitter.trigger('_noEventResize');
  10660. }
  10661. // reset all internal state
  10662. _this.draggingSeg = null;
  10663. _this.relevantEvents = null;
  10664. _this.validMutation = null;
  10665. // okay to keep eventInstance around. useful to set it in handlePointerDown
  10666. };
  10667. var component = settings.component;
  10668. var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
  10669. dragging.pointer.selector = '.fc-event-resizer';
  10670. dragging.touchScrollAllowed = false;
  10671. dragging.autoScroller.isEnabled = component.context.options.dragScroll;
  10672. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
  10673. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  10674. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  10675. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  10676. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  10677. return _this;
  10678. }
  10679. EventResizing.prototype.destroy = function () {
  10680. this.dragging.destroy();
  10681. };
  10682. EventResizing.prototype.querySegEl = function (ev) {
  10683. return elementClosest(ev.subjectEl, '.fc-event');
  10684. };
  10685. return EventResizing;
  10686. }(Interaction));
  10687. function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
  10688. var dateEnv = hit0.component.context.dateEnv;
  10689. var date0 = hit0.dateSpan.range.start;
  10690. var date1 = hit1.dateSpan.range.start;
  10691. var delta = diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
  10692. var props = {};
  10693. for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
  10694. var transform = transforms_1[_i];
  10695. var res = transform(hit0, hit1);
  10696. if (res === false) {
  10697. return null;
  10698. }
  10699. if (res) {
  10700. __assign(props, res);
  10701. }
  10702. }
  10703. if (isFromStart) {
  10704. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  10705. props.startDelta = delta;
  10706. return props;
  10707. }
  10708. }
  10709. else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  10710. props.endDelta = delta;
  10711. return props;
  10712. }
  10713. return null;
  10714. }
  10715. var UnselectAuto = /** @class */ (function () {
  10716. function UnselectAuto(context) {
  10717. var _this = this;
  10718. this.context = context;
  10719. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  10720. this.matchesCancel = false;
  10721. this.matchesEvent = false;
  10722. this.onSelect = function (selectInfo) {
  10723. if (selectInfo.jsEvent) {
  10724. _this.isRecentPointerDateSelect = true;
  10725. }
  10726. };
  10727. this.onDocumentPointerDown = function (pev) {
  10728. var unselectCancel = _this.context.options.unselectCancel;
  10729. var downEl = pev.origEvent.target;
  10730. _this.matchesCancel = !!elementClosest(downEl, unselectCancel);
  10731. _this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR); // interaction started on an event?
  10732. };
  10733. this.onDocumentPointerUp = function (pev) {
  10734. var context = _this.context;
  10735. var documentPointer = _this.documentPointer;
  10736. var calendarState = context.getCurrentData();
  10737. // touch-scrolling should never unfocus any type of selection
  10738. if (!documentPointer.wasTouchScroll) {
  10739. if (calendarState.dateSelection && // an existing date selection?
  10740. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  10741. ) {
  10742. var unselectAuto = context.options.unselectAuto;
  10743. if (unselectAuto && (!unselectAuto || !_this.matchesCancel)) {
  10744. context.calendarApi.unselect(pev);
  10745. }
  10746. }
  10747. if (calendarState.eventSelection && // an existing event selected?
  10748. !_this.matchesEvent // interaction DIDN'T start on an event
  10749. ) {
  10750. context.dispatch({ type: 'UNSELECT_EVENT' });
  10751. }
  10752. }
  10753. _this.isRecentPointerDateSelect = false;
  10754. };
  10755. var documentPointer = this.documentPointer = new PointerDragging(document);
  10756. documentPointer.shouldIgnoreMove = true;
  10757. documentPointer.shouldWatchScroll = false;
  10758. documentPointer.emitter.on('pointerdown', this.onDocumentPointerDown);
  10759. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  10760. /*
  10761. TODO: better way to know about whether there was a selection with the pointer
  10762. */
  10763. context.emitter.on('select', this.onSelect);
  10764. }
  10765. UnselectAuto.prototype.destroy = function () {
  10766. this.context.emitter.off('select', this.onSelect);
  10767. this.documentPointer.destroy();
  10768. };
  10769. return UnselectAuto;
  10770. }());
  10771. var OPTION_REFINERS = {
  10772. fixedMirrorParent: identity,
  10773. };
  10774. var LISTENER_REFINERS = {
  10775. dateClick: identity,
  10776. eventDragStart: identity,
  10777. eventDragStop: identity,
  10778. eventDrop: identity,
  10779. eventResizeStart: identity,
  10780. eventResizeStop: identity,
  10781. eventResize: identity,
  10782. drop: identity,
  10783. eventReceive: identity,
  10784. eventLeave: identity,
  10785. };
  10786. /*
  10787. Given an already instantiated draggable object for one-or-more elements,
  10788. Interprets any dragging as an attempt to drag an events that lives outside
  10789. of a calendar onto a calendar.
  10790. */
  10791. var ExternalElementDragging = /** @class */ (function () {
  10792. function ExternalElementDragging(dragging, suppliedDragMeta) {
  10793. var _this = this;
  10794. this.receivingContext = null;
  10795. this.droppableEvent = null; // will exist for all drags, even if create:false
  10796. this.suppliedDragMeta = null;
  10797. this.dragMeta = null;
  10798. this.handleDragStart = function (ev) {
  10799. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  10800. };
  10801. this.handleHitUpdate = function (hit, isFinal, ev) {
  10802. var dragging = _this.hitDragging.dragging;
  10803. var receivingContext = null;
  10804. var droppableEvent = null;
  10805. var isInvalid = false;
  10806. var interaction = {
  10807. affectedEvents: createEmptyEventStore(),
  10808. mutatedEvents: createEmptyEventStore(),
  10809. isEvent: _this.dragMeta.create,
  10810. };
  10811. if (hit) {
  10812. receivingContext = hit.component.context;
  10813. if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
  10814. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
  10815. interaction.mutatedEvents = eventTupleToStore(droppableEvent);
  10816. isInvalid = !isInteractionValid(interaction, receivingContext);
  10817. if (isInvalid) {
  10818. interaction.mutatedEvents = createEmptyEventStore();
  10819. droppableEvent = null;
  10820. }
  10821. }
  10822. }
  10823. _this.displayDrag(receivingContext, interaction);
  10824. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  10825. // TODO: wish we could somehow wait for dispatch to guarantee render
  10826. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-event-mirror'));
  10827. if (!isInvalid) {
  10828. enableCursor();
  10829. }
  10830. else {
  10831. disableCursor();
  10832. }
  10833. if (!isFinal) {
  10834. dragging.setMirrorNeedsRevert(!droppableEvent);
  10835. _this.receivingContext = receivingContext;
  10836. _this.droppableEvent = droppableEvent;
  10837. }
  10838. };
  10839. this.handleDragEnd = function (pev) {
  10840. var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
  10841. _this.clearDrag();
  10842. if (receivingContext && droppableEvent) {
  10843. var finalHit = _this.hitDragging.finalHit;
  10844. var finalView = finalHit.component.context.viewApi;
  10845. var dragMeta = _this.dragMeta;
  10846. receivingContext.emitter.trigger('drop', __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
  10847. if (dragMeta.create) {
  10848. var addingEvents_1 = eventTupleToStore(droppableEvent);
  10849. receivingContext.dispatch({
  10850. type: 'MERGE_EVENTS',
  10851. eventStore: addingEvents_1,
  10852. });
  10853. if (pev.isTouch) {
  10854. receivingContext.dispatch({
  10855. type: 'SELECT_EVENT',
  10856. eventInstanceId: droppableEvent.instance.instanceId,
  10857. });
  10858. }
  10859. // signal that an external event landed
  10860. receivingContext.emitter.trigger('eventReceive', {
  10861. event: new EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
  10862. relatedEvents: [],
  10863. revert: function () {
  10864. receivingContext.dispatch({
  10865. type: 'REMOVE_EVENTS',
  10866. eventStore: addingEvents_1,
  10867. });
  10868. },
  10869. draggedEl: pev.subjectEl,
  10870. view: finalView,
  10871. });
  10872. }
  10873. }
  10874. _this.receivingContext = null;
  10875. _this.droppableEvent = null;
  10876. };
  10877. var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
  10878. hitDragging.requireInitial = false; // will start outside of a component
  10879. hitDragging.emitter.on('dragstart', this.handleDragStart);
  10880. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  10881. hitDragging.emitter.on('dragend', this.handleDragEnd);
  10882. this.suppliedDragMeta = suppliedDragMeta;
  10883. }
  10884. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  10885. if (typeof this.suppliedDragMeta === 'object') {
  10886. return parseDragMeta(this.suppliedDragMeta);
  10887. }
  10888. if (typeof this.suppliedDragMeta === 'function') {
  10889. return parseDragMeta(this.suppliedDragMeta(subjectEl));
  10890. }
  10891. return getDragMetaFromEl(subjectEl);
  10892. };
  10893. ExternalElementDragging.prototype.displayDrag = function (nextContext, state) {
  10894. var prevContext = this.receivingContext;
  10895. if (prevContext && prevContext !== nextContext) {
  10896. prevContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10897. }
  10898. if (nextContext) {
  10899. nextContext.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  10900. }
  10901. };
  10902. ExternalElementDragging.prototype.clearDrag = function () {
  10903. if (this.receivingContext) {
  10904. this.receivingContext.dispatch({ type: 'UNSET_EVENT_DRAG' });
  10905. }
  10906. };
  10907. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingContext) {
  10908. var dropAccept = receivingContext.options.dropAccept;
  10909. if (typeof dropAccept === 'function') {
  10910. return dropAccept.call(receivingContext.calendarApi, el);
  10911. }
  10912. if (typeof dropAccept === 'string' && dropAccept) {
  10913. return Boolean(elementMatches(el, dropAccept));
  10914. }
  10915. return true;
  10916. };
  10917. return ExternalElementDragging;
  10918. }());
  10919. // Utils for computing event store from the DragMeta
  10920. // ----------------------------------------------------------------------------------------------------
  10921. function computeEventForDateSpan(dateSpan, dragMeta, context) {
  10922. var defProps = __assign({}, dragMeta.leftoverProps);
  10923. for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
  10924. var transform = _a[_i];
  10925. __assign(defProps, transform(dateSpan, dragMeta));
  10926. }
  10927. var _b = refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
  10928. var def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), // hasEnd
  10929. context);
  10930. var start = dateSpan.range.start;
  10931. // only rely on time info if drop zone is all-day,
  10932. // otherwise, we already know the time
  10933. if (dateSpan.allDay && dragMeta.startTime) {
  10934. start = context.dateEnv.add(start, dragMeta.startTime);
  10935. }
  10936. var end = dragMeta.duration ?
  10937. context.dateEnv.add(start, dragMeta.duration) :
  10938. getDefaultEventEnd(dateSpan.allDay, start, context);
  10939. var instance = createEventInstance(def.defId, { start: start, end: end });
  10940. return { def: def, instance: instance };
  10941. }
  10942. // Utils for extracting data from element
  10943. // ----------------------------------------------------------------------------------------------------
  10944. function getDragMetaFromEl(el) {
  10945. var str = getEmbeddedElData(el, 'event');
  10946. var obj = str ?
  10947. JSON.parse(str) :
  10948. { create: false }; // if no embedded data, assume no event creation
  10949. return parseDragMeta(obj);
  10950. }
  10951. config.dataAttrPrefix = '';
  10952. function getEmbeddedElData(el, name) {
  10953. var prefix = config.dataAttrPrefix;
  10954. var prefixedName = (prefix ? prefix + '-' : '') + name;
  10955. return el.getAttribute('data-' + prefixedName) || '';
  10956. }
  10957. /*
  10958. Makes an element (that is *external* to any calendar) draggable.
  10959. Can pass in data that determines how an event will be created when dropped onto a calendar.
  10960. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  10961. */
  10962. var ExternalDraggable = /** @class */ (function () {
  10963. function ExternalDraggable(el, settings) {
  10964. var _this = this;
  10965. if (settings === void 0) { settings = {}; }
  10966. this.handlePointerDown = function (ev) {
  10967. var dragging = _this.dragging;
  10968. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  10969. dragging.minDistance =
  10970. minDistance != null ?
  10971. minDistance :
  10972. (ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance);
  10973. dragging.delay =
  10974. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  10975. (longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay) :
  10976. 0;
  10977. };
  10978. this.handleDragStart = function (ev) {
  10979. if (ev.isTouch &&
  10980. _this.dragging.delay &&
  10981. ev.subjectEl.classList.contains('fc-event')) {
  10982. _this.dragging.mirror.getMirrorEl().classList.add('fc-event-selected');
  10983. }
  10984. };
  10985. this.settings = settings;
  10986. var dragging = this.dragging = new FeaturefulElementDragging(el);
  10987. dragging.touchScrollAllowed = false;
  10988. if (settings.itemSelector != null) {
  10989. dragging.pointer.selector = settings.itemSelector;
  10990. }
  10991. if (settings.appendTo != null) {
  10992. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  10993. }
  10994. dragging.emitter.on('pointerdown', this.handlePointerDown);
  10995. dragging.emitter.on('dragstart', this.handleDragStart);
  10996. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  10997. }
  10998. ExternalDraggable.prototype.destroy = function () {
  10999. this.dragging.destroy();
  11000. };
  11001. return ExternalDraggable;
  11002. }());
  11003. /*
  11004. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  11005. The third-party system is responsible for drawing the visuals effects of the drag.
  11006. This class simply monitors for pointer movements and fires events.
  11007. It also has the ability to hide the moving element (the "mirror") during the drag.
  11008. */
  11009. var InferredElementDragging = /** @class */ (function (_super) {
  11010. __extends(InferredElementDragging, _super);
  11011. function InferredElementDragging(containerEl) {
  11012. var _this = _super.call(this, containerEl) || this;
  11013. _this.shouldIgnoreMove = false;
  11014. _this.mirrorSelector = '';
  11015. _this.currentMirrorEl = null;
  11016. _this.handlePointerDown = function (ev) {
  11017. _this.emitter.trigger('pointerdown', ev);
  11018. if (!_this.shouldIgnoreMove) {
  11019. // fire dragstart right away. does not support delay or min-distance
  11020. _this.emitter.trigger('dragstart', ev);
  11021. }
  11022. };
  11023. _this.handlePointerMove = function (ev) {
  11024. if (!_this.shouldIgnoreMove) {
  11025. _this.emitter.trigger('dragmove', ev);
  11026. }
  11027. };
  11028. _this.handlePointerUp = function (ev) {
  11029. _this.emitter.trigger('pointerup', ev);
  11030. if (!_this.shouldIgnoreMove) {
  11031. // fire dragend right away. does not support a revert animation
  11032. _this.emitter.trigger('dragend', ev);
  11033. }
  11034. };
  11035. var pointer = _this.pointer = new PointerDragging(containerEl);
  11036. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  11037. pointer.emitter.on('pointermove', _this.handlePointerMove);
  11038. pointer.emitter.on('pointerup', _this.handlePointerUp);
  11039. return _this;
  11040. }
  11041. InferredElementDragging.prototype.destroy = function () {
  11042. this.pointer.destroy();
  11043. };
  11044. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  11045. this.shouldIgnoreMove = bool;
  11046. };
  11047. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  11048. if (bool) {
  11049. // restore a previously hidden element.
  11050. // use the reference in case the selector class has already been removed.
  11051. if (this.currentMirrorEl) {
  11052. this.currentMirrorEl.style.visibility = '';
  11053. this.currentMirrorEl = null;
  11054. }
  11055. }
  11056. else {
  11057. var mirrorEl = this.mirrorSelector ?
  11058. document.querySelector(this.mirrorSelector) :
  11059. null;
  11060. if (mirrorEl) {
  11061. this.currentMirrorEl = mirrorEl;
  11062. mirrorEl.style.visibility = 'hidden';
  11063. }
  11064. }
  11065. };
  11066. return InferredElementDragging;
  11067. }(ElementDragging));
  11068. /*
  11069. Bridges third-party drag-n-drop systems with FullCalendar.
  11070. Must be instantiated and destroyed by caller.
  11071. */
  11072. var ThirdPartyDraggable = /** @class */ (function () {
  11073. function ThirdPartyDraggable(containerOrSettings, settings) {
  11074. var containerEl = document;
  11075. if (
  11076. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  11077. containerOrSettings === document ||
  11078. containerOrSettings instanceof Element) {
  11079. containerEl = containerOrSettings;
  11080. settings = settings || {};
  11081. }
  11082. else {
  11083. settings = (containerOrSettings || {});
  11084. }
  11085. var dragging = this.dragging = new InferredElementDragging(containerEl);
  11086. if (typeof settings.itemSelector === 'string') {
  11087. dragging.pointer.selector = settings.itemSelector;
  11088. }
  11089. else if (containerEl === document) {
  11090. dragging.pointer.selector = '[data-event]';
  11091. }
  11092. if (typeof settings.mirrorSelector === 'string') {
  11093. dragging.mirrorSelector = settings.mirrorSelector;
  11094. }
  11095. new ExternalElementDragging(dragging, settings.eventData); // eslint-disable-line no-new
  11096. }
  11097. ThirdPartyDraggable.prototype.destroy = function () {
  11098. this.dragging.destroy();
  11099. };
  11100. return ThirdPartyDraggable;
  11101. }());
  11102. var interactionPlugin = createPlugin({
  11103. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
  11104. calendarInteractions: [UnselectAuto],
  11105. elementDraggingImpl: FeaturefulElementDragging,
  11106. optionRefiners: OPTION_REFINERS,
  11107. listenerRefiners: LISTENER_REFINERS,
  11108. });
  11109. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  11110. ----------------------------------------------------------------------------------------------------------------------*/
  11111. // It is a manager for a Table subcomponent, which does most of the heavy lifting.
  11112. // It is responsible for managing width/height.
  11113. var TableView = /** @class */ (function (_super) {
  11114. __extends(TableView, _super);
  11115. function TableView() {
  11116. var _this = _super !== null && _super.apply(this, arguments) || this;
  11117. _this.headerElRef = createRef();
  11118. return _this;
  11119. }
  11120. TableView.prototype.renderSimpleLayout = function (headerRowContent, bodyContent) {
  11121. var _a = this, props = _a.props, context = _a.context;
  11122. var sections = [];
  11123. var stickyHeaderDates = getStickyHeaderDates(context.options);
  11124. if (headerRowContent) {
  11125. sections.push({
  11126. type: 'header',
  11127. key: 'header',
  11128. isSticky: stickyHeaderDates,
  11129. chunk: {
  11130. elRef: this.headerElRef,
  11131. tableClassName: 'fc-col-header',
  11132. rowContent: headerRowContent,
  11133. },
  11134. });
  11135. }
  11136. sections.push({
  11137. type: 'body',
  11138. key: 'body',
  11139. liquid: true,
  11140. chunk: { content: bodyContent },
  11141. });
  11142. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11143. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, cols: [] /* TODO: make optional? */, sections: sections }))); }));
  11144. };
  11145. TableView.prototype.renderHScrollLayout = function (headerRowContent, bodyContent, colCnt, dayMinWidth) {
  11146. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  11147. if (!ScrollGrid) {
  11148. throw new Error('No ScrollGrid implementation');
  11149. }
  11150. var _a = this, props = _a.props, context = _a.context;
  11151. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  11152. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  11153. var sections = [];
  11154. if (headerRowContent) {
  11155. sections.push({
  11156. type: 'header',
  11157. key: 'header',
  11158. isSticky: stickyHeaderDates,
  11159. chunks: [{
  11160. key: 'main',
  11161. elRef: this.headerElRef,
  11162. tableClassName: 'fc-col-header',
  11163. rowContent: headerRowContent,
  11164. }],
  11165. });
  11166. }
  11167. sections.push({
  11168. type: 'body',
  11169. key: 'body',
  11170. liquid: true,
  11171. chunks: [{
  11172. key: 'main',
  11173. content: bodyContent,
  11174. }],
  11175. });
  11176. if (stickyFooterScrollbar) {
  11177. sections.push({
  11178. type: 'footer',
  11179. key: 'footer',
  11180. isSticky: true,
  11181. chunks: [{
  11182. key: 'main',
  11183. content: renderScrollShim,
  11184. }],
  11185. });
  11186. }
  11187. return (createElement(ViewRoot, { viewSpec: context.viewSpec }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: ['fc-daygrid'].concat(classNames).join(' ') },
  11188. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections: sections }))); }));
  11189. };
  11190. return TableView;
  11191. }(DateComponent));
  11192. function splitSegsByRow(segs, rowCnt) {
  11193. var byRow = [];
  11194. for (var i = 0; i < rowCnt; i += 1) {
  11195. byRow[i] = [];
  11196. }
  11197. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11198. var seg = segs_1[_i];
  11199. byRow[seg.row].push(seg);
  11200. }
  11201. return byRow;
  11202. }
  11203. function splitSegsByFirstCol(segs, colCnt) {
  11204. var byCol = [];
  11205. for (var i = 0; i < colCnt; i += 1) {
  11206. byCol[i] = [];
  11207. }
  11208. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11209. var seg = segs_2[_i];
  11210. byCol[seg.firstCol].push(seg);
  11211. }
  11212. return byCol;
  11213. }
  11214. function splitInteractionByRow(ui, rowCnt) {
  11215. var byRow = [];
  11216. if (!ui) {
  11217. for (var i = 0; i < rowCnt; i += 1) {
  11218. byRow[i] = null;
  11219. }
  11220. }
  11221. else {
  11222. for (var i = 0; i < rowCnt; i += 1) {
  11223. byRow[i] = {
  11224. affectedInstances: ui.affectedInstances,
  11225. isEvent: ui.isEvent,
  11226. segs: [],
  11227. };
  11228. }
  11229. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  11230. var seg = _a[_i];
  11231. byRow[seg.row].segs.push(seg);
  11232. }
  11233. }
  11234. return byRow;
  11235. }
  11236. var TableCellTop = /** @class */ (function (_super) {
  11237. __extends(TableCellTop, _super);
  11238. function TableCellTop() {
  11239. return _super !== null && _super.apply(this, arguments) || this;
  11240. }
  11241. TableCellTop.prototype.render = function () {
  11242. var props = this.props;
  11243. var navLinkAttrs = this.context.options.navLinks
  11244. ? { 'data-navlink': buildNavLinkData(props.date), tabIndex: 0 }
  11245. : {};
  11246. 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 },
  11247. createElement("a", __assign({ className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\u00A0"))))); }));
  11248. };
  11249. return TableCellTop;
  11250. }(BaseComponent));
  11251. function renderTopInner(props) {
  11252. return props.dayNumberText;
  11253. }
  11254. var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: 'narrow' });
  11255. var TableCell = /** @class */ (function (_super) {
  11256. __extends(TableCell, _super);
  11257. function TableCell() {
  11258. var _this = _super !== null && _super.apply(this, arguments) || this;
  11259. _this.handleRootEl = function (el) {
  11260. _this.rootEl = el;
  11261. setRef(_this.props.elRef, el);
  11262. };
  11263. _this.handleMoreLinkClick = function (ev) {
  11264. var props = _this.props;
  11265. if (props.onMoreClick) {
  11266. var allSegs = props.segsByEachCol;
  11267. var hiddenSegs = allSegs.filter(function (seg) { return props.segIsHidden[seg.eventRange.instance.instanceId]; });
  11268. props.onMoreClick({
  11269. date: props.date,
  11270. allSegs: allSegs,
  11271. hiddenSegs: hiddenSegs,
  11272. moreCnt: props.moreCnt,
  11273. dayEl: _this.rootEl,
  11274. ev: ev,
  11275. });
  11276. }
  11277. };
  11278. return _this;
  11279. }
  11280. TableCell.prototype.render = function () {
  11281. var _this = this;
  11282. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  11283. var props = this.props;
  11284. var date = props.date, dateProfile = props.dateProfile;
  11285. var hookProps = {
  11286. num: props.moreCnt,
  11287. text: props.buildMoreLinkText(props.moreCnt),
  11288. view: viewApi,
  11289. };
  11290. var navLinkAttrs = options.navLinks
  11291. ? { 'data-navlink': buildNavLinkData(date, 'week'), tabIndex: 0 }
  11292. : {};
  11293. 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),
  11294. createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef /* different from hook system! RENAME */ },
  11295. 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)); })),
  11296. !isDisabled && (createElement(TableCellTop, { date: date, dateProfile: dateProfile, showDayNumber: props.showDayNumber, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps })),
  11297. createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef, style: { paddingBottom: props.fgPaddingBottom } },
  11298. props.fgContent,
  11299. Boolean(props.moreCnt) && (createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } },
  11300. 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)); })))),
  11301. createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)))); }));
  11302. };
  11303. return TableCell;
  11304. }(DateComponent));
  11305. function renderMoreLinkInner(props) {
  11306. return props.text;
  11307. }
  11308. var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
  11309. hour: 'numeric',
  11310. minute: '2-digit',
  11311. omitZeroMinute: true,
  11312. meridiem: 'narrow',
  11313. });
  11314. function hasListItemDisplay(seg) {
  11315. var display = seg.eventRange.ui.display;
  11316. return display === 'list-item' || (display === 'auto' &&
  11317. !seg.eventRange.def.allDay &&
  11318. seg.firstCol === seg.lastCol && // can't be multi-day
  11319. seg.isStart && // "
  11320. seg.isEnd // "
  11321. );
  11322. }
  11323. var TableListItemEvent = /** @class */ (function (_super) {
  11324. __extends(TableListItemEvent, _super);
  11325. function TableListItemEvent() {
  11326. return _super !== null && _super.apply(this, arguments) || this;
  11327. }
  11328. TableListItemEvent.prototype.render = function () {
  11329. var _a = this, props = _a.props, context = _a.context;
  11330. var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
  11331. var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
  11332. 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!
  11333. createElement("a", __assign({ className: ['fc-daygrid-event', 'fc-daygrid-dot-event'].concat(classNames).join(' '), ref: rootElRef }, getSegAnchorAttrs$1(props.seg)), innerContent)); }));
  11334. };
  11335. return TableListItemEvent;
  11336. }(BaseComponent));
  11337. function renderInnerContent$2(innerProps) {
  11338. return (createElement(Fragment, null,
  11339. createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }),
  11340. innerProps.timeText && (createElement("div", { className: "fc-event-time" }, innerProps.timeText)),
  11341. createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\u00A0"))));
  11342. }
  11343. function getSegAnchorAttrs$1(seg) {
  11344. var url = seg.eventRange.def.url;
  11345. return url ? { href: url } : {};
  11346. }
  11347. var TableBlockEvent = /** @class */ (function (_super) {
  11348. __extends(TableBlockEvent, _super);
  11349. function TableBlockEvent() {
  11350. return _super !== null && _super.apply(this, arguments) || this;
  11351. }
  11352. TableBlockEvent.prototype.render = function () {
  11353. var props = this.props;
  11354. 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 })));
  11355. };
  11356. return TableBlockEvent;
  11357. }(BaseComponent));
  11358. function computeFgSegPlacement(// for one row. TODO: print mode?
  11359. cellModels, segs, dayMaxEvents, dayMaxEventRows, eventHeights, maxContentHeight, colCnt, eventOrderSpecs) {
  11360. var colPlacements = []; // if event spans multiple cols, its present in each col
  11361. var moreCnts = []; // by-col
  11362. var segIsHidden = {};
  11363. var segTops = {}; // always populated for each seg
  11364. var segMarginTops = {}; // simetimes populated for each seg
  11365. var moreTops = {};
  11366. var paddingBottoms = {}; // for each cell's inner-wrapper div
  11367. for (var i = 0; i < colCnt; i += 1) {
  11368. colPlacements.push([]);
  11369. moreCnts.push(0);
  11370. }
  11371. segs = sortEventSegs(segs, eventOrderSpecs);
  11372. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11373. var seg = segs_1[_i];
  11374. var instanceId = seg.eventRange.instance.instanceId;
  11375. var eventHeight = eventHeights[instanceId + ':' + seg.firstCol];
  11376. placeSeg(seg, eventHeight || 0); // will keep colPlacements sorted by top
  11377. }
  11378. if (dayMaxEvents === true || dayMaxEventRows === true) {
  11379. limitByMaxHeight(moreCnts, segIsHidden, colPlacements, maxContentHeight); // populates moreCnts/segIsHidden
  11380. }
  11381. else if (typeof dayMaxEvents === 'number') {
  11382. limitByMaxEvents(moreCnts, segIsHidden, colPlacements, dayMaxEvents); // populates moreCnts/segIsHidden
  11383. }
  11384. else if (typeof dayMaxEventRows === 'number') {
  11385. limitByMaxRows(moreCnts, segIsHidden, colPlacements, dayMaxEventRows); // populates moreCnts/segIsHidden
  11386. }
  11387. // computes segTops/segMarginTops/moreTops/paddingBottoms
  11388. for (var col = 0; col < colCnt; col += 1) {
  11389. var placements = colPlacements[col];
  11390. var currentNonAbsBottom = 0;
  11391. var currentAbsHeight = 0;
  11392. for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
  11393. var placement = placements_1[_a];
  11394. var seg = placement.seg;
  11395. if (!segIsHidden[seg.eventRange.instance.instanceId]) {
  11396. segTops[seg.eventRange.instance.instanceId] = placement.top; // from top of container
  11397. if (seg.firstCol === seg.lastCol && seg.isStart && seg.isEnd) { // TODO: simpler way? NOT DRY
  11398. segMarginTops[seg.eventRange.instance.instanceId] =
  11399. placement.top - currentNonAbsBottom; // from previous seg bottom
  11400. currentAbsHeight = 0;
  11401. currentNonAbsBottom = placement.bottom;
  11402. }
  11403. else { // multi-col event, abs positioned
  11404. currentAbsHeight = placement.bottom - currentNonAbsBottom;
  11405. }
  11406. }
  11407. }
  11408. if (currentAbsHeight) {
  11409. if (moreCnts[col]) {
  11410. moreTops[col] = currentAbsHeight;
  11411. }
  11412. else {
  11413. paddingBottoms[col] = currentAbsHeight;
  11414. }
  11415. }
  11416. }
  11417. function placeSeg(seg, segHeight) {
  11418. if (!tryPlaceSegAt(seg, segHeight, 0)) {
  11419. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11420. for (var _i = 0, _a = colPlacements[col]; _i < _a.length; _i++) { // will repeat multi-day segs!!!!!!! bad!!!!!!
  11421. var placement = _a[_i];
  11422. if (tryPlaceSegAt(seg, segHeight, placement.bottom)) {
  11423. return;
  11424. }
  11425. }
  11426. }
  11427. }
  11428. }
  11429. function tryPlaceSegAt(seg, segHeight, top) {
  11430. if (canPlaceSegAt(seg, segHeight, top)) {
  11431. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11432. var placements = colPlacements[col];
  11433. var insertionIndex = 0;
  11434. while (insertionIndex < placements.length &&
  11435. top >= placements[insertionIndex].top) {
  11436. insertionIndex += 1;
  11437. }
  11438. placements.splice(insertionIndex, 0, {
  11439. seg: seg,
  11440. top: top,
  11441. bottom: top + segHeight,
  11442. });
  11443. }
  11444. return true;
  11445. }
  11446. return false;
  11447. }
  11448. function canPlaceSegAt(seg, segHeight, top) {
  11449. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11450. for (var _i = 0, _a = colPlacements[col]; _i < _a.length; _i++) {
  11451. var placement = _a[_i];
  11452. if (top < placement.bottom && top + segHeight > placement.top) { // collide?
  11453. return false;
  11454. }
  11455. }
  11456. }
  11457. return true;
  11458. }
  11459. // what does this do!?
  11460. for (var instanceIdAndFirstCol in eventHeights) {
  11461. if (!eventHeights[instanceIdAndFirstCol]) {
  11462. segIsHidden[instanceIdAndFirstCol.split(':')[0]] = true;
  11463. }
  11464. }
  11465. var segsByFirstCol = colPlacements.map(extractFirstColSegs); // operates on the sorted cols
  11466. var segsByEachCol = colPlacements.map(function (placements, col) {
  11467. var segsForCols = extractAllColSegs(placements);
  11468. segsForCols = resliceDaySegs(segsForCols, cellModels[col].date, col);
  11469. return segsForCols;
  11470. });
  11471. return {
  11472. segsByFirstCol: segsByFirstCol,
  11473. segsByEachCol: segsByEachCol,
  11474. segIsHidden: segIsHidden,
  11475. segTops: segTops,
  11476. segMarginTops: segMarginTops,
  11477. moreCnts: moreCnts,
  11478. moreTops: moreTops,
  11479. paddingBottoms: paddingBottoms,
  11480. };
  11481. }
  11482. function extractFirstColSegs(oneColPlacements, col) {
  11483. var segs = [];
  11484. for (var _i = 0, oneColPlacements_1 = oneColPlacements; _i < oneColPlacements_1.length; _i++) {
  11485. var placement = oneColPlacements_1[_i];
  11486. if (placement.seg.firstCol === col) {
  11487. segs.push(placement.seg);
  11488. }
  11489. }
  11490. return segs;
  11491. }
  11492. function extractAllColSegs(oneColPlacements) {
  11493. var segs = [];
  11494. for (var _i = 0, oneColPlacements_2 = oneColPlacements; _i < oneColPlacements_2.length; _i++) {
  11495. var placement = oneColPlacements_2[_i];
  11496. segs.push(placement.seg);
  11497. }
  11498. return segs;
  11499. }
  11500. function limitByMaxHeight(hiddenCnts, segIsHidden, colPlacements, maxContentHeight) {
  11501. limitEvents(hiddenCnts, segIsHidden, colPlacements, true, function (placement) { return placement.bottom <= maxContentHeight; });
  11502. }
  11503. function limitByMaxEvents(hiddenCnts, segIsHidden, colPlacements, dayMaxEvents) {
  11504. limitEvents(hiddenCnts, segIsHidden, colPlacements, false, function (placement, levelIndex) { return levelIndex < dayMaxEvents; });
  11505. }
  11506. function limitByMaxRows(hiddenCnts, segIsHidden, colPlacements, dayMaxEventRows) {
  11507. limitEvents(hiddenCnts, segIsHidden, colPlacements, true, function (placement, levelIndex) { return levelIndex < dayMaxEventRows; });
  11508. }
  11509. /*
  11510. populates the given hiddenCnts/segIsHidden, which are supplied empty.
  11511. TODO: return them instead
  11512. */
  11513. function limitEvents(hiddenCnts, segIsHidden, colPlacements, _moreLinkConsumesLevel, isPlacementInBounds) {
  11514. var colCnt = hiddenCnts.length;
  11515. var segIsVisible = {}; // TODO: instead, use segIsHidden with true/false?
  11516. var visibleColPlacements = []; // will mirror colPlacements
  11517. for (var col = 0; col < colCnt; col += 1) {
  11518. visibleColPlacements.push([]);
  11519. }
  11520. for (var col = 0; col < colCnt; col += 1) {
  11521. var placements = colPlacements[col];
  11522. var level = 0;
  11523. for (var _i = 0, placements_2 = placements; _i < placements_2.length; _i++) {
  11524. var placement = placements_2[_i];
  11525. if (isPlacementInBounds(placement, level)) {
  11526. recordVisible(placement);
  11527. }
  11528. else {
  11529. recordHidden(placement, level, _moreLinkConsumesLevel);
  11530. }
  11531. // only considered a level if the seg had height
  11532. if (placement.top !== placement.bottom) {
  11533. level += 1;
  11534. }
  11535. }
  11536. }
  11537. function recordVisible(placement) {
  11538. var seg = placement.seg;
  11539. var instanceId = seg.eventRange.instance.instanceId;
  11540. if (!segIsVisible[instanceId]) {
  11541. segIsVisible[instanceId] = true;
  11542. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11543. visibleColPlacements[col].push(placement);
  11544. }
  11545. }
  11546. }
  11547. function recordHidden(placement, currentLevel, moreLinkConsumesLevel) {
  11548. var seg = placement.seg;
  11549. var instanceId = seg.eventRange.instance.instanceId;
  11550. if (!segIsHidden[instanceId]) {
  11551. segIsHidden[instanceId] = true;
  11552. for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
  11553. hiddenCnts[col] += 1;
  11554. var hiddenCnt = hiddenCnts[col];
  11555. if (moreLinkConsumesLevel && hiddenCnt === 1 && currentLevel > 0) {
  11556. var doomedLevel = currentLevel - 1;
  11557. while (visibleColPlacements[col].length > doomedLevel) {
  11558. recordHidden(visibleColPlacements[col].pop(), // removes
  11559. visibleColPlacements[col].length, // will execute after the pop. will be the index of the removed placement
  11560. false);
  11561. }
  11562. }
  11563. }
  11564. }
  11565. }
  11566. }
  11567. // Given the events within an array of segment objects, reslice them to be in a single day
  11568. function resliceDaySegs(segs, dayDate, colIndex) {
  11569. var dayStart = dayDate;
  11570. var dayEnd = addDays(dayStart, 1);
  11571. var dayRange = { start: dayStart, end: dayEnd };
  11572. var newSegs = [];
  11573. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11574. var seg = segs_2[_i];
  11575. var eventRange = seg.eventRange;
  11576. var origRange = eventRange.range;
  11577. var slicedRange = intersectRanges(origRange, dayRange);
  11578. if (slicedRange) {
  11579. newSegs.push(__assign(__assign({}, seg), { firstCol: colIndex, lastCol: colIndex, eventRange: {
  11580. def: eventRange.def,
  11581. ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
  11582. instance: eventRange.instance,
  11583. range: slicedRange,
  11584. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  11585. }
  11586. }
  11587. return newSegs;
  11588. }
  11589. var TableRow = /** @class */ (function (_super) {
  11590. __extends(TableRow, _super);
  11591. function TableRow() {
  11592. var _this = _super !== null && _super.apply(this, arguments) || this;
  11593. _this.cellElRefs = new RefMap(); // the <td>
  11594. _this.frameElRefs = new RefMap(); // the fc-daygrid-day-frame
  11595. _this.fgElRefs = new RefMap(); // the fc-daygrid-day-events
  11596. _this.segHarnessRefs = new RefMap(); // indexed by "instanceId:firstCol"
  11597. _this.rootElRef = createRef();
  11598. _this.state = {
  11599. framePositions: null,
  11600. maxContentHeight: null,
  11601. segHeights: {},
  11602. };
  11603. return _this;
  11604. }
  11605. TableRow.prototype.render = function () {
  11606. var _this = this;
  11607. var _a = this, props = _a.props, state = _a.state, context = _a.context;
  11608. var colCnt = props.cells.length;
  11609. var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
  11610. var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
  11611. var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
  11612. var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
  11613. 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;
  11614. var selectedInstanceHash = // TODO: messy way to compute this
  11615. (props.eventDrag && props.eventDrag.affectedInstances) ||
  11616. (props.eventResize && props.eventResize.affectedInstances) ||
  11617. {};
  11618. return (createElement("tr", { ref: this.rootElRef },
  11619. props.renderIntro && props.renderIntro(),
  11620. props.cells.map(function (cell, col) {
  11621. var normalFgNodes = _this.renderFgSegs(segsByFirstCol[col], segIsHidden, segTops, segMarginTops, selectedInstanceHash, props.todayRange);
  11622. var mirrorFgNodes = _this.renderFgSegs(mirrorSegsByCol[col], {}, segTops, // use same tops as real rendering
  11623. {}, {}, props.todayRange, Boolean(props.eventDrag), Boolean(props.eventResize), false);
  11624. 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: props.onMoreClick, segIsHidden: segIsHidden, moreMarginTop: moreTops[col] /* rename */, segsByEachCol: segsByEachCol[col], fgPaddingBottom: paddingBottoms[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: ( // Fragment scopes the keys
  11625. createElement(Fragment, null,
  11626. createElement(Fragment, null, normalFgNodes),
  11627. createElement(Fragment, null, mirrorFgNodes))), bgContent: ( // Fragment scopes the keys
  11628. createElement(Fragment, null,
  11629. _this.renderFillSegs(highlightSegsByCol[col], 'highlight'),
  11630. _this.renderFillSegs(businessHoursByCol[col], 'non-business'),
  11631. _this.renderFillSegs(bgEventSegsByCol[col], 'bg-event'))) }));
  11632. })));
  11633. };
  11634. TableRow.prototype.componentDidMount = function () {
  11635. this.updateSizing(true);
  11636. };
  11637. TableRow.prototype.componentDidUpdate = function (prevProps, prevState) {
  11638. var currentProps = this.props;
  11639. this.updateSizing(!isPropsEqual(prevProps, currentProps));
  11640. };
  11641. TableRow.prototype.getHighlightSegs = function () {
  11642. var props = this.props;
  11643. if (props.eventDrag && props.eventDrag.segs.length) { // messy check
  11644. return props.eventDrag.segs;
  11645. }
  11646. if (props.eventResize && props.eventResize.segs.length) { // messy check
  11647. return props.eventResize.segs;
  11648. }
  11649. return props.dateSelectionSegs;
  11650. };
  11651. TableRow.prototype.getMirrorSegs = function () {
  11652. var props = this.props;
  11653. if (props.eventResize && props.eventResize.segs.length) { // messy check
  11654. return props.eventResize.segs;
  11655. }
  11656. return [];
  11657. };
  11658. TableRow.prototype.renderFgSegs = function (segs, segIsHidden, // does NOT mean display:hidden
  11659. segTops, segMarginTops, selectedInstanceHash, todayRange, isDragging, isResizing, isDateSelecting) {
  11660. var context = this.context;
  11661. var eventSelection = this.props.eventSelection;
  11662. var framePositions = this.state.framePositions;
  11663. var defaultDisplayEventEnd = this.props.cells.length === 1; // colCnt === 1
  11664. var nodes = [];
  11665. if (framePositions) {
  11666. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  11667. var seg = segs_1[_i];
  11668. var instanceId = seg.eventRange.instance.instanceId;
  11669. var isMirror = isDragging || isResizing || isDateSelecting;
  11670. var isSelected = selectedInstanceHash[instanceId];
  11671. var isInvisible = segIsHidden[instanceId] || isSelected;
  11672. // TODO: simpler way? NOT DRY
  11673. var isAbsolute = segIsHidden[instanceId] || isMirror || seg.firstCol !== seg.lastCol || !seg.isStart || !seg.isEnd;
  11674. var marginTop = void 0;
  11675. var top_1 = void 0;
  11676. var left = void 0;
  11677. var right = void 0;
  11678. if (isAbsolute) {
  11679. top_1 = segTops[instanceId];
  11680. if (context.isRtl) {
  11681. right = 0;
  11682. left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
  11683. }
  11684. else {
  11685. left = 0;
  11686. right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
  11687. }
  11688. }
  11689. else {
  11690. marginTop = segMarginTops[instanceId];
  11691. }
  11692. /*
  11693. known bug: events that are force to be list-item but span multiple days still take up space in later columns
  11694. */
  11695. nodes.push(createElement("div", { className: 'fc-daygrid-event-harness' + (isAbsolute ? ' fc-daygrid-event-harness-abs' : ''), key: instanceId,
  11696. // in print mode when in mult cols, could collide
  11697. ref: isMirror ? null : this.segHarnessRefs.createRef(instanceId + ':' + seg.firstCol), style: {
  11698. visibility: isInvisible ? 'hidden' : '',
  11699. marginTop: marginTop || '',
  11700. top: top_1 || '',
  11701. left: left || '',
  11702. right: right || '',
  11703. } }, 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))))));
  11704. }
  11705. }
  11706. return nodes;
  11707. };
  11708. TableRow.prototype.renderFillSegs = function (segs, fillType) {
  11709. var isRtl = this.context.isRtl;
  11710. var todayRange = this.props.todayRange;
  11711. var framePositions = this.state.framePositions;
  11712. var nodes = [];
  11713. if (framePositions) {
  11714. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  11715. var seg = segs_2[_i];
  11716. var leftRightCss = isRtl ? {
  11717. right: 0,
  11718. left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol],
  11719. } : {
  11720. left: 0,
  11721. right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol],
  11722. };
  11723. nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === 'bg-event' ?
  11724. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, todayRange))) :
  11725. renderFill(fillType)));
  11726. }
  11727. }
  11728. return createElement.apply(void 0, __spreadArrays([Fragment, {}], nodes));
  11729. };
  11730. TableRow.prototype.updateSizing = function (isExternalSizingChange) {
  11731. var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
  11732. if (props.clientWidth !== null) { // positioning ready?
  11733. if (isExternalSizingChange) {
  11734. var frameEls = props.cells.map(function (cell) { return frameElRefs.currentMap[cell.key]; });
  11735. if (frameEls.length) {
  11736. var originEl = this.rootElRef.current;
  11737. this.setState({
  11738. framePositions: new PositionCache(originEl, frameEls, true, // isHorizontal
  11739. false),
  11740. });
  11741. }
  11742. }
  11743. var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
  11744. this.setState({
  11745. segHeights: this.computeSegHeights(),
  11746. maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null,
  11747. });
  11748. }
  11749. };
  11750. TableRow.prototype.computeSegHeights = function () {
  11751. return mapHash(this.segHarnessRefs.currentMap, function (eventHarnessEl) { return (eventHarnessEl.getBoundingClientRect().height); });
  11752. };
  11753. TableRow.prototype.computeMaxContentHeight = function () {
  11754. var firstKey = this.props.cells[0].key;
  11755. var cellEl = this.cellElRefs.currentMap[firstKey];
  11756. var fcContainerEl = this.fgElRefs.currentMap[firstKey];
  11757. return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
  11758. };
  11759. TableRow.prototype.getCellEls = function () {
  11760. var elMap = this.cellElRefs.currentMap;
  11761. return this.props.cells.map(function (cell) { return elMap[cell.key]; });
  11762. };
  11763. return TableRow;
  11764. }(DateComponent));
  11765. TableRow.addStateEquality({
  11766. segHeights: isPropsEqual,
  11767. });
  11768. var PADDING_FROM_VIEWPORT = 10;
  11769. var SCROLL_DEBOUNCE = 10;
  11770. var Popover = /** @class */ (function (_super) {
  11771. __extends(Popover, _super);
  11772. function Popover() {
  11773. var _this = _super !== null && _super.apply(this, arguments) || this;
  11774. _this.repositioner = new DelayedRunner(_this.updateSize.bind(_this));
  11775. _this.handleRootEl = function (el) {
  11776. _this.rootEl = el;
  11777. if (_this.props.elRef) {
  11778. setRef(_this.props.elRef, el);
  11779. }
  11780. };
  11781. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  11782. _this.handleDocumentMousedown = function (ev) {
  11783. var onClose = _this.props.onClose;
  11784. // only hide the popover if the click happened outside the popover
  11785. if (onClose && !_this.rootEl.contains(ev.target)) {
  11786. onClose();
  11787. }
  11788. };
  11789. _this.handleDocumentScroll = function () {
  11790. _this.repositioner.request(SCROLL_DEBOUNCE);
  11791. };
  11792. _this.handleCloseClick = function () {
  11793. var onClose = _this.props.onClose;
  11794. if (onClose) {
  11795. onClose();
  11796. }
  11797. };
  11798. return _this;
  11799. }
  11800. Popover.prototype.render = function () {
  11801. var theme = this.context.theme;
  11802. var props = this.props;
  11803. var classNames = [
  11804. 'fc-popover',
  11805. theme.getClass('popover'),
  11806. ].concat(props.extraClassNames || []);
  11807. return (createElement("div", __assign({ className: classNames.join(' ') }, props.extraAttrs, { ref: this.handleRootEl }),
  11808. createElement("div", { className: 'fc-popover-header ' + theme.getClass('popoverHeader') },
  11809. createElement("span", { className: "fc-popover-title" }, props.title),
  11810. createElement("span", { className: 'fc-popover-close ' + theme.getIconClass('close'), onClick: this.handleCloseClick })),
  11811. createElement("div", { className: 'fc-popover-body ' + theme.getClass('popoverContent') }, props.children)));
  11812. };
  11813. Popover.prototype.componentDidMount = function () {
  11814. document.addEventListener('mousedown', this.handleDocumentMousedown);
  11815. document.addEventListener('scroll', this.handleDocumentScroll);
  11816. this.updateSize();
  11817. };
  11818. Popover.prototype.componentWillUnmount = function () {
  11819. document.removeEventListener('mousedown', this.handleDocumentMousedown);
  11820. document.removeEventListener('scroll', this.handleDocumentScroll);
  11821. };
  11822. // TODO: adjust on window resize
  11823. /*
  11824. NOTE: the popover is position:fixed, so coordinates are relative to the viewport
  11825. NOTE: the PARENT calls this as well, on window resize. we would have wanted to use the repositioner,
  11826. but need to ensure that all other components have updated size first (for alignmentEl)
  11827. */
  11828. Popover.prototype.updateSize = function () {
  11829. var _a = this.props, alignmentEl = _a.alignmentEl, topAlignmentEl = _a.topAlignmentEl;
  11830. var rootEl = this.rootEl;
  11831. if (!rootEl) {
  11832. return; // not sure why this was null, but we shouldn't let external components call updateSize() anyway
  11833. }
  11834. var dims = rootEl.getBoundingClientRect(); // only used for width,height
  11835. var alignment = alignmentEl.getBoundingClientRect();
  11836. var top = topAlignmentEl ? topAlignmentEl.getBoundingClientRect().top : alignment.top;
  11837. top = Math.min(top, window.innerHeight - dims.height - PADDING_FROM_VIEWPORT);
  11838. top = Math.max(top, PADDING_FROM_VIEWPORT);
  11839. var left;
  11840. if (this.context.isRtl) {
  11841. left = alignment.right - dims.width;
  11842. }
  11843. else {
  11844. left = alignment.left;
  11845. }
  11846. left = Math.min(left, window.innerWidth - dims.width - PADDING_FROM_VIEWPORT);
  11847. left = Math.max(left, PADDING_FROM_VIEWPORT);
  11848. applyStyle(rootEl, { top: top, left: left });
  11849. };
  11850. return Popover;
  11851. }(BaseComponent));
  11852. var MorePopover = /** @class */ (function (_super) {
  11853. __extends(MorePopover, _super);
  11854. function MorePopover() {
  11855. var _this = _super !== null && _super.apply(this, arguments) || this;
  11856. _this.handlePopoverEl = function (popoverEl) {
  11857. _this.popoverEl = popoverEl;
  11858. if (popoverEl) {
  11859. _this.context.registerInteractiveComponent(_this, {
  11860. el: popoverEl,
  11861. useEventCenter: false,
  11862. });
  11863. }
  11864. else {
  11865. _this.context.unregisterInteractiveComponent(_this);
  11866. }
  11867. };
  11868. return _this;
  11869. }
  11870. MorePopover.prototype.render = function () {
  11871. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv;
  11872. var props = this.props;
  11873. var date = props.date, hiddenInstances = props.hiddenInstances, todayRange = props.todayRange, dateProfile = props.dateProfile, selectedInstanceId = props.selectedInstanceId;
  11874. var title = dateEnv.format(date, options.dayPopoverFormat);
  11875. return (createElement(DayCellRoot, { date: date, dateProfile: dateProfile, todayRange: todayRange, elRef: this.handlePopoverEl }, 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 },
  11876. createElement(DayCellContent, { date: date, dateProfile: dateProfile, todayRange: todayRange }, function (innerElRef, innerContent) { return (innerContent &&
  11877. createElement("div", { className: "fc-more-popover-misc", ref: innerElRef }, innerContent)); }),
  11878. props.segs.map(function (seg) {
  11879. var instanceId = seg.eventRange.instance.instanceId;
  11880. return (createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
  11881. visibility: hiddenInstances[instanceId] ? 'hidden' : '',
  11882. } }, 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))))));
  11883. }))); }));
  11884. };
  11885. MorePopover.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  11886. var date = this.props.date;
  11887. if (positionLeft < elWidth && positionTop < elHeight) {
  11888. return {
  11889. component: this,
  11890. dateSpan: {
  11891. allDay: true,
  11892. range: { start: date, end: addDays(date, 1) },
  11893. },
  11894. dayEl: this.popoverEl,
  11895. rect: {
  11896. left: 0,
  11897. top: 0,
  11898. right: elWidth,
  11899. bottom: elHeight,
  11900. },
  11901. layer: 1,
  11902. };
  11903. }
  11904. return null;
  11905. };
  11906. MorePopover.prototype.isPopover = function () {
  11907. return true; // gross
  11908. };
  11909. return MorePopover;
  11910. }(DateComponent));
  11911. var Table = /** @class */ (function (_super) {
  11912. __extends(Table, _super);
  11913. function Table() {
  11914. var _this = _super !== null && _super.apply(this, arguments) || this;
  11915. _this.splitBusinessHourSegs = memoize(splitSegsByRow);
  11916. _this.splitBgEventSegs = memoize(splitSegsByRow);
  11917. _this.splitFgEventSegs = memoize(splitSegsByRow);
  11918. _this.splitDateSelectionSegs = memoize(splitSegsByRow);
  11919. _this.splitEventDrag = memoize(splitInteractionByRow);
  11920. _this.splitEventResize = memoize(splitInteractionByRow);
  11921. _this.buildBuildMoreLinkText = memoize(buildBuildMoreLinkText);
  11922. _this.rowRefs = new RefMap();
  11923. _this.state = {
  11924. morePopoverState: null,
  11925. };
  11926. _this.handleRootEl = function (rootEl) {
  11927. _this.rootEl = rootEl;
  11928. setRef(_this.props.elRef, rootEl);
  11929. };
  11930. _this.handleMoreLinkClick = function (arg) {
  11931. var context = _this.context;
  11932. var dateEnv = context.dateEnv;
  11933. var clickOption = context.options.moreLinkClick;
  11934. function segForPublic(seg) {
  11935. var _a = seg.eventRange, def = _a.def, instance = _a.instance, range = _a.range;
  11936. return {
  11937. event: new EventApi(context, def, instance),
  11938. start: dateEnv.toDate(range.start),
  11939. end: dateEnv.toDate(range.end),
  11940. isStart: seg.isStart,
  11941. isEnd: seg.isEnd,
  11942. };
  11943. }
  11944. if (typeof clickOption === 'function') {
  11945. clickOption = clickOption({
  11946. date: dateEnv.toDate(arg.date),
  11947. allDay: true,
  11948. allSegs: arg.allSegs.map(segForPublic),
  11949. hiddenSegs: arg.hiddenSegs.map(segForPublic),
  11950. jsEvent: arg.ev,
  11951. view: context.viewApi,
  11952. }); // hack to handle void
  11953. }
  11954. if (!clickOption || clickOption === 'popover') {
  11955. _this.setState({
  11956. morePopoverState: __assign(__assign({}, arg), { currentFgEventSegs: _this.props.fgEventSegs }),
  11957. });
  11958. }
  11959. else if (typeof clickOption === 'string') { // a view name
  11960. context.calendarApi.zoomTo(arg.date, clickOption);
  11961. }
  11962. };
  11963. _this.handleMorePopoverClose = function () {
  11964. _this.setState({
  11965. morePopoverState: null,
  11966. });
  11967. };
  11968. return _this;
  11969. }
  11970. Table.prototype.render = function () {
  11971. var _this = this;
  11972. var props = this.props;
  11973. var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
  11974. var morePopoverState = this.state.morePopoverState;
  11975. var rowCnt = props.cells.length;
  11976. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
  11977. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
  11978. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
  11979. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
  11980. var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
  11981. var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
  11982. var buildMoreLinkText = this.buildBuildMoreLinkText(this.context.options.moreLinkText);
  11983. var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
  11984. // if rows can't expand to fill fixed height, can't do balanced-height event limit
  11985. // TODO: best place to normalize these options?
  11986. if (limitViaBalanced && !expandRows) {
  11987. limitViaBalanced = false;
  11988. dayMaxEventRows = null;
  11989. dayMaxEvents = null;
  11990. }
  11991. var classNames = [
  11992. 'fc-daygrid-body',
  11993. limitViaBalanced ? 'fc-daygrid-body-balanced' : 'fc-daygrid-body-unbalanced',
  11994. expandRows ? '' : 'fc-daygrid-body-natural',
  11995. ];
  11996. return (createElement("div", { className: classNames.join(' '), ref: this.handleRootEl, style: {
  11997. // these props are important to give this wrapper correct dimensions for interactions
  11998. // TODO: if we set it here, can we avoid giving to inner tables?
  11999. width: props.clientWidth,
  12000. minWidth: props.tableMinWidth,
  12001. } },
  12002. createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) { return (createElement(Fragment, null,
  12003. createElement("table", { className: "fc-scrollgrid-sync-table", style: {
  12004. width: props.clientWidth,
  12005. minWidth: props.tableMinWidth,
  12006. height: expandRows ? props.clientHeight : '',
  12007. } },
  12008. props.colGroupNode,
  12009. createElement("tbody", null, props.cells.map(function (cells, row) { return (createElement(TableRow, { ref: _this.rowRefs.createRef(row), key: cells.length
  12010. ? cells[0].date.toISOString() /* best? or put key on cell? or use diff formatter? */
  12011. : row // in case there are no cells (like when resource view is loading)
  12012. , 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: _this.handleMoreLinkClick })); }))),
  12013. (!props.forPrint && morePopoverState && morePopoverState.currentFgEventSegs === props.fgEventSegs) && (createElement(MorePopover, { 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
  12014. (props.eventDrag ? props.eventDrag.affectedInstances : null) ||
  12015. (props.eventResize ? props.eventResize.affectedInstances : null) ||
  12016. {}, todayRange: todayRange })))); })));
  12017. };
  12018. // Hit System
  12019. // ----------------------------------------------------------------------------------------------------
  12020. Table.prototype.prepareHits = function () {
  12021. 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
  12022. false, true);
  12023. this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), // cell els in first row
  12024. true, // horizontal
  12025. false);
  12026. };
  12027. Table.prototype.positionToHit = function (leftPosition, topPosition) {
  12028. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  12029. var col = colPositions.leftToIndex(leftPosition);
  12030. var row = rowPositions.topToIndex(topPosition);
  12031. if (row != null && col != null) {
  12032. return {
  12033. row: row,
  12034. col: col,
  12035. dateSpan: {
  12036. range: this.getCellRange(row, col),
  12037. allDay: true,
  12038. },
  12039. dayEl: this.getCellEl(row, col),
  12040. relativeRect: {
  12041. left: colPositions.lefts[col],
  12042. right: colPositions.rights[col],
  12043. top: rowPositions.tops[row],
  12044. bottom: rowPositions.bottoms[row],
  12045. },
  12046. };
  12047. }
  12048. return null;
  12049. };
  12050. Table.prototype.getCellEl = function (row, col) {
  12051. return this.rowRefs.currentMap[row].getCellEls()[col]; // TODO: not optimal
  12052. };
  12053. Table.prototype.getCellRange = function (row, col) {
  12054. var start = this.props.cells[row][col].date;
  12055. var end = addDays(start, 1);
  12056. return { start: start, end: end };
  12057. };
  12058. return Table;
  12059. }(DateComponent));
  12060. function buildBuildMoreLinkText(moreLinkTextInput) {
  12061. if (typeof moreLinkTextInput === 'function') {
  12062. return moreLinkTextInput;
  12063. }
  12064. return function (num) { return "+" + num + " " + moreLinkTextInput; };
  12065. }
  12066. function isSegAllDay(seg) {
  12067. return seg.eventRange.def.allDay;
  12068. }
  12069. var DayTableSlicer = /** @class */ (function (_super) {
  12070. __extends(DayTableSlicer, _super);
  12071. function DayTableSlicer() {
  12072. var _this = _super !== null && _super.apply(this, arguments) || this;
  12073. _this.forceDayIfListItem = true;
  12074. return _this;
  12075. }
  12076. DayTableSlicer.prototype.sliceRange = function (dateRange, dayTableModel) {
  12077. return dayTableModel.sliceRange(dateRange);
  12078. };
  12079. return DayTableSlicer;
  12080. }(Slicer));
  12081. var DayTable = /** @class */ (function (_super) {
  12082. __extends(DayTable, _super);
  12083. function DayTable() {
  12084. var _this = _super !== null && _super.apply(this, arguments) || this;
  12085. _this.slicer = new DayTableSlicer();
  12086. _this.tableRef = createRef();
  12087. _this.handleRootEl = function (rootEl) {
  12088. if (rootEl) {
  12089. _this.context.registerInteractiveComponent(_this, { el: rootEl });
  12090. }
  12091. else {
  12092. _this.context.unregisterInteractiveComponent(_this);
  12093. }
  12094. };
  12095. return _this;
  12096. }
  12097. DayTable.prototype.render = function () {
  12098. var _a = this, props = _a.props, context = _a.context;
  12099. 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 })));
  12100. };
  12101. DayTable.prototype.prepareHits = function () {
  12102. this.tableRef.current.prepareHits();
  12103. };
  12104. DayTable.prototype.queryHit = function (positionLeft, positionTop) {
  12105. var rawHit = this.tableRef.current.positionToHit(positionLeft, positionTop);
  12106. if (rawHit) {
  12107. return {
  12108. component: this,
  12109. dateSpan: rawHit.dateSpan,
  12110. dayEl: rawHit.dayEl,
  12111. rect: {
  12112. left: rawHit.relativeRect.left,
  12113. right: rawHit.relativeRect.right,
  12114. top: rawHit.relativeRect.top,
  12115. bottom: rawHit.relativeRect.bottom,
  12116. },
  12117. layer: 0,
  12118. };
  12119. }
  12120. return null;
  12121. };
  12122. return DayTable;
  12123. }(DateComponent));
  12124. var DayTableView = /** @class */ (function (_super) {
  12125. __extends(DayTableView, _super);
  12126. function DayTableView() {
  12127. var _this = _super !== null && _super.apply(this, arguments) || this;
  12128. _this.buildDayTableModel = memoize(buildDayTableModel);
  12129. _this.headerRef = createRef();
  12130. _this.tableRef = createRef();
  12131. return _this;
  12132. }
  12133. DayTableView.prototype.render = function () {
  12134. var _this = this;
  12135. var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
  12136. var props = this.props;
  12137. var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
  12138. var headerContent = options.dayHeaders && (createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 }));
  12139. 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 })); };
  12140. return options.dayMinWidth
  12141. ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth)
  12142. : this.renderSimpleLayout(headerContent, bodyContent);
  12143. };
  12144. return DayTableView;
  12145. }(TableView));
  12146. function buildDayTableModel(dateProfile, dateProfileGenerator) {
  12147. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  12148. return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  12149. }
  12150. var TableDateProfileGenerator = /** @class */ (function (_super) {
  12151. __extends(TableDateProfileGenerator, _super);
  12152. function TableDateProfileGenerator() {
  12153. return _super !== null && _super.apply(this, arguments) || this;
  12154. }
  12155. // Computes the date range that will be rendered.
  12156. TableDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  12157. var dateEnv = this.props.dateEnv;
  12158. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  12159. var start = renderRange.start;
  12160. var end = renderRange.end;
  12161. var endOfWeek;
  12162. // year and month views should be aligned with weeks. this is already done for week
  12163. if (/^(year|month)$/.test(currentRangeUnit)) {
  12164. start = dateEnv.startOfWeek(start);
  12165. // make end-of-week if not already
  12166. endOfWeek = dateEnv.startOfWeek(end);
  12167. if (endOfWeek.valueOf() !== end.valueOf()) {
  12168. end = addWeeks(endOfWeek, 1);
  12169. }
  12170. }
  12171. // ensure 6 weeks
  12172. if (this.props.monthMode &&
  12173. this.props.fixedWeekCount) {
  12174. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  12175. diffWeeks(start, end));
  12176. end = addWeeks(end, 6 - rowCnt);
  12177. }
  12178. return { start: start, end: end };
  12179. };
  12180. return TableDateProfileGenerator;
  12181. }(DateProfileGenerator));
  12182. var OPTION_REFINERS$1 = {
  12183. moreLinkClick: identity,
  12184. moreLinkClassNames: identity,
  12185. moreLinkContent: identity,
  12186. moreLinkDidMount: identity,
  12187. moreLinkWillUnmount: identity,
  12188. };
  12189. var dayGridPlugin = createPlugin({
  12190. initialView: 'dayGridMonth',
  12191. optionRefiners: OPTION_REFINERS$1,
  12192. views: {
  12193. dayGrid: {
  12194. component: DayTableView,
  12195. dateProfileGeneratorClass: TableDateProfileGenerator,
  12196. },
  12197. dayGridDay: {
  12198. type: 'dayGrid',
  12199. duration: { days: 1 },
  12200. },
  12201. dayGridWeek: {
  12202. type: 'dayGrid',
  12203. duration: { weeks: 1 },
  12204. },
  12205. dayGridMonth: {
  12206. type: 'dayGrid',
  12207. duration: { months: 1 },
  12208. monthMode: true,
  12209. fixedWeekCount: true,
  12210. },
  12211. },
  12212. });
  12213. var AllDaySplitter = /** @class */ (function (_super) {
  12214. __extends(AllDaySplitter, _super);
  12215. function AllDaySplitter() {
  12216. return _super !== null && _super.apply(this, arguments) || this;
  12217. }
  12218. AllDaySplitter.prototype.getKeyInfo = function () {
  12219. return {
  12220. allDay: {},
  12221. timed: {},
  12222. };
  12223. };
  12224. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  12225. if (dateSpan.allDay) {
  12226. return ['allDay'];
  12227. }
  12228. return ['timed'];
  12229. };
  12230. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  12231. if (!eventDef.allDay) {
  12232. return ['timed'];
  12233. }
  12234. if (hasBgRendering(eventDef)) {
  12235. return ['timed', 'allDay'];
  12236. }
  12237. return ['allDay'];
  12238. };
  12239. return AllDaySplitter;
  12240. }(Splitter));
  12241. var DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
  12242. hour: 'numeric',
  12243. minute: '2-digit',
  12244. omitZeroMinute: true,
  12245. meridiem: 'short',
  12246. });
  12247. function TimeColsAxisCell(props) {
  12248. var classNames = [
  12249. 'fc-timegrid-slot',
  12250. 'fc-timegrid-slot-label',
  12251. props.isLabeled ? 'fc-scrollgrid-shrink' : 'fc-timegrid-slot-minor',
  12252. ];
  12253. return (createElement(ViewContextType.Consumer, null, function (context) {
  12254. if (!props.isLabeled) {
  12255. return (createElement("td", { className: classNames.join(' '), "data-time": props.isoTimeStr }));
  12256. }
  12257. var dateEnv = context.dateEnv, options = context.options, viewApi = context.viewApi;
  12258. var labelFormat = // TODO: fully pre-parse
  12259. options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT :
  12260. Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) :
  12261. createFormatter(options.slotLabelFormat);
  12262. var hookProps = {
  12263. level: 0,
  12264. time: props.time,
  12265. date: dateEnv.toDate(props.date),
  12266. view: viewApi,
  12267. text: dateEnv.format(props.date, labelFormat),
  12268. };
  12269. 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 },
  12270. createElement("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" },
  12271. createElement("div", { className: "fc-timegrid-slot-label-cushion fc-scrollgrid-shrink-cushion", ref: innerElRef }, innerContent)))); }));
  12272. }));
  12273. }
  12274. function renderInnerContent$3(props) {
  12275. return props.text;
  12276. }
  12277. var TimeBodyAxis = /** @class */ (function (_super) {
  12278. __extends(TimeBodyAxis, _super);
  12279. function TimeBodyAxis() {
  12280. return _super !== null && _super.apply(this, arguments) || this;
  12281. }
  12282. TimeBodyAxis.prototype.render = function () {
  12283. return this.props.slatMetas.map(function (slatMeta) { return (createElement("tr", { key: slatMeta.key },
  12284. createElement(TimeColsAxisCell, __assign({}, slatMeta)))); });
  12285. };
  12286. return TimeBodyAxis;
  12287. }(BaseComponent));
  12288. var DEFAULT_WEEK_NUM_FORMAT$1 = createFormatter({ week: 'short' });
  12289. var AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
  12290. var TimeColsView = /** @class */ (function (_super) {
  12291. __extends(TimeColsView, _super);
  12292. function TimeColsView() {
  12293. var _this = _super !== null && _super.apply(this, arguments) || this;
  12294. _this.allDaySplitter = new AllDaySplitter(); // for use by subclasses
  12295. _this.headerElRef = createRef();
  12296. _this.rootElRef = createRef();
  12297. _this.scrollerElRef = createRef();
  12298. _this.state = {
  12299. slatCoords: null,
  12300. };
  12301. _this.handleScrollTopRequest = function (scrollTop) {
  12302. var scrollerEl = _this.scrollerElRef.current;
  12303. if (scrollerEl) { // TODO: not sure how this could ever be null. weirdness with the reducer
  12304. scrollerEl.scrollTop = scrollTop;
  12305. }
  12306. };
  12307. /* Header Render Methods
  12308. ------------------------------------------------------------------------------------------------------------------*/
  12309. _this.renderHeadAxis = function (frameHeight) {
  12310. if (frameHeight === void 0) { frameHeight = ''; }
  12311. var options = _this.context.options;
  12312. var dateProfile = _this.props.dateProfile;
  12313. var range = dateProfile.renderRange;
  12314. var dayCnt = diffDays(range.start, range.end);
  12315. var navLinkAttrs = (options.navLinks && dayCnt === 1) // only do in day views (to avoid doing in week views that dont need it)
  12316. ? { 'data-navlink': buildNavLinkData(range.start, 'week'), tabIndex: 0 }
  12317. : {};
  12318. if (options.weekNumbers) {
  12319. return (createElement(WeekNumberRoot, { date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT$1 }, function (rootElRef, classNames, innerElRef, innerContent) { return (createElement("th", { ref: rootElRef, className: [
  12320. 'fc-timegrid-axis',
  12321. 'fc-scrollgrid-shrink',
  12322. ].concat(classNames).join(' ') },
  12323. createElement("div", { className: "fc-timegrid-axis-frame fc-scrollgrid-shrink-frame fc-timegrid-axis-frame-liquid", style: { height: frameHeight } },
  12324. createElement("a", __assign({ ref: innerElRef, className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner" }, navLinkAttrs), innerContent)))); }));
  12325. }
  12326. return (createElement("th", { className: "fc-timegrid-axis" },
  12327. createElement("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } })));
  12328. };
  12329. /* Table Component Render Methods
  12330. ------------------------------------------------------------------------------------------------------------------*/
  12331. // only a one-way height sync. we don't send the axis inner-content height to the DayGrid,
  12332. // but DayGrid still needs to have classNames on inner elements in order to measure.
  12333. _this.renderTableRowAxis = function (rowHeight) {
  12334. var _a = _this.context, options = _a.options, viewApi = _a.viewApi;
  12335. var hookProps = {
  12336. text: options.allDayText,
  12337. view: viewApi,
  12338. };
  12339. return (
  12340. // TODO: make reusable hook. used in list view too
  12341. 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: [
  12342. 'fc-timegrid-axis',
  12343. 'fc-scrollgrid-shrink',
  12344. ].concat(classNames).join(' ') },
  12345. createElement("div", { className: 'fc-timegrid-axis-frame fc-scrollgrid-shrink-frame' + (rowHeight == null ? ' fc-timegrid-axis-frame-liquid' : ''), style: { height: rowHeight } },
  12346. createElement("span", { className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner", ref: innerElRef }, innerContent)))); }));
  12347. };
  12348. _this.handleSlatCoords = function (slatCoords) {
  12349. _this.setState({ slatCoords: slatCoords });
  12350. };
  12351. return _this;
  12352. }
  12353. // rendering
  12354. // ----------------------------------------------------------------------------------------------------
  12355. TimeColsView.prototype.renderSimpleLayout = function (headerRowContent, allDayContent, timeContent) {
  12356. var _a = this, context = _a.context, props = _a.props;
  12357. var sections = [];
  12358. var stickyHeaderDates = getStickyHeaderDates(context.options);
  12359. if (headerRowContent) {
  12360. sections.push({
  12361. type: 'header',
  12362. key: 'header',
  12363. isSticky: stickyHeaderDates,
  12364. chunk: {
  12365. elRef: this.headerElRef,
  12366. tableClassName: 'fc-col-header',
  12367. rowContent: headerRowContent,
  12368. },
  12369. });
  12370. }
  12371. if (allDayContent) {
  12372. sections.push({
  12373. type: 'body',
  12374. key: 'all-day',
  12375. chunk: { content: allDayContent },
  12376. });
  12377. sections.push({
  12378. type: 'body',
  12379. key: 'all-day-divider',
  12380. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12381. createElement("tr", { className: "fc-scrollgrid-section" },
  12382. createElement("td", { className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  12383. });
  12384. }
  12385. sections.push({
  12386. type: 'body',
  12387. key: 'body',
  12388. liquid: true,
  12389. expandRows: Boolean(context.options.expandRows),
  12390. chunk: {
  12391. scrollerElRef: this.scrollerElRef,
  12392. content: timeContent,
  12393. },
  12394. });
  12395. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12396. createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, cols: [{ width: 'shrink' }], sections: sections }))); }));
  12397. };
  12398. TimeColsView.prototype.renderHScrollLayout = function (headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
  12399. var _this = this;
  12400. var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
  12401. if (!ScrollGrid) {
  12402. throw new Error('No ScrollGrid implementation');
  12403. }
  12404. var _a = this, context = _a.context, props = _a.props;
  12405. var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
  12406. var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
  12407. var sections = [];
  12408. if (headerRowContent) {
  12409. sections.push({
  12410. type: 'header',
  12411. key: 'header',
  12412. isSticky: stickyHeaderDates,
  12413. syncRowHeights: true,
  12414. chunks: [
  12415. {
  12416. key: 'axis',
  12417. rowContent: function (arg) { return (createElement("tr", null, _this.renderHeadAxis(arg.rowSyncHeights[0]))); },
  12418. },
  12419. {
  12420. key: 'cols',
  12421. elRef: this.headerElRef,
  12422. tableClassName: 'fc-col-header',
  12423. rowContent: headerRowContent,
  12424. },
  12425. ],
  12426. });
  12427. }
  12428. if (allDayContent) {
  12429. sections.push({
  12430. type: 'body',
  12431. key: 'all-day',
  12432. syncRowHeights: true,
  12433. chunks: [
  12434. {
  12435. key: 'axis',
  12436. rowContent: function (contentArg) { return (createElement("tr", null, _this.renderTableRowAxis(contentArg.rowSyncHeights[0]))); },
  12437. },
  12438. {
  12439. key: 'cols',
  12440. content: allDayContent,
  12441. },
  12442. ],
  12443. });
  12444. sections.push({
  12445. key: 'all-day-divider',
  12446. type: 'body',
  12447. outerContent: ( // TODO: rename to cellContent so don't need to define <tr>?
  12448. createElement("tr", { className: "fc-scrollgrid-section" },
  12449. createElement("td", { colSpan: 2, className: 'fc-timegrid-divider ' + context.theme.getClass('tableCellShaded') }))),
  12450. });
  12451. }
  12452. var isNowIndicator = context.options.nowIndicator;
  12453. sections.push({
  12454. type: 'body',
  12455. key: 'body',
  12456. liquid: true,
  12457. expandRows: Boolean(context.options.expandRows),
  12458. chunks: [
  12459. {
  12460. key: 'axis',
  12461. content: function (arg) { return (
  12462. // TODO: make this now-indicator arrow more DRY with TimeColsContent
  12463. createElement("div", { className: "fc-timegrid-axis-chunk" },
  12464. createElement("table", { style: { height: arg.expandRows ? arg.clientHeight : '' } },
  12465. arg.tableColGroupNode,
  12466. createElement("tbody", null,
  12467. createElement(TimeBodyAxis, { slatMetas: slatMetas }))),
  12468. createElement("div", { className: "fc-timegrid-now-indicator-container" },
  12469. createElement(NowTimer, { unit: isNowIndicator ? 'minute' : 'day' /* hacky */ }, function (nowDate) {
  12470. var nowIndicatorTop = isNowIndicator &&
  12471. slatCoords &&
  12472. slatCoords.safeComputeTop(nowDate); // might return void
  12473. if (typeof nowIndicatorTop === 'number') {
  12474. 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)); }));
  12475. }
  12476. return null;
  12477. })))); },
  12478. },
  12479. {
  12480. key: 'cols',
  12481. scrollerElRef: this.scrollerElRef,
  12482. content: timeContent,
  12483. },
  12484. ],
  12485. });
  12486. if (stickyFooterScrollbar) {
  12487. sections.push({
  12488. key: 'footer',
  12489. type: 'footer',
  12490. isSticky: true,
  12491. chunks: [
  12492. {
  12493. key: 'axis',
  12494. content: renderScrollShim,
  12495. },
  12496. {
  12497. key: 'cols',
  12498. content: renderScrollShim,
  12499. },
  12500. ],
  12501. });
  12502. }
  12503. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function (rootElRef, classNames) { return (createElement("div", { className: ['fc-timegrid'].concat(classNames).join(' '), ref: rootElRef },
  12504. createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, colGroups: [
  12505. { width: 'shrink', cols: [{ width: 'shrink' }] },
  12506. { cols: [{ span: colCnt, minWidth: dayMinWidth }] },
  12507. ], sections: sections }))); }));
  12508. };
  12509. /* Dimensions
  12510. ------------------------------------------------------------------------------------------------------------------*/
  12511. TimeColsView.prototype.getAllDayMaxEventProps = function () {
  12512. var _a = this.context.options, dayMaxEvents = _a.dayMaxEvents, dayMaxEventRows = _a.dayMaxEventRows;
  12513. if (dayMaxEvents === true || dayMaxEventRows === true) { // is auto?
  12514. dayMaxEvents = undefined;
  12515. dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS; // make sure "auto" goes to a real number
  12516. }
  12517. return { dayMaxEvents: dayMaxEvents, dayMaxEventRows: dayMaxEventRows };
  12518. };
  12519. return TimeColsView;
  12520. }(DateComponent));
  12521. function renderAllDayInner(hookProps) {
  12522. return hookProps.text;
  12523. }
  12524. var TimeColsSlatsCoords = /** @class */ (function () {
  12525. function TimeColsSlatsCoords(positions, dateProfile, slatMetas) {
  12526. this.positions = positions;
  12527. this.dateProfile = dateProfile;
  12528. this.slatMetas = slatMetas;
  12529. }
  12530. TimeColsSlatsCoords.prototype.safeComputeTop = function (date) {
  12531. var dateProfile = this.dateProfile;
  12532. if (rangeContainsMarker(dateProfile.currentRange, date)) {
  12533. var startOfDayDate = startOfDay(date);
  12534. var timeMs = date.valueOf() - startOfDayDate.valueOf();
  12535. if (timeMs >= asRoughMs(dateProfile.slotMinTime) &&
  12536. timeMs < asRoughMs(dateProfile.slotMaxTime)) {
  12537. return this.computeTimeTop(createDuration(timeMs));
  12538. }
  12539. }
  12540. return null;
  12541. };
  12542. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  12543. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  12544. TimeColsSlatsCoords.prototype.computeDateTop = function (when, startOfDayDate) {
  12545. if (!startOfDayDate) {
  12546. startOfDayDate = startOfDay(when);
  12547. }
  12548. return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
  12549. };
  12550. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  12551. // This is a makeshify way to compute the time-top. Assumes all slatMetas dates are uniform.
  12552. // Eventually allow computation with arbirary slat dates.
  12553. TimeColsSlatsCoords.prototype.computeTimeTop = function (duration) {
  12554. var _a = this, positions = _a.positions, dateProfile = _a.dateProfile, slatMetas = _a.slatMetas;
  12555. var len = positions.els.length;
  12556. // we assume dates are uniform
  12557. var slotDurationMs = slatMetas[1].date.valueOf() - slatMetas[0].date.valueOf();
  12558. // floating-point value of # of slots covered
  12559. var slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / slotDurationMs;
  12560. var slatIndex;
  12561. var slatRemainder;
  12562. // compute a floating-point number for how many slats should be progressed through.
  12563. // from 0 to number of slats (inclusive)
  12564. // constrained because slotMinTime/slotMaxTime might be customized.
  12565. slatCoverage = Math.max(0, slatCoverage);
  12566. slatCoverage = Math.min(len, slatCoverage);
  12567. // an integer index of the furthest whole slat
  12568. // from 0 to number slats (*exclusive*, so len-1)
  12569. slatIndex = Math.floor(slatCoverage);
  12570. slatIndex = Math.min(slatIndex, len - 1);
  12571. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  12572. // could be 1.0 if slatCoverage is covering *all* the slots
  12573. slatRemainder = slatCoverage - slatIndex;
  12574. return positions.tops[slatIndex] +
  12575. positions.getHeight(slatIndex) * slatRemainder;
  12576. };
  12577. return TimeColsSlatsCoords;
  12578. }());
  12579. var TimeColsSlatsBody = /** @class */ (function (_super) {
  12580. __extends(TimeColsSlatsBody, _super);
  12581. function TimeColsSlatsBody() {
  12582. return _super !== null && _super.apply(this, arguments) || this;
  12583. }
  12584. TimeColsSlatsBody.prototype.render = function () {
  12585. var _a = this, props = _a.props, context = _a.context;
  12586. var options = context.options;
  12587. var slatElRefs = props.slatElRefs;
  12588. return (createElement("tbody", null, props.slatMetas.map(function (slatMeta, i) {
  12589. var hookProps = {
  12590. time: slatMeta.time,
  12591. date: context.dateEnv.toDate(slatMeta.date),
  12592. view: context.viewApi,
  12593. };
  12594. var classNames = [
  12595. 'fc-timegrid-slot',
  12596. 'fc-timegrid-slot-lane',
  12597. slatMeta.isLabeled ? '' : 'fc-timegrid-slot-minor',
  12598. ];
  12599. return (createElement("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) },
  12600. props.axis && (createElement(TimeColsAxisCell, __assign({}, slatMeta))),
  12601. 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)); })));
  12602. })));
  12603. };
  12604. return TimeColsSlatsBody;
  12605. }(BaseComponent));
  12606. /*
  12607. for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  12608. */
  12609. var TimeColsSlats = /** @class */ (function (_super) {
  12610. __extends(TimeColsSlats, _super);
  12611. function TimeColsSlats() {
  12612. var _this = _super !== null && _super.apply(this, arguments) || this;
  12613. _this.rootElRef = createRef();
  12614. _this.slatElRefs = new RefMap();
  12615. return _this;
  12616. }
  12617. TimeColsSlats.prototype.render = function () {
  12618. var _a = this, props = _a.props, context = _a.context;
  12619. return (createElement("div", { className: "fc-timegrid-slots", ref: this.rootElRef },
  12620. createElement("table", { className: context.theme.getClass('table'), style: {
  12621. minWidth: props.tableMinWidth,
  12622. width: props.clientWidth,
  12623. height: props.minHeight,
  12624. } },
  12625. props.tableColGroupNode /* relies on there only being a single <col> for the axis */,
  12626. createElement(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas }))));
  12627. };
  12628. TimeColsSlats.prototype.componentDidMount = function () {
  12629. this.updateSizing();
  12630. };
  12631. TimeColsSlats.prototype.componentDidUpdate = function () {
  12632. this.updateSizing();
  12633. };
  12634. TimeColsSlats.prototype.componentWillUnmount = function () {
  12635. if (this.props.onCoords) {
  12636. this.props.onCoords(null);
  12637. }
  12638. };
  12639. TimeColsSlats.prototype.updateSizing = function () {
  12640. var props = this.props;
  12641. if (props.onCoords &&
  12642. props.clientWidth !== null // means sizing has stabilized
  12643. ) {
  12644. var rootEl = this.rootElRef.current;
  12645. if (rootEl.offsetHeight) { // not hidden by css
  12646. props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, props.slatMetas));
  12647. }
  12648. }
  12649. };
  12650. return TimeColsSlats;
  12651. }(BaseComponent));
  12652. function collectSlatEls(elMap, slatMetas) {
  12653. return slatMetas.map(function (slatMeta) { return elMap[slatMeta.key]; });
  12654. }
  12655. function splitSegsByCol(segs, colCnt) {
  12656. var segsByCol = [];
  12657. var i;
  12658. for (i = 0; i < colCnt; i += 1) {
  12659. segsByCol.push([]);
  12660. }
  12661. if (segs) {
  12662. for (i = 0; i < segs.length; i += 1) {
  12663. segsByCol[segs[i].col].push(segs[i]);
  12664. }
  12665. }
  12666. return segsByCol;
  12667. }
  12668. function splitInteractionByCol(ui, colCnt) {
  12669. var byRow = [];
  12670. if (!ui) {
  12671. for (var i = 0; i < colCnt; i += 1) {
  12672. byRow[i] = null;
  12673. }
  12674. }
  12675. else {
  12676. for (var i = 0; i < colCnt; i += 1) {
  12677. byRow[i] = {
  12678. affectedInstances: ui.affectedInstances,
  12679. isEvent: ui.isEvent,
  12680. segs: [],
  12681. };
  12682. }
  12683. for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
  12684. var seg = _a[_i];
  12685. byRow[seg.col].segs.push(seg);
  12686. }
  12687. }
  12688. return byRow;
  12689. }
  12690. // UNFORTUNATELY, assigns results to the top/bottom/level/forwardCoord/backwardCoord props of the actual segs.
  12691. // TODO: return hash (by instanceId) of results
  12692. function computeSegCoords(segs, dayDate, slatCoords, eventMinHeight, eventOrderSpecs) {
  12693. computeSegVerticals(segs, dayDate, slatCoords, eventMinHeight);
  12694. return computeSegHorizontals(segs, eventOrderSpecs); // requires top/bottom from computeSegVerticals
  12695. }
  12696. // For each segment in an array, computes and assigns its top and bottom properties
  12697. function computeSegVerticals(segs, dayDate, slatCoords, eventMinHeight) {
  12698. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  12699. var seg = segs_1[_i];
  12700. seg.top = slatCoords.computeDateTop(seg.start, dayDate);
  12701. seg.bottom = Math.max(seg.top + (eventMinHeight || 0), // yuck
  12702. slatCoords.computeDateTop(seg.end, dayDate));
  12703. }
  12704. }
  12705. // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
  12706. // Assumed the segs are already ordered.
  12707. // NOTE: Also reorders the given array by date!
  12708. function computeSegHorizontals(segs, eventOrderSpecs) {
  12709. // IMPORTANT TO CLEAR OLD RESULTS :(
  12710. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  12711. var seg = segs_2[_i];
  12712. seg.level = null;
  12713. seg.forwardCoord = null;
  12714. seg.backwardCoord = null;
  12715. seg.forwardPressure = null;
  12716. }
  12717. segs = sortEventSegs(segs, eventOrderSpecs);
  12718. var level0;
  12719. var levels = buildSlotSegLevels(segs);
  12720. computeForwardSlotSegs(levels);
  12721. if ((level0 = levels[0])) {
  12722. for (var _a = 0, level0_1 = level0; _a < level0_1.length; _a++) {
  12723. var seg = level0_1[_a];
  12724. computeSlotSegPressures(seg);
  12725. }
  12726. for (var _b = 0, level0_2 = level0; _b < level0_2.length; _b++) {
  12727. var seg = level0_2[_b];
  12728. computeSegForwardBack(seg, 0, 0, eventOrderSpecs);
  12729. }
  12730. }
  12731. return segs;
  12732. }
  12733. // Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
  12734. // left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
  12735. function buildSlotSegLevels(segs) {
  12736. var levels = [];
  12737. var i;
  12738. var seg;
  12739. var j;
  12740. for (i = 0; i < segs.length; i += 1) {
  12741. seg = segs[i];
  12742. // go through all the levels and stop on the first level where there are no collisions
  12743. for (j = 0; j < levels.length; j += 1) {
  12744. if (!computeSlotSegCollisions(seg, levels[j]).length) {
  12745. break;
  12746. }
  12747. }
  12748. seg.level = j;
  12749. (levels[j] || (levels[j] = [])).push(seg);
  12750. }
  12751. return levels;
  12752. }
  12753. // Find all the segments in `otherSegs` that vertically collide with `seg`.
  12754. // Append into an optionally-supplied `results` array and return.
  12755. function computeSlotSegCollisions(seg, otherSegs, results) {
  12756. if (results === void 0) { results = []; }
  12757. for (var i = 0; i < otherSegs.length; i += 1) {
  12758. if (isSlotSegCollision(seg, otherSegs[i])) {
  12759. results.push(otherSegs[i]);
  12760. }
  12761. }
  12762. return results;
  12763. }
  12764. // Do these segments occupy the same vertical space?
  12765. function isSlotSegCollision(seg1, seg2) {
  12766. return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
  12767. }
  12768. // For every segment, figure out the other segments that are in subsequent
  12769. // levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
  12770. function computeForwardSlotSegs(levels) {
  12771. var i;
  12772. var level;
  12773. var j;
  12774. var seg;
  12775. var k;
  12776. for (i = 0; i < levels.length; i += 1) {
  12777. level = levels[i];
  12778. for (j = 0; j < level.length; j += 1) {
  12779. seg = level[j];
  12780. seg.forwardSegs = [];
  12781. for (k = i + 1; k < levels.length; k += 1) {
  12782. computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
  12783. }
  12784. }
  12785. }
  12786. }
  12787. // Figure out which path forward (via seg.forwardSegs) results in the longest path until
  12788. // the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
  12789. function computeSlotSegPressures(seg) {
  12790. var forwardSegs = seg.forwardSegs;
  12791. var forwardPressure = 0;
  12792. var i;
  12793. var forwardSeg;
  12794. if (seg.forwardPressure == null) { // not already computed
  12795. for (i = 0; i < forwardSegs.length; i += 1) {
  12796. forwardSeg = forwardSegs[i];
  12797. // figure out the child's maximum forward path
  12798. computeSlotSegPressures(forwardSeg);
  12799. // either use the existing maximum, or use the child's forward pressure
  12800. // plus one (for the forwardSeg itself)
  12801. forwardPressure = Math.max(forwardPressure, 1 + forwardSeg.forwardPressure);
  12802. }
  12803. seg.forwardPressure = forwardPressure;
  12804. }
  12805. }
  12806. // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
  12807. // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
  12808. // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
  12809. //
  12810. // The segment might be part of a "series", which means consecutive segments with the same pressure
  12811. // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
  12812. // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
  12813. // coordinate of the first segment in the series.
  12814. function computeSegForwardBack(seg, seriesBackwardPressure, seriesBackwardCoord, eventOrderSpecs) {
  12815. var forwardSegs = seg.forwardSegs;
  12816. var i;
  12817. if (seg.forwardCoord == null) { // not already computed
  12818. if (!forwardSegs.length) {
  12819. // if there are no forward segments, this segment should butt up against the edge
  12820. seg.forwardCoord = 1;
  12821. }
  12822. else {
  12823. // sort highest pressure first
  12824. sortForwardSegs(forwardSegs, eventOrderSpecs);
  12825. // this segment's forwardCoord will be calculated from the backwardCoord of the
  12826. // highest-pressure forward segment.
  12827. computeSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord, eventOrderSpecs);
  12828. seg.forwardCoord = forwardSegs[0].backwardCoord;
  12829. }
  12830. // calculate the backwardCoord from the forwardCoord. consider the series
  12831. seg.backwardCoord = seg.forwardCoord -
  12832. (seg.forwardCoord - seriesBackwardCoord) / // available width for series
  12833. (seriesBackwardPressure + 1); // # of segments in the series
  12834. // use this segment's coordinates to computed the coordinates of the less-pressurized
  12835. // forward segments
  12836. for (i = 0; i < forwardSegs.length; i += 1) {
  12837. computeSegForwardBack(forwardSegs[i], 0, seg.forwardCoord, eventOrderSpecs);
  12838. }
  12839. }
  12840. }
  12841. function sortForwardSegs(forwardSegs, eventOrderSpecs) {
  12842. var objs = forwardSegs.map(buildTimeGridSegCompareObj);
  12843. var specs = [
  12844. // put higher-pressure first
  12845. { field: 'forwardPressure', order: -1 },
  12846. // put segments that are closer to initial edge first (and favor ones with no coords yet)
  12847. { field: 'backwardCoord', order: 1 },
  12848. ].concat(eventOrderSpecs);
  12849. objs.sort(function (obj0, obj1) { return compareByFieldSpecs(obj0, obj1, specs); });
  12850. return objs.map(function (c) { return c._seg; });
  12851. }
  12852. function buildTimeGridSegCompareObj(seg) {
  12853. var obj = buildSegCompareObj(seg);
  12854. obj.forwardPressure = seg.forwardPressure;
  12855. obj.backwardCoord = seg.backwardCoord;
  12856. return obj;
  12857. }
  12858. var DEFAULT_TIME_FORMAT = createFormatter({
  12859. hour: 'numeric',
  12860. minute: '2-digit',
  12861. meridiem: false,
  12862. });
  12863. var TimeColEvent = /** @class */ (function (_super) {
  12864. __extends(TimeColEvent, _super);
  12865. function TimeColEvent() {
  12866. return _super !== null && _super.apply(this, arguments) || this;
  12867. }
  12868. TimeColEvent.prototype.render = function () {
  12869. var classNames = [
  12870. 'fc-timegrid-event',
  12871. 'fc-v-event',
  12872. ];
  12873. if (this.props.isCondensed) {
  12874. classNames.push('fc-timegrid-event-condensed');
  12875. }
  12876. return (createElement(StandardEvent, __assign({}, this.props, { defaultTimeFormat: DEFAULT_TIME_FORMAT, extraClassNames: classNames })));
  12877. };
  12878. return TimeColEvent;
  12879. }(BaseComponent));
  12880. var TimeColMisc = /** @class */ (function (_super) {
  12881. __extends(TimeColMisc, _super);
  12882. function TimeColMisc() {
  12883. return _super !== null && _super.apply(this, arguments) || this;
  12884. }
  12885. TimeColMisc.prototype.render = function () {
  12886. var props = this.props;
  12887. return (createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function (innerElRef, innerContent) { return (innerContent &&
  12888. createElement("div", { className: "fc-timegrid-col-misc", ref: innerElRef }, innerContent)); }));
  12889. };
  12890. return TimeColMisc;
  12891. }(BaseComponent));
  12892. config.timeGridEventCondensedHeight = 30;
  12893. var TimeCol = /** @class */ (function (_super) {
  12894. __extends(TimeCol, _super);
  12895. function TimeCol() {
  12896. return _super !== null && _super.apply(this, arguments) || this;
  12897. }
  12898. TimeCol.prototype.render = function () {
  12899. var _this = this;
  12900. var _a = this, props = _a.props, context = _a.context;
  12901. var isSelectMirror = context.options.selectMirror;
  12902. var mirrorSegs = (props.eventDrag && props.eventDrag.segs) ||
  12903. (props.eventResize && props.eventResize.segs) ||
  12904. (isSelectMirror && props.dateSelectionSegs) ||
  12905. [];
  12906. var interactionAffectedInstances = // TODO: messy way to compute this
  12907. (props.eventDrag && props.eventDrag.affectedInstances) ||
  12908. (props.eventResize && props.eventResize.affectedInstances) ||
  12909. {};
  12910. 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),
  12911. createElement("div", { className: "fc-timegrid-col-frame" },
  12912. createElement("div", { className: "fc-timegrid-col-bg" },
  12913. _this.renderFillSegs(props.businessHourSegs, 'non-business'),
  12914. _this.renderFillSegs(props.bgEventSegs, 'bg-event'),
  12915. _this.renderFillSegs(props.dateSelectionSegs, 'highlight')),
  12916. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(props.fgEventSegs, interactionAffectedInstances)),
  12917. createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror))),
  12918. createElement("div", { className: "fc-timegrid-now-indicator-container" }, _this.renderNowIndicator(props.nowIndicatorSegs)),
  12919. createElement(TimeColMisc, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps })))); }));
  12920. };
  12921. TimeCol.prototype.renderFgSegs = function (segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  12922. var props = this.props;
  12923. if (props.forPrint) {
  12924. return this.renderPrintFgSegs(segs);
  12925. }
  12926. if (props.slatCoords) {
  12927. return this.renderPositionedFgSegs(segs, segIsInvisible, isDragging, isResizing, isDateSelecting);
  12928. }
  12929. return null;
  12930. };
  12931. TimeCol.prototype.renderPrintFgSegs = function (segs) {
  12932. var _a = this, props = _a.props, context = _a.context;
  12933. // not DRY
  12934. segs = sortEventSegs(segs, context.options.eventOrder);
  12935. return segs.map(function (seg) { return (createElement("div", { className: "fc-timegrid-event-harness", key: seg.eventRange.instance.instanceId },
  12936. createElement(TimeColEvent, __assign({ seg: seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isCondensed: false }, getSegMeta(seg, props.todayRange, props.nowDate))))); });
  12937. };
  12938. TimeCol.prototype.renderPositionedFgSegs = function (segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
  12939. var _this = this;
  12940. var _a = this, context = _a.context, props = _a.props;
  12941. // assigns TO THE SEGS THEMSELVES
  12942. // also, receives resorted array
  12943. segs = computeSegCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight, context.options.eventOrder);
  12944. return segs.map(function (seg) {
  12945. var instanceId = seg.eventRange.instance.instanceId;
  12946. var isMirror = isDragging || isResizing || isDateSelecting;
  12947. var positionCss = isMirror
  12948. // will span entire column width
  12949. // also, won't assign z-index, which is good, fc-event-mirror will overpower other harnesses
  12950. ? __assign({ left: 0, right: 0 }, _this.computeSegTopBottomCss(seg)) : _this.computeFgSegPositionCss(seg);
  12951. 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) },
  12952. 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)))));
  12953. });
  12954. };
  12955. TimeCol.prototype.renderFillSegs = function (segs, fillType) {
  12956. var _this = this;
  12957. var _a = this, context = _a.context, props = _a.props;
  12958. if (!props.slatCoords) {
  12959. return null;
  12960. }
  12961. // BAD: assigns TO THE SEGS THEMSELVES
  12962. computeSegVerticals(segs, props.date, props.slatCoords, context.options.eventMinHeight);
  12963. 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' ?
  12964. createElement(BgEvent, __assign({ seg: seg }, getSegMeta(seg, props.todayRange, props.nowDate))) :
  12965. renderFill(fillType))); });
  12966. return createElement(Fragment, null, children);
  12967. };
  12968. TimeCol.prototype.renderNowIndicator = function (segs) {
  12969. var _a = this.props, slatCoords = _a.slatCoords, date = _a.date;
  12970. if (!slatCoords) {
  12971. return null;
  12972. }
  12973. return segs.map(function (seg, i) { return (createElement(NowIndicatorRoot, { isAxis: false, date: date,
  12974. // key doesn't matter. will only ever be one
  12975. 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)); })); });
  12976. };
  12977. TimeCol.prototype.computeFgSegPositionCss = function (seg) {
  12978. var _a = this.context, isRtl = _a.isRtl, options = _a.options;
  12979. var shouldOverlap = options.slotEventOverlap;
  12980. var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
  12981. var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
  12982. var left; // amount of space from left edge, a fraction of the total width
  12983. var right; // amount of space from right edge, a fraction of the total width
  12984. if (shouldOverlap) {
  12985. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  12986. forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
  12987. }
  12988. if (isRtl) {
  12989. left = 1 - forwardCoord;
  12990. right = backwardCoord;
  12991. }
  12992. else {
  12993. left = backwardCoord;
  12994. right = 1 - forwardCoord;
  12995. }
  12996. var props = {
  12997. zIndex: seg.level + 1,
  12998. left: left * 100 + '%',
  12999. right: right * 100 + '%',
  13000. };
  13001. if (shouldOverlap && seg.forwardPressure) {
  13002. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  13003. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  13004. }
  13005. return __assign(__assign({}, props), this.computeSegTopBottomCss(seg));
  13006. };
  13007. TimeCol.prototype.computeSegTopBottomCss = function (seg) {
  13008. return {
  13009. top: seg.top,
  13010. bottom: -seg.bottom,
  13011. };
  13012. };
  13013. return TimeCol;
  13014. }(BaseComponent));
  13015. var TimeColsContent = /** @class */ (function (_super) {
  13016. __extends(TimeColsContent, _super);
  13017. function TimeColsContent() {
  13018. var _this = _super !== null && _super.apply(this, arguments) || this;
  13019. _this.splitFgEventSegs = memoize(splitSegsByCol);
  13020. _this.splitBgEventSegs = memoize(splitSegsByCol);
  13021. _this.splitBusinessHourSegs = memoize(splitSegsByCol);
  13022. _this.splitNowIndicatorSegs = memoize(splitSegsByCol);
  13023. _this.splitDateSelectionSegs = memoize(splitSegsByCol);
  13024. _this.splitEventDrag = memoize(splitInteractionByCol);
  13025. _this.splitEventResize = memoize(splitInteractionByCol);
  13026. _this.rootElRef = createRef();
  13027. _this.cellElRefs = new RefMap();
  13028. return _this;
  13029. }
  13030. TimeColsContent.prototype.render = function () {
  13031. var _this = this;
  13032. var _a = this, props = _a.props, context = _a.context;
  13033. var nowIndicatorTop = context.options.nowIndicator &&
  13034. props.slatCoords &&
  13035. props.slatCoords.safeComputeTop(props.nowDate); // might return void
  13036. var colCnt = props.cells.length;
  13037. var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
  13038. var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
  13039. var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
  13040. var nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
  13041. var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
  13042. var eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
  13043. var eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
  13044. return (createElement("div", { className: "fc-timegrid-cols", ref: this.rootElRef },
  13045. createElement("table", { style: {
  13046. minWidth: props.tableMinWidth,
  13047. width: props.clientWidth,
  13048. } },
  13049. props.tableColGroupNode,
  13050. createElement("tbody", null,
  13051. createElement("tr", null,
  13052. props.axis && (createElement("td", { className: "fc-timegrid-col fc-timegrid-axis" },
  13053. createElement("div", { className: "fc-timegrid-col-frame" },
  13054. 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)); })))))),
  13055. 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 })); }))))));
  13056. };
  13057. TimeColsContent.prototype.componentDidMount = function () {
  13058. this.updateCoords();
  13059. };
  13060. TimeColsContent.prototype.componentDidUpdate = function () {
  13061. this.updateCoords();
  13062. };
  13063. TimeColsContent.prototype.updateCoords = function () {
  13064. var props = this.props;
  13065. if (props.onColCoords &&
  13066. props.clientWidth !== null // means sizing has stabilized
  13067. ) {
  13068. props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, // horizontal
  13069. false));
  13070. }
  13071. };
  13072. return TimeColsContent;
  13073. }(BaseComponent));
  13074. function collectCellEls(elMap, cells) {
  13075. return cells.map(function (cell) { return elMap[cell.key]; });
  13076. }
  13077. /* A component that renders one or more columns of vertical time slots
  13078. ----------------------------------------------------------------------------------------------------------------------*/
  13079. var TimeCols = /** @class */ (function (_super) {
  13080. __extends(TimeCols, _super);
  13081. function TimeCols() {
  13082. var _this = _super !== null && _super.apply(this, arguments) || this;
  13083. _this.processSlotOptions = memoize(processSlotOptions);
  13084. _this.state = {
  13085. slatCoords: null,
  13086. };
  13087. _this.handleScrollRequest = function (request) {
  13088. var onScrollTopRequest = _this.props.onScrollTopRequest;
  13089. var slatCoords = _this.state.slatCoords;
  13090. if (onScrollTopRequest && slatCoords) {
  13091. if (request.time) {
  13092. var top_1 = slatCoords.computeTimeTop(request.time);
  13093. top_1 = Math.ceil(top_1); // zoom can give weird floating-point values. rather scroll a little bit further
  13094. if (top_1) {
  13095. top_1 += 1; // to overcome top border that slots beyond the first have. looks better
  13096. }
  13097. onScrollTopRequest(top_1);
  13098. }
  13099. return true;
  13100. }
  13101. return false;
  13102. };
  13103. _this.handleColCoords = function (colCoords) {
  13104. _this.colCoords = colCoords;
  13105. };
  13106. _this.handleSlatCoords = function (slatCoords) {
  13107. _this.setState({ slatCoords: slatCoords });
  13108. if (_this.props.onSlatCoords) {
  13109. _this.props.onSlatCoords(slatCoords);
  13110. }
  13111. };
  13112. return _this;
  13113. }
  13114. TimeCols.prototype.render = function () {
  13115. var _a = this, props = _a.props, state = _a.state;
  13116. return (createElement("div", { className: "fc-timegrid-body", ref: props.rootElRef, style: {
  13117. // these props are important to give this wrapper correct dimensions for interactions
  13118. // TODO: if we set it here, can we avoid giving to inner tables?
  13119. width: props.clientWidth,
  13120. minWidth: props.tableMinWidth,
  13121. } },
  13122. 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 }),
  13123. 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 })));
  13124. };
  13125. TimeCols.prototype.componentDidMount = function () {
  13126. this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
  13127. };
  13128. TimeCols.prototype.componentDidUpdate = function (prevProps) {
  13129. this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
  13130. };
  13131. TimeCols.prototype.componentWillUnmount = function () {
  13132. this.scrollResponder.detach();
  13133. };
  13134. TimeCols.prototype.positionToHit = function (positionLeft, positionTop) {
  13135. var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
  13136. var colCoords = this.colCoords;
  13137. var dateProfile = this.props.dateProfile;
  13138. var slatCoords = this.state.slatCoords;
  13139. var _b = this.processSlotOptions(this.props.slotDuration, options.snapDuration), snapDuration = _b.snapDuration, snapsPerSlot = _b.snapsPerSlot;
  13140. var colIndex = colCoords.leftToIndex(positionLeft);
  13141. var slatIndex = slatCoords.positions.topToIndex(positionTop);
  13142. if (colIndex != null && slatIndex != null) {
  13143. var slatTop = slatCoords.positions.tops[slatIndex];
  13144. var slatHeight = slatCoords.positions.getHeight(slatIndex);
  13145. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  13146. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  13147. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  13148. var dayDate = this.props.cells[colIndex].date;
  13149. var time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
  13150. var start = dateEnv.add(dayDate, time);
  13151. var end = dateEnv.add(start, snapDuration);
  13152. return {
  13153. col: colIndex,
  13154. dateSpan: {
  13155. range: { start: start, end: end },
  13156. allDay: false,
  13157. },
  13158. dayEl: colCoords.els[colIndex],
  13159. relativeRect: {
  13160. left: colCoords.lefts[colIndex],
  13161. right: colCoords.rights[colIndex],
  13162. top: slatTop,
  13163. bottom: slatTop + slatHeight,
  13164. },
  13165. };
  13166. }
  13167. return null;
  13168. };
  13169. return TimeCols;
  13170. }(BaseComponent));
  13171. function processSlotOptions(slotDuration, snapDurationOverride) {
  13172. var snapDuration = snapDurationOverride || slotDuration;
  13173. var snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
  13174. if (snapsPerSlot === null) {
  13175. snapDuration = slotDuration;
  13176. snapsPerSlot = 1;
  13177. // TODO: say warning?
  13178. }
  13179. return { snapDuration: snapDuration, snapsPerSlot: snapsPerSlot };
  13180. }
  13181. var DayTimeColsSlicer = /** @class */ (function (_super) {
  13182. __extends(DayTimeColsSlicer, _super);
  13183. function DayTimeColsSlicer() {
  13184. return _super !== null && _super.apply(this, arguments) || this;
  13185. }
  13186. DayTimeColsSlicer.prototype.sliceRange = function (range, dayRanges) {
  13187. var segs = [];
  13188. for (var col = 0; col < dayRanges.length; col += 1) {
  13189. var segRange = intersectRanges(range, dayRanges[col]);
  13190. if (segRange) {
  13191. segs.push({
  13192. start: segRange.start,
  13193. end: segRange.end,
  13194. isStart: segRange.start.valueOf() === range.start.valueOf(),
  13195. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  13196. col: col,
  13197. });
  13198. }
  13199. }
  13200. return segs;
  13201. };
  13202. return DayTimeColsSlicer;
  13203. }(Slicer));
  13204. var DayTimeCols = /** @class */ (function (_super) {
  13205. __extends(DayTimeCols, _super);
  13206. function DayTimeCols() {
  13207. var _this = _super !== null && _super.apply(this, arguments) || this;
  13208. _this.buildDayRanges = memoize(buildDayRanges);
  13209. _this.slicer = new DayTimeColsSlicer();
  13210. _this.timeColsRef = createRef();
  13211. _this.handleRootEl = function (rootEl) {
  13212. if (rootEl) {
  13213. _this.context.registerInteractiveComponent(_this, { el: rootEl });
  13214. }
  13215. else {
  13216. _this.context.unregisterInteractiveComponent(_this);
  13217. }
  13218. };
  13219. return _this;
  13220. }
  13221. DayTimeCols.prototype.render = function () {
  13222. var _this = this;
  13223. var _a = this, props = _a.props, context = _a.context;
  13224. var dateProfile = props.dateProfile, dayTableModel = props.dayTableModel;
  13225. var isNowIndicator = context.options.nowIndicator;
  13226. var dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
  13227. // give it the first row of cells
  13228. // TODO: would move this further down hierarchy, but sliceNowDate needs it
  13229. 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 }))); }));
  13230. };
  13231. DayTimeCols.prototype.queryHit = function (positionLeft, positionTop) {
  13232. var rawHit = this.timeColsRef.current.positionToHit(positionLeft, positionTop);
  13233. if (rawHit) {
  13234. return {
  13235. component: this,
  13236. dateSpan: rawHit.dateSpan,
  13237. dayEl: rawHit.dayEl,
  13238. rect: {
  13239. left: rawHit.relativeRect.left,
  13240. right: rawHit.relativeRect.right,
  13241. top: rawHit.relativeRect.top,
  13242. bottom: rawHit.relativeRect.bottom,
  13243. },
  13244. layer: 0,
  13245. };
  13246. }
  13247. return null;
  13248. };
  13249. return DayTimeCols;
  13250. }(DateComponent));
  13251. function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
  13252. var ranges = [];
  13253. for (var _i = 0, _a = dayTableModel.headerDates; _i < _a.length; _i++) {
  13254. var date = _a[_i];
  13255. ranges.push({
  13256. start: dateEnv.add(date, dateProfile.slotMinTime),
  13257. end: dateEnv.add(date, dateProfile.slotMaxTime),
  13258. });
  13259. }
  13260. return ranges;
  13261. }
  13262. // potential nice values for the slot-duration and interval-duration
  13263. // from largest to smallest
  13264. var STOCK_SUB_DURATIONS = [
  13265. { hours: 1 },
  13266. { minutes: 30 },
  13267. { minutes: 15 },
  13268. { seconds: 30 },
  13269. { seconds: 15 },
  13270. ];
  13271. function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
  13272. var dayStart = new Date(0);
  13273. var slatTime = slotMinTime;
  13274. var slatIterator = createDuration(0);
  13275. var labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
  13276. var metas = [];
  13277. while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
  13278. var date = dateEnv.add(dayStart, slatTime);
  13279. var isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
  13280. metas.push({
  13281. date: date,
  13282. time: slatTime,
  13283. key: date.toISOString(),
  13284. isoTimeStr: formatIsoTimeString(date),
  13285. isLabeled: isLabeled,
  13286. });
  13287. slatTime = addDurations(slatTime, slotDuration);
  13288. slatIterator = addDurations(slatIterator, slotDuration);
  13289. }
  13290. return metas;
  13291. }
  13292. // Computes an automatic value for slotLabelInterval
  13293. function computeLabelInterval(slotDuration) {
  13294. var i;
  13295. var labelInterval;
  13296. var slotsPerLabel;
  13297. // find the smallest stock label interval that results in more than one slots-per-label
  13298. for (i = STOCK_SUB_DURATIONS.length - 1; i >= 0; i -= 1) {
  13299. labelInterval = createDuration(STOCK_SUB_DURATIONS[i]);
  13300. slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
  13301. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  13302. return labelInterval;
  13303. }
  13304. }
  13305. return slotDuration; // fall back
  13306. }
  13307. var DayTimeColsView = /** @class */ (function (_super) {
  13308. __extends(DayTimeColsView, _super);
  13309. function DayTimeColsView() {
  13310. var _this = _super !== null && _super.apply(this, arguments) || this;
  13311. _this.buildTimeColsModel = memoize(buildTimeColsModel);
  13312. _this.buildSlatMetas = memoize(buildSlatMetas);
  13313. return _this;
  13314. }
  13315. DayTimeColsView.prototype.render = function () {
  13316. var _this = this;
  13317. var _a = this.context, options = _a.options, dateEnv = _a.dateEnv, dateProfileGenerator = _a.dateProfileGenerator;
  13318. var props = this.props;
  13319. var dateProfile = props.dateProfile;
  13320. var dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
  13321. var splitProps = this.allDaySplitter.splitProps(props);
  13322. var slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
  13323. var dayMinWidth = options.dayMinWidth;
  13324. var hasAttachedAxis = !dayMinWidth;
  13325. var hasDetachedAxis = dayMinWidth;
  13326. var headerContent = options.dayHeaders && (createElement(DayHeader, { dates: dayTableModel.headerDates, dateProfile: dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null }));
  13327. 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()))); });
  13328. 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 }))); };
  13329. return hasDetachedAxis
  13330. ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords)
  13331. : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
  13332. };
  13333. return DayTimeColsView;
  13334. }(TimeColsView));
  13335. function buildTimeColsModel(dateProfile, dateProfileGenerator) {
  13336. var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
  13337. return new DayTableModel(daySeries, false);
  13338. }
  13339. var OPTION_REFINERS$2 = {
  13340. allDaySlot: Boolean,
  13341. };
  13342. var timeGridPlugin = createPlugin({
  13343. initialView: 'timeGridWeek',
  13344. optionRefiners: OPTION_REFINERS$2,
  13345. views: {
  13346. timeGrid: {
  13347. component: DayTimeColsView,
  13348. usesMinMaxTime: true,
  13349. allDaySlot: true,
  13350. slotDuration: '00:30:00',
  13351. slotEventOverlap: true,
  13352. },
  13353. timeGridDay: {
  13354. type: 'timeGrid',
  13355. duration: { days: 1 },
  13356. },
  13357. timeGridWeek: {
  13358. type: 'timeGrid',
  13359. duration: { weeks: 1 },
  13360. },
  13361. },
  13362. });
  13363. var ListViewHeaderRow = /** @class */ (function (_super) {
  13364. __extends(ListViewHeaderRow, _super);
  13365. function ListViewHeaderRow() {
  13366. return _super !== null && _super.apply(this, arguments) || this;
  13367. }
  13368. ListViewHeaderRow.prototype.render = function () {
  13369. var _a = this.props, dayDate = _a.dayDate, todayRange = _a.todayRange;
  13370. var _b = this.context, theme = _b.theme, dateEnv = _b.dateEnv, options = _b.options, viewApi = _b.viewApi;
  13371. var dayMeta = getDateMeta(dayDate, todayRange);
  13372. // will ever be falsy?
  13373. var text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : '';
  13374. // will ever be falsy? also, BAD NAME "alt"
  13375. var sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : '';
  13376. var navLinkData = options.navLinks
  13377. ? buildNavLinkData(dayDate)
  13378. : null;
  13379. var hookProps = __assign({ date: dateEnv.toDate(dayDate), view: viewApi, text: text,
  13380. sideText: sideText,
  13381. navLinkData: navLinkData }, dayMeta);
  13382. var classNames = ['fc-list-day'].concat(getDayClassNames(dayMeta, theme));
  13383. // TODO: make a reusable HOC for dayHeader (used in daygrid/timegrid too)
  13384. 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) },
  13385. createElement("th", { colSpan: 3 },
  13386. createElement("div", { className: 'fc-list-day-cushion ' + theme.getClass('tableCellShaded'), ref: innerElRef }, innerContent)))); }));
  13387. };
  13388. return ListViewHeaderRow;
  13389. }(BaseComponent));
  13390. function renderInnerContent$4(props) {
  13391. var navLinkAttrs = props.navLinkData // is there a type for this?
  13392. ? { 'data-navlink': props.navLinkData, tabIndex: 0 }
  13393. : {};
  13394. return (createElement(Fragment, null,
  13395. props.text && (createElement("a", __assign({ className: "fc-list-day-text" }, navLinkAttrs), props.text)),
  13396. props.sideText && (createElement("a", __assign({ className: "fc-list-day-side-text" }, navLinkAttrs), props.sideText))));
  13397. }
  13398. var DEFAULT_TIME_FORMAT$1 = createFormatter({
  13399. hour: 'numeric',
  13400. minute: '2-digit',
  13401. meridiem: 'short',
  13402. });
  13403. var ListViewEventRow = /** @class */ (function (_super) {
  13404. __extends(ListViewEventRow, _super);
  13405. function ListViewEventRow() {
  13406. return _super !== null && _super.apply(this, arguments) || this;
  13407. }
  13408. ListViewEventRow.prototype.render = function () {
  13409. var _a = this, props = _a.props, context = _a.context;
  13410. var seg = props.seg;
  13411. var timeFormat = context.options.eventTimeFormat || DEFAULT_TIME_FORMAT$1;
  13412. return (createElement(EventRoot, { seg: seg, timeText: "" // BAD. because of all-day content
  13413. , 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 },
  13414. buildTimeContent(seg, timeFormat, context),
  13415. createElement("td", { className: "fc-list-event-graphic" },
  13416. createElement("span", { className: "fc-list-event-dot", style: { borderColor: hookProps.borderColor || hookProps.backgroundColor } })),
  13417. createElement("td", { className: "fc-list-event-title", ref: innerElRef }, innerContent))); }));
  13418. };
  13419. return ListViewEventRow;
  13420. }(BaseComponent));
  13421. function renderEventInnerContent(props) {
  13422. var event = props.event;
  13423. var url = event.url;
  13424. var anchorAttrs = url ? { href: url } : {};
  13425. return (createElement("a", __assign({}, anchorAttrs), event.title));
  13426. }
  13427. function buildTimeContent(seg, timeFormat, context) {
  13428. var options = context.options;
  13429. if (options.displayEventTime !== false) {
  13430. var eventDef = seg.eventRange.def;
  13431. var eventInstance = seg.eventRange.instance;
  13432. var doAllDay = false;
  13433. var timeText = void 0;
  13434. if (eventDef.allDay) {
  13435. doAllDay = true;
  13436. }
  13437. else if (isMultiDayRange(seg.eventRange.range)) { // TODO: use (!isStart || !isEnd) instead?
  13438. if (seg.isStart) {
  13439. timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
  13440. }
  13441. else if (seg.isEnd) {
  13442. timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
  13443. }
  13444. else {
  13445. doAllDay = true;
  13446. }
  13447. }
  13448. else {
  13449. timeText = buildSegTimeText(seg, timeFormat, context);
  13450. }
  13451. if (doAllDay) {
  13452. var hookProps = {
  13453. text: context.options.allDayText,
  13454. view: context.viewApi,
  13455. };
  13456. 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)); }));
  13457. }
  13458. return (createElement("td", { className: "fc-list-event-time" }, timeText));
  13459. }
  13460. return null;
  13461. }
  13462. function renderAllDayInner$1(hookProps) {
  13463. return hookProps.text;
  13464. }
  13465. /*
  13466. Responsible for the scroller, and forwarding event-related actions into the "grid".
  13467. */
  13468. var ListView = /** @class */ (function (_super) {
  13469. __extends(ListView, _super);
  13470. function ListView() {
  13471. var _this = _super !== null && _super.apply(this, arguments) || this;
  13472. _this.computeDateVars = memoize(computeDateVars);
  13473. _this.eventStoreToSegs = memoize(_this._eventStoreToSegs);
  13474. _this.setRootEl = function (rootEl) {
  13475. if (rootEl) {
  13476. _this.context.registerInteractiveComponent(_this, {
  13477. el: rootEl,
  13478. });
  13479. }
  13480. else {
  13481. _this.context.unregisterInteractiveComponent(_this);
  13482. }
  13483. };
  13484. return _this;
  13485. }
  13486. ListView.prototype.render = function () {
  13487. var _this = this;
  13488. var _a = this, props = _a.props, context = _a.context;
  13489. var extraClassNames = [
  13490. 'fc-list',
  13491. context.theme.getClass('table'),
  13492. context.options.stickyHeaderDates !== false ? 'fc-list-sticky' : '',
  13493. ];
  13494. var _b = this.computeDateVars(props.dateProfile), dayDates = _b.dayDates, dayRanges = _b.dayRanges;
  13495. var eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
  13496. return (createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.setRootEl }, function (rootElRef, classNames) { return (createElement("div", { ref: rootElRef, className: extraClassNames.concat(classNames).join(' ') },
  13497. createElement(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? 'visible' : 'hidden', overflowY: props.isHeightAuto ? 'visible' : 'auto' }, eventSegs.length > 0 ?
  13498. _this.renderSegList(eventSegs, dayDates) :
  13499. _this.renderEmptyMessage()))); }));
  13500. };
  13501. ListView.prototype.renderEmptyMessage = function () {
  13502. var _a = this.context, options = _a.options, viewApi = _a.viewApi;
  13503. var hookProps = {
  13504. text: options.noEventsText,
  13505. view: viewApi,
  13506. };
  13507. 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 },
  13508. createElement("div", { className: "fc-list-empty-cushion", ref: innerElRef }, innerContent))); }));
  13509. };
  13510. ListView.prototype.renderSegList = function (allSegs, dayDates) {
  13511. var _a = this.context, theme = _a.theme, options = _a.options;
  13512. var segsByDay = groupSegsByDay(allSegs); // sparse array
  13513. return (createElement(NowTimer, { unit: "day" }, function (nowDate, todayRange) {
  13514. var innerNodes = [];
  13515. for (var dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
  13516. var daySegs = segsByDay[dayIndex];
  13517. if (daySegs) { // sparse array, so might be undefined
  13518. var dayStr = dayDates[dayIndex].toISOString();
  13519. // append a day header
  13520. innerNodes.push(createElement(ListViewHeaderRow, { key: dayStr, dayDate: dayDates[dayIndex], todayRange: todayRange }));
  13521. daySegs = sortEventSegs(daySegs, options.eventOrder);
  13522. for (var _i = 0, daySegs_1 = daySegs; _i < daySegs_1.length; _i++) {
  13523. var seg = daySegs_1[_i];
  13524. 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))));
  13525. }
  13526. }
  13527. }
  13528. return (createElement("table", { className: 'fc-list-table ' + theme.getClass('table') },
  13529. createElement("tbody", null, innerNodes)));
  13530. }));
  13531. };
  13532. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  13533. return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
  13534. };
  13535. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  13536. var segs = [];
  13537. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  13538. var eventRange = eventRanges_1[_i];
  13539. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  13540. }
  13541. return segs;
  13542. };
  13543. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  13544. var dateEnv = this.context.dateEnv;
  13545. var nextDayThreshold = this.context.options.nextDayThreshold;
  13546. var range = eventRange.range;
  13547. var allDay = eventRange.def.allDay;
  13548. var dayIndex;
  13549. var segRange;
  13550. var seg;
  13551. var segs = [];
  13552. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
  13553. segRange = intersectRanges(range, dayRanges[dayIndex]);
  13554. if (segRange) {
  13555. seg = {
  13556. component: this,
  13557. eventRange: eventRange,
  13558. start: segRange.start,
  13559. end: segRange.end,
  13560. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  13561. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  13562. dayIndex: dayIndex,
  13563. };
  13564. segs.push(seg);
  13565. // detect when range won't go fully into the next day,
  13566. // and mutate the latest seg to the be the end.
  13567. if (!seg.isEnd && !allDay &&
  13568. dayIndex + 1 < dayRanges.length &&
  13569. range.end <
  13570. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  13571. seg.end = range.end;
  13572. seg.isEnd = true;
  13573. break;
  13574. }
  13575. }
  13576. }
  13577. return segs;
  13578. };
  13579. return ListView;
  13580. }(DateComponent));
  13581. function renderNoEventsInner(hookProps) {
  13582. return hookProps.text;
  13583. }
  13584. function computeDateVars(dateProfile) {
  13585. var dayStart = startOfDay(dateProfile.renderRange.start);
  13586. var viewEnd = dateProfile.renderRange.end;
  13587. var dayDates = [];
  13588. var dayRanges = [];
  13589. while (dayStart < viewEnd) {
  13590. dayDates.push(dayStart);
  13591. dayRanges.push({
  13592. start: dayStart,
  13593. end: addDays(dayStart, 1),
  13594. });
  13595. dayStart = addDays(dayStart, 1);
  13596. }
  13597. return { dayDates: dayDates, dayRanges: dayRanges };
  13598. }
  13599. // Returns a sparse array of arrays, segs grouped by their dayIndex
  13600. function groupSegsByDay(segs) {
  13601. var segsByDay = []; // sparse array
  13602. var i;
  13603. var seg;
  13604. for (i = 0; i < segs.length; i += 1) {
  13605. seg = segs[i];
  13606. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  13607. .push(seg);
  13608. }
  13609. return segsByDay;
  13610. }
  13611. var OPTION_REFINERS$3 = {
  13612. listDayFormat: createFalsableFormatter,
  13613. listDaySideFormat: createFalsableFormatter,
  13614. noEventsClassNames: identity,
  13615. noEventsContent: identity,
  13616. noEventsDidMount: identity,
  13617. noEventsWillUnmount: identity,
  13618. };
  13619. function createFalsableFormatter(input) {
  13620. return input === false ? null : createFormatter(input);
  13621. }
  13622. var listPlugin = createPlugin({
  13623. optionRefiners: OPTION_REFINERS$3,
  13624. views: {
  13625. list: {
  13626. component: ListView,
  13627. buttonTextKey: 'list',
  13628. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  13629. },
  13630. listDay: {
  13631. type: 'list',
  13632. duration: { days: 1 },
  13633. listDayFormat: { weekday: 'long' },
  13634. },
  13635. listWeek: {
  13636. type: 'list',
  13637. duration: { weeks: 1 },
  13638. listDayFormat: { weekday: 'long' },
  13639. listDaySideFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  13640. },
  13641. listMonth: {
  13642. type: 'list',
  13643. duration: { month: 1 },
  13644. listDaySideFormat: { weekday: 'long' },
  13645. },
  13646. listYear: {
  13647. type: 'list',
  13648. duration: { year: 1 },
  13649. listDaySideFormat: { weekday: 'long' },
  13650. },
  13651. },
  13652. });
  13653. var BootstrapTheme = /** @class */ (function (_super) {
  13654. __extends(BootstrapTheme, _super);
  13655. function BootstrapTheme() {
  13656. return _super !== null && _super.apply(this, arguments) || this;
  13657. }
  13658. return BootstrapTheme;
  13659. }(Theme));
  13660. BootstrapTheme.prototype.classes = {
  13661. root: 'fc-theme-bootstrap',
  13662. table: 'table-bordered',
  13663. tableCellShaded: 'table-active',
  13664. buttonGroup: 'btn-group',
  13665. button: 'btn btn-primary',
  13666. buttonActive: 'active',
  13667. popover: 'popover',
  13668. popoverHeader: 'popover-header',
  13669. popoverContent: 'popover-body',
  13670. };
  13671. BootstrapTheme.prototype.baseIconClass = 'fa';
  13672. BootstrapTheme.prototype.iconClasses = {
  13673. close: 'fa-times',
  13674. prev: 'fa-chevron-left',
  13675. next: 'fa-chevron-right',
  13676. prevYear: 'fa-angle-double-left',
  13677. nextYear: 'fa-angle-double-right',
  13678. };
  13679. BootstrapTheme.prototype.rtlIconClasses = {
  13680. prev: 'fa-chevron-right',
  13681. next: 'fa-chevron-left',
  13682. prevYear: 'fa-angle-double-right',
  13683. nextYear: 'fa-angle-double-left',
  13684. };
  13685. BootstrapTheme.prototype.iconOverrideOption = 'bootstrapFontAwesome'; // TODO: make TS-friendly. move the option-processing into this plugin
  13686. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  13687. BootstrapTheme.prototype.iconOverridePrefix = 'fa-';
  13688. var plugin = createPlugin({
  13689. themeClasses: {
  13690. bootstrap: BootstrapTheme,
  13691. },
  13692. });
  13693. // rename this file to options.ts like other packages?
  13694. var OPTION_REFINERS$4 = {
  13695. googleCalendarApiKey: String,
  13696. };
  13697. var EVENT_SOURCE_REFINERS$1 = {
  13698. googleCalendarApiKey: String,
  13699. googleCalendarId: String,
  13700. googleCalendarApiBase: String,
  13701. extraParams: identity,
  13702. };
  13703. // TODO: expose somehow
  13704. var API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
  13705. var eventSourceDef$3 = {
  13706. parseMeta: function (refined) {
  13707. var googleCalendarId = refined.googleCalendarId;
  13708. if (!googleCalendarId && refined.url) {
  13709. googleCalendarId = parseGoogleCalendarId(refined.url);
  13710. }
  13711. if (googleCalendarId) {
  13712. return {
  13713. googleCalendarId: googleCalendarId,
  13714. googleCalendarApiKey: refined.googleCalendarApiKey,
  13715. googleCalendarApiBase: refined.googleCalendarApiBase,
  13716. extraParams: refined.extraParams,
  13717. };
  13718. }
  13719. return null;
  13720. },
  13721. fetch: function (arg, onSuccess, onFailure) {
  13722. var _a = arg.context, dateEnv = _a.dateEnv, options = _a.options;
  13723. var meta = arg.eventSource.meta;
  13724. var apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
  13725. if (!apiKey) {
  13726. onFailure({
  13727. message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
  13728. });
  13729. }
  13730. else {
  13731. var url = buildUrl(meta);
  13732. // TODO: make DRY with json-feed-event-source
  13733. var extraParams = meta.extraParams;
  13734. var extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
  13735. var requestParams_1 = buildRequestParams$1(arg.range, apiKey, extraParamsObj, dateEnv);
  13736. requestJson('GET', url, requestParams_1, function (body, xhr) {
  13737. if (body.error) {
  13738. onFailure({
  13739. message: 'Google Calendar API: ' + body.error.message,
  13740. errors: body.error.errors,
  13741. xhr: xhr,
  13742. });
  13743. }
  13744. else {
  13745. onSuccess({
  13746. rawEvents: gcalItemsToRawEventDefs(body.items, requestParams_1.timeZone),
  13747. xhr: xhr,
  13748. });
  13749. }
  13750. }, function (message, xhr) {
  13751. onFailure({ message: message, xhr: xhr });
  13752. });
  13753. }
  13754. },
  13755. };
  13756. function parseGoogleCalendarId(url) {
  13757. var match;
  13758. // detect if the ID was specified as a single string.
  13759. // will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
  13760. if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
  13761. return url;
  13762. }
  13763. if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) ||
  13764. (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
  13765. return decodeURIComponent(match[1]);
  13766. }
  13767. return null;
  13768. }
  13769. function buildUrl(meta) {
  13770. var apiBase = meta.googleCalendarApiBase;
  13771. if (!apiBase) {
  13772. apiBase = API_BASE;
  13773. }
  13774. return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events';
  13775. }
  13776. function buildRequestParams$1(range, apiKey, extraParams, dateEnv) {
  13777. var params;
  13778. var startStr;
  13779. var endStr;
  13780. if (dateEnv.canComputeOffset) {
  13781. // strings will naturally have offsets, which GCal needs
  13782. startStr = dateEnv.formatIso(range.start);
  13783. endStr = dateEnv.formatIso(range.end);
  13784. }
  13785. else {
  13786. // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
  13787. // from the UTC day-start to guarantee we're getting all the events
  13788. // (start/end will be UTC-coerced dates, so toISOString is okay)
  13789. startStr = addDays(range.start, -1).toISOString();
  13790. endStr = addDays(range.end, 1).toISOString();
  13791. }
  13792. params = __assign(__assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
  13793. if (dateEnv.timeZone !== 'local') {
  13794. params.timeZone = dateEnv.timeZone;
  13795. }
  13796. return params;
  13797. }
  13798. function gcalItemsToRawEventDefs(items, gcalTimezone) {
  13799. return items.map(function (item) { return gcalItemToRawEventDef(item, gcalTimezone); });
  13800. }
  13801. function gcalItemToRawEventDef(item, gcalTimezone) {
  13802. var url = item.htmlLink || null;
  13803. // make the URLs for each event show times in the correct timezone
  13804. if (url && gcalTimezone) {
  13805. url = injectQsComponent(url, 'ctz=' + gcalTimezone);
  13806. }
  13807. return {
  13808. id: item.id,
  13809. title: item.summary,
  13810. start: item.start.dateTime || item.start.date,
  13811. end: item.end.dateTime || item.end.date,
  13812. url: url,
  13813. location: item.location,
  13814. description: item.description,
  13815. };
  13816. }
  13817. // Injects a string like "arg=value" into the querystring of a URL
  13818. // TODO: move to a general util file?
  13819. function injectQsComponent(url, component) {
  13820. // inject it after the querystring but before the fragment
  13821. return url.replace(/(\?.*?)?(#|$)/, function (whole, qs, hash) { return (qs ? qs + '&' : '?') + component + hash; });
  13822. }
  13823. var googleCalendarPlugin = createPlugin({
  13824. eventSourceDefs: [eventSourceDef$3],
  13825. optionRefiners: OPTION_REFINERS$4,
  13826. eventSourceRefiners: EVENT_SOURCE_REFINERS$1,
  13827. });
  13828. globalPlugins.push(interactionPlugin, dayGridPlugin, timeGridPlugin, listPlugin, plugin, googleCalendarPlugin);
  13829. exports.BASE_OPTION_DEFAULTS = BASE_OPTION_DEFAULTS;
  13830. exports.BASE_OPTION_REFINERS = BASE_OPTION_REFINERS;
  13831. exports.BaseComponent = BaseComponent;
  13832. exports.BgEvent = BgEvent;
  13833. exports.BootstrapTheme = BootstrapTheme;
  13834. exports.Calendar = Calendar;
  13835. exports.CalendarApi = CalendarApi;
  13836. exports.CalendarContent = CalendarContent;
  13837. exports.CalendarDataManager = CalendarDataManager;
  13838. exports.CalendarDataProvider = CalendarDataProvider;
  13839. exports.CalendarRoot = CalendarRoot;
  13840. exports.Component = Component;
  13841. exports.ContentHook = ContentHook;
  13842. exports.CustomContentRenderContext = CustomContentRenderContext;
  13843. exports.DateComponent = DateComponent;
  13844. exports.DateEnv = DateEnv;
  13845. exports.DateProfileGenerator = DateProfileGenerator;
  13846. exports.DayCellContent = DayCellContent;
  13847. exports.DayCellRoot = DayCellRoot;
  13848. exports.DayGridView = DayTableView;
  13849. exports.DayHeader = DayHeader;
  13850. exports.DaySeriesModel = DaySeriesModel;
  13851. exports.DayTable = DayTable;
  13852. exports.DayTableModel = DayTableModel;
  13853. exports.DayTableSlicer = DayTableSlicer;
  13854. exports.DayTimeCols = DayTimeCols;
  13855. exports.DayTimeColsSlicer = DayTimeColsSlicer;
  13856. exports.DayTimeColsView = DayTimeColsView;
  13857. exports.DelayedRunner = DelayedRunner;
  13858. exports.Draggable = ExternalDraggable;
  13859. exports.ElementDragging = ElementDragging;
  13860. exports.ElementScrollController = ElementScrollController;
  13861. exports.Emitter = Emitter;
  13862. exports.EventApi = EventApi;
  13863. exports.EventRoot = EventRoot;
  13864. exports.EventSourceApi = EventSourceApi;
  13865. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  13866. exports.Fragment = Fragment;
  13867. exports.Interaction = Interaction;
  13868. exports.ListView = ListView;
  13869. exports.MountHook = MountHook;
  13870. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  13871. exports.NowIndicatorRoot = NowIndicatorRoot;
  13872. exports.NowTimer = NowTimer;
  13873. exports.PointerDragging = PointerDragging;
  13874. exports.PositionCache = PositionCache;
  13875. exports.RefMap = RefMap;
  13876. exports.RenderHook = RenderHook;
  13877. exports.ScrollController = ScrollController;
  13878. exports.ScrollResponder = ScrollResponder;
  13879. exports.Scroller = Scroller;
  13880. exports.SimpleScrollGrid = SimpleScrollGrid;
  13881. exports.Slicer = Slicer;
  13882. exports.Splitter = Splitter;
  13883. exports.StandardEvent = StandardEvent;
  13884. exports.Table = Table;
  13885. exports.TableDateCell = TableDateCell;
  13886. exports.TableDowCell = TableDowCell;
  13887. exports.TableView = TableView;
  13888. exports.Theme = Theme;
  13889. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  13890. exports.TimeCols = TimeCols;
  13891. exports.TimeColsSlatsCoords = TimeColsSlatsCoords;
  13892. exports.TimeColsView = TimeColsView;
  13893. exports.ViewApi = ViewApi;
  13894. exports.ViewContextType = ViewContextType;
  13895. exports.ViewRoot = ViewRoot;
  13896. exports.WeekNumberRoot = WeekNumberRoot;
  13897. exports.WindowScrollController = WindowScrollController;
  13898. exports.addDays = addDays;
  13899. exports.addDurations = addDurations;
  13900. exports.addMs = addMs;
  13901. exports.addWeeks = addWeeks;
  13902. exports.allowContextMenu = allowContextMenu;
  13903. exports.allowSelection = allowSelection;
  13904. exports.applyMutationToEventStore = applyMutationToEventStore;
  13905. exports.applyStyle = applyStyle;
  13906. exports.applyStyleProp = applyStyleProp;
  13907. exports.asCleanDays = asCleanDays;
  13908. exports.asRoughMinutes = asRoughMinutes;
  13909. exports.asRoughMs = asRoughMs;
  13910. exports.asRoughSeconds = asRoughSeconds;
  13911. exports.buildClassNameNormalizer = buildClassNameNormalizer;
  13912. exports.buildDayRanges = buildDayRanges;
  13913. exports.buildDayTableModel = buildDayTableModel;
  13914. exports.buildEventApis = buildEventApis;
  13915. exports.buildEventRangeKey = buildEventRangeKey;
  13916. exports.buildHashFromArray = buildHashFromArray;
  13917. exports.buildNavLinkData = buildNavLinkData;
  13918. exports.buildSegCompareObj = buildSegCompareObj;
  13919. exports.buildSegTimeText = buildSegTimeText;
  13920. exports.buildSlatMetas = buildSlatMetas;
  13921. exports.buildTimeColsModel = buildTimeColsModel;
  13922. exports.collectFromHash = collectFromHash;
  13923. exports.combineEventUis = combineEventUis;
  13924. exports.compareByFieldSpec = compareByFieldSpec;
  13925. exports.compareByFieldSpecs = compareByFieldSpecs;
  13926. exports.compareNumbers = compareNumbers;
  13927. exports.compareObjs = compareObjs;
  13928. exports.computeEdges = computeEdges;
  13929. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  13930. exports.computeHeightAndMargins = computeHeightAndMargins;
  13931. exports.computeInnerRect = computeInnerRect;
  13932. exports.computeRect = computeRect;
  13933. exports.computeSegDraggable = computeSegDraggable;
  13934. exports.computeSegEndResizable = computeSegEndResizable;
  13935. exports.computeSegStartResizable = computeSegStartResizable;
  13936. exports.computeShrinkWidth = computeShrinkWidth;
  13937. exports.computeSmallestCellWidth = computeSmallestCellWidth;
  13938. exports.computeVisibleDayRange = computeVisibleDayRange;
  13939. exports.config = config;
  13940. exports.constrainPoint = constrainPoint;
  13941. exports.createContext = createContext$1;
  13942. exports.createDuration = createDuration;
  13943. exports.createElement = createElement;
  13944. exports.createEmptyEventStore = createEmptyEventStore;
  13945. exports.createEventInstance = createEventInstance;
  13946. exports.createEventUi = createEventUi;
  13947. exports.createFormatter = createFormatter;
  13948. exports.createPlugin = createPlugin;
  13949. exports.createRef = createRef;
  13950. exports.diffDates = diffDates;
  13951. exports.diffDayAndTime = diffDayAndTime;
  13952. exports.diffDays = diffDays;
  13953. exports.diffPoints = diffPoints;
  13954. exports.diffWeeks = diffWeeks;
  13955. exports.diffWholeDays = diffWholeDays;
  13956. exports.diffWholeWeeks = diffWholeWeeks;
  13957. exports.disableCursor = disableCursor;
  13958. exports.elementClosest = elementClosest;
  13959. exports.elementMatches = elementMatches;
  13960. exports.enableCursor = enableCursor;
  13961. exports.eventTupleToStore = eventTupleToStore;
  13962. exports.filterEventStoreDefs = filterEventStoreDefs;
  13963. exports.filterHash = filterHash;
  13964. exports.findDirectChildren = findDirectChildren;
  13965. exports.findElements = findElements;
  13966. exports.flexibleCompare = flexibleCompare;
  13967. exports.flushToDom = flushToDom$1;
  13968. exports.formatDate = formatDate;
  13969. exports.formatDayString = formatDayString;
  13970. exports.formatIsoTimeString = formatIsoTimeString;
  13971. exports.formatRange = formatRange;
  13972. exports.getAllowYScrolling = getAllowYScrolling;
  13973. exports.getCanVGrowWithinCell = getCanVGrowWithinCell;
  13974. exports.getClippingParents = getClippingParents;
  13975. exports.getDateMeta = getDateMeta;
  13976. exports.getDayClassNames = getDayClassNames;
  13977. exports.getDefaultEventEnd = getDefaultEventEnd;
  13978. exports.getElSeg = getElSeg;
  13979. exports.getEventClassNames = getEventClassNames;
  13980. exports.getIsRtlScrollbarOnLeft = getIsRtlScrollbarOnLeft;
  13981. exports.getRectCenter = getRectCenter;
  13982. exports.getRelevantEvents = getRelevantEvents;
  13983. exports.getScrollGridClassNames = getScrollGridClassNames;
  13984. exports.getScrollbarWidths = getScrollbarWidths;
  13985. exports.getSectionClassNames = getSectionClassNames;
  13986. exports.getSectionHasLiquidHeight = getSectionHasLiquidHeight;
  13987. exports.getSegMeta = getSegMeta;
  13988. exports.getSlotClassNames = getSlotClassNames;
  13989. exports.getStickyFooterScrollbar = getStickyFooterScrollbar;
  13990. exports.getStickyHeaderDates = getStickyHeaderDates;
  13991. exports.getUnequalProps = getUnequalProps;
  13992. exports.globalLocales = globalLocales;
  13993. exports.globalPlugins = globalPlugins;
  13994. exports.greatestDurationDenominator = greatestDurationDenominator;
  13995. exports.guid = guid;
  13996. exports.hasBgRendering = hasBgRendering;
  13997. exports.hasShrinkWidth = hasShrinkWidth;
  13998. exports.identity = identity;
  13999. exports.interactionSettingsStore = interactionSettingsStore;
  14000. exports.interactionSettingsToStore = interactionSettingsToStore;
  14001. exports.intersectRanges = intersectRanges;
  14002. exports.intersectRects = intersectRects;
  14003. exports.isArraysEqual = isArraysEqual;
  14004. exports.isColPropsEqual = isColPropsEqual;
  14005. exports.isDateSpansEqual = isDateSpansEqual;
  14006. exports.isInt = isInt;
  14007. exports.isInteractionValid = isInteractionValid;
  14008. exports.isMultiDayRange = isMultiDayRange;
  14009. exports.isPropsEqual = isPropsEqual;
  14010. exports.isPropsValid = isPropsValid;
  14011. exports.isValidDate = isValidDate;
  14012. exports.listenBySelector = listenBySelector;
  14013. exports.mapHash = mapHash;
  14014. exports.memoize = memoize;
  14015. exports.memoizeArraylike = memoizeArraylike;
  14016. exports.memoizeHashlike = memoizeHashlike;
  14017. exports.memoizeObjArg = memoizeObjArg;
  14018. exports.mergeEventStores = mergeEventStores;
  14019. exports.multiplyDuration = multiplyDuration;
  14020. exports.padStart = padStart;
  14021. exports.parseBusinessHours = parseBusinessHours;
  14022. exports.parseClassNames = parseClassNames;
  14023. exports.parseDragMeta = parseDragMeta;
  14024. exports.parseEventDef = parseEventDef;
  14025. exports.parseFieldSpecs = parseFieldSpecs;
  14026. exports.parseMarker = parse;
  14027. exports.pointInsideRect = pointInsideRect;
  14028. exports.preventContextMenu = preventContextMenu;
  14029. exports.preventDefault = preventDefault;
  14030. exports.preventSelection = preventSelection;
  14031. exports.rangeContainsMarker = rangeContainsMarker;
  14032. exports.rangeContainsRange = rangeContainsRange;
  14033. exports.rangesEqual = rangesEqual;
  14034. exports.rangesIntersect = rangesIntersect;
  14035. exports.refineEventDef = refineEventDef;
  14036. exports.refineProps = refineProps;
  14037. exports.removeElement = removeElement;
  14038. exports.removeExact = removeExact;
  14039. exports.render = render;
  14040. exports.renderChunkContent = renderChunkContent;
  14041. exports.renderFill = renderFill;
  14042. exports.renderMicroColGroup = renderMicroColGroup;
  14043. exports.renderScrollShim = renderScrollShim;
  14044. exports.requestJson = requestJson;
  14045. exports.sanitizeShrinkWidth = sanitizeShrinkWidth;
  14046. exports.setElSeg = setElSeg;
  14047. exports.setRef = setRef;
  14048. exports.sliceEventStore = sliceEventStore;
  14049. exports.sliceEvents = sliceEvents;
  14050. exports.sortEventSegs = sortEventSegs;
  14051. exports.startOfDay = startOfDay;
  14052. exports.translateRect = translateRect;
  14053. exports.triggerDateSelect = triggerDateSelect;
  14054. exports.unmountComponentAtNode = unmountComponentAtNode$1;
  14055. exports.unpromisify = unpromisify;
  14056. exports.version = version;
  14057. exports.whenTransitionDone = whenTransitionDone;
  14058. exports.wholeDivideDurations = wholeDivideDurations;
  14059. Object.defineProperty(exports, '__esModule', { value: true });
  14060. return exports;
  14061. }({}));