fullcalendar.bundle.js 628 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296
  1. /*!
  2. FullCalendar Core Package v4.3.1
  3. Docs & License: https://fullcalendar.io/
  4. (c) 2019 Adam Shaw
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  8. typeof define === 'function' && define.amd ? define(['exports'], factory) :
  9. (global = global || self, factory(global.FullCalendar = {}));
  10. }(this, function (exports) { 'use strict';
  11. // Creating
  12. // ----------------------------------------------------------------------------------------------------------------
  13. var elementPropHash = {
  14. className: true,
  15. colSpan: true,
  16. rowSpan: true
  17. };
  18. var containerTagHash = {
  19. '<tr': 'tbody',
  20. '<td': 'tr'
  21. };
  22. function createElement(tagName, attrs, content) {
  23. var el = document.createElement(tagName);
  24. if (attrs) {
  25. for (var attrName in attrs) {
  26. if (attrName === 'style') {
  27. applyStyle(el, attrs[attrName]);
  28. }
  29. else if (elementPropHash[attrName]) {
  30. el[attrName] = attrs[attrName];
  31. }
  32. else {
  33. el.setAttribute(attrName, attrs[attrName]);
  34. }
  35. }
  36. }
  37. if (typeof content === 'string') {
  38. el.innerHTML = content; // shortcut. no need to process HTML in any way
  39. }
  40. else if (content != null) {
  41. appendToElement(el, content);
  42. }
  43. return el;
  44. }
  45. function htmlToElement(html) {
  46. html = html.trim();
  47. var container = document.createElement(computeContainerTag(html));
  48. container.innerHTML = html;
  49. return container.firstChild;
  50. }
  51. function htmlToElements(html) {
  52. return Array.prototype.slice.call(htmlToNodeList(html));
  53. }
  54. function htmlToNodeList(html) {
  55. html = html.trim();
  56. var container = document.createElement(computeContainerTag(html));
  57. container.innerHTML = html;
  58. return container.childNodes;
  59. }
  60. // assumes html already trimmed and tag names are lowercase
  61. function computeContainerTag(html) {
  62. return containerTagHash[html.substr(0, 3) // faster than using regex
  63. ] || 'div';
  64. }
  65. function appendToElement(el, content) {
  66. var childNodes = normalizeContent(content);
  67. for (var i = 0; i < childNodes.length; i++) {
  68. el.appendChild(childNodes[i]);
  69. }
  70. }
  71. function prependToElement(parent, content) {
  72. var newEls = normalizeContent(content);
  73. var afterEl = parent.firstChild || null; // if no firstChild, will append to end, but that's okay, b/c there were no children
  74. for (var i = 0; i < newEls.length; i++) {
  75. parent.insertBefore(newEls[i], afterEl);
  76. }
  77. }
  78. function insertAfterElement(refEl, content) {
  79. var newEls = normalizeContent(content);
  80. var afterEl = refEl.nextSibling || null;
  81. for (var i = 0; i < newEls.length; i++) {
  82. refEl.parentNode.insertBefore(newEls[i], afterEl);
  83. }
  84. }
  85. function normalizeContent(content) {
  86. var els;
  87. if (typeof content === 'string') {
  88. els = htmlToElements(content);
  89. }
  90. else if (content instanceof Node) {
  91. els = [content];
  92. }
  93. else { // Node[] or NodeList
  94. els = Array.prototype.slice.call(content);
  95. }
  96. return els;
  97. }
  98. function removeElement(el) {
  99. if (el.parentNode) {
  100. el.parentNode.removeChild(el);
  101. }
  102. }
  103. // Querying
  104. // ----------------------------------------------------------------------------------------------------------------
  105. // from https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
  106. var matchesMethod = Element.prototype.matches ||
  107. Element.prototype.matchesSelector ||
  108. Element.prototype.msMatchesSelector;
  109. var closestMethod = Element.prototype.closest || function (selector) {
  110. // polyfill
  111. var el = this;
  112. if (!document.documentElement.contains(el)) {
  113. return null;
  114. }
  115. do {
  116. if (elementMatches(el, selector)) {
  117. return el;
  118. }
  119. el = el.parentElement || el.parentNode;
  120. } while (el !== null && el.nodeType === 1);
  121. return null;
  122. };
  123. function elementClosest(el, selector) {
  124. return closestMethod.call(el, selector);
  125. }
  126. function elementMatches(el, selector) {
  127. return matchesMethod.call(el, selector);
  128. }
  129. // accepts multiple subject els
  130. // returns a real array. good for methods like forEach
  131. function findElements(container, selector) {
  132. var containers = container instanceof HTMLElement ? [container] : container;
  133. var allMatches = [];
  134. for (var i = 0; i < containers.length; i++) {
  135. var matches = containers[i].querySelectorAll(selector);
  136. for (var j = 0; j < matches.length; j++) {
  137. allMatches.push(matches[j]);
  138. }
  139. }
  140. return allMatches;
  141. }
  142. // accepts multiple subject els
  143. // only queries direct child elements
  144. function findChildren(parent, selector) {
  145. var parents = parent instanceof HTMLElement ? [parent] : parent;
  146. var allMatches = [];
  147. for (var i = 0; i < parents.length; i++) {
  148. var childNodes = parents[i].children; // only ever elements
  149. for (var j = 0; j < childNodes.length; j++) {
  150. var childNode = childNodes[j];
  151. if (!selector || elementMatches(childNode, selector)) {
  152. allMatches.push(childNode);
  153. }
  154. }
  155. }
  156. return allMatches;
  157. }
  158. // Attributes
  159. // ----------------------------------------------------------------------------------------------------------------
  160. function forceClassName(el, className, bool) {
  161. if (bool) {
  162. el.classList.add(className);
  163. }
  164. else {
  165. el.classList.remove(className);
  166. }
  167. }
  168. // Style
  169. // ----------------------------------------------------------------------------------------------------------------
  170. var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
  171. function applyStyle(el, props) {
  172. for (var propName in props) {
  173. applyStyleProp(el, propName, props[propName]);
  174. }
  175. }
  176. function applyStyleProp(el, name, val) {
  177. if (val == null) {
  178. el.style[name] = '';
  179. }
  180. else if (typeof val === 'number' && PIXEL_PROP_RE.test(name)) {
  181. el.style[name] = val + 'px';
  182. }
  183. else {
  184. el.style[name] = val;
  185. }
  186. }
  187. function pointInsideRect(point, rect) {
  188. return point.left >= rect.left &&
  189. point.left < rect.right &&
  190. point.top >= rect.top &&
  191. point.top < rect.bottom;
  192. }
  193. // Returns a new rectangle that is the intersection of the two rectangles. If they don't intersect, returns false
  194. function intersectRects(rect1, rect2) {
  195. var res = {
  196. left: Math.max(rect1.left, rect2.left),
  197. right: Math.min(rect1.right, rect2.right),
  198. top: Math.max(rect1.top, rect2.top),
  199. bottom: Math.min(rect1.bottom, rect2.bottom)
  200. };
  201. if (res.left < res.right && res.top < res.bottom) {
  202. return res;
  203. }
  204. return false;
  205. }
  206. function translateRect(rect, deltaX, deltaY) {
  207. return {
  208. left: rect.left + deltaX,
  209. right: rect.right + deltaX,
  210. top: rect.top + deltaY,
  211. bottom: rect.bottom + deltaY
  212. };
  213. }
  214. // Returns a new point that will have been moved to reside within the given rectangle
  215. function constrainPoint(point, rect) {
  216. return {
  217. left: Math.min(Math.max(point.left, rect.left), rect.right),
  218. top: Math.min(Math.max(point.top, rect.top), rect.bottom)
  219. };
  220. }
  221. // Returns a point that is the center of the given rectangle
  222. function getRectCenter(rect) {
  223. return {
  224. left: (rect.left + rect.right) / 2,
  225. top: (rect.top + rect.bottom) / 2
  226. };
  227. }
  228. // Subtracts point2's coordinates from point1's coordinates, returning a delta
  229. function diffPoints(point1, point2) {
  230. return {
  231. left: point1.left - point2.left,
  232. top: point1.top - point2.top
  233. };
  234. }
  235. // Logic for determining if, when the element is right-to-left, the scrollbar appears on the left side
  236. var isRtlScrollbarOnLeft = null;
  237. function getIsRtlScrollbarOnLeft() {
  238. if (isRtlScrollbarOnLeft === null) {
  239. isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
  240. }
  241. return isRtlScrollbarOnLeft;
  242. }
  243. function computeIsRtlScrollbarOnLeft() {
  244. var outerEl = createElement('div', {
  245. style: {
  246. position: 'absolute',
  247. top: -1000,
  248. left: 0,
  249. border: 0,
  250. padding: 0,
  251. overflow: 'scroll',
  252. direction: 'rtl'
  253. }
  254. }, '<div></div>');
  255. document.body.appendChild(outerEl);
  256. var innerEl = outerEl.firstChild;
  257. var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
  258. removeElement(outerEl);
  259. return res;
  260. }
  261. // The scrollbar width computations in computeEdges are sometimes flawed when it comes to
  262. // retina displays, rounding, and IE11. Massage them into a usable value.
  263. function sanitizeScrollbarWidth(width) {
  264. width = Math.max(0, width); // no negatives
  265. width = Math.round(width);
  266. return width;
  267. }
  268. function computeEdges(el, getPadding) {
  269. if (getPadding === void 0) { getPadding = false; }
  270. var computedStyle = window.getComputedStyle(el);
  271. var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
  272. var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
  273. var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
  274. var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
  275. // must use offset(Width|Height) because compatible with client(Width|Height)
  276. var scrollbarLeftRight = sanitizeScrollbarWidth(el.offsetWidth - el.clientWidth - borderLeft - borderRight);
  277. var scrollbarBottom = sanitizeScrollbarWidth(el.offsetHeight - el.clientHeight - borderTop - borderBottom);
  278. var res = {
  279. borderLeft: borderLeft,
  280. borderRight: borderRight,
  281. borderTop: borderTop,
  282. borderBottom: borderBottom,
  283. scrollbarBottom: scrollbarBottom,
  284. scrollbarLeft: 0,
  285. scrollbarRight: 0
  286. };
  287. if (getIsRtlScrollbarOnLeft() && computedStyle.direction === 'rtl') { // is the scrollbar on the left side?
  288. res.scrollbarLeft = scrollbarLeftRight;
  289. }
  290. else {
  291. res.scrollbarRight = scrollbarLeftRight;
  292. }
  293. if (getPadding) {
  294. res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
  295. res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
  296. res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
  297. res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
  298. }
  299. return res;
  300. }
  301. function computeInnerRect(el, goWithinPadding) {
  302. if (goWithinPadding === void 0) { goWithinPadding = false; }
  303. var outerRect = computeRect(el);
  304. var edges = computeEdges(el, goWithinPadding);
  305. var res = {
  306. left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
  307. right: outerRect.right - edges.borderRight - edges.scrollbarRight,
  308. top: outerRect.top + edges.borderTop,
  309. bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom
  310. };
  311. if (goWithinPadding) {
  312. res.left += edges.paddingLeft;
  313. res.right -= edges.paddingRight;
  314. res.top += edges.paddingTop;
  315. res.bottom -= edges.paddingBottom;
  316. }
  317. return res;
  318. }
  319. function computeRect(el) {
  320. var rect = el.getBoundingClientRect();
  321. return {
  322. left: rect.left + window.pageXOffset,
  323. top: rect.top + window.pageYOffset,
  324. right: rect.right + window.pageXOffset,
  325. bottom: rect.bottom + window.pageYOffset
  326. };
  327. }
  328. function computeViewportRect() {
  329. return {
  330. left: window.pageXOffset,
  331. right: window.pageXOffset + document.documentElement.clientWidth,
  332. top: window.pageYOffset,
  333. bottom: window.pageYOffset + document.documentElement.clientHeight
  334. };
  335. }
  336. function computeHeightAndMargins(el) {
  337. return el.getBoundingClientRect().height + computeVMargins(el);
  338. }
  339. function computeVMargins(el) {
  340. var computed = window.getComputedStyle(el);
  341. return parseInt(computed.marginTop, 10) +
  342. parseInt(computed.marginBottom, 10);
  343. }
  344. // does not return window
  345. function getClippingParents(el) {
  346. var parents = [];
  347. while (el instanceof HTMLElement) { // will stop when gets to document or null
  348. var computedStyle = window.getComputedStyle(el);
  349. if (computedStyle.position === 'fixed') {
  350. break;
  351. }
  352. if ((/(auto|scroll)/).test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
  353. parents.push(el);
  354. }
  355. el = el.parentNode;
  356. }
  357. return parents;
  358. }
  359. function computeClippingRect(el) {
  360. return getClippingParents(el)
  361. .map(function (el) {
  362. return computeInnerRect(el);
  363. })
  364. .concat(computeViewportRect())
  365. .reduce(function (rect0, rect1) {
  366. return intersectRects(rect0, rect1) || rect1; // should always intersect
  367. });
  368. }
  369. // Stops a mouse/touch event from doing it's native browser action
  370. function preventDefault(ev) {
  371. ev.preventDefault();
  372. }
  373. // Event Delegation
  374. // ----------------------------------------------------------------------------------------------------------------
  375. function listenBySelector(container, eventType, selector, handler) {
  376. function realHandler(ev) {
  377. var matchedChild = elementClosest(ev.target, selector);
  378. if (matchedChild) {
  379. handler.call(matchedChild, ev, matchedChild);
  380. }
  381. }
  382. container.addEventListener(eventType, realHandler);
  383. return function () {
  384. container.removeEventListener(eventType, realHandler);
  385. };
  386. }
  387. function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
  388. var currentMatchedChild;
  389. return listenBySelector(container, 'mouseover', selector, function (ev, matchedChild) {
  390. if (matchedChild !== currentMatchedChild) {
  391. currentMatchedChild = matchedChild;
  392. onMouseEnter(ev, matchedChild);
  393. var realOnMouseLeave_1 = function (ev) {
  394. currentMatchedChild = null;
  395. onMouseLeave(ev, matchedChild);
  396. matchedChild.removeEventListener('mouseleave', realOnMouseLeave_1);
  397. };
  398. // listen to the next mouseleave, and then unattach
  399. matchedChild.addEventListener('mouseleave', realOnMouseLeave_1);
  400. }
  401. });
  402. }
  403. // Animation
  404. // ----------------------------------------------------------------------------------------------------------------
  405. var transitionEventNames = [
  406. 'webkitTransitionEnd',
  407. 'otransitionend',
  408. 'oTransitionEnd',
  409. 'msTransitionEnd',
  410. 'transitionend'
  411. ];
  412. // triggered only when the next single subsequent transition finishes
  413. function whenTransitionDone(el, callback) {
  414. var realCallback = function (ev) {
  415. callback(ev);
  416. transitionEventNames.forEach(function (eventName) {
  417. el.removeEventListener(eventName, realCallback);
  418. });
  419. };
  420. transitionEventNames.forEach(function (eventName) {
  421. el.addEventListener(eventName, realCallback); // cross-browser way to determine when the transition finishes
  422. });
  423. }
  424. var DAY_IDS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
  425. // Adding
  426. function addWeeks(m, n) {
  427. var a = dateToUtcArray(m);
  428. a[2] += n * 7;
  429. return arrayToUtcDate(a);
  430. }
  431. function addDays(m, n) {
  432. var a = dateToUtcArray(m);
  433. a[2] += n;
  434. return arrayToUtcDate(a);
  435. }
  436. function addMs(m, n) {
  437. var a = dateToUtcArray(m);
  438. a[6] += n;
  439. return arrayToUtcDate(a);
  440. }
  441. // Diffing (all return floats)
  442. function diffWeeks(m0, m1) {
  443. return diffDays(m0, m1) / 7;
  444. }
  445. function diffDays(m0, m1) {
  446. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60 * 24);
  447. }
  448. function diffHours(m0, m1) {
  449. return (m1.valueOf() - m0.valueOf()) / (1000 * 60 * 60);
  450. }
  451. function diffMinutes(m0, m1) {
  452. return (m1.valueOf() - m0.valueOf()) / (1000 * 60);
  453. }
  454. function diffSeconds(m0, m1) {
  455. return (m1.valueOf() - m0.valueOf()) / 1000;
  456. }
  457. function diffDayAndTime(m0, m1) {
  458. var m0day = startOfDay(m0);
  459. var m1day = startOfDay(m1);
  460. return {
  461. years: 0,
  462. months: 0,
  463. days: Math.round(diffDays(m0day, m1day)),
  464. milliseconds: (m1.valueOf() - m1day.valueOf()) - (m0.valueOf() - m0day.valueOf())
  465. };
  466. }
  467. // Diffing Whole Units
  468. function diffWholeWeeks(m0, m1) {
  469. var d = diffWholeDays(m0, m1);
  470. if (d !== null && d % 7 === 0) {
  471. return d / 7;
  472. }
  473. return null;
  474. }
  475. function diffWholeDays(m0, m1) {
  476. if (timeAsMs(m0) === timeAsMs(m1)) {
  477. return Math.round(diffDays(m0, m1));
  478. }
  479. return null;
  480. }
  481. // Start-Of
  482. function startOfDay(m) {
  483. return arrayToUtcDate([
  484. m.getUTCFullYear(),
  485. m.getUTCMonth(),
  486. m.getUTCDate()
  487. ]);
  488. }
  489. function startOfHour(m) {
  490. return arrayToUtcDate([
  491. m.getUTCFullYear(),
  492. m.getUTCMonth(),
  493. m.getUTCDate(),
  494. m.getUTCHours()
  495. ]);
  496. }
  497. function startOfMinute(m) {
  498. return arrayToUtcDate([
  499. m.getUTCFullYear(),
  500. m.getUTCMonth(),
  501. m.getUTCDate(),
  502. m.getUTCHours(),
  503. m.getUTCMinutes()
  504. ]);
  505. }
  506. function startOfSecond(m) {
  507. return arrayToUtcDate([
  508. m.getUTCFullYear(),
  509. m.getUTCMonth(),
  510. m.getUTCDate(),
  511. m.getUTCHours(),
  512. m.getUTCMinutes(),
  513. m.getUTCSeconds()
  514. ]);
  515. }
  516. // Week Computation
  517. function weekOfYear(marker, dow, doy) {
  518. var y = marker.getUTCFullYear();
  519. var w = weekOfGivenYear(marker, y, dow, doy);
  520. if (w < 1) {
  521. return weekOfGivenYear(marker, y - 1, dow, doy);
  522. }
  523. var nextW = weekOfGivenYear(marker, y + 1, dow, doy);
  524. if (nextW >= 1) {
  525. return Math.min(w, nextW);
  526. }
  527. return w;
  528. }
  529. function weekOfGivenYear(marker, year, dow, doy) {
  530. var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
  531. var dayStart = startOfDay(marker);
  532. var days = Math.round(diffDays(firstWeekStart, dayStart));
  533. return Math.floor(days / 7) + 1; // zero-indexed
  534. }
  535. // start-of-first-week - start-of-year
  536. function firstWeekOffset(year, dow, doy) {
  537. // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  538. var fwd = 7 + dow - doy;
  539. // first-week day local weekday -- which local weekday is fwd
  540. var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
  541. return -fwdlw + fwd - 1;
  542. }
  543. // Array Conversion
  544. function dateToLocalArray(date) {
  545. return [
  546. date.getFullYear(),
  547. date.getMonth(),
  548. date.getDate(),
  549. date.getHours(),
  550. date.getMinutes(),
  551. date.getSeconds(),
  552. date.getMilliseconds()
  553. ];
  554. }
  555. function arrayToLocalDate(a) {
  556. return new Date(a[0], a[1] || 0, a[2] == null ? 1 : a[2], // day of month
  557. a[3] || 0, a[4] || 0, a[5] || 0);
  558. }
  559. function dateToUtcArray(date) {
  560. return [
  561. date.getUTCFullYear(),
  562. date.getUTCMonth(),
  563. date.getUTCDate(),
  564. date.getUTCHours(),
  565. date.getUTCMinutes(),
  566. date.getUTCSeconds(),
  567. date.getUTCMilliseconds()
  568. ];
  569. }
  570. function arrayToUtcDate(a) {
  571. // according to web standards (and Safari), a month index is required.
  572. // massage if only given a year.
  573. if (a.length === 1) {
  574. a = a.concat([0]);
  575. }
  576. return new Date(Date.UTC.apply(Date, a));
  577. }
  578. // Other Utils
  579. function isValidDate(m) {
  580. return !isNaN(m.valueOf());
  581. }
  582. function timeAsMs(m) {
  583. return m.getUTCHours() * 1000 * 60 * 60 +
  584. m.getUTCMinutes() * 1000 * 60 +
  585. m.getUTCSeconds() * 1000 +
  586. m.getUTCMilliseconds();
  587. }
  588. var INTERNAL_UNITS = ['years', 'months', 'days', 'milliseconds'];
  589. var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
  590. // Parsing and Creation
  591. function createDuration(input, unit) {
  592. var _a;
  593. if (typeof input === 'string') {
  594. return parseString(input);
  595. }
  596. else if (typeof input === 'object' && input) { // non-null object
  597. return normalizeObject(input);
  598. }
  599. else if (typeof input === 'number') {
  600. return normalizeObject((_a = {}, _a[unit || 'milliseconds'] = input, _a));
  601. }
  602. else {
  603. return null;
  604. }
  605. }
  606. function parseString(s) {
  607. var m = PARSE_RE.exec(s);
  608. if (m) {
  609. var sign = m[1] ? -1 : 1;
  610. return {
  611. years: 0,
  612. months: 0,
  613. days: sign * (m[2] ? parseInt(m[2], 10) : 0),
  614. milliseconds: sign * ((m[3] ? parseInt(m[3], 10) : 0) * 60 * 60 * 1000 + // hours
  615. (m[4] ? parseInt(m[4], 10) : 0) * 60 * 1000 + // minutes
  616. (m[5] ? parseInt(m[5], 10) : 0) * 1000 + // seconds
  617. (m[6] ? parseInt(m[6], 10) : 0) // ms
  618. )
  619. };
  620. }
  621. return null;
  622. }
  623. function normalizeObject(obj) {
  624. return {
  625. years: obj.years || obj.year || 0,
  626. months: obj.months || obj.month || 0,
  627. days: (obj.days || obj.day || 0) +
  628. getWeeksFromInput(obj) * 7,
  629. milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1000 + // hours
  630. (obj.minutes || obj.minute || 0) * 60 * 1000 + // minutes
  631. (obj.seconds || obj.second || 0) * 1000 + // seconds
  632. (obj.milliseconds || obj.millisecond || obj.ms || 0) // ms
  633. };
  634. }
  635. function getWeeksFromInput(obj) {
  636. return obj.weeks || obj.week || 0;
  637. }
  638. // Equality
  639. function durationsEqual(d0, d1) {
  640. return d0.years === d1.years &&
  641. d0.months === d1.months &&
  642. d0.days === d1.days &&
  643. d0.milliseconds === d1.milliseconds;
  644. }
  645. function isSingleDay(dur) {
  646. return dur.years === 0 && dur.months === 0 && dur.days === 1 && dur.milliseconds === 0;
  647. }
  648. // Simple Math
  649. function addDurations(d0, d1) {
  650. return {
  651. years: d0.years + d1.years,
  652. months: d0.months + d1.months,
  653. days: d0.days + d1.days,
  654. milliseconds: d0.milliseconds + d1.milliseconds
  655. };
  656. }
  657. function subtractDurations(d1, d0) {
  658. return {
  659. years: d1.years - d0.years,
  660. months: d1.months - d0.months,
  661. days: d1.days - d0.days,
  662. milliseconds: d1.milliseconds - d0.milliseconds
  663. };
  664. }
  665. function multiplyDuration(d, n) {
  666. return {
  667. years: d.years * n,
  668. months: d.months * n,
  669. days: d.days * n,
  670. milliseconds: d.milliseconds * n
  671. };
  672. }
  673. // Conversions
  674. // "Rough" because they are based on average-case Gregorian months/years
  675. function asRoughYears(dur) {
  676. return asRoughDays(dur) / 365;
  677. }
  678. function asRoughMonths(dur) {
  679. return asRoughDays(dur) / 30;
  680. }
  681. function asRoughDays(dur) {
  682. return asRoughMs(dur) / 864e5;
  683. }
  684. function asRoughMinutes(dur) {
  685. return asRoughMs(dur) / (1000 * 60);
  686. }
  687. function asRoughSeconds(dur) {
  688. return asRoughMs(dur) / 1000;
  689. }
  690. function asRoughMs(dur) {
  691. return dur.years * (365 * 864e5) +
  692. dur.months * (30 * 864e5) +
  693. dur.days * 864e5 +
  694. dur.milliseconds;
  695. }
  696. // Advanced Math
  697. function wholeDivideDurations(numerator, denominator) {
  698. var res = null;
  699. for (var i = 0; i < INTERNAL_UNITS.length; i++) {
  700. var unit = INTERNAL_UNITS[i];
  701. if (denominator[unit]) {
  702. var localRes = numerator[unit] / denominator[unit];
  703. if (!isInt(localRes) || (res !== null && res !== localRes)) {
  704. return null;
  705. }
  706. res = localRes;
  707. }
  708. else if (numerator[unit]) {
  709. // needs to divide by something but can't!
  710. return null;
  711. }
  712. }
  713. return res;
  714. }
  715. function greatestDurationDenominator(dur, dontReturnWeeks) {
  716. var ms = dur.milliseconds;
  717. if (ms) {
  718. if (ms % 1000 !== 0) {
  719. return { unit: 'millisecond', value: ms };
  720. }
  721. if (ms % (1000 * 60) !== 0) {
  722. return { unit: 'second', value: ms / 1000 };
  723. }
  724. if (ms % (1000 * 60 * 60) !== 0) {
  725. return { unit: 'minute', value: ms / (1000 * 60) };
  726. }
  727. if (ms) {
  728. return { unit: 'hour', value: ms / (1000 * 60 * 60) };
  729. }
  730. }
  731. if (dur.days) {
  732. if (!dontReturnWeeks && dur.days % 7 === 0) {
  733. return { unit: 'week', value: dur.days / 7 };
  734. }
  735. return { unit: 'day', value: dur.days };
  736. }
  737. if (dur.months) {
  738. return { unit: 'month', value: dur.months };
  739. }
  740. if (dur.years) {
  741. return { unit: 'year', value: dur.years };
  742. }
  743. return { unit: 'millisecond', value: 0 };
  744. }
  745. /* FullCalendar-specific DOM Utilities
  746. ----------------------------------------------------------------------------------------------------------------------*/
  747. // Given the scrollbar widths of some other container, create borders/margins on rowEls in order to match the left
  748. // and right space that was offset by the scrollbars. A 1-pixel border first, then margin beyond that.
  749. function compensateScroll(rowEl, scrollbarWidths) {
  750. if (scrollbarWidths.left) {
  751. applyStyle(rowEl, {
  752. borderLeftWidth: 1,
  753. marginLeft: scrollbarWidths.left - 1
  754. });
  755. }
  756. if (scrollbarWidths.right) {
  757. applyStyle(rowEl, {
  758. borderRightWidth: 1,
  759. marginRight: scrollbarWidths.right - 1
  760. });
  761. }
  762. }
  763. // Undoes compensateScroll and restores all borders/margins
  764. function uncompensateScroll(rowEl) {
  765. applyStyle(rowEl, {
  766. marginLeft: '',
  767. marginRight: '',
  768. borderLeftWidth: '',
  769. borderRightWidth: ''
  770. });
  771. }
  772. // Make the mouse cursor express that an event is not allowed in the current area
  773. function disableCursor() {
  774. document.body.classList.add('fc-not-allowed');
  775. }
  776. // Returns the mouse cursor to its original look
  777. function enableCursor() {
  778. document.body.classList.remove('fc-not-allowed');
  779. }
  780. // Given a total available height to fill, have `els` (essentially child rows) expand to accomodate.
  781. // By default, all elements that are shorter than the recommended height are expanded uniformly, not considering
  782. // any other els that are already too tall. if `shouldRedistribute` is on, it considers these tall rows and
  783. // reduces the available height.
  784. function distributeHeight(els, availableHeight, shouldRedistribute) {
  785. // *FLOORING NOTE*: we floor in certain places because zoom can give inaccurate floating-point dimensions,
  786. // and it is better to be shorter than taller, to avoid creating unnecessary scrollbars.
  787. var minOffset1 = Math.floor(availableHeight / els.length); // for non-last element
  788. var minOffset2 = Math.floor(availableHeight - minOffset1 * (els.length - 1)); // for last element *FLOORING NOTE*
  789. var flexEls = []; // elements that are allowed to expand. array of DOM nodes
  790. var flexOffsets = []; // amount of vertical space it takes up
  791. var flexHeights = []; // actual css height
  792. var usedHeight = 0;
  793. undistributeHeight(els); // give all elements their natural height
  794. // find elements that are below the recommended height (expandable).
  795. // important to query for heights in a single first pass (to avoid reflow oscillation).
  796. els.forEach(function (el, i) {
  797. var minOffset = i === els.length - 1 ? minOffset2 : minOffset1;
  798. var naturalHeight = el.getBoundingClientRect().height;
  799. var naturalOffset = naturalHeight + computeVMargins(el);
  800. if (naturalOffset < minOffset) {
  801. flexEls.push(el);
  802. flexOffsets.push(naturalOffset);
  803. flexHeights.push(naturalHeight);
  804. }
  805. else {
  806. // this element stretches past recommended height (non-expandable). mark the space as occupied.
  807. usedHeight += naturalOffset;
  808. }
  809. });
  810. // readjust the recommended height to only consider the height available to non-maxed-out rows.
  811. if (shouldRedistribute) {
  812. availableHeight -= usedHeight;
  813. minOffset1 = Math.floor(availableHeight / flexEls.length);
  814. minOffset2 = Math.floor(availableHeight - minOffset1 * (flexEls.length - 1)); // *FLOORING NOTE*
  815. }
  816. // assign heights to all expandable elements
  817. flexEls.forEach(function (el, i) {
  818. var minOffset = i === flexEls.length - 1 ? minOffset2 : minOffset1;
  819. var naturalOffset = flexOffsets[i];
  820. var naturalHeight = flexHeights[i];
  821. var newHeight = minOffset - (naturalOffset - naturalHeight); // subtract the margin/padding
  822. if (naturalOffset < minOffset) { // we check this again because redistribution might have changed things
  823. el.style.height = newHeight + 'px';
  824. }
  825. });
  826. }
  827. // Undoes distrubuteHeight, restoring all els to their natural height
  828. function undistributeHeight(els) {
  829. els.forEach(function (el) {
  830. el.style.height = '';
  831. });
  832. }
  833. // Given `els`, a set of <td> cells, find the cell with the largest natural width and set the widths of all the
  834. // cells to be that width.
  835. // PREREQUISITE: if you want a cell to take up width, it needs to have a single inner element w/ display:inline
  836. function matchCellWidths(els) {
  837. var maxInnerWidth = 0;
  838. els.forEach(function (el) {
  839. var innerEl = el.firstChild; // hopefully an element
  840. if (innerEl instanceof HTMLElement) {
  841. var innerWidth_1 = innerEl.getBoundingClientRect().width;
  842. if (innerWidth_1 > maxInnerWidth) {
  843. maxInnerWidth = innerWidth_1;
  844. }
  845. }
  846. });
  847. maxInnerWidth++; // sometimes not accurate of width the text needs to stay on one line. insurance
  848. els.forEach(function (el) {
  849. el.style.width = maxInnerWidth + 'px';
  850. });
  851. return maxInnerWidth;
  852. }
  853. // Given one element that resides inside another,
  854. // Subtracts the height of the inner element from the outer element.
  855. function subtractInnerElHeight(outerEl, innerEl) {
  856. // effin' IE8/9/10/11 sometimes returns 0 for dimensions. this weird hack was the only thing that worked
  857. var reflowStyleProps = {
  858. position: 'relative',
  859. left: -1 // ensure reflow in case the el was already relative. negative is less likely to cause new scroll
  860. };
  861. applyStyle(outerEl, reflowStyleProps);
  862. applyStyle(innerEl, reflowStyleProps);
  863. var diff = // grab the dimensions
  864. outerEl.getBoundingClientRect().height -
  865. innerEl.getBoundingClientRect().height;
  866. // undo hack
  867. var resetStyleProps = { position: '', left: '' };
  868. applyStyle(outerEl, resetStyleProps);
  869. applyStyle(innerEl, resetStyleProps);
  870. return diff;
  871. }
  872. /* Selection
  873. ----------------------------------------------------------------------------------------------------------------------*/
  874. function preventSelection(el) {
  875. el.classList.add('fc-unselectable');
  876. el.addEventListener('selectstart', preventDefault);
  877. }
  878. function allowSelection(el) {
  879. el.classList.remove('fc-unselectable');
  880. el.removeEventListener('selectstart', preventDefault);
  881. }
  882. /* Context Menu
  883. ----------------------------------------------------------------------------------------------------------------------*/
  884. function preventContextMenu(el) {
  885. el.addEventListener('contextmenu', preventDefault);
  886. }
  887. function allowContextMenu(el) {
  888. el.removeEventListener('contextmenu', preventDefault);
  889. }
  890. /* Object Ordering by Field
  891. ----------------------------------------------------------------------------------------------------------------------*/
  892. function parseFieldSpecs(input) {
  893. var specs = [];
  894. var tokens = [];
  895. var i;
  896. var token;
  897. if (typeof input === 'string') {
  898. tokens = input.split(/\s*,\s*/);
  899. }
  900. else if (typeof input === 'function') {
  901. tokens = [input];
  902. }
  903. else if (Array.isArray(input)) {
  904. tokens = input;
  905. }
  906. for (i = 0; i < tokens.length; i++) {
  907. token = tokens[i];
  908. if (typeof token === 'string') {
  909. specs.push(token.charAt(0) === '-' ?
  910. { field: token.substring(1), order: -1 } :
  911. { field: token, order: 1 });
  912. }
  913. else if (typeof token === 'function') {
  914. specs.push({ func: token });
  915. }
  916. }
  917. return specs;
  918. }
  919. function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
  920. var i;
  921. var cmp;
  922. for (i = 0; i < fieldSpecs.length; i++) {
  923. cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i]);
  924. if (cmp) {
  925. return cmp;
  926. }
  927. }
  928. return 0;
  929. }
  930. function compareByFieldSpec(obj0, obj1, fieldSpec) {
  931. if (fieldSpec.func) {
  932. return fieldSpec.func(obj0, obj1);
  933. }
  934. return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field])
  935. * (fieldSpec.order || 1);
  936. }
  937. function flexibleCompare(a, b) {
  938. if (!a && !b) {
  939. return 0;
  940. }
  941. if (b == null) {
  942. return -1;
  943. }
  944. if (a == null) {
  945. return 1;
  946. }
  947. if (typeof a === 'string' || typeof b === 'string') {
  948. return String(a).localeCompare(String(b));
  949. }
  950. return a - b;
  951. }
  952. /* String Utilities
  953. ----------------------------------------------------------------------------------------------------------------------*/
  954. function capitaliseFirstLetter(str) {
  955. return str.charAt(0).toUpperCase() + str.slice(1);
  956. }
  957. function padStart(val, len) {
  958. var s = String(val);
  959. return '000'.substr(0, len - s.length) + s;
  960. }
  961. /* Number Utilities
  962. ----------------------------------------------------------------------------------------------------------------------*/
  963. function compareNumbers(a, b) {
  964. return a - b;
  965. }
  966. function isInt(n) {
  967. return n % 1 === 0;
  968. }
  969. /* Weird Utilities
  970. ----------------------------------------------------------------------------------------------------------------------*/
  971. function applyAll(functions, thisObj, args) {
  972. if (typeof functions === 'function') { // supplied a single function
  973. functions = [functions];
  974. }
  975. if (functions) {
  976. var i = void 0;
  977. var ret = void 0;
  978. for (i = 0; i < functions.length; i++) {
  979. ret = functions[i].apply(thisObj, args) || ret;
  980. }
  981. return ret;
  982. }
  983. }
  984. function firstDefined() {
  985. var args = [];
  986. for (var _i = 0; _i < arguments.length; _i++) {
  987. args[_i] = arguments[_i];
  988. }
  989. for (var i = 0; i < args.length; i++) {
  990. if (args[i] !== undefined) {
  991. return args[i];
  992. }
  993. }
  994. }
  995. // Returns a function, that, as long as it continues to be invoked, will not
  996. // be triggered. The function will be called after it stops being called for
  997. // N milliseconds. If `immediate` is passed, trigger the function on the
  998. // leading edge, instead of the trailing.
  999. // https://github.com/jashkenas/underscore/blob/1.6.0/underscore.js#L714
  1000. function debounce(func, wait) {
  1001. var timeout;
  1002. var args;
  1003. var context;
  1004. var timestamp;
  1005. var result;
  1006. var later = function () {
  1007. var last = new Date().valueOf() - timestamp;
  1008. if (last < wait) {
  1009. timeout = setTimeout(later, wait - last);
  1010. }
  1011. else {
  1012. timeout = null;
  1013. result = func.apply(context, args);
  1014. context = args = null;
  1015. }
  1016. };
  1017. return function () {
  1018. context = this;
  1019. args = arguments;
  1020. timestamp = new Date().valueOf();
  1021. if (!timeout) {
  1022. timeout = setTimeout(later, wait);
  1023. }
  1024. return result;
  1025. };
  1026. }
  1027. // Number and Boolean are only types that defaults or not computed for
  1028. // TODO: write more comments
  1029. function refineProps(rawProps, processors, defaults, leftoverProps) {
  1030. if (defaults === void 0) { defaults = {}; }
  1031. var refined = {};
  1032. for (var key in processors) {
  1033. var processor = processors[key];
  1034. if (rawProps[key] !== undefined) {
  1035. // found
  1036. if (processor === Function) {
  1037. refined[key] = typeof rawProps[key] === 'function' ? rawProps[key] : null;
  1038. }
  1039. else if (processor) { // a refining function?
  1040. refined[key] = processor(rawProps[key]);
  1041. }
  1042. else {
  1043. refined[key] = rawProps[key];
  1044. }
  1045. }
  1046. else if (defaults[key] !== undefined) {
  1047. // there's an explicit default
  1048. refined[key] = defaults[key];
  1049. }
  1050. else {
  1051. // must compute a default
  1052. if (processor === String) {
  1053. refined[key] = ''; // empty string is default for String
  1054. }
  1055. else if (!processor || processor === Number || processor === Boolean || processor === Function) {
  1056. refined[key] = null; // assign null for other non-custom processor funcs
  1057. }
  1058. else {
  1059. refined[key] = processor(null); // run the custom processor func
  1060. }
  1061. }
  1062. }
  1063. if (leftoverProps) {
  1064. for (var key in rawProps) {
  1065. if (processors[key] === undefined) {
  1066. leftoverProps[key] = rawProps[key];
  1067. }
  1068. }
  1069. }
  1070. return refined;
  1071. }
  1072. /* Date stuff that doesn't belong in datelib core
  1073. ----------------------------------------------------------------------------------------------------------------------*/
  1074. // given a timed range, computes an all-day range that has the same exact duration,
  1075. // but whose start time is aligned with the start of the day.
  1076. function computeAlignedDayRange(timedRange) {
  1077. var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
  1078. var start = startOfDay(timedRange.start);
  1079. var end = addDays(start, dayCnt);
  1080. return { start: start, end: end };
  1081. }
  1082. // given a timed range, computes an all-day range based on how for the end date bleeds into the next day
  1083. // TODO: give nextDayThreshold a default arg
  1084. function computeVisibleDayRange(timedRange, nextDayThreshold) {
  1085. if (nextDayThreshold === void 0) { nextDayThreshold = createDuration(0); }
  1086. var startDay = null;
  1087. var endDay = null;
  1088. if (timedRange.end) {
  1089. endDay = startOfDay(timedRange.end);
  1090. var endTimeMS = timedRange.end.valueOf() - endDay.valueOf(); // # of milliseconds into `endDay`
  1091. // If the end time is actually inclusively part of the next day and is equal to or
  1092. // beyond the next day threshold, adjust the end to be the exclusive end of `endDay`.
  1093. // Otherwise, leaving it as inclusive will cause it to exclude `endDay`.
  1094. if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
  1095. endDay = addDays(endDay, 1);
  1096. }
  1097. }
  1098. if (timedRange.start) {
  1099. startDay = startOfDay(timedRange.start); // the beginning of the day the range starts
  1100. // If end is within `startDay` but not past nextDayThreshold, assign the default duration of one day.
  1101. if (endDay && endDay <= startDay) {
  1102. endDay = addDays(startDay, 1);
  1103. }
  1104. }
  1105. return { start: startDay, end: endDay };
  1106. }
  1107. // spans from one day into another?
  1108. function isMultiDayRange(range) {
  1109. var visibleRange = computeVisibleDayRange(range);
  1110. return diffDays(visibleRange.start, visibleRange.end) > 1;
  1111. }
  1112. function diffDates(date0, date1, dateEnv, largeUnit) {
  1113. if (largeUnit === 'year') {
  1114. return createDuration(dateEnv.diffWholeYears(date0, date1), 'year');
  1115. }
  1116. else if (largeUnit === 'month') {
  1117. return createDuration(dateEnv.diffWholeMonths(date0, date1), 'month');
  1118. }
  1119. else {
  1120. return diffDayAndTime(date0, date1); // returns a duration
  1121. }
  1122. }
  1123. /*! *****************************************************************************
  1124. Copyright (c) Microsoft Corporation. All rights reserved.
  1125. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  1126. this file except in compliance with the License. You may obtain a copy of the
  1127. License at http://www.apache.org/licenses/LICENSE-2.0
  1128. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1129. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  1130. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  1131. MERCHANTABLITY OR NON-INFRINGEMENT.
  1132. See the Apache Version 2.0 License for specific language governing permissions
  1133. and limitations under the License.
  1134. ***************************************************************************** */
  1135. /* global Reflect, Promise */
  1136. var extendStatics = function(d, b) {
  1137. extendStatics = Object.setPrototypeOf ||
  1138. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1139. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1140. return extendStatics(d, b);
  1141. };
  1142. function __extends(d, b) {
  1143. extendStatics(d, b);
  1144. function __() { this.constructor = d; }
  1145. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1146. }
  1147. var __assign = function() {
  1148. __assign = Object.assign || function __assign(t) {
  1149. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1150. s = arguments[i];
  1151. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1152. }
  1153. return t;
  1154. };
  1155. return __assign.apply(this, arguments);
  1156. };
  1157. function parseRecurring(eventInput, allDayDefault, dateEnv, recurringTypes, leftovers) {
  1158. for (var i = 0; i < recurringTypes.length; i++) {
  1159. var localLeftovers = {};
  1160. var parsed = recurringTypes[i].parse(eventInput, localLeftovers, dateEnv);
  1161. if (parsed) {
  1162. var allDay = localLeftovers.allDay;
  1163. delete localLeftovers.allDay; // remove from leftovers
  1164. if (allDay == null) {
  1165. allDay = allDayDefault;
  1166. if (allDay == null) {
  1167. allDay = parsed.allDayGuess;
  1168. if (allDay == null) {
  1169. allDay = false;
  1170. }
  1171. }
  1172. }
  1173. __assign(leftovers, localLeftovers);
  1174. return {
  1175. allDay: allDay,
  1176. duration: parsed.duration,
  1177. typeData: parsed.typeData,
  1178. typeId: i
  1179. };
  1180. }
  1181. }
  1182. return null;
  1183. }
  1184. /*
  1185. Event MUST have a recurringDef
  1186. */
  1187. function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
  1188. var typeDef = recurringTypes[eventDef.recurringDef.typeId];
  1189. var markers = typeDef.expand(eventDef.recurringDef.typeData, {
  1190. start: dateEnv.subtract(framingRange.start, duration),
  1191. end: framingRange.end
  1192. }, dateEnv);
  1193. // the recurrence plugins don't guarantee that all-day events are start-of-day, so we have to
  1194. if (eventDef.allDay) {
  1195. markers = markers.map(startOfDay);
  1196. }
  1197. return markers;
  1198. }
  1199. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1200. // Merges an array of objects into a single object.
  1201. // The second argument allows for an array of property names who's object values will be merged together.
  1202. function mergeProps(propObjs, complexProps) {
  1203. var dest = {};
  1204. var i;
  1205. var name;
  1206. var complexObjs;
  1207. var j;
  1208. var val;
  1209. var props;
  1210. if (complexProps) {
  1211. for (i = 0; i < complexProps.length; i++) {
  1212. name = complexProps[i];
  1213. complexObjs = [];
  1214. // collect the trailing object values, stopping when a non-object is discovered
  1215. for (j = propObjs.length - 1; j >= 0; j--) {
  1216. val = propObjs[j][name];
  1217. if (typeof val === 'object' && val) { // non-null object
  1218. complexObjs.unshift(val);
  1219. }
  1220. else if (val !== undefined) {
  1221. dest[name] = val; // if there were no objects, this value will be used
  1222. break;
  1223. }
  1224. }
  1225. // if the trailing values were objects, use the merged value
  1226. if (complexObjs.length) {
  1227. dest[name] = mergeProps(complexObjs);
  1228. }
  1229. }
  1230. }
  1231. // copy values into the destination, going from last to first
  1232. for (i = propObjs.length - 1; i >= 0; i--) {
  1233. props = propObjs[i];
  1234. for (name in props) {
  1235. if (!(name in dest)) { // if already assigned by previous props or complex props, don't reassign
  1236. dest[name] = props[name];
  1237. }
  1238. }
  1239. }
  1240. return dest;
  1241. }
  1242. function filterHash(hash, func) {
  1243. var filtered = {};
  1244. for (var key in hash) {
  1245. if (func(hash[key], key)) {
  1246. filtered[key] = hash[key];
  1247. }
  1248. }
  1249. return filtered;
  1250. }
  1251. function mapHash(hash, func) {
  1252. var newHash = {};
  1253. for (var key in hash) {
  1254. newHash[key] = func(hash[key], key);
  1255. }
  1256. return newHash;
  1257. }
  1258. function arrayToHash(a) {
  1259. var hash = {};
  1260. for (var _i = 0, a_1 = a; _i < a_1.length; _i++) {
  1261. var item = a_1[_i];
  1262. hash[item] = true;
  1263. }
  1264. return hash;
  1265. }
  1266. function hashValuesToArray(obj) {
  1267. var a = [];
  1268. for (var key in obj) {
  1269. a.push(obj[key]);
  1270. }
  1271. return a;
  1272. }
  1273. function isPropsEqual(obj0, obj1) {
  1274. for (var key in obj0) {
  1275. if (hasOwnProperty.call(obj0, key)) {
  1276. if (!(key in obj1)) {
  1277. return false;
  1278. }
  1279. }
  1280. }
  1281. for (var key in obj1) {
  1282. if (hasOwnProperty.call(obj1, key)) {
  1283. if (obj0[key] !== obj1[key]) {
  1284. return false;
  1285. }
  1286. }
  1287. }
  1288. return true;
  1289. }
  1290. function parseEvents(rawEvents, sourceId, calendar, allowOpenRange) {
  1291. var eventStore = createEmptyEventStore();
  1292. for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
  1293. var rawEvent = rawEvents_1[_i];
  1294. var tuple = parseEvent(rawEvent, sourceId, calendar, allowOpenRange);
  1295. if (tuple) {
  1296. eventTupleToStore(tuple, eventStore);
  1297. }
  1298. }
  1299. return eventStore;
  1300. }
  1301. function eventTupleToStore(tuple, eventStore) {
  1302. if (eventStore === void 0) { eventStore = createEmptyEventStore(); }
  1303. eventStore.defs[tuple.def.defId] = tuple.def;
  1304. if (tuple.instance) {
  1305. eventStore.instances[tuple.instance.instanceId] = tuple.instance;
  1306. }
  1307. return eventStore;
  1308. }
  1309. function expandRecurring(eventStore, framingRange, calendar) {
  1310. var dateEnv = calendar.dateEnv;
  1311. var defs = eventStore.defs, instances = eventStore.instances;
  1312. // remove existing recurring instances
  1313. instances = filterHash(instances, function (instance) {
  1314. return !defs[instance.defId].recurringDef;
  1315. });
  1316. for (var defId in defs) {
  1317. var def = defs[defId];
  1318. if (def.recurringDef) {
  1319. var duration = def.recurringDef.duration;
  1320. if (!duration) {
  1321. duration = def.allDay ?
  1322. calendar.defaultAllDayEventDuration :
  1323. calendar.defaultTimedEventDuration;
  1324. }
  1325. var starts = expandRecurringRanges(def, duration, framingRange, calendar.dateEnv, calendar.pluginSystem.hooks.recurringTypes);
  1326. for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
  1327. var start = starts_1[_i];
  1328. var instance = createEventInstance(defId, {
  1329. start: start,
  1330. end: dateEnv.add(start, duration)
  1331. });
  1332. instances[instance.instanceId] = instance;
  1333. }
  1334. }
  1335. }
  1336. return { defs: defs, instances: instances };
  1337. }
  1338. // retrieves events that have the same groupId as the instance specified by `instanceId`
  1339. // or they are the same as the instance.
  1340. // why might instanceId not be in the store? an event from another calendar?
  1341. function getRelevantEvents(eventStore, instanceId) {
  1342. var instance = eventStore.instances[instanceId];
  1343. if (instance) {
  1344. var def_1 = eventStore.defs[instance.defId];
  1345. // get events/instances with same group
  1346. var newStore = filterEventStoreDefs(eventStore, function (lookDef) {
  1347. return isEventDefsGrouped(def_1, lookDef);
  1348. });
  1349. // add the original
  1350. // TODO: wish we could use eventTupleToStore or something like it
  1351. newStore.defs[def_1.defId] = def_1;
  1352. newStore.instances[instance.instanceId] = instance;
  1353. return newStore;
  1354. }
  1355. return createEmptyEventStore();
  1356. }
  1357. function isEventDefsGrouped(def0, def1) {
  1358. return Boolean(def0.groupId && def0.groupId === def1.groupId);
  1359. }
  1360. function transformRawEvents(rawEvents, eventSource, calendar) {
  1361. var calEachTransform = calendar.opt('eventDataTransform');
  1362. var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
  1363. if (sourceEachTransform) {
  1364. rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
  1365. }
  1366. if (calEachTransform) {
  1367. rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
  1368. }
  1369. return rawEvents;
  1370. }
  1371. function transformEachRawEvent(rawEvents, func) {
  1372. var refinedEvents;
  1373. if (!func) {
  1374. refinedEvents = rawEvents;
  1375. }
  1376. else {
  1377. refinedEvents = [];
  1378. for (var _i = 0, rawEvents_2 = rawEvents; _i < rawEvents_2.length; _i++) {
  1379. var rawEvent = rawEvents_2[_i];
  1380. var refinedEvent = func(rawEvent);
  1381. if (refinedEvent) {
  1382. refinedEvents.push(refinedEvent);
  1383. }
  1384. else if (refinedEvent == null) {
  1385. refinedEvents.push(rawEvent);
  1386. } // if a different falsy value, do nothing
  1387. }
  1388. }
  1389. return refinedEvents;
  1390. }
  1391. function createEmptyEventStore() {
  1392. return { defs: {}, instances: {} };
  1393. }
  1394. function mergeEventStores(store0, store1) {
  1395. return {
  1396. defs: __assign({}, store0.defs, store1.defs),
  1397. instances: __assign({}, store0.instances, store1.instances)
  1398. };
  1399. }
  1400. function filterEventStoreDefs(eventStore, filterFunc) {
  1401. var defs = filterHash(eventStore.defs, filterFunc);
  1402. var instances = filterHash(eventStore.instances, function (instance) {
  1403. return defs[instance.defId]; // still exists?
  1404. });
  1405. return { defs: defs, instances: instances };
  1406. }
  1407. function parseRange(input, dateEnv) {
  1408. var start = null;
  1409. var end = null;
  1410. if (input.start) {
  1411. start = dateEnv.createMarker(input.start);
  1412. }
  1413. if (input.end) {
  1414. end = dateEnv.createMarker(input.end);
  1415. }
  1416. if (!start && !end) {
  1417. return null;
  1418. }
  1419. if (start && end && end < start) {
  1420. return null;
  1421. }
  1422. return { start: start, end: end };
  1423. }
  1424. // SIDE-EFFECT: will mutate ranges.
  1425. // Will return a new array result.
  1426. function invertRanges(ranges, constraintRange) {
  1427. var invertedRanges = [];
  1428. var start = constraintRange.start; // the end of the previous range. the start of the new range
  1429. var i;
  1430. var dateRange;
  1431. // ranges need to be in order. required for our date-walking algorithm
  1432. ranges.sort(compareRanges);
  1433. for (i = 0; i < ranges.length; i++) {
  1434. dateRange = ranges[i];
  1435. // add the span of time before the event (if there is any)
  1436. if (dateRange.start > start) { // compare millisecond time (skip any ambig logic)
  1437. invertedRanges.push({ start: start, end: dateRange.start });
  1438. }
  1439. if (dateRange.end > start) {
  1440. start = dateRange.end;
  1441. }
  1442. }
  1443. // add the span of time after the last event (if there is any)
  1444. if (start < constraintRange.end) { // compare millisecond time (skip any ambig logic)
  1445. invertedRanges.push({ start: start, end: constraintRange.end });
  1446. }
  1447. return invertedRanges;
  1448. }
  1449. function compareRanges(range0, range1) {
  1450. return range0.start.valueOf() - range1.start.valueOf(); // earlier ranges go first
  1451. }
  1452. function intersectRanges(range0, range1) {
  1453. var start = range0.start;
  1454. var end = range0.end;
  1455. var newRange = null;
  1456. if (range1.start !== null) {
  1457. if (start === null) {
  1458. start = range1.start;
  1459. }
  1460. else {
  1461. start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
  1462. }
  1463. }
  1464. if (range1.end != null) {
  1465. if (end === null) {
  1466. end = range1.end;
  1467. }
  1468. else {
  1469. end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
  1470. }
  1471. }
  1472. if (start === null || end === null || start < end) {
  1473. newRange = { start: start, end: end };
  1474. }
  1475. return newRange;
  1476. }
  1477. function rangesEqual(range0, range1) {
  1478. return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) &&
  1479. (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
  1480. }
  1481. function rangesIntersect(range0, range1) {
  1482. return (range0.end === null || range1.start === null || range0.end > range1.start) &&
  1483. (range0.start === null || range1.end === null || range0.start < range1.end);
  1484. }
  1485. function rangeContainsRange(outerRange, innerRange) {
  1486. return (outerRange.start === null || (innerRange.start !== null && innerRange.start >= outerRange.start)) &&
  1487. (outerRange.end === null || (innerRange.end !== null && innerRange.end <= outerRange.end));
  1488. }
  1489. function rangeContainsMarker(range, date) {
  1490. return (range.start === null || date >= range.start) &&
  1491. (range.end === null || date < range.end);
  1492. }
  1493. // If the given date is not within the given range, move it inside.
  1494. // (If it's past the end, make it one millisecond before the end).
  1495. function constrainMarkerToRange(date, range) {
  1496. if (range.start != null && date < range.start) {
  1497. return range.start;
  1498. }
  1499. if (range.end != null && date >= range.end) {
  1500. return new Date(range.end.valueOf() - 1);
  1501. }
  1502. return date;
  1503. }
  1504. function removeExact(array, exactVal) {
  1505. var removeCnt = 0;
  1506. var i = 0;
  1507. while (i < array.length) {
  1508. if (array[i] === exactVal) {
  1509. array.splice(i, 1);
  1510. removeCnt++;
  1511. }
  1512. else {
  1513. i++;
  1514. }
  1515. }
  1516. return removeCnt;
  1517. }
  1518. function isArraysEqual(a0, a1) {
  1519. var len = a0.length;
  1520. var i;
  1521. if (len !== a1.length) { // not array? or not same length?
  1522. return false;
  1523. }
  1524. for (i = 0; i < len; i++) {
  1525. if (a0[i] !== a1[i]) {
  1526. return false;
  1527. }
  1528. }
  1529. return true;
  1530. }
  1531. function memoize(workerFunc) {
  1532. var args;
  1533. var res;
  1534. return function () {
  1535. if (!args || !isArraysEqual(args, arguments)) {
  1536. args = arguments;
  1537. res = workerFunc.apply(this, arguments);
  1538. }
  1539. return res;
  1540. };
  1541. }
  1542. /*
  1543. always executes the workerFunc, but if the result is equal to the previous result,
  1544. return the previous result instead.
  1545. */
  1546. function memoizeOutput(workerFunc, equalityFunc) {
  1547. var cachedRes = null;
  1548. return function () {
  1549. var newRes = workerFunc.apply(this, arguments);
  1550. if (cachedRes === null || !(cachedRes === newRes || equalityFunc(cachedRes, newRes))) {
  1551. cachedRes = newRes;
  1552. }
  1553. return cachedRes;
  1554. };
  1555. }
  1556. var EXTENDED_SETTINGS_AND_SEVERITIES = {
  1557. week: 3,
  1558. separator: 0,
  1559. omitZeroMinute: 0,
  1560. meridiem: 0,
  1561. omitCommas: 0
  1562. };
  1563. var STANDARD_DATE_PROP_SEVERITIES = {
  1564. timeZoneName: 7,
  1565. era: 6,
  1566. year: 5,
  1567. month: 4,
  1568. day: 2,
  1569. weekday: 2,
  1570. hour: 1,
  1571. minute: 1,
  1572. second: 1
  1573. };
  1574. var MERIDIEM_RE = /\s*([ap])\.?m\.?/i; // eats up leading spaces too
  1575. var COMMA_RE = /,/g; // we need re for globalness
  1576. var MULTI_SPACE_RE = /\s+/g;
  1577. var LTR_RE = /\u200e/g; // control character
  1578. var UTC_RE = /UTC|GMT/;
  1579. var NativeFormatter = /** @class */ (function () {
  1580. function NativeFormatter(formatSettings) {
  1581. var standardDateProps = {};
  1582. var extendedSettings = {};
  1583. var severity = 0;
  1584. for (var name_1 in formatSettings) {
  1585. if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
  1586. extendedSettings[name_1] = formatSettings[name_1];
  1587. severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
  1588. }
  1589. else {
  1590. standardDateProps[name_1] = formatSettings[name_1];
  1591. if (name_1 in STANDARD_DATE_PROP_SEVERITIES) {
  1592. severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
  1593. }
  1594. }
  1595. }
  1596. this.standardDateProps = standardDateProps;
  1597. this.extendedSettings = extendedSettings;
  1598. this.severity = severity;
  1599. this.buildFormattingFunc = memoize(buildFormattingFunc);
  1600. }
  1601. NativeFormatter.prototype.format = function (date, context) {
  1602. return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
  1603. };
  1604. NativeFormatter.prototype.formatRange = function (start, end, context) {
  1605. var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
  1606. var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
  1607. if (!diffSeverity) {
  1608. return this.format(start, context);
  1609. }
  1610. var biggestUnitForPartial = diffSeverity;
  1611. if (biggestUnitForPartial > 1 && // the two dates are different in a way that's larger scale than time
  1612. (standardDateProps.year === 'numeric' || standardDateProps.year === '2-digit') &&
  1613. (standardDateProps.month === 'numeric' || standardDateProps.month === '2-digit') &&
  1614. (standardDateProps.day === 'numeric' || standardDateProps.day === '2-digit')) {
  1615. biggestUnitForPartial = 1; // make it look like the dates are only different in terms of time
  1616. }
  1617. var full0 = this.format(start, context);
  1618. var full1 = this.format(end, context);
  1619. if (full0 === full1) {
  1620. return full0;
  1621. }
  1622. var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
  1623. var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
  1624. var partial0 = partialFormattingFunc(start);
  1625. var partial1 = partialFormattingFunc(end);
  1626. var insertion = findCommonInsertion(full0, partial0, full1, partial1);
  1627. var separator = extendedSettings.separator || '';
  1628. if (insertion) {
  1629. return insertion.before + partial0 + separator + partial1 + insertion.after;
  1630. }
  1631. return full0 + separator + full1;
  1632. };
  1633. NativeFormatter.prototype.getLargestUnit = function () {
  1634. switch (this.severity) {
  1635. case 7:
  1636. case 6:
  1637. case 5:
  1638. return 'year';
  1639. case 4:
  1640. return 'month';
  1641. case 3:
  1642. return 'week';
  1643. default:
  1644. return 'day';
  1645. }
  1646. };
  1647. return NativeFormatter;
  1648. }());
  1649. function buildFormattingFunc(standardDateProps, extendedSettings, context) {
  1650. var standardDatePropCnt = Object.keys(standardDateProps).length;
  1651. if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === 'short') {
  1652. return function (date) {
  1653. return formatTimeZoneOffset(date.timeZoneOffset);
  1654. };
  1655. }
  1656. if (standardDatePropCnt === 0 && extendedSettings.week) {
  1657. return function (date) {
  1658. return formatWeekNumber(context.computeWeekNumber(date.marker), context.weekLabel, context.locale, extendedSettings.week);
  1659. };
  1660. }
  1661. return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
  1662. }
  1663. function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
  1664. standardDateProps = __assign({}, standardDateProps); // copy
  1665. extendedSettings = __assign({}, extendedSettings); // copy
  1666. sanitizeSettings(standardDateProps, extendedSettings);
  1667. standardDateProps.timeZone = 'UTC'; // we leverage the only guaranteed timeZone for our UTC markers
  1668. var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
  1669. var zeroFormat; // needed?
  1670. if (extendedSettings.omitZeroMinute) {
  1671. var zeroProps = __assign({}, standardDateProps);
  1672. delete zeroProps.minute; // seconds and ms were already considered in sanitizeSettings
  1673. zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
  1674. }
  1675. return function (date) {
  1676. var marker = date.marker;
  1677. var format;
  1678. if (zeroFormat && !marker.getUTCMinutes()) {
  1679. format = zeroFormat;
  1680. }
  1681. else {
  1682. format = normalFormat;
  1683. }
  1684. var s = format.format(marker);
  1685. return postProcess(s, date, standardDateProps, extendedSettings, context);
  1686. };
  1687. }
  1688. function sanitizeSettings(standardDateProps, extendedSettings) {
  1689. // deal with a browser inconsistency where formatting the timezone
  1690. // requires that the hour/minute be present.
  1691. if (standardDateProps.timeZoneName) {
  1692. if (!standardDateProps.hour) {
  1693. standardDateProps.hour = '2-digit';
  1694. }
  1695. if (!standardDateProps.minute) {
  1696. standardDateProps.minute = '2-digit';
  1697. }
  1698. }
  1699. // only support short timezone names
  1700. if (standardDateProps.timeZoneName === 'long') {
  1701. standardDateProps.timeZoneName = 'short';
  1702. }
  1703. // if requesting to display seconds, MUST display minutes
  1704. if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
  1705. delete extendedSettings.omitZeroMinute;
  1706. }
  1707. }
  1708. function postProcess(s, date, standardDateProps, extendedSettings, context) {
  1709. s = s.replace(LTR_RE, ''); // remove left-to-right control chars. do first. good for other regexes
  1710. if (standardDateProps.timeZoneName === 'short') {
  1711. s = injectTzoStr(s, (context.timeZone === 'UTC' || date.timeZoneOffset == null) ?
  1712. 'UTC' : // important to normalize for IE, which does "GMT"
  1713. formatTimeZoneOffset(date.timeZoneOffset));
  1714. }
  1715. if (extendedSettings.omitCommas) {
  1716. s = s.replace(COMMA_RE, '').trim();
  1717. }
  1718. if (extendedSettings.omitZeroMinute) {
  1719. s = s.replace(':00', ''); // zeroFormat doesn't always achieve this
  1720. }
  1721. // ^ do anything that might create adjacent spaces before this point,
  1722. // because MERIDIEM_RE likes to eat up loading spaces
  1723. if (extendedSettings.meridiem === false) {
  1724. s = s.replace(MERIDIEM_RE, '').trim();
  1725. }
  1726. else if (extendedSettings.meridiem === 'narrow') { // a/p
  1727. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1728. return m1.toLocaleLowerCase();
  1729. });
  1730. }
  1731. else if (extendedSettings.meridiem === 'short') { // am/pm
  1732. s = s.replace(MERIDIEM_RE, function (m0, m1) {
  1733. return m1.toLocaleLowerCase() + 'm';
  1734. });
  1735. }
  1736. else if (extendedSettings.meridiem === 'lowercase') { // other meridiem transformers already converted to lowercase
  1737. s = s.replace(MERIDIEM_RE, function (m0) {
  1738. return m0.toLocaleLowerCase();
  1739. });
  1740. }
  1741. s = s.replace(MULTI_SPACE_RE, ' ');
  1742. s = s.trim();
  1743. return s;
  1744. }
  1745. function injectTzoStr(s, tzoStr) {
  1746. var replaced = false;
  1747. s = s.replace(UTC_RE, function () {
  1748. replaced = true;
  1749. return tzoStr;
  1750. });
  1751. // IE11 doesn't include UTC/GMT in the original string, so append to end
  1752. if (!replaced) {
  1753. s += ' ' + tzoStr;
  1754. }
  1755. return s;
  1756. }
  1757. function formatWeekNumber(num, weekLabel, locale, display) {
  1758. var parts = [];
  1759. if (display === 'narrow') {
  1760. parts.push(weekLabel);
  1761. }
  1762. else if (display === 'short') {
  1763. parts.push(weekLabel, ' ');
  1764. }
  1765. // otherwise, considered 'numeric'
  1766. parts.push(locale.simpleNumberFormat.format(num));
  1767. if (locale.options.isRtl) { // TODO: use control characters instead?
  1768. parts.reverse();
  1769. }
  1770. return parts.join('');
  1771. }
  1772. // Range Formatting Utils
  1773. // 0 = exactly the same
  1774. // 1 = different by time
  1775. // and bigger
  1776. function computeMarkerDiffSeverity(d0, d1, ca) {
  1777. if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
  1778. return 5;
  1779. }
  1780. if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
  1781. return 4;
  1782. }
  1783. if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
  1784. return 2;
  1785. }
  1786. if (timeAsMs(d0) !== timeAsMs(d1)) {
  1787. return 1;
  1788. }
  1789. return 0;
  1790. }
  1791. function computePartialFormattingOptions(options, biggestUnit) {
  1792. var partialOptions = {};
  1793. for (var name_2 in options) {
  1794. if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || // not a date part prop (like timeZone)
  1795. STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
  1796. partialOptions[name_2] = options[name_2];
  1797. }
  1798. }
  1799. return partialOptions;
  1800. }
  1801. function findCommonInsertion(full0, partial0, full1, partial1) {
  1802. var i0 = 0;
  1803. while (i0 < full0.length) {
  1804. var found0 = full0.indexOf(partial0, i0);
  1805. if (found0 === -1) {
  1806. break;
  1807. }
  1808. var before0 = full0.substr(0, found0);
  1809. i0 = found0 + partial0.length;
  1810. var after0 = full0.substr(i0);
  1811. var i1 = 0;
  1812. while (i1 < full1.length) {
  1813. var found1 = full1.indexOf(partial1, i1);
  1814. if (found1 === -1) {
  1815. break;
  1816. }
  1817. var before1 = full1.substr(0, found1);
  1818. i1 = found1 + partial1.length;
  1819. var after1 = full1.substr(i1);
  1820. if (before0 === before1 && after0 === after1) {
  1821. return {
  1822. before: before0,
  1823. after: after0
  1824. };
  1825. }
  1826. }
  1827. }
  1828. return null;
  1829. }
  1830. /*
  1831. TODO: fix the terminology of "formatter" vs "formatting func"
  1832. */
  1833. /*
  1834. At the time of instantiation, this object does not know which cmd-formatting system it will use.
  1835. It receives this at the time of formatting, as a setting.
  1836. */
  1837. var CmdFormatter = /** @class */ (function () {
  1838. function CmdFormatter(cmdStr, separator) {
  1839. this.cmdStr = cmdStr;
  1840. this.separator = separator;
  1841. }
  1842. CmdFormatter.prototype.format = function (date, context) {
  1843. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, this.separator));
  1844. };
  1845. CmdFormatter.prototype.formatRange = function (start, end, context) {
  1846. return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, this.separator));
  1847. };
  1848. return CmdFormatter;
  1849. }());
  1850. var FuncFormatter = /** @class */ (function () {
  1851. function FuncFormatter(func) {
  1852. this.func = func;
  1853. }
  1854. FuncFormatter.prototype.format = function (date, context) {
  1855. return this.func(createVerboseFormattingArg(date, null, context));
  1856. };
  1857. FuncFormatter.prototype.formatRange = function (start, end, context) {
  1858. return this.func(createVerboseFormattingArg(start, end, context));
  1859. };
  1860. return FuncFormatter;
  1861. }());
  1862. // Formatter Object Creation
  1863. function createFormatter(input, defaultSeparator) {
  1864. if (typeof input === 'object' && input) { // non-null object
  1865. if (typeof defaultSeparator === 'string') {
  1866. input = __assign({ separator: defaultSeparator }, input);
  1867. }
  1868. return new NativeFormatter(input);
  1869. }
  1870. else if (typeof input === 'string') {
  1871. return new CmdFormatter(input, defaultSeparator);
  1872. }
  1873. else if (typeof input === 'function') {
  1874. return new FuncFormatter(input);
  1875. }
  1876. }
  1877. // String Utils
  1878. // timeZoneOffset is in minutes
  1879. function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
  1880. if (stripZeroTime === void 0) { stripZeroTime = false; }
  1881. var s = marker.toISOString();
  1882. s = s.replace('.000', '');
  1883. if (stripZeroTime) {
  1884. s = s.replace('T00:00:00Z', '');
  1885. }
  1886. if (s.length > 10) { // time part wasn't stripped, can add timezone info
  1887. if (timeZoneOffset == null) {
  1888. s = s.replace('Z', '');
  1889. }
  1890. else if (timeZoneOffset !== 0) {
  1891. s = s.replace('Z', formatTimeZoneOffset(timeZoneOffset, true));
  1892. }
  1893. // otherwise, its UTC-0 and we want to keep the Z
  1894. }
  1895. return s;
  1896. }
  1897. function formatIsoTimeString(marker) {
  1898. return padStart(marker.getUTCHours(), 2) + ':' +
  1899. padStart(marker.getUTCMinutes(), 2) + ':' +
  1900. padStart(marker.getUTCSeconds(), 2);
  1901. }
  1902. function formatTimeZoneOffset(minutes, doIso) {
  1903. if (doIso === void 0) { doIso = false; }
  1904. var sign = minutes < 0 ? '-' : '+';
  1905. var abs = Math.abs(minutes);
  1906. var hours = Math.floor(abs / 60);
  1907. var mins = Math.round(abs % 60);
  1908. if (doIso) {
  1909. return sign + padStart(hours, 2) + ':' + padStart(mins, 2);
  1910. }
  1911. else {
  1912. return 'GMT' + sign + hours + (mins ? ':' + padStart(mins, 2) : '');
  1913. }
  1914. }
  1915. // Arg Utils
  1916. function createVerboseFormattingArg(start, end, context, separator) {
  1917. var startInfo = expandZonedMarker(start, context.calendarSystem);
  1918. var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
  1919. return {
  1920. date: startInfo,
  1921. start: startInfo,
  1922. end: endInfo,
  1923. timeZone: context.timeZone,
  1924. localeCodes: context.locale.codes,
  1925. separator: separator
  1926. };
  1927. }
  1928. function expandZonedMarker(dateInfo, calendarSystem) {
  1929. var a = calendarSystem.markerToArray(dateInfo.marker);
  1930. return {
  1931. marker: dateInfo.marker,
  1932. timeZoneOffset: dateInfo.timeZoneOffset,
  1933. array: a,
  1934. year: a[0],
  1935. month: a[1],
  1936. day: a[2],
  1937. hour: a[3],
  1938. minute: a[4],
  1939. second: a[5],
  1940. millisecond: a[6]
  1941. };
  1942. }
  1943. var EventSourceApi = /** @class */ (function () {
  1944. function EventSourceApi(calendar, internalEventSource) {
  1945. this.calendar = calendar;
  1946. this.internalEventSource = internalEventSource;
  1947. }
  1948. EventSourceApi.prototype.remove = function () {
  1949. this.calendar.dispatch({
  1950. type: 'REMOVE_EVENT_SOURCE',
  1951. sourceId: this.internalEventSource.sourceId
  1952. });
  1953. };
  1954. EventSourceApi.prototype.refetch = function () {
  1955. this.calendar.dispatch({
  1956. type: 'FETCH_EVENT_SOURCES',
  1957. sourceIds: [this.internalEventSource.sourceId]
  1958. });
  1959. };
  1960. Object.defineProperty(EventSourceApi.prototype, "id", {
  1961. get: function () {
  1962. return this.internalEventSource.publicId;
  1963. },
  1964. enumerable: true,
  1965. configurable: true
  1966. });
  1967. Object.defineProperty(EventSourceApi.prototype, "url", {
  1968. // only relevant to json-feed event sources
  1969. get: function () {
  1970. return this.internalEventSource.meta.url;
  1971. },
  1972. enumerable: true,
  1973. configurable: true
  1974. });
  1975. return EventSourceApi;
  1976. }());
  1977. var EventApi = /** @class */ (function () {
  1978. function EventApi(calendar, def, instance) {
  1979. this._calendar = calendar;
  1980. this._def = def;
  1981. this._instance = instance || null;
  1982. }
  1983. /*
  1984. TODO: make event struct more responsible for this
  1985. */
  1986. EventApi.prototype.setProp = function (name, val) {
  1987. var _a, _b;
  1988. if (name in DATE_PROPS) ;
  1989. else if (name in NON_DATE_PROPS) {
  1990. if (typeof NON_DATE_PROPS[name] === 'function') {
  1991. val = NON_DATE_PROPS[name](val);
  1992. }
  1993. this.mutate({
  1994. standardProps: (_a = {}, _a[name] = val, _a)
  1995. });
  1996. }
  1997. else if (name in UNSCOPED_EVENT_UI_PROPS) {
  1998. var ui = void 0;
  1999. if (typeof UNSCOPED_EVENT_UI_PROPS[name] === 'function') {
  2000. val = UNSCOPED_EVENT_UI_PROPS[name](val);
  2001. }
  2002. if (name === 'color') {
  2003. ui = { backgroundColor: val, borderColor: val };
  2004. }
  2005. else if (name === 'editable') {
  2006. ui = { startEditable: val, durationEditable: val };
  2007. }
  2008. else {
  2009. ui = (_b = {}, _b[name] = val, _b);
  2010. }
  2011. this.mutate({
  2012. standardProps: { ui: ui }
  2013. });
  2014. }
  2015. };
  2016. EventApi.prototype.setExtendedProp = function (name, val) {
  2017. var _a;
  2018. this.mutate({
  2019. extendedProps: (_a = {}, _a[name] = val, _a)
  2020. });
  2021. };
  2022. EventApi.prototype.setStart = function (startInput, options) {
  2023. if (options === void 0) { options = {}; }
  2024. var dateEnv = this._calendar.dateEnv;
  2025. var start = dateEnv.createMarker(startInput);
  2026. if (start && this._instance) { // TODO: warning if parsed bad
  2027. var instanceRange = this._instance.range;
  2028. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity); // what if parsed bad!?
  2029. if (options.maintainDuration) {
  2030. this.mutate({ datesDelta: startDelta });
  2031. }
  2032. else {
  2033. this.mutate({ startDelta: startDelta });
  2034. }
  2035. }
  2036. };
  2037. EventApi.prototype.setEnd = function (endInput, options) {
  2038. if (options === void 0) { options = {}; }
  2039. var dateEnv = this._calendar.dateEnv;
  2040. var end;
  2041. if (endInput != null) {
  2042. end = dateEnv.createMarker(endInput);
  2043. if (!end) {
  2044. return; // TODO: warning if parsed bad
  2045. }
  2046. }
  2047. if (this._instance) {
  2048. if (end) {
  2049. var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
  2050. this.mutate({ endDelta: endDelta });
  2051. }
  2052. else {
  2053. this.mutate({ standardProps: { hasEnd: false } });
  2054. }
  2055. }
  2056. };
  2057. EventApi.prototype.setDates = function (startInput, endInput, options) {
  2058. if (options === void 0) { options = {}; }
  2059. var dateEnv = this._calendar.dateEnv;
  2060. var standardProps = { allDay: options.allDay };
  2061. var start = dateEnv.createMarker(startInput);
  2062. var end;
  2063. if (!start) {
  2064. return; // TODO: warning if parsed bad
  2065. }
  2066. if (endInput != null) {
  2067. end = dateEnv.createMarker(endInput);
  2068. if (!end) { // TODO: warning if parsed bad
  2069. return;
  2070. }
  2071. }
  2072. if (this._instance) {
  2073. var instanceRange = this._instance.range;
  2074. // when computing the diff for an event being converted to all-day,
  2075. // compute diff off of the all-day values the way event-mutation does.
  2076. if (options.allDay === true) {
  2077. instanceRange = computeAlignedDayRange(instanceRange);
  2078. }
  2079. var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
  2080. if (end) {
  2081. var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
  2082. if (durationsEqual(startDelta, endDelta)) {
  2083. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  2084. }
  2085. else {
  2086. this.mutate({ startDelta: startDelta, endDelta: endDelta, standardProps: standardProps });
  2087. }
  2088. }
  2089. else { // means "clear the end"
  2090. standardProps.hasEnd = false;
  2091. this.mutate({ datesDelta: startDelta, standardProps: standardProps });
  2092. }
  2093. }
  2094. };
  2095. EventApi.prototype.moveStart = function (deltaInput) {
  2096. var delta = createDuration(deltaInput);
  2097. if (delta) { // TODO: warning if parsed bad
  2098. this.mutate({ startDelta: delta });
  2099. }
  2100. };
  2101. EventApi.prototype.moveEnd = function (deltaInput) {
  2102. var delta = createDuration(deltaInput);
  2103. if (delta) { // TODO: warning if parsed bad
  2104. this.mutate({ endDelta: delta });
  2105. }
  2106. };
  2107. EventApi.prototype.moveDates = function (deltaInput) {
  2108. var delta = createDuration(deltaInput);
  2109. if (delta) { // TODO: warning if parsed bad
  2110. this.mutate({ datesDelta: delta });
  2111. }
  2112. };
  2113. EventApi.prototype.setAllDay = function (allDay, options) {
  2114. if (options === void 0) { options = {}; }
  2115. var standardProps = { allDay: allDay };
  2116. var maintainDuration = options.maintainDuration;
  2117. if (maintainDuration == null) {
  2118. maintainDuration = this._calendar.opt('allDayMaintainDuration');
  2119. }
  2120. if (this._def.allDay !== allDay) {
  2121. standardProps.hasEnd = maintainDuration;
  2122. }
  2123. this.mutate({ standardProps: standardProps });
  2124. };
  2125. EventApi.prototype.formatRange = function (formatInput) {
  2126. var dateEnv = this._calendar.dateEnv;
  2127. var instance = this._instance;
  2128. var formatter = createFormatter(formatInput, this._calendar.opt('defaultRangeSeparator'));
  2129. if (this._def.hasEnd) {
  2130. return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
  2131. forcedStartTzo: instance.forcedStartTzo,
  2132. forcedEndTzo: instance.forcedEndTzo
  2133. });
  2134. }
  2135. else {
  2136. return dateEnv.format(instance.range.start, formatter, {
  2137. forcedTzo: instance.forcedStartTzo
  2138. });
  2139. }
  2140. };
  2141. EventApi.prototype.mutate = function (mutation) {
  2142. var def = this._def;
  2143. var instance = this._instance;
  2144. if (instance) {
  2145. this._calendar.dispatch({
  2146. type: 'MUTATE_EVENTS',
  2147. instanceId: instance.instanceId,
  2148. mutation: mutation,
  2149. fromApi: true
  2150. });
  2151. var eventStore = this._calendar.state.eventStore;
  2152. this._def = eventStore.defs[def.defId];
  2153. this._instance = eventStore.instances[instance.instanceId];
  2154. }
  2155. };
  2156. EventApi.prototype.remove = function () {
  2157. this._calendar.dispatch({
  2158. type: 'REMOVE_EVENT_DEF',
  2159. defId: this._def.defId
  2160. });
  2161. };
  2162. Object.defineProperty(EventApi.prototype, "source", {
  2163. get: function () {
  2164. var sourceId = this._def.sourceId;
  2165. if (sourceId) {
  2166. return new EventSourceApi(this._calendar, this._calendar.state.eventSources[sourceId]);
  2167. }
  2168. return null;
  2169. },
  2170. enumerable: true,
  2171. configurable: true
  2172. });
  2173. Object.defineProperty(EventApi.prototype, "start", {
  2174. get: function () {
  2175. return this._instance ?
  2176. this._calendar.dateEnv.toDate(this._instance.range.start) :
  2177. null;
  2178. },
  2179. enumerable: true,
  2180. configurable: true
  2181. });
  2182. Object.defineProperty(EventApi.prototype, "end", {
  2183. get: function () {
  2184. return (this._instance && this._def.hasEnd) ?
  2185. this._calendar.dateEnv.toDate(this._instance.range.end) :
  2186. null;
  2187. },
  2188. enumerable: true,
  2189. configurable: true
  2190. });
  2191. Object.defineProperty(EventApi.prototype, "id", {
  2192. // computable props that all access the def
  2193. // TODO: find a TypeScript-compatible way to do this at scale
  2194. get: function () { return this._def.publicId; },
  2195. enumerable: true,
  2196. configurable: true
  2197. });
  2198. Object.defineProperty(EventApi.prototype, "groupId", {
  2199. get: function () { return this._def.groupId; },
  2200. enumerable: true,
  2201. configurable: true
  2202. });
  2203. Object.defineProperty(EventApi.prototype, "allDay", {
  2204. get: function () { return this._def.allDay; },
  2205. enumerable: true,
  2206. configurable: true
  2207. });
  2208. Object.defineProperty(EventApi.prototype, "title", {
  2209. get: function () { return this._def.title; },
  2210. enumerable: true,
  2211. configurable: true
  2212. });
  2213. Object.defineProperty(EventApi.prototype, "url", {
  2214. get: function () { return this._def.url; },
  2215. enumerable: true,
  2216. configurable: true
  2217. });
  2218. Object.defineProperty(EventApi.prototype, "rendering", {
  2219. get: function () { return this._def.rendering; },
  2220. enumerable: true,
  2221. configurable: true
  2222. });
  2223. Object.defineProperty(EventApi.prototype, "startEditable", {
  2224. get: function () { return this._def.ui.startEditable; },
  2225. enumerable: true,
  2226. configurable: true
  2227. });
  2228. Object.defineProperty(EventApi.prototype, "durationEditable", {
  2229. get: function () { return this._def.ui.durationEditable; },
  2230. enumerable: true,
  2231. configurable: true
  2232. });
  2233. Object.defineProperty(EventApi.prototype, "constraint", {
  2234. get: function () { return this._def.ui.constraints[0] || null; },
  2235. enumerable: true,
  2236. configurable: true
  2237. });
  2238. Object.defineProperty(EventApi.prototype, "overlap", {
  2239. get: function () { return this._def.ui.overlap; },
  2240. enumerable: true,
  2241. configurable: true
  2242. });
  2243. Object.defineProperty(EventApi.prototype, "allow", {
  2244. get: function () { return this._def.ui.allows[0] || null; },
  2245. enumerable: true,
  2246. configurable: true
  2247. });
  2248. Object.defineProperty(EventApi.prototype, "backgroundColor", {
  2249. get: function () { return this._def.ui.backgroundColor; },
  2250. enumerable: true,
  2251. configurable: true
  2252. });
  2253. Object.defineProperty(EventApi.prototype, "borderColor", {
  2254. get: function () { return this._def.ui.borderColor; },
  2255. enumerable: true,
  2256. configurable: true
  2257. });
  2258. Object.defineProperty(EventApi.prototype, "textColor", {
  2259. get: function () { return this._def.ui.textColor; },
  2260. enumerable: true,
  2261. configurable: true
  2262. });
  2263. Object.defineProperty(EventApi.prototype, "classNames", {
  2264. // NOTE: user can't modify these because Object.freeze was called in event-def parsing
  2265. get: function () { return this._def.ui.classNames; },
  2266. enumerable: true,
  2267. configurable: true
  2268. });
  2269. Object.defineProperty(EventApi.prototype, "extendedProps", {
  2270. get: function () { return this._def.extendedProps; },
  2271. enumerable: true,
  2272. configurable: true
  2273. });
  2274. return EventApi;
  2275. }());
  2276. /*
  2277. Specifying nextDayThreshold signals that all-day ranges should be sliced.
  2278. */
  2279. function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
  2280. var inverseBgByGroupId = {};
  2281. var inverseBgByDefId = {};
  2282. var defByGroupId = {};
  2283. var bgRanges = [];
  2284. var fgRanges = [];
  2285. var eventUis = compileEventUis(eventStore.defs, eventUiBases);
  2286. for (var defId in eventStore.defs) {
  2287. var def = eventStore.defs[defId];
  2288. if (def.rendering === 'inverse-background') {
  2289. if (def.groupId) {
  2290. inverseBgByGroupId[def.groupId] = [];
  2291. if (!defByGroupId[def.groupId]) {
  2292. defByGroupId[def.groupId] = def;
  2293. }
  2294. }
  2295. else {
  2296. inverseBgByDefId[defId] = [];
  2297. }
  2298. }
  2299. }
  2300. for (var instanceId in eventStore.instances) {
  2301. var instance = eventStore.instances[instanceId];
  2302. var def = eventStore.defs[instance.defId];
  2303. var ui = eventUis[def.defId];
  2304. var origRange = instance.range;
  2305. var normalRange = (!def.allDay && nextDayThreshold) ?
  2306. computeVisibleDayRange(origRange, nextDayThreshold) :
  2307. origRange;
  2308. var slicedRange = intersectRanges(normalRange, framingRange);
  2309. if (slicedRange) {
  2310. if (def.rendering === 'inverse-background') {
  2311. if (def.groupId) {
  2312. inverseBgByGroupId[def.groupId].push(slicedRange);
  2313. }
  2314. else {
  2315. inverseBgByDefId[instance.defId].push(slicedRange);
  2316. }
  2317. }
  2318. else {
  2319. (def.rendering === 'background' ? bgRanges : fgRanges).push({
  2320. def: def,
  2321. ui: ui,
  2322. instance: instance,
  2323. range: slicedRange,
  2324. isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
  2325. isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf()
  2326. });
  2327. }
  2328. }
  2329. }
  2330. for (var groupId in inverseBgByGroupId) { // BY GROUP
  2331. var ranges = inverseBgByGroupId[groupId];
  2332. var invertedRanges = invertRanges(ranges, framingRange);
  2333. for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
  2334. var invertedRange = invertedRanges_1[_i];
  2335. var def = defByGroupId[groupId];
  2336. var ui = eventUis[def.defId];
  2337. bgRanges.push({
  2338. def: def,
  2339. ui: ui,
  2340. instance: null,
  2341. range: invertedRange,
  2342. isStart: false,
  2343. isEnd: false
  2344. });
  2345. }
  2346. }
  2347. for (var defId in inverseBgByDefId) {
  2348. var ranges = inverseBgByDefId[defId];
  2349. var invertedRanges = invertRanges(ranges, framingRange);
  2350. for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
  2351. var invertedRange = invertedRanges_2[_a];
  2352. bgRanges.push({
  2353. def: eventStore.defs[defId],
  2354. ui: eventUis[defId],
  2355. instance: null,
  2356. range: invertedRange,
  2357. isStart: false,
  2358. isEnd: false
  2359. });
  2360. }
  2361. }
  2362. return { bg: bgRanges, fg: fgRanges };
  2363. }
  2364. function hasBgRendering(def) {
  2365. return def.rendering === 'background' || def.rendering === 'inverse-background';
  2366. }
  2367. function filterSegsViaEls(view, segs, isMirror) {
  2368. if (view.hasPublicHandlers('eventRender')) {
  2369. segs = segs.filter(function (seg) {
  2370. var custom = view.publiclyTrigger('eventRender', [
  2371. {
  2372. event: new EventApi(view.calendar, seg.eventRange.def, seg.eventRange.instance),
  2373. isMirror: isMirror,
  2374. isStart: seg.isStart,
  2375. isEnd: seg.isEnd,
  2376. // TODO: include seg.range once all components consistently generate it
  2377. el: seg.el,
  2378. view: view
  2379. }
  2380. ]);
  2381. if (custom === false) { // means don't render at all
  2382. return false;
  2383. }
  2384. else if (custom && custom !== true) {
  2385. seg.el = custom;
  2386. }
  2387. return true;
  2388. });
  2389. }
  2390. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  2391. var seg = segs_1[_i];
  2392. setElSeg(seg.el, seg);
  2393. }
  2394. return segs;
  2395. }
  2396. function setElSeg(el, seg) {
  2397. el.fcSeg = seg;
  2398. }
  2399. function getElSeg(el) {
  2400. return el.fcSeg || null;
  2401. }
  2402. // event ui computation
  2403. function compileEventUis(eventDefs, eventUiBases) {
  2404. return mapHash(eventDefs, function (eventDef) {
  2405. return compileEventUi(eventDef, eventUiBases);
  2406. });
  2407. }
  2408. function compileEventUi(eventDef, eventUiBases) {
  2409. var uis = [];
  2410. if (eventUiBases['']) {
  2411. uis.push(eventUiBases['']);
  2412. }
  2413. if (eventUiBases[eventDef.defId]) {
  2414. uis.push(eventUiBases[eventDef.defId]);
  2415. }
  2416. uis.push(eventDef.ui);
  2417. return combineEventUis(uis);
  2418. }
  2419. // applies the mutation to ALL defs/instances within the event store
  2420. function applyMutationToEventStore(eventStore, eventConfigBase, mutation, calendar) {
  2421. var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
  2422. var dest = createEmptyEventStore();
  2423. for (var defId in eventStore.defs) {
  2424. var def = eventStore.defs[defId];
  2425. dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, calendar.pluginSystem.hooks.eventDefMutationAppliers, calendar);
  2426. }
  2427. for (var instanceId in eventStore.instances) {
  2428. var instance = eventStore.instances[instanceId];
  2429. var def = dest.defs[instance.defId]; // important to grab the newly modified def
  2430. dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, calendar);
  2431. }
  2432. return dest;
  2433. }
  2434. function applyMutationToEventDef(eventDef, eventConfig, mutation, appliers, calendar) {
  2435. var standardProps = mutation.standardProps || {};
  2436. // if hasEnd has not been specified, guess a good value based on deltas.
  2437. // if duration will change, there's no way the default duration will persist,
  2438. // and thus, we need to mark the event as having a real end
  2439. if (standardProps.hasEnd == null &&
  2440. eventConfig.durationEditable &&
  2441. (mutation.startDelta || mutation.endDelta)) {
  2442. standardProps.hasEnd = true; // TODO: is this mutation okay?
  2443. }
  2444. var copy = __assign({}, eventDef, standardProps, { ui: __assign({}, eventDef.ui, standardProps.ui) });
  2445. if (mutation.extendedProps) {
  2446. copy.extendedProps = __assign({}, copy.extendedProps, mutation.extendedProps);
  2447. }
  2448. for (var _i = 0, appliers_1 = appliers; _i < appliers_1.length; _i++) {
  2449. var applier = appliers_1[_i];
  2450. applier(copy, mutation, calendar);
  2451. }
  2452. if (!copy.hasEnd && calendar.opt('forceEventDuration')) {
  2453. copy.hasEnd = true;
  2454. }
  2455. return copy;
  2456. }
  2457. function applyMutationToEventInstance(eventInstance, eventDef, // must first be modified by applyMutationToEventDef
  2458. eventConfig, mutation, calendar) {
  2459. var dateEnv = calendar.dateEnv;
  2460. var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
  2461. var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
  2462. var copy = __assign({}, eventInstance);
  2463. if (forceAllDay) {
  2464. copy.range = computeAlignedDayRange(copy.range);
  2465. }
  2466. if (mutation.datesDelta && eventConfig.startEditable) {
  2467. copy.range = {
  2468. start: dateEnv.add(copy.range.start, mutation.datesDelta),
  2469. end: dateEnv.add(copy.range.end, mutation.datesDelta)
  2470. };
  2471. }
  2472. if (mutation.startDelta && eventConfig.durationEditable) {
  2473. copy.range = {
  2474. start: dateEnv.add(copy.range.start, mutation.startDelta),
  2475. end: copy.range.end
  2476. };
  2477. }
  2478. if (mutation.endDelta && eventConfig.durationEditable) {
  2479. copy.range = {
  2480. start: copy.range.start,
  2481. end: dateEnv.add(copy.range.end, mutation.endDelta)
  2482. };
  2483. }
  2484. if (clearEnd) {
  2485. copy.range = {
  2486. start: copy.range.start,
  2487. end: calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start)
  2488. };
  2489. }
  2490. // in case event was all-day but the supplied deltas were not
  2491. // better util for this?
  2492. if (eventDef.allDay) {
  2493. copy.range = {
  2494. start: startOfDay(copy.range.start),
  2495. end: startOfDay(copy.range.end)
  2496. };
  2497. }
  2498. // handle invalid durations
  2499. if (copy.range.end < copy.range.start) {
  2500. copy.range.end = calendar.getDefaultEventEnd(eventDef.allDay, copy.range.start);
  2501. }
  2502. return copy;
  2503. }
  2504. function reduceEventStore (eventStore, action, eventSources, dateProfile, calendar) {
  2505. switch (action.type) {
  2506. case 'RECEIVE_EVENTS': // raw
  2507. return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, calendar);
  2508. case 'ADD_EVENTS': // already parsed, but not expanded
  2509. return addEvent(eventStore, action.eventStore, // new ones
  2510. dateProfile ? dateProfile.activeRange : null, calendar);
  2511. case 'MERGE_EVENTS': // already parsed and expanded
  2512. return mergeEventStores(eventStore, action.eventStore);
  2513. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  2514. case 'NEXT':
  2515. case 'SET_DATE':
  2516. case 'SET_VIEW_TYPE':
  2517. if (dateProfile) {
  2518. return expandRecurring(eventStore, dateProfile.activeRange, calendar);
  2519. }
  2520. else {
  2521. return eventStore;
  2522. }
  2523. case 'CHANGE_TIMEZONE':
  2524. return rezoneDates(eventStore, action.oldDateEnv, calendar.dateEnv);
  2525. case 'MUTATE_EVENTS':
  2526. return applyMutationToRelated(eventStore, action.instanceId, action.mutation, action.fromApi, calendar);
  2527. case 'REMOVE_EVENT_INSTANCES':
  2528. return excludeInstances(eventStore, action.instances);
  2529. case 'REMOVE_EVENT_DEF':
  2530. return filterEventStoreDefs(eventStore, function (eventDef) {
  2531. return eventDef.defId !== action.defId;
  2532. });
  2533. case 'REMOVE_EVENT_SOURCE':
  2534. return excludeEventsBySourceId(eventStore, action.sourceId);
  2535. case 'REMOVE_ALL_EVENT_SOURCES':
  2536. return filterEventStoreDefs(eventStore, function (eventDef) {
  2537. return !eventDef.sourceId; // only keep events with no source id
  2538. });
  2539. case 'REMOVE_ALL_EVENTS':
  2540. return createEmptyEventStore();
  2541. case 'RESET_EVENTS':
  2542. return {
  2543. defs: eventStore.defs,
  2544. instances: eventStore.instances
  2545. };
  2546. default:
  2547. return eventStore;
  2548. }
  2549. }
  2550. function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, calendar) {
  2551. if (eventSource && // not already removed
  2552. fetchId === eventSource.latestFetchId // TODO: wish this logic was always in event-sources
  2553. ) {
  2554. var subset = parseEvents(transformRawEvents(rawEvents, eventSource, calendar), eventSource.sourceId, calendar);
  2555. if (fetchRange) {
  2556. subset = expandRecurring(subset, fetchRange, calendar);
  2557. }
  2558. return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
  2559. }
  2560. return eventStore;
  2561. }
  2562. function addEvent(eventStore, subset, expandRange, calendar) {
  2563. if (expandRange) {
  2564. subset = expandRecurring(subset, expandRange, calendar);
  2565. }
  2566. return mergeEventStores(eventStore, subset);
  2567. }
  2568. function rezoneDates(eventStore, oldDateEnv, newDateEnv) {
  2569. var defs = eventStore.defs;
  2570. var instances = mapHash(eventStore.instances, function (instance) {
  2571. var def = defs[instance.defId];
  2572. if (def.allDay || def.recurringDef) {
  2573. return instance; // isn't dependent on timezone
  2574. }
  2575. else {
  2576. return __assign({}, instance, { range: {
  2577. start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
  2578. end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo))
  2579. }, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
  2580. }
  2581. });
  2582. return { defs: defs, instances: instances };
  2583. }
  2584. function applyMutationToRelated(eventStore, instanceId, mutation, fromApi, calendar) {
  2585. var relevant = getRelevantEvents(eventStore, instanceId);
  2586. var eventConfigBase = fromApi ?
  2587. { '': {
  2588. startEditable: true,
  2589. durationEditable: true,
  2590. constraints: [],
  2591. overlap: null,
  2592. allows: [],
  2593. backgroundColor: '',
  2594. borderColor: '',
  2595. textColor: '',
  2596. classNames: []
  2597. } } :
  2598. calendar.eventUiBases;
  2599. relevant = applyMutationToEventStore(relevant, eventConfigBase, mutation, calendar);
  2600. return mergeEventStores(eventStore, relevant);
  2601. }
  2602. function excludeEventsBySourceId(eventStore, sourceId) {
  2603. return filterEventStoreDefs(eventStore, function (eventDef) {
  2604. return eventDef.sourceId !== sourceId;
  2605. });
  2606. }
  2607. // QUESTION: why not just return instances? do a general object-property-exclusion util
  2608. function excludeInstances(eventStore, removals) {
  2609. return {
  2610. defs: eventStore.defs,
  2611. instances: filterHash(eventStore.instances, function (instance) {
  2612. return !removals[instance.instanceId];
  2613. })
  2614. };
  2615. }
  2616. // high-level segmenting-aware tester functions
  2617. // ------------------------------------------------------------------------------------------------------------------------
  2618. function isInteractionValid(interaction, calendar) {
  2619. return isNewPropsValid({ eventDrag: interaction }, calendar); // HACK: the eventDrag props is used for ALL interactions
  2620. }
  2621. function isDateSelectionValid(dateSelection, calendar) {
  2622. return isNewPropsValid({ dateSelection: dateSelection }, calendar);
  2623. }
  2624. function isNewPropsValid(newProps, calendar) {
  2625. var view = calendar.view;
  2626. var props = __assign({ businessHours: view ? view.props.businessHours : createEmptyEventStore(), dateSelection: '', eventStore: calendar.state.eventStore, eventUiBases: calendar.eventUiBases, eventSelection: '', eventDrag: null, eventResize: null }, newProps);
  2627. return (calendar.pluginSystem.hooks.isPropsValid || isPropsValid)(props, calendar);
  2628. }
  2629. function isPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2630. if (dateSpanMeta === void 0) { dateSpanMeta = {}; }
  2631. if (state.eventDrag && !isInteractionPropsValid(state, calendar, dateSpanMeta, filterConfig)) {
  2632. return false;
  2633. }
  2634. if (state.dateSelection && !isDateSelectionPropsValid(state, calendar, dateSpanMeta, filterConfig)) {
  2635. return false;
  2636. }
  2637. return true;
  2638. }
  2639. // Moving Event Validation
  2640. // ------------------------------------------------------------------------------------------------------------------------
  2641. function isInteractionPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2642. var interaction = state.eventDrag; // HACK: the eventDrag props is used for ALL interactions
  2643. var subjectEventStore = interaction.mutatedEvents;
  2644. var subjectDefs = subjectEventStore.defs;
  2645. var subjectInstances = subjectEventStore.instances;
  2646. var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ?
  2647. state.eventUiBases :
  2648. { '': calendar.selectionConfig } // if not a real event, validate as a selection
  2649. );
  2650. if (filterConfig) {
  2651. subjectConfigs = mapHash(subjectConfigs, filterConfig);
  2652. }
  2653. var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances); // exclude the subject events. TODO: exclude defs too?
  2654. var otherDefs = otherEventStore.defs;
  2655. var otherInstances = otherEventStore.instances;
  2656. var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
  2657. for (var subjectInstanceId in subjectInstances) {
  2658. var subjectInstance = subjectInstances[subjectInstanceId];
  2659. var subjectRange = subjectInstance.range;
  2660. var subjectConfig = subjectConfigs[subjectInstance.defId];
  2661. var subjectDef = subjectDefs[subjectInstance.defId];
  2662. // constraint
  2663. if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, calendar)) {
  2664. return false;
  2665. }
  2666. // overlap
  2667. var overlapFunc = calendar.opt('eventOverlap');
  2668. if (typeof overlapFunc !== 'function') {
  2669. overlapFunc = null;
  2670. }
  2671. for (var otherInstanceId in otherInstances) {
  2672. var otherInstance = otherInstances[otherInstanceId];
  2673. // intersect! evaluate
  2674. if (rangesIntersect(subjectRange, otherInstance.range)) {
  2675. var otherOverlap = otherConfigs[otherInstance.defId].overlap;
  2676. // consider the other event's overlap. only do this if the subject event is a "real" event
  2677. if (otherOverlap === false && interaction.isEvent) {
  2678. return false;
  2679. }
  2680. if (subjectConfig.overlap === false) {
  2681. return false;
  2682. }
  2683. if (overlapFunc && !overlapFunc(new EventApi(calendar, otherDefs[otherInstance.defId], otherInstance), // still event
  2684. new EventApi(calendar, subjectDef, subjectInstance) // moving event
  2685. )) {
  2686. return false;
  2687. }
  2688. }
  2689. }
  2690. // allow (a function)
  2691. var calendarEventStore = calendar.state.eventStore; // need global-to-calendar, not local to component (splittable)state
  2692. for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
  2693. var subjectAllow = _a[_i];
  2694. var subjectDateSpan = __assign({}, dateSpanMeta, { range: subjectInstance.range, allDay: subjectDef.allDay });
  2695. var origDef = calendarEventStore.defs[subjectDef.defId];
  2696. var origInstance = calendarEventStore.instances[subjectInstanceId];
  2697. var eventApi = void 0;
  2698. if (origDef) { // was previously in the calendar
  2699. eventApi = new EventApi(calendar, origDef, origInstance);
  2700. }
  2701. else { // was an external event
  2702. eventApi = new EventApi(calendar, subjectDef); // no instance, because had no dates
  2703. }
  2704. if (!subjectAllow(calendar.buildDateSpanApi(subjectDateSpan), eventApi)) {
  2705. return false;
  2706. }
  2707. }
  2708. }
  2709. return true;
  2710. }
  2711. // Date Selection Validation
  2712. // ------------------------------------------------------------------------------------------------------------------------
  2713. function isDateSelectionPropsValid(state, calendar, dateSpanMeta, filterConfig) {
  2714. var relevantEventStore = state.eventStore;
  2715. var relevantDefs = relevantEventStore.defs;
  2716. var relevantInstances = relevantEventStore.instances;
  2717. var selection = state.dateSelection;
  2718. var selectionRange = selection.range;
  2719. var selectionConfig = calendar.selectionConfig;
  2720. if (filterConfig) {
  2721. selectionConfig = filterConfig(selectionConfig);
  2722. }
  2723. // constraint
  2724. if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, calendar)) {
  2725. return false;
  2726. }
  2727. // overlap
  2728. var overlapFunc = calendar.opt('selectOverlap');
  2729. if (typeof overlapFunc !== 'function') {
  2730. overlapFunc = null;
  2731. }
  2732. for (var relevantInstanceId in relevantInstances) {
  2733. var relevantInstance = relevantInstances[relevantInstanceId];
  2734. // intersect! evaluate
  2735. if (rangesIntersect(selectionRange, relevantInstance.range)) {
  2736. if (selectionConfig.overlap === false) {
  2737. return false;
  2738. }
  2739. if (overlapFunc && !overlapFunc(new EventApi(calendar, relevantDefs[relevantInstance.defId], relevantInstance))) {
  2740. return false;
  2741. }
  2742. }
  2743. }
  2744. // allow (a function)
  2745. for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
  2746. var selectionAllow = _a[_i];
  2747. var fullDateSpan = __assign({}, dateSpanMeta, selection);
  2748. if (!selectionAllow(calendar.buildDateSpanApi(fullDateSpan), null)) {
  2749. return false;
  2750. }
  2751. }
  2752. return true;
  2753. }
  2754. // Constraint Utils
  2755. // ------------------------------------------------------------------------------------------------------------------------
  2756. function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, calendar) {
  2757. for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
  2758. var constraint = constraints_1[_i];
  2759. if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, calendar), subjectRange)) {
  2760. return false;
  2761. }
  2762. }
  2763. return true;
  2764. }
  2765. function constraintToRanges(constraint, subjectRange, // for expanding a recurring constraint, or expanding business hours
  2766. otherEventStore, // for if constraint is an even group ID
  2767. businessHoursUnexpanded, // for if constraint is 'businessHours'
  2768. calendar // for expanding businesshours
  2769. ) {
  2770. if (constraint === 'businessHours') {
  2771. return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, calendar));
  2772. }
  2773. else if (typeof constraint === 'string') { // an group ID
  2774. return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function (eventDef) {
  2775. return eventDef.groupId === constraint;
  2776. }));
  2777. }
  2778. else if (typeof constraint === 'object' && constraint) { // non-null object
  2779. return eventStoreToRanges(expandRecurring(constraint, subjectRange, calendar));
  2780. }
  2781. return []; // if it's false
  2782. }
  2783. // TODO: move to event-store file?
  2784. function eventStoreToRanges(eventStore) {
  2785. var instances = eventStore.instances;
  2786. var ranges = [];
  2787. for (var instanceId in instances) {
  2788. ranges.push(instances[instanceId].range);
  2789. }
  2790. return ranges;
  2791. }
  2792. // TODO: move to geom file?
  2793. function anyRangesContainRange(outerRanges, innerRange) {
  2794. for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
  2795. var outerRange = outerRanges_1[_i];
  2796. if (rangeContainsRange(outerRange, innerRange)) {
  2797. return true;
  2798. }
  2799. }
  2800. return false;
  2801. }
  2802. // Parsing
  2803. // ------------------------------------------------------------------------------------------------------------------------
  2804. function normalizeConstraint(input, calendar) {
  2805. if (Array.isArray(input)) {
  2806. return parseEvents(input, '', calendar, true); // allowOpenRange=true
  2807. }
  2808. else if (typeof input === 'object' && input) { // non-null object
  2809. return parseEvents([input], '', calendar, true); // allowOpenRange=true
  2810. }
  2811. else if (input != null) {
  2812. return String(input);
  2813. }
  2814. else {
  2815. return null;
  2816. }
  2817. }
  2818. function htmlEscape(s) {
  2819. return (s + '').replace(/&/g, '&amp;')
  2820. .replace(/</g, '&lt;')
  2821. .replace(/>/g, '&gt;')
  2822. .replace(/'/g, '&#039;')
  2823. .replace(/"/g, '&quot;')
  2824. .replace(/\n/g, '<br />');
  2825. }
  2826. // Given a hash of CSS properties, returns a string of CSS.
  2827. // Uses property names as-is (no camel-case conversion). Will not make statements for null/undefined values.
  2828. function cssToStr(cssProps) {
  2829. var statements = [];
  2830. for (var name_1 in cssProps) {
  2831. var val = cssProps[name_1];
  2832. if (val != null && val !== '') {
  2833. statements.push(name_1 + ':' + val);
  2834. }
  2835. }
  2836. return statements.join(';');
  2837. }
  2838. // Given an object hash of HTML attribute names to values,
  2839. // generates a string that can be injected between < > in HTML
  2840. function attrsToStr(attrs) {
  2841. var parts = [];
  2842. for (var name_2 in attrs) {
  2843. var val = attrs[name_2];
  2844. if (val != null) {
  2845. parts.push(name_2 + '="' + htmlEscape(val) + '"');
  2846. }
  2847. }
  2848. return parts.join(' ');
  2849. }
  2850. function parseClassName(raw) {
  2851. if (Array.isArray(raw)) {
  2852. return raw;
  2853. }
  2854. else if (typeof raw === 'string') {
  2855. return raw.split(/\s+/);
  2856. }
  2857. else {
  2858. return [];
  2859. }
  2860. }
  2861. var UNSCOPED_EVENT_UI_PROPS = {
  2862. editable: Boolean,
  2863. startEditable: Boolean,
  2864. durationEditable: Boolean,
  2865. constraint: null,
  2866. overlap: null,
  2867. allow: null,
  2868. className: parseClassName,
  2869. classNames: parseClassName,
  2870. color: String,
  2871. backgroundColor: String,
  2872. borderColor: String,
  2873. textColor: String
  2874. };
  2875. function processUnscopedUiProps(rawProps, calendar, leftovers) {
  2876. var props = refineProps(rawProps, UNSCOPED_EVENT_UI_PROPS, {}, leftovers);
  2877. var constraint = normalizeConstraint(props.constraint, calendar);
  2878. return {
  2879. startEditable: props.startEditable != null ? props.startEditable : props.editable,
  2880. durationEditable: props.durationEditable != null ? props.durationEditable : props.editable,
  2881. constraints: constraint != null ? [constraint] : [],
  2882. overlap: props.overlap,
  2883. allows: props.allow != null ? [props.allow] : [],
  2884. backgroundColor: props.backgroundColor || props.color,
  2885. borderColor: props.borderColor || props.color,
  2886. textColor: props.textColor,
  2887. classNames: props.classNames.concat(props.className)
  2888. };
  2889. }
  2890. function processScopedUiProps(prefix, rawScoped, calendar, leftovers) {
  2891. var rawUnscoped = {};
  2892. var wasFound = {};
  2893. for (var key in UNSCOPED_EVENT_UI_PROPS) {
  2894. var scopedKey = prefix + capitaliseFirstLetter(key);
  2895. rawUnscoped[key] = rawScoped[scopedKey];
  2896. wasFound[scopedKey] = true;
  2897. }
  2898. if (prefix === 'event') {
  2899. rawUnscoped.editable = rawScoped.editable; // special case. there is no 'eventEditable', just 'editable'
  2900. }
  2901. if (leftovers) {
  2902. for (var key in rawScoped) {
  2903. if (!wasFound[key]) {
  2904. leftovers[key] = rawScoped[key];
  2905. }
  2906. }
  2907. }
  2908. return processUnscopedUiProps(rawUnscoped, calendar);
  2909. }
  2910. var EMPTY_EVENT_UI = {
  2911. startEditable: null,
  2912. durationEditable: null,
  2913. constraints: [],
  2914. overlap: null,
  2915. allows: [],
  2916. backgroundColor: '',
  2917. borderColor: '',
  2918. textColor: '',
  2919. classNames: []
  2920. };
  2921. // prevent against problems with <2 args!
  2922. function combineEventUis(uis) {
  2923. return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
  2924. }
  2925. function combineTwoEventUis(item0, item1) {
  2926. return {
  2927. startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
  2928. durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
  2929. constraints: item0.constraints.concat(item1.constraints),
  2930. overlap: typeof item1.overlap === 'boolean' ? item1.overlap : item0.overlap,
  2931. allows: item0.allows.concat(item1.allows),
  2932. backgroundColor: item1.backgroundColor || item0.backgroundColor,
  2933. borderColor: item1.borderColor || item0.borderColor,
  2934. textColor: item1.textColor || item0.textColor,
  2935. classNames: item0.classNames.concat(item1.classNames)
  2936. };
  2937. }
  2938. var NON_DATE_PROPS = {
  2939. id: String,
  2940. groupId: String,
  2941. title: String,
  2942. url: String,
  2943. rendering: String,
  2944. extendedProps: null
  2945. };
  2946. var DATE_PROPS = {
  2947. start: null,
  2948. date: null,
  2949. end: null,
  2950. allDay: null
  2951. };
  2952. var uid = 0;
  2953. function parseEvent(raw, sourceId, calendar, allowOpenRange) {
  2954. var allDayDefault = computeIsAllDayDefault(sourceId, calendar);
  2955. var leftovers0 = {};
  2956. var recurringRes = parseRecurring(raw, // raw, but with single-event stuff stripped out
  2957. allDayDefault, calendar.dateEnv, calendar.pluginSystem.hooks.recurringTypes, leftovers0 // will populate with non-recurring props
  2958. );
  2959. if (recurringRes) {
  2960. var def = parseEventDef(leftovers0, sourceId, recurringRes.allDay, Boolean(recurringRes.duration), calendar);
  2961. def.recurringDef = {
  2962. typeId: recurringRes.typeId,
  2963. typeData: recurringRes.typeData,
  2964. duration: recurringRes.duration
  2965. };
  2966. return { def: def, instance: null };
  2967. }
  2968. else {
  2969. var leftovers1 = {};
  2970. var singleRes = parseSingle(raw, allDayDefault, calendar, leftovers1, allowOpenRange);
  2971. if (singleRes) {
  2972. var def = parseEventDef(leftovers1, sourceId, singleRes.allDay, singleRes.hasEnd, calendar);
  2973. var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
  2974. return { def: def, instance: instance };
  2975. }
  2976. }
  2977. return null;
  2978. }
  2979. /*
  2980. Will NOT populate extendedProps with the leftover properties.
  2981. Will NOT populate date-related props.
  2982. The EventNonDateInput has been normalized (id => publicId, etc).
  2983. */
  2984. function parseEventDef(raw, sourceId, allDay, hasEnd, calendar) {
  2985. var leftovers = {};
  2986. var def = pluckNonDateProps(raw, calendar, leftovers);
  2987. def.defId = String(uid++);
  2988. def.sourceId = sourceId;
  2989. def.allDay = allDay;
  2990. def.hasEnd = hasEnd;
  2991. for (var _i = 0, _a = calendar.pluginSystem.hooks.eventDefParsers; _i < _a.length; _i++) {
  2992. var eventDefParser = _a[_i];
  2993. var newLeftovers = {};
  2994. eventDefParser(def, leftovers, newLeftovers);
  2995. leftovers = newLeftovers;
  2996. }
  2997. def.extendedProps = __assign(leftovers, def.extendedProps || {});
  2998. // help out EventApi from having user modify props
  2999. Object.freeze(def.ui.classNames);
  3000. Object.freeze(def.extendedProps);
  3001. return def;
  3002. }
  3003. function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
  3004. return {
  3005. instanceId: String(uid++),
  3006. defId: defId,
  3007. range: range,
  3008. forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
  3009. forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
  3010. };
  3011. }
  3012. function parseSingle(raw, allDayDefault, calendar, leftovers, allowOpenRange) {
  3013. var props = pluckDateProps(raw, leftovers);
  3014. var allDay = props.allDay;
  3015. var startMeta;
  3016. var startMarker = null;
  3017. var hasEnd = false;
  3018. var endMeta;
  3019. var endMarker = null;
  3020. startMeta = calendar.dateEnv.createMarkerMeta(props.start);
  3021. if (startMeta) {
  3022. startMarker = startMeta.marker;
  3023. }
  3024. else if (!allowOpenRange) {
  3025. return null;
  3026. }
  3027. if (props.end != null) {
  3028. endMeta = calendar.dateEnv.createMarkerMeta(props.end);
  3029. }
  3030. if (allDay == null) {
  3031. if (allDayDefault != null) {
  3032. allDay = allDayDefault;
  3033. }
  3034. else {
  3035. // fall back to the date props LAST
  3036. allDay = (!startMeta || startMeta.isTimeUnspecified) &&
  3037. (!endMeta || endMeta.isTimeUnspecified);
  3038. }
  3039. }
  3040. if (allDay && startMarker) {
  3041. startMarker = startOfDay(startMarker);
  3042. }
  3043. if (endMeta) {
  3044. endMarker = endMeta.marker;
  3045. if (allDay) {
  3046. endMarker = startOfDay(endMarker);
  3047. }
  3048. if (startMarker && endMarker <= startMarker) {
  3049. endMarker = null;
  3050. }
  3051. }
  3052. if (endMarker) {
  3053. hasEnd = true;
  3054. }
  3055. else if (!allowOpenRange) {
  3056. hasEnd = calendar.opt('forceEventDuration') || false;
  3057. endMarker = calendar.dateEnv.add(startMarker, allDay ?
  3058. calendar.defaultAllDayEventDuration :
  3059. calendar.defaultTimedEventDuration);
  3060. }
  3061. return {
  3062. allDay: allDay,
  3063. hasEnd: hasEnd,
  3064. range: { start: startMarker, end: endMarker },
  3065. forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
  3066. forcedEndTzo: endMeta ? endMeta.forcedTzo : null
  3067. };
  3068. }
  3069. function pluckDateProps(raw, leftovers) {
  3070. var props = refineProps(raw, DATE_PROPS, {}, leftovers);
  3071. props.start = (props.start !== null) ? props.start : props.date;
  3072. delete props.date;
  3073. return props;
  3074. }
  3075. function pluckNonDateProps(raw, calendar, leftovers) {
  3076. var preLeftovers = {};
  3077. var props = refineProps(raw, NON_DATE_PROPS, {}, preLeftovers);
  3078. var ui = processUnscopedUiProps(preLeftovers, calendar, leftovers);
  3079. props.publicId = props.id;
  3080. delete props.id;
  3081. props.ui = ui;
  3082. return props;
  3083. }
  3084. function computeIsAllDayDefault(sourceId, calendar) {
  3085. var res = null;
  3086. if (sourceId) {
  3087. var source = calendar.state.eventSources[sourceId];
  3088. res = source.allDayDefault;
  3089. }
  3090. if (res == null) {
  3091. res = calendar.opt('allDayDefault');
  3092. }
  3093. return res;
  3094. }
  3095. var DEF_DEFAULTS = {
  3096. startTime: '09:00',
  3097. endTime: '17:00',
  3098. daysOfWeek: [1, 2, 3, 4, 5],
  3099. rendering: 'inverse-background',
  3100. classNames: 'fc-nonbusiness',
  3101. groupId: '_businessHours' // so multiple defs get grouped
  3102. };
  3103. /*
  3104. TODO: pass around as EventDefHash!!!
  3105. */
  3106. function parseBusinessHours(input, calendar) {
  3107. return parseEvents(refineInputs(input), '', calendar);
  3108. }
  3109. function refineInputs(input) {
  3110. var rawDefs;
  3111. if (input === true) {
  3112. rawDefs = [{}]; // will get DEF_DEFAULTS verbatim
  3113. }
  3114. else if (Array.isArray(input)) {
  3115. // if specifying an array, every sub-definition NEEDS a day-of-week
  3116. rawDefs = input.filter(function (rawDef) {
  3117. return rawDef.daysOfWeek;
  3118. });
  3119. }
  3120. else if (typeof input === 'object' && input) { // non-null object
  3121. rawDefs = [input];
  3122. }
  3123. else { // is probably false
  3124. rawDefs = [];
  3125. }
  3126. rawDefs = rawDefs.map(function (rawDef) {
  3127. return __assign({}, DEF_DEFAULTS, rawDef);
  3128. });
  3129. return rawDefs;
  3130. }
  3131. function memoizeRendering(renderFunc, unrenderFunc, dependencies) {
  3132. if (dependencies === void 0) { dependencies = []; }
  3133. var dependents = [];
  3134. var thisContext;
  3135. var prevArgs;
  3136. function unrender() {
  3137. if (prevArgs) {
  3138. for (var _i = 0, dependents_1 = dependents; _i < dependents_1.length; _i++) {
  3139. var dependent = dependents_1[_i];
  3140. dependent.unrender();
  3141. }
  3142. if (unrenderFunc) {
  3143. unrenderFunc.apply(thisContext, prevArgs);
  3144. }
  3145. prevArgs = null;
  3146. }
  3147. }
  3148. function res() {
  3149. if (!prevArgs || !isArraysEqual(prevArgs, arguments)) {
  3150. unrender();
  3151. thisContext = this;
  3152. prevArgs = arguments;
  3153. renderFunc.apply(this, arguments);
  3154. }
  3155. }
  3156. res.dependents = dependents;
  3157. res.unrender = unrender;
  3158. for (var _i = 0, dependencies_1 = dependencies; _i < dependencies_1.length; _i++) {
  3159. var dependency = dependencies_1[_i];
  3160. dependency.dependents.push(res);
  3161. }
  3162. return res;
  3163. }
  3164. var EMPTY_EVENT_STORE = createEmptyEventStore(); // for purecomponents. TODO: keep elsewhere
  3165. var Splitter = /** @class */ (function () {
  3166. function Splitter() {
  3167. this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
  3168. this.splitDateSelection = memoize(this._splitDateSpan);
  3169. this.splitEventStore = memoize(this._splitEventStore);
  3170. this.splitIndividualUi = memoize(this._splitIndividualUi);
  3171. this.splitEventDrag = memoize(this._splitInteraction);
  3172. this.splitEventResize = memoize(this._splitInteraction);
  3173. this.eventUiBuilders = {}; // TODO: typescript protection
  3174. }
  3175. Splitter.prototype.splitProps = function (props) {
  3176. var _this = this;
  3177. var keyInfos = this.getKeyInfo(props);
  3178. var defKeys = this.getKeysForEventDefs(props.eventStore);
  3179. var dateSelections = this.splitDateSelection(props.dateSelection);
  3180. var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys); // the individual *bases*
  3181. var eventStores = this.splitEventStore(props.eventStore, defKeys);
  3182. var eventDrags = this.splitEventDrag(props.eventDrag);
  3183. var eventResizes = this.splitEventResize(props.eventResize);
  3184. var splitProps = {};
  3185. this.eventUiBuilders = mapHash(keyInfos, function (info, key) {
  3186. return _this.eventUiBuilders[key] || memoize(buildEventUiForKey);
  3187. });
  3188. for (var key in keyInfos) {
  3189. var keyInfo = keyInfos[key];
  3190. var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
  3191. var buildEventUi = this.eventUiBuilders[key];
  3192. splitProps[key] = {
  3193. businessHours: keyInfo.businessHours || props.businessHours,
  3194. dateSelection: dateSelections[key] || null,
  3195. eventStore: eventStore,
  3196. eventUiBases: buildEventUi(props.eventUiBases[''], keyInfo.ui, individualUi[key]),
  3197. eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : '',
  3198. eventDrag: eventDrags[key] || null,
  3199. eventResize: eventResizes[key] || null
  3200. };
  3201. }
  3202. return splitProps;
  3203. };
  3204. Splitter.prototype._splitDateSpan = function (dateSpan) {
  3205. var dateSpans = {};
  3206. if (dateSpan) {
  3207. var keys = this.getKeysForDateSpan(dateSpan);
  3208. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  3209. var key = keys_1[_i];
  3210. dateSpans[key] = dateSpan;
  3211. }
  3212. }
  3213. return dateSpans;
  3214. };
  3215. Splitter.prototype._getKeysForEventDefs = function (eventStore) {
  3216. var _this = this;
  3217. return mapHash(eventStore.defs, function (eventDef) {
  3218. return _this.getKeysForEventDef(eventDef);
  3219. });
  3220. };
  3221. Splitter.prototype._splitEventStore = function (eventStore, defKeys) {
  3222. var defs = eventStore.defs, instances = eventStore.instances;
  3223. var splitStores = {};
  3224. for (var defId in defs) {
  3225. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  3226. var key = _a[_i];
  3227. if (!splitStores[key]) {
  3228. splitStores[key] = createEmptyEventStore();
  3229. }
  3230. splitStores[key].defs[defId] = defs[defId];
  3231. }
  3232. }
  3233. for (var instanceId in instances) {
  3234. var instance = instances[instanceId];
  3235. for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
  3236. var key = _c[_b];
  3237. if (splitStores[key]) { // must have already been created
  3238. splitStores[key].instances[instanceId] = instance;
  3239. }
  3240. }
  3241. }
  3242. return splitStores;
  3243. };
  3244. Splitter.prototype._splitIndividualUi = function (eventUiBases, defKeys) {
  3245. var splitHashes = {};
  3246. for (var defId in eventUiBases) {
  3247. if (defId) { // not the '' key
  3248. for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
  3249. var key = _a[_i];
  3250. if (!splitHashes[key]) {
  3251. splitHashes[key] = {};
  3252. }
  3253. splitHashes[key][defId] = eventUiBases[defId];
  3254. }
  3255. }
  3256. }
  3257. return splitHashes;
  3258. };
  3259. Splitter.prototype._splitInteraction = function (interaction) {
  3260. var splitStates = {};
  3261. if (interaction) {
  3262. var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents) // can't use cached. might be events from other calendar
  3263. );
  3264. // can't rely on defKeys because event data is mutated
  3265. var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
  3266. var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
  3267. var populate = function (key) {
  3268. if (!splitStates[key]) {
  3269. splitStates[key] = {
  3270. affectedEvents: affectedStores_1[key] || EMPTY_EVENT_STORE,
  3271. mutatedEvents: mutatedStores_1[key] || EMPTY_EVENT_STORE,
  3272. isEvent: interaction.isEvent,
  3273. origSeg: interaction.origSeg
  3274. };
  3275. }
  3276. };
  3277. for (var key in affectedStores_1) {
  3278. populate(key);
  3279. }
  3280. for (var key in mutatedStores_1) {
  3281. populate(key);
  3282. }
  3283. }
  3284. return splitStates;
  3285. };
  3286. return Splitter;
  3287. }());
  3288. function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
  3289. var baseParts = [];
  3290. if (allUi) {
  3291. baseParts.push(allUi);
  3292. }
  3293. if (eventUiForKey) {
  3294. baseParts.push(eventUiForKey);
  3295. }
  3296. var stuff = {
  3297. '': combineEventUis(baseParts)
  3298. };
  3299. if (individualUi) {
  3300. __assign(stuff, individualUi);
  3301. }
  3302. return stuff;
  3303. }
  3304. // Generates HTML for an anchor to another view into the calendar.
  3305. // Will either generate an <a> tag or a non-clickable <span> tag, depending on enabled settings.
  3306. // `gotoOptions` can either be a DateMarker, or an object with the form:
  3307. // { date, type, forceOff }
  3308. // `type` is a view-type like "day" or "week". default value is "day".
  3309. // `attrs` and `innerHtml` are use to generate the rest of the HTML tag.
  3310. function buildGotoAnchorHtml(component, gotoOptions, attrs, innerHtml) {
  3311. var dateEnv = component.dateEnv;
  3312. var date;
  3313. var type;
  3314. var forceOff;
  3315. var finalOptions;
  3316. if (gotoOptions instanceof Date) {
  3317. date = gotoOptions; // a single date-like input
  3318. }
  3319. else {
  3320. date = gotoOptions.date;
  3321. type = gotoOptions.type;
  3322. forceOff = gotoOptions.forceOff;
  3323. }
  3324. finalOptions = {
  3325. date: dateEnv.formatIso(date, { omitTime: true }),
  3326. type: type || 'day'
  3327. };
  3328. if (typeof attrs === 'string') {
  3329. innerHtml = attrs;
  3330. attrs = null;
  3331. }
  3332. attrs = attrs ? ' ' + attrsToStr(attrs) : ''; // will have a leading space
  3333. innerHtml = innerHtml || '';
  3334. if (!forceOff && component.opt('navLinks')) {
  3335. return '<a' + attrs +
  3336. ' data-goto="' + htmlEscape(JSON.stringify(finalOptions)) + '">' +
  3337. innerHtml +
  3338. '</a>';
  3339. }
  3340. else {
  3341. return '<span' + attrs + '>' +
  3342. innerHtml +
  3343. '</span>';
  3344. }
  3345. }
  3346. function getAllDayHtml(component) {
  3347. return component.opt('allDayHtml') || htmlEscape(component.opt('allDayText'));
  3348. }
  3349. // Computes HTML classNames for a single-day element
  3350. function getDayClasses(date, dateProfile, context, noThemeHighlight) {
  3351. var calendar = context.calendar, view = context.view, theme = context.theme, dateEnv = context.dateEnv;
  3352. var classes = [];
  3353. var todayStart;
  3354. var todayEnd;
  3355. if (!rangeContainsMarker(dateProfile.activeRange, date)) {
  3356. classes.push('fc-disabled-day');
  3357. }
  3358. else {
  3359. classes.push('fc-' + DAY_IDS[date.getUTCDay()]);
  3360. if (view.opt('monthMode') &&
  3361. dateEnv.getMonth(date) !== dateEnv.getMonth(dateProfile.currentRange.start)) {
  3362. classes.push('fc-other-month');
  3363. }
  3364. todayStart = startOfDay(calendar.getNow());
  3365. todayEnd = addDays(todayStart, 1);
  3366. if (date < todayStart) {
  3367. classes.push('fc-past');
  3368. }
  3369. else if (date >= todayEnd) {
  3370. classes.push('fc-future');
  3371. }
  3372. else {
  3373. classes.push('fc-today');
  3374. if (noThemeHighlight !== true) {
  3375. classes.push(theme.getClass('today'));
  3376. }
  3377. }
  3378. }
  3379. return classes;
  3380. }
  3381. // given a function that resolves a result asynchronously.
  3382. // the function can either call passed-in success and failure callbacks,
  3383. // or it can return a promise.
  3384. // if you need to pass additional params to func, bind them first.
  3385. function unpromisify(func, success, failure) {
  3386. // guard against success/failure callbacks being called more than once
  3387. // and guard against a promise AND callback being used together.
  3388. var isResolved = false;
  3389. var wrappedSuccess = function () {
  3390. if (!isResolved) {
  3391. isResolved = true;
  3392. success.apply(this, arguments);
  3393. }
  3394. };
  3395. var wrappedFailure = function () {
  3396. if (!isResolved) {
  3397. isResolved = true;
  3398. if (failure) {
  3399. failure.apply(this, arguments);
  3400. }
  3401. }
  3402. };
  3403. var res = func(wrappedSuccess, wrappedFailure);
  3404. if (res && typeof res.then === 'function') {
  3405. res.then(wrappedSuccess, wrappedFailure);
  3406. }
  3407. }
  3408. var Mixin = /** @class */ (function () {
  3409. function Mixin() {
  3410. }
  3411. // mix into a CLASS
  3412. Mixin.mixInto = function (destClass) {
  3413. this.mixIntoObj(destClass.prototype);
  3414. };
  3415. // mix into ANY object
  3416. Mixin.mixIntoObj = function (destObj) {
  3417. var _this = this;
  3418. Object.getOwnPropertyNames(this.prototype).forEach(function (name) {
  3419. if (!destObj[name]) { // if destination doesn't already define it
  3420. destObj[name] = _this.prototype[name];
  3421. }
  3422. });
  3423. };
  3424. /*
  3425. will override existing methods
  3426. TODO: remove! not used anymore
  3427. */
  3428. Mixin.mixOver = function (destClass) {
  3429. var _this = this;
  3430. Object.getOwnPropertyNames(this.prototype).forEach(function (name) {
  3431. destClass.prototype[name] = _this.prototype[name];
  3432. });
  3433. };
  3434. return Mixin;
  3435. }());
  3436. /*
  3437. USAGE:
  3438. import { default as EmitterMixin, EmitterInterface } from './EmitterMixin'
  3439. in class:
  3440. on: EmitterInterface['on']
  3441. one: EmitterInterface['one']
  3442. off: EmitterInterface['off']
  3443. trigger: EmitterInterface['trigger']
  3444. triggerWith: EmitterInterface['triggerWith']
  3445. hasHandlers: EmitterInterface['hasHandlers']
  3446. after class:
  3447. EmitterMixin.mixInto(TheClass)
  3448. */
  3449. var EmitterMixin = /** @class */ (function (_super) {
  3450. __extends(EmitterMixin, _super);
  3451. function EmitterMixin() {
  3452. return _super !== null && _super.apply(this, arguments) || this;
  3453. }
  3454. EmitterMixin.prototype.on = function (type, handler) {
  3455. addToHash(this._handlers || (this._handlers = {}), type, handler);
  3456. return this; // for chaining
  3457. };
  3458. // todo: add comments
  3459. EmitterMixin.prototype.one = function (type, handler) {
  3460. addToHash(this._oneHandlers || (this._oneHandlers = {}), type, handler);
  3461. return this; // for chaining
  3462. };
  3463. EmitterMixin.prototype.off = function (type, handler) {
  3464. if (this._handlers) {
  3465. removeFromHash(this._handlers, type, handler);
  3466. }
  3467. if (this._oneHandlers) {
  3468. removeFromHash(this._oneHandlers, type, handler);
  3469. }
  3470. return this; // for chaining
  3471. };
  3472. EmitterMixin.prototype.trigger = function (type) {
  3473. var args = [];
  3474. for (var _i = 1; _i < arguments.length; _i++) {
  3475. args[_i - 1] = arguments[_i];
  3476. }
  3477. this.triggerWith(type, this, args);
  3478. return this; // for chaining
  3479. };
  3480. EmitterMixin.prototype.triggerWith = function (type, context, args) {
  3481. if (this._handlers) {
  3482. applyAll(this._handlers[type], context, args);
  3483. }
  3484. if (this._oneHandlers) {
  3485. applyAll(this._oneHandlers[type], context, args);
  3486. delete this._oneHandlers[type]; // will never fire again
  3487. }
  3488. return this; // for chaining
  3489. };
  3490. EmitterMixin.prototype.hasHandlers = function (type) {
  3491. return (this._handlers && this._handlers[type] && this._handlers[type].length) ||
  3492. (this._oneHandlers && this._oneHandlers[type] && this._oneHandlers[type].length);
  3493. };
  3494. return EmitterMixin;
  3495. }(Mixin));
  3496. function addToHash(hash, type, handler) {
  3497. (hash[type] || (hash[type] = []))
  3498. .push(handler);
  3499. }
  3500. function removeFromHash(hash, type, handler) {
  3501. if (handler) {
  3502. if (hash[type]) {
  3503. hash[type] = hash[type].filter(function (func) {
  3504. return func !== handler;
  3505. });
  3506. }
  3507. }
  3508. else {
  3509. delete hash[type]; // remove all handler funcs for this type
  3510. }
  3511. }
  3512. /*
  3513. Records offset information for a set of elements, relative to an origin element.
  3514. Can record the left/right OR the top/bottom OR both.
  3515. Provides methods for querying the cache by position.
  3516. */
  3517. var PositionCache = /** @class */ (function () {
  3518. function PositionCache(originEl, els, isHorizontal, isVertical) {
  3519. this.originEl = originEl;
  3520. this.els = els;
  3521. this.isHorizontal = isHorizontal;
  3522. this.isVertical = isVertical;
  3523. }
  3524. // Queries the els for coordinates and stores them.
  3525. // Call this method before using and of the get* methods below.
  3526. PositionCache.prototype.build = function () {
  3527. var originEl = this.originEl;
  3528. var originClientRect = this.originClientRect =
  3529. originEl.getBoundingClientRect(); // relative to viewport top-left
  3530. if (this.isHorizontal) {
  3531. this.buildElHorizontals(originClientRect.left);
  3532. }
  3533. if (this.isVertical) {
  3534. this.buildElVerticals(originClientRect.top);
  3535. }
  3536. };
  3537. // Populates the left/right internal coordinate arrays
  3538. PositionCache.prototype.buildElHorizontals = function (originClientLeft) {
  3539. var lefts = [];
  3540. var rights = [];
  3541. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  3542. var el = _a[_i];
  3543. var rect = el.getBoundingClientRect();
  3544. lefts.push(rect.left - originClientLeft);
  3545. rights.push(rect.right - originClientLeft);
  3546. }
  3547. this.lefts = lefts;
  3548. this.rights = rights;
  3549. };
  3550. // Populates the top/bottom internal coordinate arrays
  3551. PositionCache.prototype.buildElVerticals = function (originClientTop) {
  3552. var tops = [];
  3553. var bottoms = [];
  3554. for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
  3555. var el = _a[_i];
  3556. var rect = el.getBoundingClientRect();
  3557. tops.push(rect.top - originClientTop);
  3558. bottoms.push(rect.bottom - originClientTop);
  3559. }
  3560. this.tops = tops;
  3561. this.bottoms = bottoms;
  3562. };
  3563. // Given a left offset (from document left), returns the index of the el that it horizontally intersects.
  3564. // If no intersection is made, returns undefined.
  3565. PositionCache.prototype.leftToIndex = function (leftPosition) {
  3566. var lefts = this.lefts;
  3567. var rights = this.rights;
  3568. var len = lefts.length;
  3569. var i;
  3570. for (i = 0; i < len; i++) {
  3571. if (leftPosition >= lefts[i] && leftPosition < rights[i]) {
  3572. return i;
  3573. }
  3574. }
  3575. };
  3576. // Given a top offset (from document top), returns the index of the el that it vertically intersects.
  3577. // If no intersection is made, returns undefined.
  3578. PositionCache.prototype.topToIndex = function (topPosition) {
  3579. var tops = this.tops;
  3580. var bottoms = this.bottoms;
  3581. var len = tops.length;
  3582. var i;
  3583. for (i = 0; i < len; i++) {
  3584. if (topPosition >= tops[i] && topPosition < bottoms[i]) {
  3585. return i;
  3586. }
  3587. }
  3588. };
  3589. // Gets the width of the element at the given index
  3590. PositionCache.prototype.getWidth = function (leftIndex) {
  3591. return this.rights[leftIndex] - this.lefts[leftIndex];
  3592. };
  3593. // Gets the height of the element at the given index
  3594. PositionCache.prototype.getHeight = function (topIndex) {
  3595. return this.bottoms[topIndex] - this.tops[topIndex];
  3596. };
  3597. return PositionCache;
  3598. }());
  3599. /*
  3600. An object for getting/setting scroll-related information for an element.
  3601. Internally, this is done very differently for window versus DOM element,
  3602. so this object serves as a common interface.
  3603. */
  3604. var ScrollController = /** @class */ (function () {
  3605. function ScrollController() {
  3606. }
  3607. ScrollController.prototype.getMaxScrollTop = function () {
  3608. return this.getScrollHeight() - this.getClientHeight();
  3609. };
  3610. ScrollController.prototype.getMaxScrollLeft = function () {
  3611. return this.getScrollWidth() - this.getClientWidth();
  3612. };
  3613. ScrollController.prototype.canScrollVertically = function () {
  3614. return this.getMaxScrollTop() > 0;
  3615. };
  3616. ScrollController.prototype.canScrollHorizontally = function () {
  3617. return this.getMaxScrollLeft() > 0;
  3618. };
  3619. ScrollController.prototype.canScrollUp = function () {
  3620. return this.getScrollTop() > 0;
  3621. };
  3622. ScrollController.prototype.canScrollDown = function () {
  3623. return this.getScrollTop() < this.getMaxScrollTop();
  3624. };
  3625. ScrollController.prototype.canScrollLeft = function () {
  3626. return this.getScrollLeft() > 0;
  3627. };
  3628. ScrollController.prototype.canScrollRight = function () {
  3629. return this.getScrollLeft() < this.getMaxScrollLeft();
  3630. };
  3631. return ScrollController;
  3632. }());
  3633. var ElementScrollController = /** @class */ (function (_super) {
  3634. __extends(ElementScrollController, _super);
  3635. function ElementScrollController(el) {
  3636. var _this = _super.call(this) || this;
  3637. _this.el = el;
  3638. return _this;
  3639. }
  3640. ElementScrollController.prototype.getScrollTop = function () {
  3641. return this.el.scrollTop;
  3642. };
  3643. ElementScrollController.prototype.getScrollLeft = function () {
  3644. return this.el.scrollLeft;
  3645. };
  3646. ElementScrollController.prototype.setScrollTop = function (top) {
  3647. this.el.scrollTop = top;
  3648. };
  3649. ElementScrollController.prototype.setScrollLeft = function (left) {
  3650. this.el.scrollLeft = left;
  3651. };
  3652. ElementScrollController.prototype.getScrollWidth = function () {
  3653. return this.el.scrollWidth;
  3654. };
  3655. ElementScrollController.prototype.getScrollHeight = function () {
  3656. return this.el.scrollHeight;
  3657. };
  3658. ElementScrollController.prototype.getClientHeight = function () {
  3659. return this.el.clientHeight;
  3660. };
  3661. ElementScrollController.prototype.getClientWidth = function () {
  3662. return this.el.clientWidth;
  3663. };
  3664. return ElementScrollController;
  3665. }(ScrollController));
  3666. var WindowScrollController = /** @class */ (function (_super) {
  3667. __extends(WindowScrollController, _super);
  3668. function WindowScrollController() {
  3669. return _super !== null && _super.apply(this, arguments) || this;
  3670. }
  3671. WindowScrollController.prototype.getScrollTop = function () {
  3672. return window.pageYOffset;
  3673. };
  3674. WindowScrollController.prototype.getScrollLeft = function () {
  3675. return window.pageXOffset;
  3676. };
  3677. WindowScrollController.prototype.setScrollTop = function (n) {
  3678. window.scroll(window.pageXOffset, n);
  3679. };
  3680. WindowScrollController.prototype.setScrollLeft = function (n) {
  3681. window.scroll(n, window.pageYOffset);
  3682. };
  3683. WindowScrollController.prototype.getScrollWidth = function () {
  3684. return document.documentElement.scrollWidth;
  3685. };
  3686. WindowScrollController.prototype.getScrollHeight = function () {
  3687. return document.documentElement.scrollHeight;
  3688. };
  3689. WindowScrollController.prototype.getClientHeight = function () {
  3690. return document.documentElement.clientHeight;
  3691. };
  3692. WindowScrollController.prototype.getClientWidth = function () {
  3693. return document.documentElement.clientWidth;
  3694. };
  3695. return WindowScrollController;
  3696. }(ScrollController));
  3697. /*
  3698. Embodies a div that has potential scrollbars
  3699. */
  3700. var ScrollComponent = /** @class */ (function (_super) {
  3701. __extends(ScrollComponent, _super);
  3702. function ScrollComponent(overflowX, overflowY) {
  3703. var _this = _super.call(this, createElement('div', {
  3704. className: 'fc-scroller'
  3705. })) || this;
  3706. _this.overflowX = overflowX;
  3707. _this.overflowY = overflowY;
  3708. _this.applyOverflow();
  3709. return _this;
  3710. }
  3711. // sets to natural height, unlocks overflow
  3712. ScrollComponent.prototype.clear = function () {
  3713. this.setHeight('auto');
  3714. this.applyOverflow();
  3715. };
  3716. ScrollComponent.prototype.destroy = function () {
  3717. removeElement(this.el);
  3718. };
  3719. // Overflow
  3720. // -----------------------------------------------------------------------------------------------------------------
  3721. ScrollComponent.prototype.applyOverflow = function () {
  3722. applyStyle(this.el, {
  3723. overflowX: this.overflowX,
  3724. overflowY: this.overflowY
  3725. });
  3726. };
  3727. // Causes any 'auto' overflow values to resolves to 'scroll' or 'hidden'.
  3728. // Useful for preserving scrollbar widths regardless of future resizes.
  3729. // Can pass in scrollbarWidths for optimization.
  3730. ScrollComponent.prototype.lockOverflow = function (scrollbarWidths) {
  3731. var overflowX = this.overflowX;
  3732. var overflowY = this.overflowY;
  3733. scrollbarWidths = scrollbarWidths || this.getScrollbarWidths();
  3734. if (overflowX === 'auto') {
  3735. overflowX = (scrollbarWidths.bottom || // horizontal scrollbars?
  3736. this.canScrollHorizontally() // OR scrolling pane with massless scrollbars?
  3737. ) ? 'scroll' : 'hidden';
  3738. }
  3739. if (overflowY === 'auto') {
  3740. overflowY = (scrollbarWidths.left || scrollbarWidths.right || // horizontal scrollbars?
  3741. this.canScrollVertically() // OR scrolling pane with massless scrollbars?
  3742. ) ? 'scroll' : 'hidden';
  3743. }
  3744. applyStyle(this.el, { overflowX: overflowX, overflowY: overflowY });
  3745. };
  3746. ScrollComponent.prototype.setHeight = function (height) {
  3747. applyStyleProp(this.el, 'height', height);
  3748. };
  3749. ScrollComponent.prototype.getScrollbarWidths = function () {
  3750. var edges = computeEdges(this.el);
  3751. return {
  3752. left: edges.scrollbarLeft,
  3753. right: edges.scrollbarRight,
  3754. bottom: edges.scrollbarBottom
  3755. };
  3756. };
  3757. return ScrollComponent;
  3758. }(ElementScrollController));
  3759. var Theme = /** @class */ (function () {
  3760. function Theme(calendarOptions) {
  3761. this.calendarOptions = calendarOptions;
  3762. this.processIconOverride();
  3763. }
  3764. Theme.prototype.processIconOverride = function () {
  3765. if (this.iconOverrideOption) {
  3766. this.setIconOverride(this.calendarOptions[this.iconOverrideOption]);
  3767. }
  3768. };
  3769. Theme.prototype.setIconOverride = function (iconOverrideHash) {
  3770. var iconClassesCopy;
  3771. var buttonName;
  3772. if (typeof iconOverrideHash === 'object' && iconOverrideHash) { // non-null object
  3773. iconClassesCopy = __assign({}, this.iconClasses);
  3774. for (buttonName in iconOverrideHash) {
  3775. iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
  3776. }
  3777. this.iconClasses = iconClassesCopy;
  3778. }
  3779. else if (iconOverrideHash === false) {
  3780. this.iconClasses = {};
  3781. }
  3782. };
  3783. Theme.prototype.applyIconOverridePrefix = function (className) {
  3784. var prefix = this.iconOverridePrefix;
  3785. if (prefix && className.indexOf(prefix) !== 0) { // if not already present
  3786. className = prefix + className;
  3787. }
  3788. return className;
  3789. };
  3790. Theme.prototype.getClass = function (key) {
  3791. return this.classes[key] || '';
  3792. };
  3793. Theme.prototype.getIconClass = function (buttonName) {
  3794. var className = this.iconClasses[buttonName];
  3795. if (className) {
  3796. return this.baseIconClass + ' ' + className;
  3797. }
  3798. return '';
  3799. };
  3800. Theme.prototype.getCustomButtonIconClass = function (customButtonProps) {
  3801. var className;
  3802. if (this.iconOverrideCustomButtonOption) {
  3803. className = customButtonProps[this.iconOverrideCustomButtonOption];
  3804. if (className) {
  3805. return this.baseIconClass + ' ' + this.applyIconOverridePrefix(className);
  3806. }
  3807. }
  3808. return '';
  3809. };
  3810. return Theme;
  3811. }());
  3812. Theme.prototype.classes = {};
  3813. Theme.prototype.iconClasses = {};
  3814. Theme.prototype.baseIconClass = '';
  3815. Theme.prototype.iconOverridePrefix = '';
  3816. var guid = 0;
  3817. var Component = /** @class */ (function () {
  3818. function Component(context, isView) {
  3819. // HACK to populate view at top of component instantiation call chain
  3820. if (isView) {
  3821. context.view = this;
  3822. }
  3823. this.uid = String(guid++);
  3824. this.context = context;
  3825. this.dateEnv = context.dateEnv;
  3826. this.theme = context.theme;
  3827. this.view = context.view;
  3828. this.calendar = context.calendar;
  3829. this.isRtl = this.opt('dir') === 'rtl';
  3830. }
  3831. Component.addEqualityFuncs = function (newFuncs) {
  3832. this.prototype.equalityFuncs = __assign({}, this.prototype.equalityFuncs, newFuncs);
  3833. };
  3834. Component.prototype.opt = function (name) {
  3835. return this.context.options[name];
  3836. };
  3837. Component.prototype.receiveProps = function (props) {
  3838. var _a = recycleProps(this.props || {}, props, this.equalityFuncs), anyChanges = _a.anyChanges, comboProps = _a.comboProps;
  3839. this.props = comboProps;
  3840. if (anyChanges) {
  3841. this.render(comboProps);
  3842. }
  3843. };
  3844. Component.prototype.render = function (props) {
  3845. };
  3846. // after destroy is called, this component won't ever be used again
  3847. Component.prototype.destroy = function () {
  3848. };
  3849. return Component;
  3850. }());
  3851. Component.prototype.equalityFuncs = {};
  3852. /*
  3853. Reuses old values when equal. If anything is unequal, returns newProps as-is.
  3854. Great for PureComponent, but won't be feasible with React, so just eliminate and use React's DOM diffing.
  3855. */
  3856. function recycleProps(oldProps, newProps, equalityFuncs) {
  3857. var comboProps = {}; // some old, some new
  3858. var anyChanges = false;
  3859. for (var key in newProps) {
  3860. if (key in oldProps && (oldProps[key] === newProps[key] ||
  3861. (equalityFuncs[key] && equalityFuncs[key](oldProps[key], newProps[key])))) {
  3862. // equal to old? use old prop
  3863. comboProps[key] = oldProps[key];
  3864. }
  3865. else {
  3866. comboProps[key] = newProps[key];
  3867. anyChanges = true;
  3868. }
  3869. }
  3870. for (var key in oldProps) {
  3871. if (!(key in newProps)) {
  3872. anyChanges = true;
  3873. break;
  3874. }
  3875. }
  3876. return { anyChanges: anyChanges, comboProps: comboProps };
  3877. }
  3878. /*
  3879. PURPOSES:
  3880. - hook up to fg, fill, and mirror renderers
  3881. - interface for dragging and hits
  3882. */
  3883. var DateComponent = /** @class */ (function (_super) {
  3884. __extends(DateComponent, _super);
  3885. function DateComponent(context, el, isView) {
  3886. var _this = _super.call(this, context, isView) || this;
  3887. _this.el = el;
  3888. return _this;
  3889. }
  3890. DateComponent.prototype.destroy = function () {
  3891. _super.prototype.destroy.call(this);
  3892. removeElement(this.el);
  3893. };
  3894. // TODO: WHAT ABOUT (sourceSeg && sourceSeg.component.doesDragMirror)
  3895. //
  3896. // Event Drag-n-Drop Rendering (for both events and external elements)
  3897. // ---------------------------------------------------------------------------------------------------------------
  3898. /*
  3899. renderEventDragSegs(state: EventSegUiInteractionState) {
  3900. if (state) {
  3901. let { isEvent, segs, sourceSeg } = state
  3902. if (this.eventRenderer) {
  3903. this.eventRenderer.hideByHash(state.affectedInstances)
  3904. }
  3905. // if the user is dragging something that is considered an event with real event data,
  3906. // and this component likes to do drag mirrors OR the component where the seg came from
  3907. // likes to do drag mirrors, then render a drag mirror.
  3908. if (isEvent && (this.doesDragMirror || sourceSeg && sourceSeg.component.doesDragMirror)) {
  3909. if (this.mirrorRenderer) {
  3910. this.mirrorRenderer.renderSegs(segs, { isDragging: true, sourceSeg })
  3911. }
  3912. }
  3913. // if it would be impossible to render a drag mirror OR this component likes to render
  3914. // highlights, then render a highlight.
  3915. if (!isEvent || this.doesDragHighlight) {
  3916. if (this.fillRenderer) {
  3917. this.fillRenderer.renderSegs('highlight', segs)
  3918. }
  3919. }
  3920. }
  3921. }
  3922. */
  3923. // Hit System
  3924. // -----------------------------------------------------------------------------------------------------------------
  3925. DateComponent.prototype.buildPositionCaches = function () {
  3926. };
  3927. DateComponent.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  3928. return null; // this should be abstract
  3929. };
  3930. // Validation
  3931. // -----------------------------------------------------------------------------------------------------------------
  3932. DateComponent.prototype.isInteractionValid = function (interaction) {
  3933. var calendar = this.calendar;
  3934. var dateProfile = this.props.dateProfile; // HACK
  3935. var instances = interaction.mutatedEvents.instances;
  3936. if (dateProfile) { // HACK for DayTile
  3937. for (var instanceId in instances) {
  3938. if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
  3939. return false;
  3940. }
  3941. }
  3942. }
  3943. return isInteractionValid(interaction, calendar);
  3944. };
  3945. DateComponent.prototype.isDateSelectionValid = function (selection) {
  3946. var dateProfile = this.props.dateProfile; // HACK
  3947. if (dateProfile && // HACK for DayTile
  3948. !rangeContainsRange(dateProfile.validRange, selection.range)) {
  3949. return false;
  3950. }
  3951. return isDateSelectionValid(selection, this.calendar);
  3952. };
  3953. // Triggering
  3954. // -----------------------------------------------------------------------------------------------------------------
  3955. // TODO: move to Calendar
  3956. DateComponent.prototype.publiclyTrigger = function (name, args) {
  3957. var calendar = this.calendar;
  3958. return calendar.publiclyTrigger(name, args);
  3959. };
  3960. DateComponent.prototype.publiclyTriggerAfterSizing = function (name, args) {
  3961. var calendar = this.calendar;
  3962. return calendar.publiclyTriggerAfterSizing(name, args);
  3963. };
  3964. DateComponent.prototype.hasPublicHandlers = function (name) {
  3965. var calendar = this.calendar;
  3966. return calendar.hasPublicHandlers(name);
  3967. };
  3968. DateComponent.prototype.triggerRenderedSegs = function (segs, isMirrors) {
  3969. var calendar = this.calendar;
  3970. if (this.hasPublicHandlers('eventPositioned')) {
  3971. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  3972. var seg = segs_1[_i];
  3973. this.publiclyTriggerAfterSizing('eventPositioned', [
  3974. {
  3975. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  3976. isMirror: isMirrors,
  3977. isStart: seg.isStart,
  3978. isEnd: seg.isEnd,
  3979. el: seg.el,
  3980. view: this // safe to cast because this method is only called on context.view
  3981. }
  3982. ]);
  3983. }
  3984. }
  3985. if (!calendar.state.loadingLevel) { // avoid initial empty state while pending
  3986. calendar.afterSizingTriggers._eventsPositioned = [null]; // fire once
  3987. }
  3988. };
  3989. DateComponent.prototype.triggerWillRemoveSegs = function (segs, isMirrors) {
  3990. var calendar = this.calendar;
  3991. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  3992. var seg = segs_2[_i];
  3993. calendar.trigger('eventElRemove', seg.el);
  3994. }
  3995. if (this.hasPublicHandlers('eventDestroy')) {
  3996. for (var _a = 0, segs_3 = segs; _a < segs_3.length; _a++) {
  3997. var seg = segs_3[_a];
  3998. this.publiclyTrigger('eventDestroy', [
  3999. {
  4000. event: new EventApi(calendar, seg.eventRange.def, seg.eventRange.instance),
  4001. isMirror: isMirrors,
  4002. el: seg.el,
  4003. view: this // safe to cast because this method is only called on context.view
  4004. }
  4005. ]);
  4006. }
  4007. }
  4008. };
  4009. // Pointer Interaction Utils
  4010. // -----------------------------------------------------------------------------------------------------------------
  4011. DateComponent.prototype.isValidSegDownEl = function (el) {
  4012. return !this.props.eventDrag && // HACK
  4013. !this.props.eventResize && // HACK
  4014. !elementClosest(el, '.fc-mirror') &&
  4015. (this.isPopover() || !this.isInPopover(el));
  4016. // ^above line ensures we don't detect a seg interaction within a nested component.
  4017. // it's a HACK because it only supports a popover as the nested component.
  4018. };
  4019. DateComponent.prototype.isValidDateDownEl = function (el) {
  4020. var segEl = elementClosest(el, this.fgSegSelector);
  4021. return (!segEl || segEl.classList.contains('fc-mirror')) &&
  4022. !elementClosest(el, '.fc-more') && // a "more.." link
  4023. !elementClosest(el, 'a[data-goto]') && // a clickable nav link
  4024. !this.isInPopover(el);
  4025. };
  4026. DateComponent.prototype.isPopover = function () {
  4027. return this.el.classList.contains('fc-popover');
  4028. };
  4029. DateComponent.prototype.isInPopover = function (el) {
  4030. return Boolean(elementClosest(el, '.fc-popover'));
  4031. };
  4032. return DateComponent;
  4033. }(Component));
  4034. DateComponent.prototype.fgSegSelector = '.fc-event-container > *';
  4035. DateComponent.prototype.bgSegSelector = '.fc-bgevent:not(.fc-nonbusiness)';
  4036. var uid$1 = 0;
  4037. function createPlugin(input) {
  4038. return {
  4039. id: String(uid$1++),
  4040. deps: input.deps || [],
  4041. reducers: input.reducers || [],
  4042. eventDefParsers: input.eventDefParsers || [],
  4043. isDraggableTransformers: input.isDraggableTransformers || [],
  4044. eventDragMutationMassagers: input.eventDragMutationMassagers || [],
  4045. eventDefMutationAppliers: input.eventDefMutationAppliers || [],
  4046. dateSelectionTransformers: input.dateSelectionTransformers || [],
  4047. datePointTransforms: input.datePointTransforms || [],
  4048. dateSpanTransforms: input.dateSpanTransforms || [],
  4049. views: input.views || {},
  4050. viewPropsTransformers: input.viewPropsTransformers || [],
  4051. isPropsValid: input.isPropsValid || null,
  4052. externalDefTransforms: input.externalDefTransforms || [],
  4053. eventResizeJoinTransforms: input.eventResizeJoinTransforms || [],
  4054. viewContainerModifiers: input.viewContainerModifiers || [],
  4055. eventDropTransformers: input.eventDropTransformers || [],
  4056. componentInteractions: input.componentInteractions || [],
  4057. calendarInteractions: input.calendarInteractions || [],
  4058. themeClasses: input.themeClasses || {},
  4059. eventSourceDefs: input.eventSourceDefs || [],
  4060. cmdFormatter: input.cmdFormatter,
  4061. recurringTypes: input.recurringTypes || [],
  4062. namedTimeZonedImpl: input.namedTimeZonedImpl,
  4063. defaultView: input.defaultView || '',
  4064. elementDraggingImpl: input.elementDraggingImpl,
  4065. optionChangeHandlers: input.optionChangeHandlers || {}
  4066. };
  4067. }
  4068. var PluginSystem = /** @class */ (function () {
  4069. function PluginSystem() {
  4070. this.hooks = {
  4071. reducers: [],
  4072. eventDefParsers: [],
  4073. isDraggableTransformers: [],
  4074. eventDragMutationMassagers: [],
  4075. eventDefMutationAppliers: [],
  4076. dateSelectionTransformers: [],
  4077. datePointTransforms: [],
  4078. dateSpanTransforms: [],
  4079. views: {},
  4080. viewPropsTransformers: [],
  4081. isPropsValid: null,
  4082. externalDefTransforms: [],
  4083. eventResizeJoinTransforms: [],
  4084. viewContainerModifiers: [],
  4085. eventDropTransformers: [],
  4086. componentInteractions: [],
  4087. calendarInteractions: [],
  4088. themeClasses: {},
  4089. eventSourceDefs: [],
  4090. cmdFormatter: null,
  4091. recurringTypes: [],
  4092. namedTimeZonedImpl: null,
  4093. defaultView: '',
  4094. elementDraggingImpl: null,
  4095. optionChangeHandlers: {}
  4096. };
  4097. this.addedHash = {};
  4098. }
  4099. PluginSystem.prototype.add = function (plugin) {
  4100. if (!this.addedHash[plugin.id]) {
  4101. this.addedHash[plugin.id] = true;
  4102. for (var _i = 0, _a = plugin.deps; _i < _a.length; _i++) {
  4103. var dep = _a[_i];
  4104. this.add(dep);
  4105. }
  4106. this.hooks = combineHooks(this.hooks, plugin);
  4107. }
  4108. };
  4109. return PluginSystem;
  4110. }());
  4111. function combineHooks(hooks0, hooks1) {
  4112. return {
  4113. reducers: hooks0.reducers.concat(hooks1.reducers),
  4114. eventDefParsers: hooks0.eventDefParsers.concat(hooks1.eventDefParsers),
  4115. isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
  4116. eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
  4117. eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
  4118. dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
  4119. datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
  4120. dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
  4121. views: __assign({}, hooks0.views, hooks1.views),
  4122. viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
  4123. isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
  4124. externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
  4125. eventResizeJoinTransforms: hooks0.eventResizeJoinTransforms.concat(hooks1.eventResizeJoinTransforms),
  4126. viewContainerModifiers: hooks0.viewContainerModifiers.concat(hooks1.viewContainerModifiers),
  4127. eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
  4128. calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
  4129. componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
  4130. themeClasses: __assign({}, hooks0.themeClasses, hooks1.themeClasses),
  4131. eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
  4132. cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
  4133. recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
  4134. namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
  4135. defaultView: hooks0.defaultView || hooks1.defaultView,
  4136. elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
  4137. optionChangeHandlers: __assign({}, hooks0.optionChangeHandlers, hooks1.optionChangeHandlers)
  4138. };
  4139. }
  4140. var eventSourceDef = {
  4141. ignoreRange: true,
  4142. parseMeta: function (raw) {
  4143. if (Array.isArray(raw)) { // short form
  4144. return raw;
  4145. }
  4146. else if (Array.isArray(raw.events)) {
  4147. return raw.events;
  4148. }
  4149. return null;
  4150. },
  4151. fetch: function (arg, success) {
  4152. success({
  4153. rawEvents: arg.eventSource.meta
  4154. });
  4155. }
  4156. };
  4157. var ArrayEventSourcePlugin = createPlugin({
  4158. eventSourceDefs: [eventSourceDef]
  4159. });
  4160. var eventSourceDef$1 = {
  4161. parseMeta: function (raw) {
  4162. if (typeof raw === 'function') { // short form
  4163. return raw;
  4164. }
  4165. else if (typeof raw.events === 'function') {
  4166. return raw.events;
  4167. }
  4168. return null;
  4169. },
  4170. fetch: function (arg, success, failure) {
  4171. var dateEnv = arg.calendar.dateEnv;
  4172. var func = arg.eventSource.meta;
  4173. unpromisify(func.bind(null, {
  4174. start: dateEnv.toDate(arg.range.start),
  4175. end: dateEnv.toDate(arg.range.end),
  4176. startStr: dateEnv.formatIso(arg.range.start),
  4177. endStr: dateEnv.formatIso(arg.range.end),
  4178. timeZone: dateEnv.timeZone
  4179. }), function (rawEvents) {
  4180. success({ rawEvents: rawEvents }); // needs an object response
  4181. }, failure // send errorObj directly to failure callback
  4182. );
  4183. }
  4184. };
  4185. var FuncEventSourcePlugin = createPlugin({
  4186. eventSourceDefs: [eventSourceDef$1]
  4187. });
  4188. function requestJson(method, url, params, successCallback, failureCallback) {
  4189. method = method.toUpperCase();
  4190. var body = null;
  4191. if (method === 'GET') {
  4192. url = injectQueryStringParams(url, params);
  4193. }
  4194. else {
  4195. body = encodeParams(params);
  4196. }
  4197. var xhr = new XMLHttpRequest();
  4198. xhr.open(method, url, true);
  4199. if (method !== 'GET') {
  4200. xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  4201. }
  4202. xhr.onload = function () {
  4203. if (xhr.status >= 200 && xhr.status < 400) {
  4204. try {
  4205. var res = JSON.parse(xhr.responseText);
  4206. successCallback(res, xhr);
  4207. }
  4208. catch (err) {
  4209. failureCallback('Failure parsing JSON', xhr);
  4210. }
  4211. }
  4212. else {
  4213. failureCallback('Request failed', xhr);
  4214. }
  4215. };
  4216. xhr.onerror = function () {
  4217. failureCallback('Request failed', xhr);
  4218. };
  4219. xhr.send(body);
  4220. }
  4221. function injectQueryStringParams(url, params) {
  4222. return url +
  4223. (url.indexOf('?') === -1 ? '?' : '&') +
  4224. encodeParams(params);
  4225. }
  4226. function encodeParams(params) {
  4227. var parts = [];
  4228. for (var key in params) {
  4229. parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key]));
  4230. }
  4231. return parts.join('&');
  4232. }
  4233. var eventSourceDef$2 = {
  4234. parseMeta: function (raw) {
  4235. if (typeof raw === 'string') { // short form
  4236. raw = { url: raw };
  4237. }
  4238. else if (!raw || typeof raw !== 'object' || !raw.url) {
  4239. return null;
  4240. }
  4241. return {
  4242. url: raw.url,
  4243. method: (raw.method || 'GET').toUpperCase(),
  4244. extraParams: raw.extraParams,
  4245. startParam: raw.startParam,
  4246. endParam: raw.endParam,
  4247. timeZoneParam: raw.timeZoneParam
  4248. };
  4249. },
  4250. fetch: function (arg, success, failure) {
  4251. var meta = arg.eventSource.meta;
  4252. var requestParams = buildRequestParams(meta, arg.range, arg.calendar);
  4253. requestJson(meta.method, meta.url, requestParams, function (rawEvents, xhr) {
  4254. success({ rawEvents: rawEvents, xhr: xhr });
  4255. }, function (errorMessage, xhr) {
  4256. failure({ message: errorMessage, xhr: xhr });
  4257. });
  4258. }
  4259. };
  4260. var JsonFeedEventSourcePlugin = createPlugin({
  4261. eventSourceDefs: [eventSourceDef$2]
  4262. });
  4263. function buildRequestParams(meta, range, calendar) {
  4264. var dateEnv = calendar.dateEnv;
  4265. var startParam;
  4266. var endParam;
  4267. var timeZoneParam;
  4268. var customRequestParams;
  4269. var params = {};
  4270. startParam = meta.startParam;
  4271. if (startParam == null) {
  4272. startParam = calendar.opt('startParam');
  4273. }
  4274. endParam = meta.endParam;
  4275. if (endParam == null) {
  4276. endParam = calendar.opt('endParam');
  4277. }
  4278. timeZoneParam = meta.timeZoneParam;
  4279. if (timeZoneParam == null) {
  4280. timeZoneParam = calendar.opt('timeZoneParam');
  4281. }
  4282. // retrieve any outbound GET/POST data from the options
  4283. if (typeof meta.extraParams === 'function') {
  4284. // supplied as a function that returns a key/value object
  4285. customRequestParams = meta.extraParams();
  4286. }
  4287. else {
  4288. // probably supplied as a straight key/value object
  4289. customRequestParams = meta.extraParams || {};
  4290. }
  4291. __assign(params, customRequestParams);
  4292. params[startParam] = dateEnv.formatIso(range.start);
  4293. params[endParam] = dateEnv.formatIso(range.end);
  4294. if (dateEnv.timeZone !== 'local') {
  4295. params[timeZoneParam] = dateEnv.timeZone;
  4296. }
  4297. return params;
  4298. }
  4299. var recurring = {
  4300. parse: function (rawEvent, leftoverProps, dateEnv) {
  4301. var createMarker = dateEnv.createMarker.bind(dateEnv);
  4302. var processors = {
  4303. daysOfWeek: null,
  4304. startTime: createDuration,
  4305. endTime: createDuration,
  4306. startRecur: createMarker,
  4307. endRecur: createMarker
  4308. };
  4309. var props = refineProps(rawEvent, processors, {}, leftoverProps);
  4310. var anyValid = false;
  4311. for (var propName in props) {
  4312. if (props[propName] != null) {
  4313. anyValid = true;
  4314. break;
  4315. }
  4316. }
  4317. if (anyValid) {
  4318. var duration = null;
  4319. if ('duration' in leftoverProps) {
  4320. duration = createDuration(leftoverProps.duration);
  4321. delete leftoverProps.duration;
  4322. }
  4323. if (!duration && props.startTime && props.endTime) {
  4324. duration = subtractDurations(props.endTime, props.startTime);
  4325. }
  4326. return {
  4327. allDayGuess: Boolean(!props.startTime && !props.endTime),
  4328. duration: duration,
  4329. typeData: props // doesn't need endTime anymore but oh well
  4330. };
  4331. }
  4332. return null;
  4333. },
  4334. expand: function (typeData, framingRange, dateEnv) {
  4335. var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
  4336. if (clippedFramingRange) {
  4337. return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
  4338. }
  4339. else {
  4340. return [];
  4341. }
  4342. }
  4343. };
  4344. var SimpleRecurrencePlugin = createPlugin({
  4345. recurringTypes: [recurring]
  4346. });
  4347. function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
  4348. var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
  4349. var dayMarker = startOfDay(framingRange.start);
  4350. var endMarker = framingRange.end;
  4351. var instanceStarts = [];
  4352. while (dayMarker < endMarker) {
  4353. var instanceStart
  4354. // if everyday, or this particular day-of-week
  4355. = void 0;
  4356. // if everyday, or this particular day-of-week
  4357. if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
  4358. if (startTime) {
  4359. instanceStart = dateEnv.add(dayMarker, startTime);
  4360. }
  4361. else {
  4362. instanceStart = dayMarker;
  4363. }
  4364. instanceStarts.push(instanceStart);
  4365. }
  4366. dayMarker = addDays(dayMarker, 1);
  4367. }
  4368. return instanceStarts;
  4369. }
  4370. var DefaultOptionChangeHandlers = createPlugin({
  4371. optionChangeHandlers: {
  4372. events: function (events, calendar, deepEqual) {
  4373. handleEventSources([events], calendar, deepEqual);
  4374. },
  4375. eventSources: handleEventSources,
  4376. plugins: handlePlugins
  4377. }
  4378. });
  4379. function handleEventSources(inputs, calendar, deepEqual) {
  4380. var unfoundSources = hashValuesToArray(calendar.state.eventSources);
  4381. var newInputs = [];
  4382. for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
  4383. var input = inputs_1[_i];
  4384. var inputFound = false;
  4385. for (var i = 0; i < unfoundSources.length; i++) {
  4386. if (deepEqual(unfoundSources[i]._raw, input)) {
  4387. unfoundSources.splice(i, 1); // delete
  4388. inputFound = true;
  4389. break;
  4390. }
  4391. }
  4392. if (!inputFound) {
  4393. newInputs.push(input);
  4394. }
  4395. }
  4396. for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
  4397. var unfoundSource = unfoundSources_1[_a];
  4398. calendar.dispatch({
  4399. type: 'REMOVE_EVENT_SOURCE',
  4400. sourceId: unfoundSource.sourceId
  4401. });
  4402. }
  4403. for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
  4404. var newInput = newInputs_1[_b];
  4405. calendar.addEventSource(newInput);
  4406. }
  4407. }
  4408. // shortcoming: won't remove plugins
  4409. function handlePlugins(inputs, calendar) {
  4410. calendar.addPluginInputs(inputs); // will gracefully handle duplicates
  4411. }
  4412. var config = {}; // TODO: make these options
  4413. var globalDefaults = {
  4414. defaultRangeSeparator: ' - ',
  4415. titleRangeSeparator: ' \u2013 ',
  4416. defaultTimedEventDuration: '01:00:00',
  4417. defaultAllDayEventDuration: { day: 1 },
  4418. forceEventDuration: false,
  4419. nextDayThreshold: '00:00:00',
  4420. // display
  4421. columnHeader: true,
  4422. defaultView: '',
  4423. aspectRatio: 1.35,
  4424. header: {
  4425. left: 'title',
  4426. center: '',
  4427. right: 'today prev,next'
  4428. },
  4429. weekends: true,
  4430. weekNumbers: false,
  4431. weekNumberCalculation: 'local',
  4432. editable: false,
  4433. // nowIndicator: false,
  4434. scrollTime: '06:00:00',
  4435. minTime: '00:00:00',
  4436. maxTime: '24:00:00',
  4437. showNonCurrentDates: true,
  4438. // event ajax
  4439. lazyFetching: true,
  4440. startParam: 'start',
  4441. endParam: 'end',
  4442. timeZoneParam: 'timeZone',
  4443. timeZone: 'local',
  4444. // allDayDefault: undefined,
  4445. // locale
  4446. locales: [],
  4447. locale: '',
  4448. // dir: will get this from the default locale
  4449. // buttonIcons: null,
  4450. // allows setting a min-height to the event segment to prevent short events overlapping each other
  4451. timeGridEventMinHeight: 0,
  4452. themeSystem: 'standard',
  4453. // eventResizableFromStart: false,
  4454. dragRevertDuration: 500,
  4455. dragScroll: true,
  4456. allDayMaintainDuration: false,
  4457. // selectable: false,
  4458. unselectAuto: true,
  4459. // selectMinDistance: 0,
  4460. dropAccept: '*',
  4461. eventOrder: 'start,-duration,allDay,title',
  4462. // ^ if start tie, longer events go before shorter. final tie-breaker is title text
  4463. // rerenderDelay: null,
  4464. eventLimit: false,
  4465. eventLimitClick: 'popover',
  4466. dayPopoverFormat: { month: 'long', day: 'numeric', year: 'numeric' },
  4467. handleWindowResize: true,
  4468. windowResizeDelay: 100,
  4469. longPressDelay: 1000,
  4470. eventDragMinDistance: 5 // only applies to mouse
  4471. };
  4472. var rtlDefaults = {
  4473. header: {
  4474. left: 'next,prev today',
  4475. center: '',
  4476. right: 'title'
  4477. },
  4478. buttonIcons: {
  4479. // TODO: make RTL support the responibility of the theme
  4480. prev: 'fc-icon-chevron-right',
  4481. next: 'fc-icon-chevron-left',
  4482. prevYear: 'fc-icon-chevrons-right',
  4483. nextYear: 'fc-icon-chevrons-left'
  4484. }
  4485. };
  4486. var complexOptions = [
  4487. 'header',
  4488. 'footer',
  4489. 'buttonText',
  4490. 'buttonIcons'
  4491. ];
  4492. // Merges an array of option objects into a single object
  4493. function mergeOptions(optionObjs) {
  4494. return mergeProps(optionObjs, complexOptions);
  4495. }
  4496. // TODO: move this stuff to a "plugin"-related file...
  4497. var INTERNAL_PLUGINS = [
  4498. ArrayEventSourcePlugin,
  4499. FuncEventSourcePlugin,
  4500. JsonFeedEventSourcePlugin,
  4501. SimpleRecurrencePlugin,
  4502. DefaultOptionChangeHandlers
  4503. ];
  4504. function refinePluginDefs(pluginInputs) {
  4505. var plugins = [];
  4506. for (var _i = 0, pluginInputs_1 = pluginInputs; _i < pluginInputs_1.length; _i++) {
  4507. var pluginInput = pluginInputs_1[_i];
  4508. if (typeof pluginInput === 'string') {
  4509. var globalName = 'FullCalendar' + capitaliseFirstLetter(pluginInput);
  4510. if (!window[globalName]) {
  4511. console.warn('Plugin file not loaded for ' + pluginInput);
  4512. }
  4513. else {
  4514. plugins.push(window[globalName].default); // is an ES6 module
  4515. }
  4516. }
  4517. else {
  4518. plugins.push(pluginInput);
  4519. }
  4520. }
  4521. return INTERNAL_PLUGINS.concat(plugins);
  4522. }
  4523. var RAW_EN_LOCALE = {
  4524. code: 'en',
  4525. week: {
  4526. dow: 0,
  4527. doy: 4 // 4 days need to be within the year to be considered the first week
  4528. },
  4529. dir: 'ltr',
  4530. buttonText: {
  4531. prev: 'prev',
  4532. next: 'next',
  4533. prevYear: 'prev year',
  4534. nextYear: 'next year',
  4535. year: 'year',
  4536. today: 'today',
  4537. month: 'month',
  4538. week: 'week',
  4539. day: 'day',
  4540. list: 'list'
  4541. },
  4542. weekLabel: 'W',
  4543. allDayText: 'all-day',
  4544. eventLimitText: 'more',
  4545. noEventsMessage: 'No events to display'
  4546. };
  4547. function parseRawLocales(explicitRawLocales) {
  4548. var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
  4549. var globalArray = window['FullCalendarLocalesAll'] || []; // from locales-all.js
  4550. var globalObject = window['FullCalendarLocales'] || {}; // from locales/*.js. keys are meaningless
  4551. var allRawLocales = globalArray.concat(// globalArray is low prio
  4552. hashValuesToArray(globalObject), // medium prio
  4553. explicitRawLocales // highest prio
  4554. );
  4555. var rawLocaleMap = {
  4556. en: RAW_EN_LOCALE // necessary?
  4557. };
  4558. for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
  4559. var rawLocale = allRawLocales_1[_i];
  4560. rawLocaleMap[rawLocale.code] = rawLocale;
  4561. }
  4562. return {
  4563. map: rawLocaleMap,
  4564. defaultCode: defaultCode
  4565. };
  4566. }
  4567. function buildLocale(inputSingular, available) {
  4568. if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
  4569. return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
  4570. }
  4571. else {
  4572. return queryLocale(inputSingular, available);
  4573. }
  4574. }
  4575. function queryLocale(codeArg, available) {
  4576. var codes = [].concat(codeArg || []); // will convert to array
  4577. var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
  4578. return parseLocale(codeArg, codes, raw);
  4579. }
  4580. function queryRawLocale(codes, available) {
  4581. for (var i = 0; i < codes.length; i++) {
  4582. var parts = codes[i].toLocaleLowerCase().split('-');
  4583. for (var j = parts.length; j > 0; j--) {
  4584. var simpleId = parts.slice(0, j).join('-');
  4585. if (available[simpleId]) {
  4586. return available[simpleId];
  4587. }
  4588. }
  4589. }
  4590. return null;
  4591. }
  4592. function parseLocale(codeArg, codes, raw) {
  4593. var merged = mergeProps([RAW_EN_LOCALE, raw], ['buttonText']);
  4594. delete merged.code; // don't want this part of the options
  4595. var week = merged.week;
  4596. delete merged.week;
  4597. return {
  4598. codeArg: codeArg,
  4599. codes: codes,
  4600. week: week,
  4601. simpleNumberFormat: new Intl.NumberFormat(codeArg),
  4602. options: merged
  4603. };
  4604. }
  4605. var OptionsManager = /** @class */ (function () {
  4606. function OptionsManager(overrides) {
  4607. this.overrides = __assign({}, overrides); // make a copy
  4608. this.dynamicOverrides = {};
  4609. this.compute();
  4610. }
  4611. OptionsManager.prototype.mutate = function (updates, removals, isDynamic) {
  4612. var overrideHash = isDynamic ? this.dynamicOverrides : this.overrides;
  4613. __assign(overrideHash, updates);
  4614. for (var _i = 0, removals_1 = removals; _i < removals_1.length; _i++) {
  4615. var propName = removals_1[_i];
  4616. delete overrideHash[propName];
  4617. }
  4618. this.compute();
  4619. };
  4620. // Computes the flattened options hash for the calendar and assigns to `this.options`.
  4621. // Assumes this.overrides and this.dynamicOverrides have already been initialized.
  4622. OptionsManager.prototype.compute = function () {
  4623. // TODO: not a very efficient system
  4624. var locales = firstDefined(// explicit locale option given?
  4625. this.dynamicOverrides.locales, this.overrides.locales, globalDefaults.locales);
  4626. var locale = firstDefined(// explicit locales option given?
  4627. this.dynamicOverrides.locale, this.overrides.locale, globalDefaults.locale);
  4628. var available = parseRawLocales(locales);
  4629. var localeDefaults = buildLocale(locale || available.defaultCode, available.map).options;
  4630. var dir = firstDefined(// based on options computed so far, is direction RTL?
  4631. this.dynamicOverrides.dir, this.overrides.dir, localeDefaults.dir);
  4632. var dirDefaults = dir === 'rtl' ? rtlDefaults : {};
  4633. this.dirDefaults = dirDefaults;
  4634. this.localeDefaults = localeDefaults;
  4635. this.computed = mergeOptions([
  4636. globalDefaults,
  4637. dirDefaults,
  4638. localeDefaults,
  4639. this.overrides,
  4640. this.dynamicOverrides
  4641. ]);
  4642. };
  4643. return OptionsManager;
  4644. }());
  4645. var calendarSystemClassMap = {};
  4646. function registerCalendarSystem(name, theClass) {
  4647. calendarSystemClassMap[name] = theClass;
  4648. }
  4649. function createCalendarSystem(name) {
  4650. return new calendarSystemClassMap[name]();
  4651. }
  4652. var GregorianCalendarSystem = /** @class */ (function () {
  4653. function GregorianCalendarSystem() {
  4654. }
  4655. GregorianCalendarSystem.prototype.getMarkerYear = function (d) {
  4656. return d.getUTCFullYear();
  4657. };
  4658. GregorianCalendarSystem.prototype.getMarkerMonth = function (d) {
  4659. return d.getUTCMonth();
  4660. };
  4661. GregorianCalendarSystem.prototype.getMarkerDay = function (d) {
  4662. return d.getUTCDate();
  4663. };
  4664. GregorianCalendarSystem.prototype.arrayToMarker = function (arr) {
  4665. return arrayToUtcDate(arr);
  4666. };
  4667. GregorianCalendarSystem.prototype.markerToArray = function (marker) {
  4668. return dateToUtcArray(marker);
  4669. };
  4670. return GregorianCalendarSystem;
  4671. }());
  4672. registerCalendarSystem('gregory', GregorianCalendarSystem);
  4673. var ISO_RE = /^\s*(\d{4})(-(\d{2})(-(\d{2})([T ](\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
  4674. function parse(str) {
  4675. var m = ISO_RE.exec(str);
  4676. if (m) {
  4677. 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));
  4678. if (isValidDate(marker)) {
  4679. var timeZoneOffset = null;
  4680. if (m[13]) {
  4681. timeZoneOffset = (m[15] === '-' ? -1 : 1) * (Number(m[16] || 0) * 60 +
  4682. Number(m[18] || 0));
  4683. }
  4684. return {
  4685. marker: marker,
  4686. isTimeUnspecified: !m[6],
  4687. timeZoneOffset: timeZoneOffset
  4688. };
  4689. }
  4690. }
  4691. return null;
  4692. }
  4693. var DateEnv = /** @class */ (function () {
  4694. function DateEnv(settings) {
  4695. var timeZone = this.timeZone = settings.timeZone;
  4696. var isNamedTimeZone = timeZone !== 'local' && timeZone !== 'UTC';
  4697. if (settings.namedTimeZoneImpl && isNamedTimeZone) {
  4698. this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
  4699. }
  4700. this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
  4701. this.calendarSystem = createCalendarSystem(settings.calendarSystem);
  4702. this.locale = settings.locale;
  4703. this.weekDow = settings.locale.week.dow;
  4704. this.weekDoy = settings.locale.week.doy;
  4705. if (settings.weekNumberCalculation === 'ISO') {
  4706. this.weekDow = 1;
  4707. this.weekDoy = 4;
  4708. }
  4709. if (typeof settings.firstDay === 'number') {
  4710. this.weekDow = settings.firstDay;
  4711. }
  4712. if (typeof settings.weekNumberCalculation === 'function') {
  4713. this.weekNumberFunc = settings.weekNumberCalculation;
  4714. }
  4715. this.weekLabel = settings.weekLabel != null ? settings.weekLabel : settings.locale.options.weekLabel;
  4716. this.cmdFormatter = settings.cmdFormatter;
  4717. }
  4718. // Creating / Parsing
  4719. DateEnv.prototype.createMarker = function (input) {
  4720. var meta = this.createMarkerMeta(input);
  4721. if (meta === null) {
  4722. return null;
  4723. }
  4724. return meta.marker;
  4725. };
  4726. DateEnv.prototype.createNowMarker = function () {
  4727. if (this.canComputeOffset) {
  4728. return this.timestampToMarker(new Date().valueOf());
  4729. }
  4730. else {
  4731. // if we can't compute the current date val for a timezone,
  4732. // better to give the current local date vals than UTC
  4733. return arrayToUtcDate(dateToLocalArray(new Date()));
  4734. }
  4735. };
  4736. DateEnv.prototype.createMarkerMeta = function (input) {
  4737. if (typeof input === 'string') {
  4738. return this.parse(input);
  4739. }
  4740. var marker = null;
  4741. if (typeof input === 'number') {
  4742. marker = this.timestampToMarker(input);
  4743. }
  4744. else if (input instanceof Date) {
  4745. input = input.valueOf();
  4746. if (!isNaN(input)) {
  4747. marker = this.timestampToMarker(input);
  4748. }
  4749. }
  4750. else if (Array.isArray(input)) {
  4751. marker = arrayToUtcDate(input);
  4752. }
  4753. if (marker === null || !isValidDate(marker)) {
  4754. return null;
  4755. }
  4756. return { marker: marker, isTimeUnspecified: false, forcedTzo: null };
  4757. };
  4758. DateEnv.prototype.parse = function (s) {
  4759. var parts = parse(s);
  4760. if (parts === null) {
  4761. return null;
  4762. }
  4763. var marker = parts.marker;
  4764. var forcedTzo = null;
  4765. if (parts.timeZoneOffset !== null) {
  4766. if (this.canComputeOffset) {
  4767. marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1000);
  4768. }
  4769. else {
  4770. forcedTzo = parts.timeZoneOffset;
  4771. }
  4772. }
  4773. return { marker: marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo: forcedTzo };
  4774. };
  4775. // Accessors
  4776. DateEnv.prototype.getYear = function (marker) {
  4777. return this.calendarSystem.getMarkerYear(marker);
  4778. };
  4779. DateEnv.prototype.getMonth = function (marker) {
  4780. return this.calendarSystem.getMarkerMonth(marker);
  4781. };
  4782. // Adding / Subtracting
  4783. DateEnv.prototype.add = function (marker, dur) {
  4784. var a = this.calendarSystem.markerToArray(marker);
  4785. a[0] += dur.years;
  4786. a[1] += dur.months;
  4787. a[2] += dur.days;
  4788. a[6] += dur.milliseconds;
  4789. return this.calendarSystem.arrayToMarker(a);
  4790. };
  4791. DateEnv.prototype.subtract = function (marker, dur) {
  4792. var a = this.calendarSystem.markerToArray(marker);
  4793. a[0] -= dur.years;
  4794. a[1] -= dur.months;
  4795. a[2] -= dur.days;
  4796. a[6] -= dur.milliseconds;
  4797. return this.calendarSystem.arrayToMarker(a);
  4798. };
  4799. DateEnv.prototype.addYears = function (marker, n) {
  4800. var a = this.calendarSystem.markerToArray(marker);
  4801. a[0] += n;
  4802. return this.calendarSystem.arrayToMarker(a);
  4803. };
  4804. DateEnv.prototype.addMonths = function (marker, n) {
  4805. var a = this.calendarSystem.markerToArray(marker);
  4806. a[1] += n;
  4807. return this.calendarSystem.arrayToMarker(a);
  4808. };
  4809. // Diffing Whole Units
  4810. DateEnv.prototype.diffWholeYears = function (m0, m1) {
  4811. var calendarSystem = this.calendarSystem;
  4812. if (timeAsMs(m0) === timeAsMs(m1) &&
  4813. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) &&
  4814. calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
  4815. return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
  4816. }
  4817. return null;
  4818. };
  4819. DateEnv.prototype.diffWholeMonths = function (m0, m1) {
  4820. var calendarSystem = this.calendarSystem;
  4821. if (timeAsMs(m0) === timeAsMs(m1) &&
  4822. calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
  4823. return (calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0)) +
  4824. (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
  4825. }
  4826. return null;
  4827. };
  4828. // Range / Duration
  4829. DateEnv.prototype.greatestWholeUnit = function (m0, m1) {
  4830. var n = this.diffWholeYears(m0, m1);
  4831. if (n !== null) {
  4832. return { unit: 'year', value: n };
  4833. }
  4834. n = this.diffWholeMonths(m0, m1);
  4835. if (n !== null) {
  4836. return { unit: 'month', value: n };
  4837. }
  4838. n = diffWholeWeeks(m0, m1);
  4839. if (n !== null) {
  4840. return { unit: 'week', value: n };
  4841. }
  4842. n = diffWholeDays(m0, m1);
  4843. if (n !== null) {
  4844. return { unit: 'day', value: n };
  4845. }
  4846. n = diffHours(m0, m1);
  4847. if (isInt(n)) {
  4848. return { unit: 'hour', value: n };
  4849. }
  4850. n = diffMinutes(m0, m1);
  4851. if (isInt(n)) {
  4852. return { unit: 'minute', value: n };
  4853. }
  4854. n = diffSeconds(m0, m1);
  4855. if (isInt(n)) {
  4856. return { unit: 'second', value: n };
  4857. }
  4858. return { unit: 'millisecond', value: m1.valueOf() - m0.valueOf() };
  4859. };
  4860. DateEnv.prototype.countDurationsBetween = function (m0, m1, d) {
  4861. // TODO: can use greatestWholeUnit
  4862. var diff;
  4863. if (d.years) {
  4864. diff = this.diffWholeYears(m0, m1);
  4865. if (diff !== null) {
  4866. return diff / asRoughYears(d);
  4867. }
  4868. }
  4869. if (d.months) {
  4870. diff = this.diffWholeMonths(m0, m1);
  4871. if (diff !== null) {
  4872. return diff / asRoughMonths(d);
  4873. }
  4874. }
  4875. if (d.days) {
  4876. diff = diffWholeDays(m0, m1);
  4877. if (diff !== null) {
  4878. return diff / asRoughDays(d);
  4879. }
  4880. }
  4881. return (m1.valueOf() - m0.valueOf()) / asRoughMs(d);
  4882. };
  4883. // Start-Of
  4884. DateEnv.prototype.startOf = function (m, unit) {
  4885. if (unit === 'year') {
  4886. return this.startOfYear(m);
  4887. }
  4888. else if (unit === 'month') {
  4889. return this.startOfMonth(m);
  4890. }
  4891. else if (unit === 'week') {
  4892. return this.startOfWeek(m);
  4893. }
  4894. else if (unit === 'day') {
  4895. return startOfDay(m);
  4896. }
  4897. else if (unit === 'hour') {
  4898. return startOfHour(m);
  4899. }
  4900. else if (unit === 'minute') {
  4901. return startOfMinute(m);
  4902. }
  4903. else if (unit === 'second') {
  4904. return startOfSecond(m);
  4905. }
  4906. };
  4907. DateEnv.prototype.startOfYear = function (m) {
  4908. return this.calendarSystem.arrayToMarker([
  4909. this.calendarSystem.getMarkerYear(m)
  4910. ]);
  4911. };
  4912. DateEnv.prototype.startOfMonth = function (m) {
  4913. return this.calendarSystem.arrayToMarker([
  4914. this.calendarSystem.getMarkerYear(m),
  4915. this.calendarSystem.getMarkerMonth(m)
  4916. ]);
  4917. };
  4918. DateEnv.prototype.startOfWeek = function (m) {
  4919. return this.calendarSystem.arrayToMarker([
  4920. this.calendarSystem.getMarkerYear(m),
  4921. this.calendarSystem.getMarkerMonth(m),
  4922. m.getUTCDate() - ((m.getUTCDay() - this.weekDow + 7) % 7)
  4923. ]);
  4924. };
  4925. // Week Number
  4926. DateEnv.prototype.computeWeekNumber = function (marker) {
  4927. if (this.weekNumberFunc) {
  4928. return this.weekNumberFunc(this.toDate(marker));
  4929. }
  4930. else {
  4931. return weekOfYear(marker, this.weekDow, this.weekDoy);
  4932. }
  4933. };
  4934. // TODO: choke on timeZoneName: long
  4935. DateEnv.prototype.format = function (marker, formatter, dateOptions) {
  4936. if (dateOptions === void 0) { dateOptions = {}; }
  4937. return formatter.format({
  4938. marker: marker,
  4939. timeZoneOffset: dateOptions.forcedTzo != null ?
  4940. dateOptions.forcedTzo :
  4941. this.offsetForMarker(marker)
  4942. }, this);
  4943. };
  4944. DateEnv.prototype.formatRange = function (start, end, formatter, dateOptions) {
  4945. if (dateOptions === void 0) { dateOptions = {}; }
  4946. if (dateOptions.isEndExclusive) {
  4947. end = addMs(end, -1);
  4948. }
  4949. return formatter.formatRange({
  4950. marker: start,
  4951. timeZoneOffset: dateOptions.forcedStartTzo != null ?
  4952. dateOptions.forcedStartTzo :
  4953. this.offsetForMarker(start)
  4954. }, {
  4955. marker: end,
  4956. timeZoneOffset: dateOptions.forcedEndTzo != null ?
  4957. dateOptions.forcedEndTzo :
  4958. this.offsetForMarker(end)
  4959. }, this);
  4960. };
  4961. DateEnv.prototype.formatIso = function (marker, extraOptions) {
  4962. if (extraOptions === void 0) { extraOptions = {}; }
  4963. var timeZoneOffset = null;
  4964. if (!extraOptions.omitTimeZoneOffset) {
  4965. if (extraOptions.forcedTzo != null) {
  4966. timeZoneOffset = extraOptions.forcedTzo;
  4967. }
  4968. else {
  4969. timeZoneOffset = this.offsetForMarker(marker);
  4970. }
  4971. }
  4972. return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
  4973. };
  4974. // TimeZone
  4975. DateEnv.prototype.timestampToMarker = function (ms) {
  4976. if (this.timeZone === 'local') {
  4977. return arrayToUtcDate(dateToLocalArray(new Date(ms)));
  4978. }
  4979. else if (this.timeZone === 'UTC' || !this.namedTimeZoneImpl) {
  4980. return new Date(ms);
  4981. }
  4982. else {
  4983. return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
  4984. }
  4985. };
  4986. DateEnv.prototype.offsetForMarker = function (m) {
  4987. if (this.timeZone === 'local') {
  4988. return -arrayToLocalDate(dateToUtcArray(m)).getTimezoneOffset(); // convert "inverse" offset to "normal" offset
  4989. }
  4990. else if (this.timeZone === 'UTC') {
  4991. return 0;
  4992. }
  4993. else if (this.namedTimeZoneImpl) {
  4994. return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m));
  4995. }
  4996. return null;
  4997. };
  4998. // Conversion
  4999. DateEnv.prototype.toDate = function (m, forcedTzo) {
  5000. if (this.timeZone === 'local') {
  5001. return arrayToLocalDate(dateToUtcArray(m));
  5002. }
  5003. else if (this.timeZone === 'UTC') {
  5004. return new Date(m.valueOf()); // make sure it's a copy
  5005. }
  5006. else if (!this.namedTimeZoneImpl) {
  5007. return new Date(m.valueOf() - (forcedTzo || 0));
  5008. }
  5009. else {
  5010. return new Date(m.valueOf() -
  5011. this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m)) * 1000 * 60 // convert minutes -> ms
  5012. );
  5013. }
  5014. };
  5015. return DateEnv;
  5016. }());
  5017. var SIMPLE_SOURCE_PROPS = {
  5018. id: String,
  5019. allDayDefault: Boolean,
  5020. eventDataTransform: Function,
  5021. success: Function,
  5022. failure: Function
  5023. };
  5024. var uid$2 = 0;
  5025. function doesSourceNeedRange(eventSource, calendar) {
  5026. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5027. return !defs[eventSource.sourceDefId].ignoreRange;
  5028. }
  5029. function parseEventSource(raw, calendar) {
  5030. var defs = calendar.pluginSystem.hooks.eventSourceDefs;
  5031. for (var i = defs.length - 1; i >= 0; i--) { // later-added plugins take precedence
  5032. var def = defs[i];
  5033. var meta = def.parseMeta(raw);
  5034. if (meta) {
  5035. var res = parseEventSourceProps(typeof raw === 'object' ? raw : {}, meta, i, calendar);
  5036. res._raw = raw;
  5037. return res;
  5038. }
  5039. }
  5040. return null;
  5041. }
  5042. function parseEventSourceProps(raw, meta, sourceDefId, calendar) {
  5043. var leftovers0 = {};
  5044. var props = refineProps(raw, SIMPLE_SOURCE_PROPS, {}, leftovers0);
  5045. var leftovers1 = {};
  5046. var ui = processUnscopedUiProps(leftovers0, calendar, leftovers1);
  5047. props.isFetching = false;
  5048. props.latestFetchId = '';
  5049. props.fetchRange = null;
  5050. props.publicId = String(raw.id || '');
  5051. props.sourceId = String(uid$2++);
  5052. props.sourceDefId = sourceDefId;
  5053. props.meta = meta;
  5054. props.ui = ui;
  5055. props.extendedProps = leftovers1;
  5056. return props;
  5057. }
  5058. function reduceEventSources (eventSources, action, dateProfile, calendar) {
  5059. switch (action.type) {
  5060. case 'ADD_EVENT_SOURCES': // already parsed
  5061. return addSources(eventSources, action.sources, dateProfile ? dateProfile.activeRange : null, calendar);
  5062. case 'REMOVE_EVENT_SOURCE':
  5063. return removeSource(eventSources, action.sourceId);
  5064. case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
  5065. case 'NEXT':
  5066. case 'SET_DATE':
  5067. case 'SET_VIEW_TYPE':
  5068. if (dateProfile) {
  5069. return fetchDirtySources(eventSources, dateProfile.activeRange, calendar);
  5070. }
  5071. else {
  5072. return eventSources;
  5073. }
  5074. case 'FETCH_EVENT_SOURCES':
  5075. case 'CHANGE_TIMEZONE':
  5076. return fetchSourcesByIds(eventSources, action.sourceIds ?
  5077. arrayToHash(action.sourceIds) :
  5078. excludeStaticSources(eventSources, calendar), dateProfile ? dateProfile.activeRange : null, calendar);
  5079. case 'RECEIVE_EVENTS':
  5080. case 'RECEIVE_EVENT_ERROR':
  5081. return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
  5082. case 'REMOVE_ALL_EVENT_SOURCES':
  5083. return {};
  5084. default:
  5085. return eventSources;
  5086. }
  5087. }
  5088. var uid$3 = 0;
  5089. function addSources(eventSourceHash, sources, fetchRange, calendar) {
  5090. var hash = {};
  5091. for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
  5092. var source = sources_1[_i];
  5093. hash[source.sourceId] = source;
  5094. }
  5095. if (fetchRange) {
  5096. hash = fetchDirtySources(hash, fetchRange, calendar);
  5097. }
  5098. return __assign({}, eventSourceHash, hash);
  5099. }
  5100. function removeSource(eventSourceHash, sourceId) {
  5101. return filterHash(eventSourceHash, function (eventSource) {
  5102. return eventSource.sourceId !== sourceId;
  5103. });
  5104. }
  5105. function fetchDirtySources(sourceHash, fetchRange, calendar) {
  5106. return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function (eventSource) {
  5107. return isSourceDirty(eventSource, fetchRange, calendar);
  5108. }), fetchRange, calendar);
  5109. }
  5110. function isSourceDirty(eventSource, fetchRange, calendar) {
  5111. if (!doesSourceNeedRange(eventSource, calendar)) {
  5112. return !eventSource.latestFetchId;
  5113. }
  5114. else {
  5115. return !calendar.opt('lazyFetching') ||
  5116. !eventSource.fetchRange ||
  5117. fetchRange.start < eventSource.fetchRange.start ||
  5118. fetchRange.end > eventSource.fetchRange.end;
  5119. }
  5120. }
  5121. function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, calendar) {
  5122. var nextSources = {};
  5123. for (var sourceId in prevSources) {
  5124. var source = prevSources[sourceId];
  5125. if (sourceIdHash[sourceId]) {
  5126. nextSources[sourceId] = fetchSource(source, fetchRange, calendar);
  5127. }
  5128. else {
  5129. nextSources[sourceId] = source;
  5130. }
  5131. }
  5132. return nextSources;
  5133. }
  5134. function fetchSource(eventSource, fetchRange, calendar) {
  5135. var sourceDef = calendar.pluginSystem.hooks.eventSourceDefs[eventSource.sourceDefId];
  5136. var fetchId = String(uid$3++);
  5137. sourceDef.fetch({
  5138. eventSource: eventSource,
  5139. calendar: calendar,
  5140. range: fetchRange
  5141. }, function (res) {
  5142. var rawEvents = res.rawEvents;
  5143. var calSuccess = calendar.opt('eventSourceSuccess');
  5144. var calSuccessRes;
  5145. var sourceSuccessRes;
  5146. if (eventSource.success) {
  5147. sourceSuccessRes = eventSource.success(rawEvents, res.xhr);
  5148. }
  5149. if (calSuccess) {
  5150. calSuccessRes = calSuccess(rawEvents, res.xhr);
  5151. }
  5152. rawEvents = sourceSuccessRes || calSuccessRes || rawEvents;
  5153. calendar.dispatch({
  5154. type: 'RECEIVE_EVENTS',
  5155. sourceId: eventSource.sourceId,
  5156. fetchId: fetchId,
  5157. fetchRange: fetchRange,
  5158. rawEvents: rawEvents
  5159. });
  5160. }, function (error) {
  5161. var callFailure = calendar.opt('eventSourceFailure');
  5162. console.warn(error.message, error);
  5163. if (eventSource.failure) {
  5164. eventSource.failure(error);
  5165. }
  5166. if (callFailure) {
  5167. callFailure(error);
  5168. }
  5169. calendar.dispatch({
  5170. type: 'RECEIVE_EVENT_ERROR',
  5171. sourceId: eventSource.sourceId,
  5172. fetchId: fetchId,
  5173. fetchRange: fetchRange,
  5174. error: error
  5175. });
  5176. });
  5177. return __assign({}, eventSource, { isFetching: true, latestFetchId: fetchId });
  5178. }
  5179. function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
  5180. var _a;
  5181. var eventSource = sourceHash[sourceId];
  5182. if (eventSource && // not already removed
  5183. fetchId === eventSource.latestFetchId) {
  5184. return __assign({}, sourceHash, (_a = {}, _a[sourceId] = __assign({}, eventSource, { isFetching: false, fetchRange: fetchRange }), _a));
  5185. }
  5186. return sourceHash;
  5187. }
  5188. function excludeStaticSources(eventSources, calendar) {
  5189. return filterHash(eventSources, function (eventSource) {
  5190. return doesSourceNeedRange(eventSource, calendar);
  5191. });
  5192. }
  5193. var DateProfileGenerator = /** @class */ (function () {
  5194. function DateProfileGenerator(viewSpec, calendar) {
  5195. this.viewSpec = viewSpec;
  5196. this.options = viewSpec.options;
  5197. this.dateEnv = calendar.dateEnv;
  5198. this.calendar = calendar;
  5199. this.initHiddenDays();
  5200. }
  5201. /* Date Range Computation
  5202. ------------------------------------------------------------------------------------------------------------------*/
  5203. // Builds a structure with info about what the dates/ranges will be for the "prev" view.
  5204. DateProfileGenerator.prototype.buildPrev = function (currentDateProfile, currentDate) {
  5205. var dateEnv = this.dateEnv;
  5206. var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5207. currentDateProfile.dateIncrement);
  5208. return this.build(prevDate, -1);
  5209. };
  5210. // Builds a structure with info about what the dates/ranges will be for the "next" view.
  5211. DateProfileGenerator.prototype.buildNext = function (currentDateProfile, currentDate) {
  5212. var dateEnv = this.dateEnv;
  5213. var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), // important for start-of-month
  5214. currentDateProfile.dateIncrement);
  5215. return this.build(nextDate, 1);
  5216. };
  5217. // Builds a structure holding dates/ranges for rendering around the given date.
  5218. // Optional direction param indicates whether the date is being incremented/decremented
  5219. // from its previous value. decremented = -1, incremented = 1 (default).
  5220. DateProfileGenerator.prototype.build = function (currentDate, direction, forceToValid) {
  5221. if (forceToValid === void 0) { forceToValid = false; }
  5222. var validRange;
  5223. var minTime = null;
  5224. var maxTime = null;
  5225. var currentInfo;
  5226. var isRangeAllDay;
  5227. var renderRange;
  5228. var activeRange;
  5229. var isValid;
  5230. validRange = this.buildValidRange();
  5231. validRange = this.trimHiddenDays(validRange);
  5232. if (forceToValid) {
  5233. currentDate = constrainMarkerToRange(currentDate, validRange);
  5234. }
  5235. currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
  5236. isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
  5237. renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
  5238. renderRange = this.trimHiddenDays(renderRange);
  5239. activeRange = renderRange;
  5240. if (!this.options.showNonCurrentDates) {
  5241. activeRange = intersectRanges(activeRange, currentInfo.range);
  5242. }
  5243. minTime = createDuration(this.options.minTime);
  5244. maxTime = createDuration(this.options.maxTime);
  5245. activeRange = this.adjustActiveRange(activeRange, minTime, maxTime);
  5246. activeRange = intersectRanges(activeRange, validRange); // might return null
  5247. // it's invalid if the originally requested date is not contained,
  5248. // or if the range is completely outside of the valid range.
  5249. isValid = rangesIntersect(currentInfo.range, validRange);
  5250. return {
  5251. // constraint for where prev/next operations can go and where events can be dragged/resized to.
  5252. // an object with optional start and end properties.
  5253. validRange: validRange,
  5254. // range the view is formally responsible for.
  5255. // for example, a month view might have 1st-31st, excluding padded dates
  5256. currentRange: currentInfo.range,
  5257. // name of largest unit being displayed, like "month" or "week"
  5258. currentRangeUnit: currentInfo.unit,
  5259. isRangeAllDay: isRangeAllDay,
  5260. // dates that display events and accept drag-n-drop
  5261. // will be `null` if no dates accept events
  5262. activeRange: activeRange,
  5263. // date range with a rendered skeleton
  5264. // includes not-active days that need some sort of DOM
  5265. renderRange: renderRange,
  5266. // Duration object that denotes the first visible time of any given day
  5267. minTime: minTime,
  5268. // Duration object that denotes the exclusive visible end time of any given day
  5269. maxTime: maxTime,
  5270. isValid: isValid,
  5271. // how far the current date will move for a prev/next operation
  5272. dateIncrement: this.buildDateIncrement(currentInfo.duration)
  5273. // pass a fallback (might be null) ^
  5274. };
  5275. };
  5276. // Builds an object with optional start/end properties.
  5277. // Indicates the minimum/maximum dates to display.
  5278. // not responsible for trimming hidden days.
  5279. DateProfileGenerator.prototype.buildValidRange = function () {
  5280. return this.getRangeOption('validRange', this.calendar.getNow()) ||
  5281. { start: null, end: null }; // completely open-ended
  5282. };
  5283. // Builds a structure with info about the "current" range, the range that is
  5284. // highlighted as being the current month for example.
  5285. // See cloud() for a description of `direction`.
  5286. // Guaranteed to have `range` and `unit` properties. `duration` is optional.
  5287. DateProfileGenerator.prototype.buildCurrentRangeInfo = function (date, direction) {
  5288. var _a = this, viewSpec = _a.viewSpec, dateEnv = _a.dateEnv;
  5289. var duration = null;
  5290. var unit = null;
  5291. var range = null;
  5292. var dayCount;
  5293. if (viewSpec.duration) {
  5294. duration = viewSpec.duration;
  5295. unit = viewSpec.durationUnit;
  5296. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5297. }
  5298. else if ((dayCount = this.options.dayCount)) {
  5299. unit = 'day';
  5300. range = this.buildRangeFromDayCount(date, direction, dayCount);
  5301. }
  5302. else if ((range = this.buildCustomVisibleRange(date))) {
  5303. unit = dateEnv.greatestWholeUnit(range.start, range.end).unit;
  5304. }
  5305. else {
  5306. duration = this.getFallbackDuration();
  5307. unit = greatestDurationDenominator(duration).unit;
  5308. range = this.buildRangeFromDuration(date, direction, duration, unit);
  5309. }
  5310. return { duration: duration, unit: unit, range: range };
  5311. };
  5312. DateProfileGenerator.prototype.getFallbackDuration = function () {
  5313. return createDuration({ day: 1 });
  5314. };
  5315. // Returns a new activeRange to have time values (un-ambiguate)
  5316. // minTime or maxTime causes the range to expand.
  5317. DateProfileGenerator.prototype.adjustActiveRange = function (range, minTime, maxTime) {
  5318. var dateEnv = this.dateEnv;
  5319. var start = range.start;
  5320. var end = range.end;
  5321. if (this.viewSpec.class.prototype.usesMinMaxTime) {
  5322. // expand active range if minTime is negative (why not when positive?)
  5323. if (asRoughDays(minTime) < 0) {
  5324. start = startOfDay(start); // necessary?
  5325. start = dateEnv.add(start, minTime);
  5326. }
  5327. // expand active range if maxTime is beyond one day (why not when positive?)
  5328. if (asRoughDays(maxTime) > 1) {
  5329. end = startOfDay(end); // necessary?
  5330. end = addDays(end, -1);
  5331. end = dateEnv.add(end, maxTime);
  5332. }
  5333. }
  5334. return { start: start, end: end };
  5335. };
  5336. // Builds the "current" range when it is specified as an explicit duration.
  5337. // `unit` is the already-computed greatestDurationDenominator unit of duration.
  5338. DateProfileGenerator.prototype.buildRangeFromDuration = function (date, direction, duration, unit) {
  5339. var dateEnv = this.dateEnv;
  5340. var alignment = this.options.dateAlignment;
  5341. var dateIncrementInput;
  5342. var dateIncrementDuration;
  5343. var start;
  5344. var end;
  5345. var res;
  5346. // compute what the alignment should be
  5347. if (!alignment) {
  5348. dateIncrementInput = this.options.dateIncrement;
  5349. if (dateIncrementInput) {
  5350. dateIncrementDuration = createDuration(dateIncrementInput);
  5351. // use the smaller of the two units
  5352. if (asRoughMs(dateIncrementDuration) < asRoughMs(duration)) {
  5353. alignment = greatestDurationDenominator(dateIncrementDuration, !getWeeksFromInput(dateIncrementInput)).unit;
  5354. }
  5355. else {
  5356. alignment = unit;
  5357. }
  5358. }
  5359. else {
  5360. alignment = unit;
  5361. }
  5362. }
  5363. // if the view displays a single day or smaller
  5364. if (asRoughDays(duration) <= 1) {
  5365. if (this.isHiddenDay(start)) {
  5366. start = this.skipHiddenDays(start, direction);
  5367. start = startOfDay(start);
  5368. }
  5369. }
  5370. function computeRes() {
  5371. start = dateEnv.startOf(date, alignment);
  5372. end = dateEnv.add(start, duration);
  5373. res = { start: start, end: end };
  5374. }
  5375. computeRes();
  5376. // if range is completely enveloped by hidden days, go past the hidden days
  5377. if (!this.trimHiddenDays(res)) {
  5378. date = this.skipHiddenDays(date, direction);
  5379. computeRes();
  5380. }
  5381. return res;
  5382. };
  5383. // Builds the "current" range when a dayCount is specified.
  5384. DateProfileGenerator.prototype.buildRangeFromDayCount = function (date, direction, dayCount) {
  5385. var dateEnv = this.dateEnv;
  5386. var customAlignment = this.options.dateAlignment;
  5387. var runningCount = 0;
  5388. var start = date;
  5389. var end;
  5390. if (customAlignment) {
  5391. start = dateEnv.startOf(start, customAlignment);
  5392. }
  5393. start = startOfDay(start);
  5394. start = this.skipHiddenDays(start, direction);
  5395. end = start;
  5396. do {
  5397. end = addDays(end, 1);
  5398. if (!this.isHiddenDay(end)) {
  5399. runningCount++;
  5400. }
  5401. } while (runningCount < dayCount);
  5402. return { start: start, end: end };
  5403. };
  5404. // Builds a normalized range object for the "visible" range,
  5405. // which is a way to define the currentRange and activeRange at the same time.
  5406. DateProfileGenerator.prototype.buildCustomVisibleRange = function (date) {
  5407. var dateEnv = this.dateEnv;
  5408. var visibleRange = this.getRangeOption('visibleRange', dateEnv.toDate(date));
  5409. if (visibleRange && (visibleRange.start == null || visibleRange.end == null)) {
  5410. return null;
  5411. }
  5412. return visibleRange;
  5413. };
  5414. // Computes the range that will represent the element/cells for *rendering*,
  5415. // but which may have voided days/times.
  5416. // not responsible for trimming hidden days.
  5417. DateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  5418. return currentRange;
  5419. };
  5420. // Compute the duration value that should be added/substracted to the current date
  5421. // when a prev/next operation happens.
  5422. DateProfileGenerator.prototype.buildDateIncrement = function (fallback) {
  5423. var dateIncrementInput = this.options.dateIncrement;
  5424. var customAlignment;
  5425. if (dateIncrementInput) {
  5426. return createDuration(dateIncrementInput);
  5427. }
  5428. else if ((customAlignment = this.options.dateAlignment)) {
  5429. return createDuration(1, customAlignment);
  5430. }
  5431. else if (fallback) {
  5432. return fallback;
  5433. }
  5434. else {
  5435. return createDuration({ days: 1 });
  5436. }
  5437. };
  5438. // Arguments after name will be forwarded to a hypothetical function value
  5439. // WARNING: passed-in arguments will be given to generator functions as-is and can cause side-effects.
  5440. // Always clone your objects if you fear mutation.
  5441. DateProfileGenerator.prototype.getRangeOption = function (name) {
  5442. var otherArgs = [];
  5443. for (var _i = 1; _i < arguments.length; _i++) {
  5444. otherArgs[_i - 1] = arguments[_i];
  5445. }
  5446. var val = this.options[name];
  5447. if (typeof val === 'function') {
  5448. val = val.apply(null, otherArgs);
  5449. }
  5450. if (val) {
  5451. val = parseRange(val, this.dateEnv);
  5452. }
  5453. if (val) {
  5454. val = computeVisibleDayRange(val);
  5455. }
  5456. return val;
  5457. };
  5458. /* Hidden Days
  5459. ------------------------------------------------------------------------------------------------------------------*/
  5460. // Initializes internal variables related to calculating hidden days-of-week
  5461. DateProfileGenerator.prototype.initHiddenDays = function () {
  5462. var hiddenDays = this.options.hiddenDays || []; // array of day-of-week indices that are hidden
  5463. var isHiddenDayHash = []; // is the day-of-week hidden? (hash with day-of-week-index -> bool)
  5464. var dayCnt = 0;
  5465. var i;
  5466. if (this.options.weekends === false) {
  5467. hiddenDays.push(0, 6); // 0=sunday, 6=saturday
  5468. }
  5469. for (i = 0; i < 7; i++) {
  5470. if (!(isHiddenDayHash[i] = hiddenDays.indexOf(i) !== -1)) {
  5471. dayCnt++;
  5472. }
  5473. }
  5474. if (!dayCnt) {
  5475. throw new Error('invalid hiddenDays'); // all days were hidden? bad.
  5476. }
  5477. this.isHiddenDayHash = isHiddenDayHash;
  5478. };
  5479. // Remove days from the beginning and end of the range that are computed as hidden.
  5480. // If the whole range is trimmed off, returns null
  5481. DateProfileGenerator.prototype.trimHiddenDays = function (range) {
  5482. var start = range.start;
  5483. var end = range.end;
  5484. if (start) {
  5485. start = this.skipHiddenDays(start);
  5486. }
  5487. if (end) {
  5488. end = this.skipHiddenDays(end, -1, true);
  5489. }
  5490. if (start == null || end == null || start < end) {
  5491. return { start: start, end: end };
  5492. }
  5493. return null;
  5494. };
  5495. // Is the current day hidden?
  5496. // `day` is a day-of-week index (0-6), or a Date (used for UTC)
  5497. DateProfileGenerator.prototype.isHiddenDay = function (day) {
  5498. if (day instanceof Date) {
  5499. day = day.getUTCDay();
  5500. }
  5501. return this.isHiddenDayHash[day];
  5502. };
  5503. // Incrementing the current day until it is no longer a hidden day, returning a copy.
  5504. // DOES NOT CONSIDER validRange!
  5505. // If the initial value of `date` is not a hidden day, don't do anything.
  5506. // Pass `isExclusive` as `true` if you are dealing with an end date.
  5507. // `inc` defaults to `1` (increment one day forward each time)
  5508. DateProfileGenerator.prototype.skipHiddenDays = function (date, inc, isExclusive) {
  5509. if (inc === void 0) { inc = 1; }
  5510. if (isExclusive === void 0) { isExclusive = false; }
  5511. while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
  5512. date = addDays(date, inc);
  5513. }
  5514. return date;
  5515. };
  5516. return DateProfileGenerator;
  5517. }());
  5518. // TODO: find a way to avoid comparing DateProfiles. it's tedious
  5519. function isDateProfilesEqual(p0, p1) {
  5520. return rangesEqual(p0.validRange, p1.validRange) &&
  5521. rangesEqual(p0.activeRange, p1.activeRange) &&
  5522. rangesEqual(p0.renderRange, p1.renderRange) &&
  5523. durationsEqual(p0.minTime, p1.minTime) &&
  5524. durationsEqual(p0.maxTime, p1.maxTime);
  5525. /*
  5526. TODO: compare more?
  5527. currentRange: DateRange
  5528. currentRangeUnit: string
  5529. isRangeAllDay: boolean
  5530. isValid: boolean
  5531. dateIncrement: Duration
  5532. */
  5533. }
  5534. function reduce (state, action, calendar) {
  5535. var viewType = reduceViewType(state.viewType, action);
  5536. var dateProfile = reduceDateProfile(state.dateProfile, action, state.currentDate, viewType, calendar);
  5537. var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendar);
  5538. var nextState = __assign({}, state, { viewType: viewType,
  5539. dateProfile: dateProfile, currentDate: reduceCurrentDate(state.currentDate, action, dateProfile), eventSources: eventSources, eventStore: reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendar), dateSelection: reduceDateSelection(state.dateSelection, action, calendar), eventSelection: reduceSelectedEvent(state.eventSelection, action), eventDrag: reduceEventDrag(state.eventDrag, action, eventSources, calendar), eventResize: reduceEventResize(state.eventResize, action, eventSources, calendar), eventSourceLoadingLevel: computeLoadingLevel(eventSources), loadingLevel: computeLoadingLevel(eventSources) });
  5540. for (var _i = 0, _a = calendar.pluginSystem.hooks.reducers; _i < _a.length; _i++) {
  5541. var reducerFunc = _a[_i];
  5542. nextState = reducerFunc(nextState, action, calendar);
  5543. }
  5544. // console.log(action.type, nextState)
  5545. return nextState;
  5546. }
  5547. function reduceViewType(currentViewType, action) {
  5548. switch (action.type) {
  5549. case 'SET_VIEW_TYPE':
  5550. return action.viewType;
  5551. default:
  5552. return currentViewType;
  5553. }
  5554. }
  5555. function reduceDateProfile(currentDateProfile, action, currentDate, viewType, calendar) {
  5556. var newDateProfile;
  5557. switch (action.type) {
  5558. case 'PREV':
  5559. newDateProfile = calendar.dateProfileGenerators[viewType].buildPrev(currentDateProfile, currentDate);
  5560. break;
  5561. case 'NEXT':
  5562. newDateProfile = calendar.dateProfileGenerators[viewType].buildNext(currentDateProfile, currentDate);
  5563. break;
  5564. case 'SET_DATE':
  5565. if (!currentDateProfile.activeRange ||
  5566. !rangeContainsMarker(currentDateProfile.currentRange, action.dateMarker)) {
  5567. newDateProfile = calendar.dateProfileGenerators[viewType].build(action.dateMarker, undefined, true // forceToValid
  5568. );
  5569. }
  5570. break;
  5571. case 'SET_VIEW_TYPE':
  5572. var generator = calendar.dateProfileGenerators[viewType];
  5573. if (!generator) {
  5574. throw new Error(viewType ?
  5575. 'The FullCalendar view "' + viewType + '" does not exist. Make sure your plugins are loaded correctly.' :
  5576. 'No available FullCalendar view plugins.');
  5577. }
  5578. newDateProfile = generator.build(action.dateMarker || currentDate, undefined, true // forceToValid
  5579. );
  5580. break;
  5581. }
  5582. if (newDateProfile &&
  5583. newDateProfile.isValid &&
  5584. !(currentDateProfile && isDateProfilesEqual(currentDateProfile, newDateProfile))) {
  5585. return newDateProfile;
  5586. }
  5587. else {
  5588. return currentDateProfile;
  5589. }
  5590. }
  5591. function reduceCurrentDate(currentDate, action, dateProfile) {
  5592. switch (action.type) {
  5593. case 'PREV':
  5594. case 'NEXT':
  5595. if (!rangeContainsMarker(dateProfile.currentRange, currentDate)) {
  5596. return dateProfile.currentRange.start;
  5597. }
  5598. else {
  5599. return currentDate;
  5600. }
  5601. case 'SET_DATE':
  5602. case 'SET_VIEW_TYPE':
  5603. var newDate = action.dateMarker || currentDate;
  5604. if (dateProfile.activeRange && !rangeContainsMarker(dateProfile.activeRange, newDate)) {
  5605. return dateProfile.currentRange.start;
  5606. }
  5607. else {
  5608. return newDate;
  5609. }
  5610. default:
  5611. return currentDate;
  5612. }
  5613. }
  5614. function reduceDateSelection(currentSelection, action, calendar) {
  5615. switch (action.type) {
  5616. case 'SELECT_DATES':
  5617. return action.selection;
  5618. case 'UNSELECT_DATES':
  5619. return null;
  5620. default:
  5621. return currentSelection;
  5622. }
  5623. }
  5624. function reduceSelectedEvent(currentInstanceId, action) {
  5625. switch (action.type) {
  5626. case 'SELECT_EVENT':
  5627. return action.eventInstanceId;
  5628. case 'UNSELECT_EVENT':
  5629. return '';
  5630. default:
  5631. return currentInstanceId;
  5632. }
  5633. }
  5634. function reduceEventDrag(currentDrag, action, sources, calendar) {
  5635. switch (action.type) {
  5636. case 'SET_EVENT_DRAG':
  5637. var newDrag = action.state;
  5638. return {
  5639. affectedEvents: newDrag.affectedEvents,
  5640. mutatedEvents: newDrag.mutatedEvents,
  5641. isEvent: newDrag.isEvent,
  5642. origSeg: newDrag.origSeg
  5643. };
  5644. case 'UNSET_EVENT_DRAG':
  5645. return null;
  5646. default:
  5647. return currentDrag;
  5648. }
  5649. }
  5650. function reduceEventResize(currentResize, action, sources, calendar) {
  5651. switch (action.type) {
  5652. case 'SET_EVENT_RESIZE':
  5653. var newResize = action.state;
  5654. return {
  5655. affectedEvents: newResize.affectedEvents,
  5656. mutatedEvents: newResize.mutatedEvents,
  5657. isEvent: newResize.isEvent,
  5658. origSeg: newResize.origSeg
  5659. };
  5660. case 'UNSET_EVENT_RESIZE':
  5661. return null;
  5662. default:
  5663. return currentResize;
  5664. }
  5665. }
  5666. function computeLoadingLevel(eventSources) {
  5667. var cnt = 0;
  5668. for (var sourceId in eventSources) {
  5669. if (eventSources[sourceId].isFetching) {
  5670. cnt++;
  5671. }
  5672. }
  5673. return cnt;
  5674. }
  5675. var STANDARD_PROPS = {
  5676. start: null,
  5677. end: null,
  5678. allDay: Boolean
  5679. };
  5680. function parseDateSpan(raw, dateEnv, defaultDuration) {
  5681. var span = parseOpenDateSpan(raw, dateEnv);
  5682. var range = span.range;
  5683. if (!range.start) {
  5684. return null;
  5685. }
  5686. if (!range.end) {
  5687. if (defaultDuration == null) {
  5688. return null;
  5689. }
  5690. else {
  5691. range.end = dateEnv.add(range.start, defaultDuration);
  5692. }
  5693. }
  5694. return span;
  5695. }
  5696. /*
  5697. TODO: somehow combine with parseRange?
  5698. Will return null if the start/end props were present but parsed invalidly.
  5699. */
  5700. function parseOpenDateSpan(raw, dateEnv) {
  5701. var leftovers = {};
  5702. var standardProps = refineProps(raw, STANDARD_PROPS, {}, leftovers);
  5703. var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
  5704. var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
  5705. var allDay = standardProps.allDay;
  5706. if (allDay == null) {
  5707. allDay = (startMeta && startMeta.isTimeUnspecified) &&
  5708. (!endMeta || endMeta.isTimeUnspecified);
  5709. }
  5710. // use this leftover object as the selection object
  5711. leftovers.range = {
  5712. start: startMeta ? startMeta.marker : null,
  5713. end: endMeta ? endMeta.marker : null
  5714. };
  5715. leftovers.allDay = allDay;
  5716. return leftovers;
  5717. }
  5718. function isDateSpansEqual(span0, span1) {
  5719. return rangesEqual(span0.range, span1.range) &&
  5720. span0.allDay === span1.allDay &&
  5721. isSpanPropsEqual(span0, span1);
  5722. }
  5723. // the NON-DATE-RELATED props
  5724. function isSpanPropsEqual(span0, span1) {
  5725. for (var propName in span1) {
  5726. if (propName !== 'range' && propName !== 'allDay') {
  5727. if (span0[propName] !== span1[propName]) {
  5728. return false;
  5729. }
  5730. }
  5731. }
  5732. // are there any props that span0 has that span1 DOESN'T have?
  5733. // both have range/allDay, so no need to special-case.
  5734. for (var propName in span0) {
  5735. if (!(propName in span1)) {
  5736. return false;
  5737. }
  5738. }
  5739. return true;
  5740. }
  5741. function buildDateSpanApi(span, dateEnv) {
  5742. return {
  5743. start: dateEnv.toDate(span.range.start),
  5744. end: dateEnv.toDate(span.range.end),
  5745. startStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5746. endStr: dateEnv.formatIso(span.range.end, { omitTime: span.allDay }),
  5747. allDay: span.allDay
  5748. };
  5749. }
  5750. function buildDatePointApi(span, dateEnv) {
  5751. return {
  5752. date: dateEnv.toDate(span.range.start),
  5753. dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
  5754. allDay: span.allDay
  5755. };
  5756. }
  5757. function fabricateEventRange(dateSpan, eventUiBases, calendar) {
  5758. var def = parseEventDef({ editable: false }, '', // sourceId
  5759. dateSpan.allDay, true, // hasEnd
  5760. calendar);
  5761. return {
  5762. def: def,
  5763. ui: compileEventUi(def, eventUiBases),
  5764. instance: createEventInstance(def.defId, dateSpan.range),
  5765. range: dateSpan.range,
  5766. isStart: true,
  5767. isEnd: true
  5768. };
  5769. }
  5770. function compileViewDefs(defaultConfigs, overrideConfigs) {
  5771. var hash = {};
  5772. var viewType;
  5773. for (viewType in defaultConfigs) {
  5774. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5775. }
  5776. for (viewType in overrideConfigs) {
  5777. ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5778. }
  5779. return hash;
  5780. }
  5781. function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5782. if (hash[viewType]) {
  5783. return hash[viewType];
  5784. }
  5785. var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
  5786. if (viewDef) {
  5787. hash[viewType] = viewDef;
  5788. }
  5789. return viewDef;
  5790. }
  5791. function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
  5792. var defaultConfig = defaultConfigs[viewType];
  5793. var overrideConfig = overrideConfigs[viewType];
  5794. var queryProp = function (name) {
  5795. return (defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
  5796. ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null);
  5797. };
  5798. var theClass = queryProp('class');
  5799. var superType = queryProp('superType');
  5800. if (!superType && theClass) {
  5801. superType =
  5802. findViewNameBySubclass(theClass, overrideConfigs) ||
  5803. findViewNameBySubclass(theClass, defaultConfigs);
  5804. }
  5805. var superDef = null;
  5806. if (superType) {
  5807. if (superType === viewType) {
  5808. throw new Error('Can\'t have a custom view type that references itself');
  5809. }
  5810. superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
  5811. }
  5812. if (!theClass && superDef) {
  5813. theClass = superDef.class;
  5814. }
  5815. if (!theClass) {
  5816. return null; // don't throw a warning, might be settings for a single-unit view
  5817. }
  5818. return {
  5819. type: viewType,
  5820. class: theClass,
  5821. defaults: __assign({}, (superDef ? superDef.defaults : {}), (defaultConfig ? defaultConfig.options : {})),
  5822. overrides: __assign({}, (superDef ? superDef.overrides : {}), (overrideConfig ? overrideConfig.options : {}))
  5823. };
  5824. }
  5825. function findViewNameBySubclass(viewSubclass, configs) {
  5826. var superProto = Object.getPrototypeOf(viewSubclass.prototype);
  5827. for (var viewType in configs) {
  5828. var parsed = configs[viewType];
  5829. // need DIRECT subclass, so instanceof won't do it
  5830. if (parsed.class && parsed.class.prototype === superProto) {
  5831. return viewType;
  5832. }
  5833. }
  5834. return '';
  5835. }
  5836. function parseViewConfigs(inputs) {
  5837. return mapHash(inputs, parseViewConfig);
  5838. }
  5839. var VIEW_DEF_PROPS = {
  5840. type: String,
  5841. class: null
  5842. };
  5843. function parseViewConfig(input) {
  5844. if (typeof input === 'function') {
  5845. input = { class: input };
  5846. }
  5847. var options = {};
  5848. var props = refineProps(input, VIEW_DEF_PROPS, {}, options);
  5849. return {
  5850. superType: props.type,
  5851. class: props.class,
  5852. options: options
  5853. };
  5854. }
  5855. function buildViewSpecs(defaultInputs, optionsManager) {
  5856. var defaultConfigs = parseViewConfigs(defaultInputs);
  5857. var overrideConfigs = parseViewConfigs(optionsManager.overrides.views);
  5858. var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
  5859. return mapHash(viewDefs, function (viewDef) {
  5860. return buildViewSpec(viewDef, overrideConfigs, optionsManager);
  5861. });
  5862. }
  5863. function buildViewSpec(viewDef, overrideConfigs, optionsManager) {
  5864. var durationInput = viewDef.overrides.duration ||
  5865. viewDef.defaults.duration ||
  5866. optionsManager.dynamicOverrides.duration ||
  5867. optionsManager.overrides.duration;
  5868. var duration = null;
  5869. var durationUnit = '';
  5870. var singleUnit = '';
  5871. var singleUnitOverrides = {};
  5872. if (durationInput) {
  5873. duration = createDuration(durationInput);
  5874. if (duration) { // valid?
  5875. var denom = greatestDurationDenominator(duration, !getWeeksFromInput(durationInput));
  5876. durationUnit = denom.unit;
  5877. if (denom.value === 1) {
  5878. singleUnit = durationUnit;
  5879. singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].options : {};
  5880. }
  5881. }
  5882. }
  5883. var queryButtonText = function (options) {
  5884. var buttonTextMap = options.buttonText || {};
  5885. var buttonTextKey = viewDef.defaults.buttonTextKey;
  5886. if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
  5887. return buttonTextMap[buttonTextKey];
  5888. }
  5889. if (buttonTextMap[viewDef.type] != null) {
  5890. return buttonTextMap[viewDef.type];
  5891. }
  5892. if (buttonTextMap[singleUnit] != null) {
  5893. return buttonTextMap[singleUnit];
  5894. }
  5895. };
  5896. return {
  5897. type: viewDef.type,
  5898. class: viewDef.class,
  5899. duration: duration,
  5900. durationUnit: durationUnit,
  5901. singleUnit: singleUnit,
  5902. options: __assign({}, globalDefaults, viewDef.defaults, optionsManager.dirDefaults, optionsManager.localeDefaults, optionsManager.overrides, singleUnitOverrides, viewDef.overrides, optionsManager.dynamicOverrides),
  5903. buttonTextOverride: queryButtonText(optionsManager.dynamicOverrides) ||
  5904. queryButtonText(optionsManager.overrides) || // constructor-specified buttonText lookup hash takes precedence
  5905. viewDef.overrides.buttonText,
  5906. buttonTextDefault: queryButtonText(optionsManager.localeDefaults) ||
  5907. queryButtonText(optionsManager.dirDefaults) ||
  5908. viewDef.defaults.buttonText ||
  5909. queryButtonText(globalDefaults) ||
  5910. viewDef.type // fall back to given view name
  5911. };
  5912. }
  5913. var Toolbar = /** @class */ (function (_super) {
  5914. __extends(Toolbar, _super);
  5915. function Toolbar(context, extraClassName) {
  5916. var _this = _super.call(this, context) || this;
  5917. _this._renderLayout = memoizeRendering(_this.renderLayout, _this.unrenderLayout);
  5918. _this._updateTitle = memoizeRendering(_this.updateTitle, null, [_this._renderLayout]);
  5919. _this._updateActiveButton = memoizeRendering(_this.updateActiveButton, null, [_this._renderLayout]);
  5920. _this._updateToday = memoizeRendering(_this.updateToday, null, [_this._renderLayout]);
  5921. _this._updatePrev = memoizeRendering(_this.updatePrev, null, [_this._renderLayout]);
  5922. _this._updateNext = memoizeRendering(_this.updateNext, null, [_this._renderLayout]);
  5923. _this.el = createElement('div', { className: 'fc-toolbar ' + extraClassName });
  5924. return _this;
  5925. }
  5926. Toolbar.prototype.destroy = function () {
  5927. _super.prototype.destroy.call(this);
  5928. this._renderLayout.unrender(); // should unrender everything else
  5929. removeElement(this.el);
  5930. };
  5931. Toolbar.prototype.render = function (props) {
  5932. this._renderLayout(props.layout);
  5933. this._updateTitle(props.title);
  5934. this._updateActiveButton(props.activeButton);
  5935. this._updateToday(props.isTodayEnabled);
  5936. this._updatePrev(props.isPrevEnabled);
  5937. this._updateNext(props.isNextEnabled);
  5938. };
  5939. Toolbar.prototype.renderLayout = function (layout) {
  5940. var el = this.el;
  5941. this.viewsWithButtons = [];
  5942. appendToElement(el, this.renderSection('left', layout.left));
  5943. appendToElement(el, this.renderSection('center', layout.center));
  5944. appendToElement(el, this.renderSection('right', layout.right));
  5945. };
  5946. Toolbar.prototype.unrenderLayout = function () {
  5947. this.el.innerHTML = '';
  5948. };
  5949. Toolbar.prototype.renderSection = function (position, buttonStr) {
  5950. var _this = this;
  5951. var _a = this, theme = _a.theme, calendar = _a.calendar;
  5952. var optionsManager = calendar.optionsManager;
  5953. var viewSpecs = calendar.viewSpecs;
  5954. var sectionEl = createElement('div', { className: 'fc-' + position });
  5955. var calendarCustomButtons = optionsManager.computed.customButtons || {};
  5956. var calendarButtonTextOverrides = optionsManager.overrides.buttonText || {};
  5957. var calendarButtonText = optionsManager.computed.buttonText || {};
  5958. if (buttonStr) {
  5959. buttonStr.split(' ').forEach(function (buttonGroupStr, i) {
  5960. var groupChildren = [];
  5961. var isOnlyButtons = true;
  5962. var groupEl;
  5963. buttonGroupStr.split(',').forEach(function (buttonName, j) {
  5964. var customButtonProps;
  5965. var viewSpec;
  5966. var buttonClick;
  5967. var buttonIcon; // only one of these will be set
  5968. var buttonText; // "
  5969. var buttonInnerHtml;
  5970. var buttonClasses;
  5971. var buttonEl;
  5972. var buttonAriaAttr;
  5973. if (buttonName === 'title') {
  5974. groupChildren.push(htmlToElement('<h2>&nbsp;</h2>')); // we always want it to take up height
  5975. isOnlyButtons = false;
  5976. }
  5977. else {
  5978. if ((customButtonProps = calendarCustomButtons[buttonName])) {
  5979. buttonClick = function (ev) {
  5980. if (customButtonProps.click) {
  5981. customButtonProps.click.call(buttonEl, ev);
  5982. }
  5983. };
  5984. (buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) ||
  5985. (buttonIcon = theme.getIconClass(buttonName)) ||
  5986. (buttonText = customButtonProps.text);
  5987. }
  5988. else if ((viewSpec = viewSpecs[buttonName])) {
  5989. _this.viewsWithButtons.push(buttonName);
  5990. buttonClick = function () {
  5991. calendar.changeView(buttonName);
  5992. };
  5993. (buttonText = viewSpec.buttonTextOverride) ||
  5994. (buttonIcon = theme.getIconClass(buttonName)) ||
  5995. (buttonText = viewSpec.buttonTextDefault);
  5996. }
  5997. else if (calendar[buttonName]) { // a calendar method
  5998. buttonClick = function () {
  5999. calendar[buttonName]();
  6000. };
  6001. (buttonText = calendarButtonTextOverrides[buttonName]) ||
  6002. (buttonIcon = theme.getIconClass(buttonName)) ||
  6003. (buttonText = calendarButtonText[buttonName]);
  6004. // ^ everything else is considered default
  6005. }
  6006. if (buttonClick) {
  6007. buttonClasses = [
  6008. 'fc-' + buttonName + '-button',
  6009. theme.getClass('button')
  6010. ];
  6011. if (buttonText) {
  6012. buttonInnerHtml = htmlEscape(buttonText);
  6013. buttonAriaAttr = '';
  6014. }
  6015. else if (buttonIcon) {
  6016. buttonInnerHtml = "<span class='" + buttonIcon + "'></span>";
  6017. buttonAriaAttr = ' aria-label="' + buttonName + '"';
  6018. }
  6019. buttonEl = htmlToElement(// type="button" so that it doesn't submit a form
  6020. '<button type="button" class="' + buttonClasses.join(' ') + '"' +
  6021. buttonAriaAttr +
  6022. '>' + buttonInnerHtml + '</button>');
  6023. buttonEl.addEventListener('click', buttonClick);
  6024. groupChildren.push(buttonEl);
  6025. }
  6026. }
  6027. });
  6028. if (groupChildren.length > 1) {
  6029. groupEl = document.createElement('div');
  6030. var buttonGroupClassName = theme.getClass('buttonGroup');
  6031. if (isOnlyButtons && buttonGroupClassName) {
  6032. groupEl.classList.add(buttonGroupClassName);
  6033. }
  6034. appendToElement(groupEl, groupChildren);
  6035. sectionEl.appendChild(groupEl);
  6036. }
  6037. else {
  6038. appendToElement(sectionEl, groupChildren); // 1 or 0 children
  6039. }
  6040. });
  6041. }
  6042. return sectionEl;
  6043. };
  6044. Toolbar.prototype.updateToday = function (isTodayEnabled) {
  6045. this.toggleButtonEnabled('today', isTodayEnabled);
  6046. };
  6047. Toolbar.prototype.updatePrev = function (isPrevEnabled) {
  6048. this.toggleButtonEnabled('prev', isPrevEnabled);
  6049. };
  6050. Toolbar.prototype.updateNext = function (isNextEnabled) {
  6051. this.toggleButtonEnabled('next', isNextEnabled);
  6052. };
  6053. Toolbar.prototype.updateTitle = function (text) {
  6054. findElements(this.el, 'h2').forEach(function (titleEl) {
  6055. titleEl.innerText = text;
  6056. });
  6057. };
  6058. Toolbar.prototype.updateActiveButton = function (buttonName) {
  6059. var className = this.theme.getClass('buttonActive');
  6060. findElements(this.el, 'button').forEach(function (buttonEl) {
  6061. if (buttonName && buttonEl.classList.contains('fc-' + buttonName + '-button')) {
  6062. buttonEl.classList.add(className);
  6063. }
  6064. else {
  6065. buttonEl.classList.remove(className);
  6066. }
  6067. });
  6068. };
  6069. Toolbar.prototype.toggleButtonEnabled = function (buttonName, bool) {
  6070. findElements(this.el, '.fc-' + buttonName + '-button').forEach(function (buttonEl) {
  6071. buttonEl.disabled = !bool;
  6072. });
  6073. };
  6074. return Toolbar;
  6075. }(Component));
  6076. var CalendarComponent = /** @class */ (function (_super) {
  6077. __extends(CalendarComponent, _super);
  6078. function CalendarComponent(context, el) {
  6079. var _this = _super.call(this, context) || this;
  6080. _this._renderToolbars = memoizeRendering(_this.renderToolbars);
  6081. _this.buildViewPropTransformers = memoize(buildViewPropTransformers);
  6082. _this.el = el;
  6083. prependToElement(el, _this.contentEl = createElement('div', { className: 'fc-view-container' }));
  6084. var calendar = _this.calendar;
  6085. for (var _i = 0, _a = calendar.pluginSystem.hooks.viewContainerModifiers; _i < _a.length; _i++) {
  6086. var modifyViewContainer = _a[_i];
  6087. modifyViewContainer(_this.contentEl, calendar);
  6088. }
  6089. _this.toggleElClassNames(true);
  6090. _this.computeTitle = memoize(computeTitle);
  6091. _this.parseBusinessHours = memoize(function (input) {
  6092. return parseBusinessHours(input, _this.calendar);
  6093. });
  6094. return _this;
  6095. }
  6096. CalendarComponent.prototype.destroy = function () {
  6097. if (this.header) {
  6098. this.header.destroy();
  6099. }
  6100. if (this.footer) {
  6101. this.footer.destroy();
  6102. }
  6103. if (this.view) {
  6104. this.view.destroy();
  6105. }
  6106. removeElement(this.contentEl);
  6107. this.toggleElClassNames(false);
  6108. _super.prototype.destroy.call(this);
  6109. };
  6110. CalendarComponent.prototype.toggleElClassNames = function (bool) {
  6111. var classList = this.el.classList;
  6112. var dirClassName = 'fc-' + this.opt('dir');
  6113. var themeClassName = this.theme.getClass('widget');
  6114. if (bool) {
  6115. classList.add('fc');
  6116. classList.add(dirClassName);
  6117. classList.add(themeClassName);
  6118. }
  6119. else {
  6120. classList.remove('fc');
  6121. classList.remove(dirClassName);
  6122. classList.remove(themeClassName);
  6123. }
  6124. };
  6125. CalendarComponent.prototype.render = function (props) {
  6126. this.freezeHeight();
  6127. var title = this.computeTitle(props.dateProfile, props.viewSpec.options);
  6128. this._renderToolbars(props.viewSpec, props.dateProfile, props.currentDate, props.dateProfileGenerator, title);
  6129. this.renderView(props, title);
  6130. this.updateSize();
  6131. this.thawHeight();
  6132. };
  6133. CalendarComponent.prototype.renderToolbars = function (viewSpec, dateProfile, currentDate, dateProfileGenerator, title) {
  6134. var headerLayout = this.opt('header');
  6135. var footerLayout = this.opt('footer');
  6136. var now = this.calendar.getNow();
  6137. var todayInfo = dateProfileGenerator.build(now);
  6138. var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate);
  6139. var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate);
  6140. var toolbarProps = {
  6141. title: title,
  6142. activeButton: viewSpec.type,
  6143. isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
  6144. isPrevEnabled: prevInfo.isValid,
  6145. isNextEnabled: nextInfo.isValid
  6146. };
  6147. if (headerLayout) {
  6148. if (!this.header) {
  6149. this.header = new Toolbar(this.context, 'fc-header-toolbar');
  6150. prependToElement(this.el, this.header.el);
  6151. }
  6152. this.header.receiveProps(__assign({ layout: headerLayout }, toolbarProps));
  6153. }
  6154. else if (this.header) {
  6155. this.header.destroy();
  6156. this.header = null;
  6157. }
  6158. if (footerLayout) {
  6159. if (!this.footer) {
  6160. this.footer = new Toolbar(this.context, 'fc-footer-toolbar');
  6161. appendToElement(this.el, this.footer.el);
  6162. }
  6163. this.footer.receiveProps(__assign({ layout: footerLayout }, toolbarProps));
  6164. }
  6165. else if (this.footer) {
  6166. this.footer.destroy();
  6167. this.footer = null;
  6168. }
  6169. };
  6170. CalendarComponent.prototype.renderView = function (props, title) {
  6171. var view = this.view;
  6172. var viewSpec = props.viewSpec, dateProfileGenerator = props.dateProfileGenerator;
  6173. if (!view || view.viewSpec !== viewSpec) {
  6174. if (view) {
  6175. view.destroy();
  6176. }
  6177. view = this.view = new viewSpec['class']({
  6178. calendar: this.calendar,
  6179. view: null,
  6180. dateEnv: this.dateEnv,
  6181. theme: this.theme,
  6182. options: viewSpec.options
  6183. }, viewSpec, dateProfileGenerator, this.contentEl);
  6184. }
  6185. else {
  6186. view.addScroll(view.queryScroll());
  6187. }
  6188. view.title = title; // for the API
  6189. var viewProps = {
  6190. dateProfile: props.dateProfile,
  6191. businessHours: this.parseBusinessHours(viewSpec.options.businessHours),
  6192. eventStore: props.eventStore,
  6193. eventUiBases: props.eventUiBases,
  6194. dateSelection: props.dateSelection,
  6195. eventSelection: props.eventSelection,
  6196. eventDrag: props.eventDrag,
  6197. eventResize: props.eventResize
  6198. };
  6199. var transformers = this.buildViewPropTransformers(this.calendar.pluginSystem.hooks.viewPropsTransformers);
  6200. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  6201. var transformer = transformers_1[_i];
  6202. __assign(viewProps, transformer.transform(viewProps, viewSpec, props, view));
  6203. }
  6204. view.receiveProps(viewProps);
  6205. };
  6206. // Sizing
  6207. // -----------------------------------------------------------------------------------------------------------------
  6208. CalendarComponent.prototype.updateSize = function (isResize) {
  6209. if (isResize === void 0) { isResize = false; }
  6210. var view = this.view;
  6211. if (isResize) {
  6212. view.addScroll(view.queryScroll());
  6213. }
  6214. if (isResize || this.isHeightAuto == null) {
  6215. this.computeHeightVars();
  6216. }
  6217. view.updateSize(isResize, this.viewHeight, this.isHeightAuto);
  6218. view.updateNowIndicator(); // we need to guarantee this will run after updateSize
  6219. view.popScroll(isResize);
  6220. };
  6221. CalendarComponent.prototype.computeHeightVars = function () {
  6222. var calendar = this.calendar; // yuck. need to handle dynamic options
  6223. var heightInput = calendar.opt('height');
  6224. var contentHeightInput = calendar.opt('contentHeight');
  6225. this.isHeightAuto = heightInput === 'auto' || contentHeightInput === 'auto';
  6226. if (typeof contentHeightInput === 'number') { // exists and not 'auto'
  6227. this.viewHeight = contentHeightInput;
  6228. }
  6229. else if (typeof contentHeightInput === 'function') { // exists and is a function
  6230. this.viewHeight = contentHeightInput();
  6231. }
  6232. else if (typeof heightInput === 'number') { // exists and not 'auto'
  6233. this.viewHeight = heightInput - this.queryToolbarsHeight();
  6234. }
  6235. else if (typeof heightInput === 'function') { // exists and is a function
  6236. this.viewHeight = heightInput() - this.queryToolbarsHeight();
  6237. }
  6238. else if (heightInput === 'parent') { // set to height of parent element
  6239. var parentEl = this.el.parentNode;
  6240. this.viewHeight = parentEl.getBoundingClientRect().height - this.queryToolbarsHeight();
  6241. }
  6242. else {
  6243. this.viewHeight = Math.round(this.contentEl.getBoundingClientRect().width /
  6244. Math.max(calendar.opt('aspectRatio'), .5));
  6245. }
  6246. };
  6247. CalendarComponent.prototype.queryToolbarsHeight = function () {
  6248. var height = 0;
  6249. if (this.header) {
  6250. height += computeHeightAndMargins(this.header.el);
  6251. }
  6252. if (this.footer) {
  6253. height += computeHeightAndMargins(this.footer.el);
  6254. }
  6255. return height;
  6256. };
  6257. // Height "Freezing"
  6258. // -----------------------------------------------------------------------------------------------------------------
  6259. CalendarComponent.prototype.freezeHeight = function () {
  6260. applyStyle(this.el, {
  6261. height: this.el.getBoundingClientRect().height,
  6262. overflow: 'hidden'
  6263. });
  6264. };
  6265. CalendarComponent.prototype.thawHeight = function () {
  6266. applyStyle(this.el, {
  6267. height: '',
  6268. overflow: ''
  6269. });
  6270. };
  6271. return CalendarComponent;
  6272. }(Component));
  6273. // Title and Date Formatting
  6274. // -----------------------------------------------------------------------------------------------------------------
  6275. // Computes what the title at the top of the calendar should be for this view
  6276. function computeTitle(dateProfile, viewOptions) {
  6277. var range;
  6278. // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
  6279. if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
  6280. range = dateProfile.currentRange;
  6281. }
  6282. else { // for day units or smaller, use the actual day range
  6283. range = dateProfile.activeRange;
  6284. }
  6285. return this.dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || computeTitleFormat(dateProfile), viewOptions.titleRangeSeparator), { isEndExclusive: dateProfile.isRangeAllDay });
  6286. }
  6287. // Generates the format string that should be used to generate the title for the current date range.
  6288. // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
  6289. function computeTitleFormat(dateProfile) {
  6290. var currentRangeUnit = dateProfile.currentRangeUnit;
  6291. if (currentRangeUnit === 'year') {
  6292. return { year: 'numeric' };
  6293. }
  6294. else if (currentRangeUnit === 'month') {
  6295. return { year: 'numeric', month: 'long' }; // like "September 2014"
  6296. }
  6297. else {
  6298. var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
  6299. if (days !== null && days > 1) {
  6300. // multi-day range. shorter, like "Sep 9 - 10 2014"
  6301. return { year: 'numeric', month: 'short', day: 'numeric' };
  6302. }
  6303. else {
  6304. // one day. longer, like "September 9 2014"
  6305. return { year: 'numeric', month: 'long', day: 'numeric' };
  6306. }
  6307. }
  6308. }
  6309. // Plugin
  6310. // -----------------------------------------------------------------------------------------------------------------
  6311. function buildViewPropTransformers(theClasses) {
  6312. return theClasses.map(function (theClass) {
  6313. return new theClass();
  6314. });
  6315. }
  6316. var Interaction = /** @class */ (function () {
  6317. function Interaction(settings) {
  6318. this.component = settings.component;
  6319. }
  6320. Interaction.prototype.destroy = function () {
  6321. };
  6322. return Interaction;
  6323. }());
  6324. function parseInteractionSettings(component, input) {
  6325. return {
  6326. component: component,
  6327. el: input.el,
  6328. useEventCenter: input.useEventCenter != null ? input.useEventCenter : true
  6329. };
  6330. }
  6331. function interactionSettingsToStore(settings) {
  6332. var _a;
  6333. return _a = {},
  6334. _a[settings.component.uid] = settings,
  6335. _a;
  6336. }
  6337. // global state
  6338. var interactionSettingsStore = {};
  6339. /*
  6340. Detects when the user clicks on an event within a DateComponent
  6341. */
  6342. var EventClicking = /** @class */ (function (_super) {
  6343. __extends(EventClicking, _super);
  6344. function EventClicking(settings) {
  6345. var _this = _super.call(this, settings) || this;
  6346. _this.handleSegClick = function (ev, segEl) {
  6347. var component = _this.component;
  6348. var seg = getElSeg(segEl);
  6349. if (seg && // might be the <div> surrounding the more link
  6350. component.isValidSegDownEl(ev.target)) {
  6351. // our way to simulate a link click for elements that can't be <a> tags
  6352. // grab before trigger fired in case trigger trashes DOM thru rerendering
  6353. var hasUrlContainer = elementClosest(ev.target, '.fc-has-url');
  6354. var url = hasUrlContainer ? hasUrlContainer.querySelector('a[href]').href : '';
  6355. component.publiclyTrigger('eventClick', [
  6356. {
  6357. el: segEl,
  6358. event: new EventApi(component.calendar, seg.eventRange.def, seg.eventRange.instance),
  6359. jsEvent: ev,
  6360. view: component.view
  6361. }
  6362. ]);
  6363. if (url && !ev.defaultPrevented) {
  6364. window.location.href = url;
  6365. }
  6366. }
  6367. };
  6368. var component = settings.component;
  6369. _this.destroy = listenBySelector(component.el, 'click', component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegClick);
  6370. return _this;
  6371. }
  6372. return EventClicking;
  6373. }(Interaction));
  6374. /*
  6375. Triggers events and adds/removes core classNames when the user's pointer
  6376. enters/leaves event-elements of a component.
  6377. */
  6378. var EventHovering = /** @class */ (function (_super) {
  6379. __extends(EventHovering, _super);
  6380. function EventHovering(settings) {
  6381. var _this = _super.call(this, settings) || this;
  6382. // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
  6383. _this.handleEventElRemove = function (el) {
  6384. if (el === _this.currentSegEl) {
  6385. _this.handleSegLeave(null, _this.currentSegEl);
  6386. }
  6387. };
  6388. _this.handleSegEnter = function (ev, segEl) {
  6389. if (getElSeg(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
  6390. segEl.classList.add('fc-allow-mouse-resize');
  6391. _this.currentSegEl = segEl;
  6392. _this.triggerEvent('eventMouseEnter', ev, segEl);
  6393. }
  6394. };
  6395. _this.handleSegLeave = function (ev, segEl) {
  6396. if (_this.currentSegEl) {
  6397. segEl.classList.remove('fc-allow-mouse-resize');
  6398. _this.currentSegEl = null;
  6399. _this.triggerEvent('eventMouseLeave', ev, segEl);
  6400. }
  6401. };
  6402. var component = settings.component;
  6403. _this.removeHoverListeners = listenToHoverBySelector(component.el, component.fgSegSelector + ',' + component.bgSegSelector, _this.handleSegEnter, _this.handleSegLeave);
  6404. component.calendar.on('eventElRemove', _this.handleEventElRemove);
  6405. return _this;
  6406. }
  6407. EventHovering.prototype.destroy = function () {
  6408. this.removeHoverListeners();
  6409. this.component.calendar.off('eventElRemove', this.handleEventElRemove);
  6410. };
  6411. EventHovering.prototype.triggerEvent = function (publicEvName, ev, segEl) {
  6412. var component = this.component;
  6413. var seg = getElSeg(segEl);
  6414. if (!ev || component.isValidSegDownEl(ev.target)) {
  6415. component.publiclyTrigger(publicEvName, [
  6416. {
  6417. el: segEl,
  6418. event: new EventApi(this.component.calendar, seg.eventRange.def, seg.eventRange.instance),
  6419. jsEvent: ev,
  6420. view: component.view
  6421. }
  6422. ]);
  6423. }
  6424. };
  6425. return EventHovering;
  6426. }(Interaction));
  6427. var StandardTheme = /** @class */ (function (_super) {
  6428. __extends(StandardTheme, _super);
  6429. function StandardTheme() {
  6430. return _super !== null && _super.apply(this, arguments) || this;
  6431. }
  6432. return StandardTheme;
  6433. }(Theme));
  6434. StandardTheme.prototype.classes = {
  6435. widget: 'fc-unthemed',
  6436. widgetHeader: 'fc-widget-header',
  6437. widgetContent: 'fc-widget-content',
  6438. buttonGroup: 'fc-button-group',
  6439. button: 'fc-button fc-button-primary',
  6440. buttonActive: 'fc-button-active',
  6441. popoverHeader: 'fc-widget-header',
  6442. popoverContent: 'fc-widget-content',
  6443. // day grid
  6444. headerRow: 'fc-widget-header',
  6445. dayRow: 'fc-widget-content',
  6446. // list view
  6447. listView: 'fc-widget-content'
  6448. };
  6449. StandardTheme.prototype.baseIconClass = 'fc-icon';
  6450. StandardTheme.prototype.iconClasses = {
  6451. close: 'fc-icon-x',
  6452. prev: 'fc-icon-chevron-left',
  6453. next: 'fc-icon-chevron-right',
  6454. prevYear: 'fc-icon-chevrons-left',
  6455. nextYear: 'fc-icon-chevrons-right'
  6456. };
  6457. StandardTheme.prototype.iconOverrideOption = 'buttonIcons';
  6458. StandardTheme.prototype.iconOverrideCustomButtonOption = 'icon';
  6459. StandardTheme.prototype.iconOverridePrefix = 'fc-icon-';
  6460. var Calendar = /** @class */ (function () {
  6461. function Calendar(el, overrides) {
  6462. var _this = this;
  6463. this.parseRawLocales = memoize(parseRawLocales);
  6464. this.buildLocale = memoize(buildLocale);
  6465. this.buildDateEnv = memoize(buildDateEnv);
  6466. this.buildTheme = memoize(buildTheme);
  6467. this.buildEventUiSingleBase = memoize(this._buildEventUiSingleBase);
  6468. this.buildSelectionConfig = memoize(this._buildSelectionConfig);
  6469. this.buildEventUiBySource = memoizeOutput(buildEventUiBySource, isPropsEqual);
  6470. this.buildEventUiBases = memoize(buildEventUiBases);
  6471. this.interactionsStore = {};
  6472. this.actionQueue = [];
  6473. this.isReducing = false;
  6474. // isDisplaying: boolean = false // installed in DOM? accepting renders?
  6475. this.needsRerender = false; // needs a render?
  6476. this.needsFullRerender = false;
  6477. this.isRendering = false; // currently in the executeRender function?
  6478. this.renderingPauseDepth = 0;
  6479. this.buildDelayedRerender = memoize(buildDelayedRerender);
  6480. this.afterSizingTriggers = {};
  6481. this.isViewUpdated = false;
  6482. this.isDatesUpdated = false;
  6483. this.isEventsUpdated = false;
  6484. this.el = el;
  6485. this.optionsManager = new OptionsManager(overrides || {});
  6486. this.pluginSystem = new PluginSystem();
  6487. // only do once. don't do in handleOptions. because can't remove plugins
  6488. this.addPluginInputs(this.optionsManager.computed.plugins || []);
  6489. this.handleOptions(this.optionsManager.computed);
  6490. this.publiclyTrigger('_init'); // for tests
  6491. this.hydrate();
  6492. this.calendarInteractions = this.pluginSystem.hooks.calendarInteractions
  6493. .map(function (calendarInteractionClass) {
  6494. return new calendarInteractionClass(_this);
  6495. });
  6496. }
  6497. Calendar.prototype.addPluginInputs = function (pluginInputs) {
  6498. var pluginDefs = refinePluginDefs(pluginInputs);
  6499. for (var _i = 0, pluginDefs_1 = pluginDefs; _i < pluginDefs_1.length; _i++) {
  6500. var pluginDef = pluginDefs_1[_i];
  6501. this.pluginSystem.add(pluginDef);
  6502. }
  6503. };
  6504. Object.defineProperty(Calendar.prototype, "view", {
  6505. // public API
  6506. get: function () {
  6507. return this.component ? this.component.view : null;
  6508. },
  6509. enumerable: true,
  6510. configurable: true
  6511. });
  6512. // Public API for rendering
  6513. // -----------------------------------------------------------------------------------------------------------------
  6514. Calendar.prototype.render = function () {
  6515. if (!this.component) {
  6516. this.renderableEventStore = createEmptyEventStore();
  6517. this.bindHandlers();
  6518. this.executeRender();
  6519. }
  6520. else {
  6521. this.requestRerender(true);
  6522. }
  6523. };
  6524. Calendar.prototype.destroy = function () {
  6525. if (this.component) {
  6526. this.unbindHandlers();
  6527. this.component.destroy(); // don't null-out. in case API needs access
  6528. this.component = null; // umm ???
  6529. for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
  6530. var interaction = _a[_i];
  6531. interaction.destroy();
  6532. }
  6533. this.publiclyTrigger('_destroyed');
  6534. }
  6535. };
  6536. // Handlers
  6537. // -----------------------------------------------------------------------------------------------------------------
  6538. Calendar.prototype.bindHandlers = function () {
  6539. var _this = this;
  6540. // event delegation for nav links
  6541. this.removeNavLinkListener = listenBySelector(this.el, 'click', 'a[data-goto]', function (ev, anchorEl) {
  6542. var gotoOptions = anchorEl.getAttribute('data-goto');
  6543. gotoOptions = gotoOptions ? JSON.parse(gotoOptions) : {};
  6544. var dateEnv = _this.dateEnv;
  6545. var dateMarker = dateEnv.createMarker(gotoOptions.date);
  6546. var viewType = gotoOptions.type;
  6547. // property like "navLinkDayClick". might be a string or a function
  6548. var customAction = _this.viewOpt('navLink' + capitaliseFirstLetter(viewType) + 'Click');
  6549. if (typeof customAction === 'function') {
  6550. customAction(dateEnv.toDate(dateMarker), ev);
  6551. }
  6552. else {
  6553. if (typeof customAction === 'string') {
  6554. viewType = customAction;
  6555. }
  6556. _this.zoomTo(dateMarker, viewType);
  6557. }
  6558. });
  6559. if (this.opt('handleWindowResize')) {
  6560. window.addEventListener('resize', this.windowResizeProxy = debounce(// prevents rapid calls
  6561. this.windowResize.bind(this), this.opt('windowResizeDelay')));
  6562. }
  6563. };
  6564. Calendar.prototype.unbindHandlers = function () {
  6565. this.removeNavLinkListener();
  6566. if (this.windowResizeProxy) {
  6567. window.removeEventListener('resize', this.windowResizeProxy);
  6568. this.windowResizeProxy = null;
  6569. }
  6570. };
  6571. // Dispatcher
  6572. // -----------------------------------------------------------------------------------------------------------------
  6573. Calendar.prototype.hydrate = function () {
  6574. var _this = this;
  6575. this.state = this.buildInitialState();
  6576. var rawSources = this.opt('eventSources') || [];
  6577. var singleRawSource = this.opt('events');
  6578. var sources = []; // parsed
  6579. if (singleRawSource) {
  6580. rawSources.unshift(singleRawSource);
  6581. }
  6582. for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
  6583. var rawSource = rawSources_1[_i];
  6584. var source = parseEventSource(rawSource, this);
  6585. if (source) {
  6586. sources.push(source);
  6587. }
  6588. }
  6589. this.batchRendering(function () {
  6590. _this.dispatch({ type: 'INIT' }); // pass in sources here?
  6591. _this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: sources });
  6592. _this.dispatch({
  6593. type: 'SET_VIEW_TYPE',
  6594. viewType: _this.opt('defaultView') || _this.pluginSystem.hooks.defaultView
  6595. });
  6596. });
  6597. };
  6598. Calendar.prototype.buildInitialState = function () {
  6599. return {
  6600. viewType: null,
  6601. loadingLevel: 0,
  6602. eventSourceLoadingLevel: 0,
  6603. currentDate: this.getInitialDate(),
  6604. dateProfile: null,
  6605. eventSources: {},
  6606. eventStore: createEmptyEventStore(),
  6607. dateSelection: null,
  6608. eventSelection: '',
  6609. eventDrag: null,
  6610. eventResize: null
  6611. };
  6612. };
  6613. Calendar.prototype.dispatch = function (action) {
  6614. this.actionQueue.push(action);
  6615. if (!this.isReducing) {
  6616. this.isReducing = true;
  6617. var oldState = this.state;
  6618. while (this.actionQueue.length) {
  6619. this.state = this.reduce(this.state, this.actionQueue.shift(), this);
  6620. }
  6621. var newState = this.state;
  6622. this.isReducing = false;
  6623. if (!oldState.loadingLevel && newState.loadingLevel) {
  6624. this.publiclyTrigger('loading', [true]);
  6625. }
  6626. else if (oldState.loadingLevel && !newState.loadingLevel) {
  6627. this.publiclyTrigger('loading', [false]);
  6628. }
  6629. var view = this.component && this.component.view;
  6630. if (oldState.eventStore !== newState.eventStore || this.needsFullRerender) {
  6631. if (oldState.eventStore) {
  6632. this.isEventsUpdated = true;
  6633. }
  6634. }
  6635. if (oldState.dateProfile !== newState.dateProfile || this.needsFullRerender) {
  6636. if (oldState.dateProfile && view) { // why would view be null!?
  6637. this.publiclyTrigger('datesDestroy', [
  6638. {
  6639. view: view,
  6640. el: view.el
  6641. }
  6642. ]);
  6643. }
  6644. this.isDatesUpdated = true;
  6645. }
  6646. if (oldState.viewType !== newState.viewType || this.needsFullRerender) {
  6647. if (oldState.viewType && view) { // why would view be null!?
  6648. this.publiclyTrigger('viewSkeletonDestroy', [
  6649. {
  6650. view: view,
  6651. el: view.el
  6652. }
  6653. ]);
  6654. }
  6655. this.isViewUpdated = true;
  6656. }
  6657. this.requestRerender();
  6658. }
  6659. };
  6660. Calendar.prototype.reduce = function (state, action, calendar) {
  6661. return reduce(state, action, calendar);
  6662. };
  6663. // Render Queue
  6664. // -----------------------------------------------------------------------------------------------------------------
  6665. Calendar.prototype.requestRerender = function (needsFull) {
  6666. if (needsFull === void 0) { needsFull = false; }
  6667. this.needsRerender = true;
  6668. this.needsFullRerender = this.needsFullRerender || needsFull;
  6669. this.delayedRerender(); // will call a debounced-version of tryRerender
  6670. };
  6671. Calendar.prototype.tryRerender = function () {
  6672. if (this.component && // must be accepting renders
  6673. this.needsRerender && // indicates that a rerender was requested
  6674. !this.renderingPauseDepth && // not paused
  6675. !this.isRendering // not currently in the render loop
  6676. ) {
  6677. this.executeRender();
  6678. }
  6679. };
  6680. Calendar.prototype.batchRendering = function (func) {
  6681. this.renderingPauseDepth++;
  6682. func();
  6683. this.renderingPauseDepth--;
  6684. if (this.needsRerender) {
  6685. this.requestRerender();
  6686. }
  6687. };
  6688. // Rendering
  6689. // -----------------------------------------------------------------------------------------------------------------
  6690. Calendar.prototype.executeRender = function () {
  6691. var needsFullRerender = this.needsFullRerender; // save before clearing
  6692. // clear these BEFORE the render so that new values will accumulate during render
  6693. this.needsRerender = false;
  6694. this.needsFullRerender = false;
  6695. this.isRendering = true;
  6696. this.renderComponent(needsFullRerender);
  6697. this.isRendering = false;
  6698. // received a rerender request while rendering
  6699. if (this.needsRerender) {
  6700. this.delayedRerender();
  6701. }
  6702. };
  6703. /*
  6704. don't call this directly. use executeRender instead
  6705. */
  6706. Calendar.prototype.renderComponent = function (needsFull) {
  6707. var _a = this, state = _a.state, component = _a.component;
  6708. var viewType = state.viewType;
  6709. var viewSpec = this.viewSpecs[viewType];
  6710. var savedScroll = (needsFull && component) ? component.view.queryScroll() : null;
  6711. if (!viewSpec) {
  6712. throw new Error("View type \"" + viewType + "\" is not valid");
  6713. }
  6714. // if event sources are still loading and progressive rendering hasn't been enabled,
  6715. // keep rendering the last fully loaded set of events
  6716. var renderableEventStore = this.renderableEventStore =
  6717. (state.eventSourceLoadingLevel && !this.opt('progressiveEventRendering')) ?
  6718. this.renderableEventStore :
  6719. state.eventStore;
  6720. var eventUiSingleBase = this.buildEventUiSingleBase(viewSpec.options);
  6721. var eventUiBySource = this.buildEventUiBySource(state.eventSources);
  6722. var eventUiBases = this.eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
  6723. if (needsFull || !component) {
  6724. if (component) {
  6725. component.freezeHeight(); // next component will unfreeze it
  6726. component.destroy();
  6727. }
  6728. component = this.component = new CalendarComponent({
  6729. calendar: this,
  6730. view: null,
  6731. dateEnv: this.dateEnv,
  6732. theme: this.theme,
  6733. options: this.optionsManager.computed
  6734. }, this.el);
  6735. this.isViewUpdated = true;
  6736. this.isDatesUpdated = true;
  6737. this.isEventsUpdated = true;
  6738. }
  6739. component.receiveProps(__assign({}, state, { viewSpec: viewSpec, dateProfile: state.dateProfile, dateProfileGenerator: this.dateProfileGenerators[viewType], eventStore: renderableEventStore, eventUiBases: eventUiBases, dateSelection: state.dateSelection, eventSelection: state.eventSelection, eventDrag: state.eventDrag, eventResize: state.eventResize }));
  6740. if (savedScroll) {
  6741. component.view.applyScroll(savedScroll, false);
  6742. }
  6743. if (this.isViewUpdated) {
  6744. this.isViewUpdated = false;
  6745. this.publiclyTrigger('viewSkeletonRender', [
  6746. {
  6747. view: component.view,
  6748. el: component.view.el
  6749. }
  6750. ]);
  6751. }
  6752. if (this.isDatesUpdated) {
  6753. this.isDatesUpdated = false;
  6754. this.publiclyTrigger('datesRender', [
  6755. {
  6756. view: component.view,
  6757. el: component.view.el
  6758. }
  6759. ]);
  6760. }
  6761. if (this.isEventsUpdated) {
  6762. this.isEventsUpdated = false;
  6763. }
  6764. this.releaseAfterSizingTriggers();
  6765. };
  6766. // Options
  6767. // -----------------------------------------------------------------------------------------------------------------
  6768. Calendar.prototype.setOption = function (name, val) {
  6769. var _a;
  6770. this.mutateOptions((_a = {}, _a[name] = val, _a), [], true);
  6771. };
  6772. Calendar.prototype.getOption = function (name) {
  6773. return this.optionsManager.computed[name];
  6774. };
  6775. Calendar.prototype.opt = function (name) {
  6776. return this.optionsManager.computed[name];
  6777. };
  6778. Calendar.prototype.viewOpt = function (name) {
  6779. return this.viewOpts()[name];
  6780. };
  6781. Calendar.prototype.viewOpts = function () {
  6782. return this.viewSpecs[this.state.viewType].options;
  6783. };
  6784. /*
  6785. handles option changes (like a diff)
  6786. */
  6787. Calendar.prototype.mutateOptions = function (updates, removals, isDynamic, deepEqual) {
  6788. var _this = this;
  6789. var changeHandlers = this.pluginSystem.hooks.optionChangeHandlers;
  6790. var normalUpdates = {};
  6791. var specialUpdates = {};
  6792. var oldDateEnv = this.dateEnv; // do this before handleOptions
  6793. var isTimeZoneDirty = false;
  6794. var isSizeDirty = false;
  6795. var anyDifficultOptions = Boolean(removals.length);
  6796. for (var name_1 in updates) {
  6797. if (changeHandlers[name_1]) {
  6798. specialUpdates[name_1] = updates[name_1];
  6799. }
  6800. else {
  6801. normalUpdates[name_1] = updates[name_1];
  6802. }
  6803. }
  6804. for (var name_2 in normalUpdates) {
  6805. if (/^(height|contentHeight|aspectRatio)$/.test(name_2)) {
  6806. isSizeDirty = true;
  6807. }
  6808. else if (/^(defaultDate|defaultView)$/.test(name_2)) ;
  6809. else {
  6810. anyDifficultOptions = true;
  6811. if (name_2 === 'timeZone') {
  6812. isTimeZoneDirty = true;
  6813. }
  6814. }
  6815. }
  6816. this.optionsManager.mutate(normalUpdates, removals, isDynamic);
  6817. if (anyDifficultOptions) {
  6818. this.handleOptions(this.optionsManager.computed);
  6819. this.needsFullRerender = true;
  6820. }
  6821. this.batchRendering(function () {
  6822. if (anyDifficultOptions) {
  6823. if (isTimeZoneDirty) {
  6824. _this.dispatch({
  6825. type: 'CHANGE_TIMEZONE',
  6826. oldDateEnv: oldDateEnv
  6827. });
  6828. }
  6829. /* HACK
  6830. has the same effect as calling this.requestRerender(true)
  6831. but recomputes the state's dateProfile
  6832. */
  6833. _this.dispatch({
  6834. type: 'SET_VIEW_TYPE',
  6835. viewType: _this.state.viewType
  6836. });
  6837. }
  6838. else if (isSizeDirty) {
  6839. _this.updateSize();
  6840. }
  6841. // special updates
  6842. if (deepEqual) {
  6843. for (var name_3 in specialUpdates) {
  6844. changeHandlers[name_3](specialUpdates[name_3], _this, deepEqual);
  6845. }
  6846. }
  6847. });
  6848. };
  6849. /*
  6850. rebuilds things based off of a complete set of refined options
  6851. */
  6852. Calendar.prototype.handleOptions = function (options) {
  6853. var _this = this;
  6854. var pluginHooks = this.pluginSystem.hooks;
  6855. this.defaultAllDayEventDuration = createDuration(options.defaultAllDayEventDuration);
  6856. this.defaultTimedEventDuration = createDuration(options.defaultTimedEventDuration);
  6857. this.delayedRerender = this.buildDelayedRerender(options.rerenderDelay);
  6858. this.theme = this.buildTheme(options);
  6859. var available = this.parseRawLocales(options.locales);
  6860. this.availableRawLocales = available.map;
  6861. var locale = this.buildLocale(options.locale || available.defaultCode, available.map);
  6862. this.dateEnv = this.buildDateEnv(locale, options.timeZone, pluginHooks.namedTimeZonedImpl, options.firstDay, options.weekNumberCalculation, options.weekLabel, pluginHooks.cmdFormatter);
  6863. this.selectionConfig = this.buildSelectionConfig(options); // needs dateEnv. do after :(
  6864. // ineffecient to do every time?
  6865. this.viewSpecs = buildViewSpecs(pluginHooks.views, this.optionsManager);
  6866. // ineffecient to do every time?
  6867. this.dateProfileGenerators = mapHash(this.viewSpecs, function (viewSpec) {
  6868. return new viewSpec.class.prototype.dateProfileGeneratorClass(viewSpec, _this);
  6869. });
  6870. };
  6871. Calendar.prototype.getAvailableLocaleCodes = function () {
  6872. return Object.keys(this.availableRawLocales);
  6873. };
  6874. Calendar.prototype._buildSelectionConfig = function (rawOpts) {
  6875. return processScopedUiProps('select', rawOpts, this);
  6876. };
  6877. Calendar.prototype._buildEventUiSingleBase = function (rawOpts) {
  6878. if (rawOpts.editable) { // so 'editable' affected events
  6879. rawOpts = __assign({}, rawOpts, { eventEditable: true });
  6880. }
  6881. return processScopedUiProps('event', rawOpts, this);
  6882. };
  6883. // Trigger
  6884. // -----------------------------------------------------------------------------------------------------------------
  6885. Calendar.prototype.hasPublicHandlers = function (name) {
  6886. return this.hasHandlers(name) ||
  6887. this.opt(name); // handler specified in options
  6888. };
  6889. Calendar.prototype.publiclyTrigger = function (name, args) {
  6890. var optHandler = this.opt(name);
  6891. this.triggerWith(name, this, args);
  6892. if (optHandler) {
  6893. return optHandler.apply(this, args);
  6894. }
  6895. };
  6896. Calendar.prototype.publiclyTriggerAfterSizing = function (name, args) {
  6897. var afterSizingTriggers = this.afterSizingTriggers;
  6898. (afterSizingTriggers[name] || (afterSizingTriggers[name] = [])).push(args);
  6899. };
  6900. Calendar.prototype.releaseAfterSizingTriggers = function () {
  6901. var afterSizingTriggers = this.afterSizingTriggers;
  6902. for (var name_4 in afterSizingTriggers) {
  6903. for (var _i = 0, _a = afterSizingTriggers[name_4]; _i < _a.length; _i++) {
  6904. var args = _a[_i];
  6905. this.publiclyTrigger(name_4, args);
  6906. }
  6907. }
  6908. this.afterSizingTriggers = {};
  6909. };
  6910. // View
  6911. // -----------------------------------------------------------------------------------------------------------------
  6912. // Returns a boolean about whether the view is okay to instantiate at some point
  6913. Calendar.prototype.isValidViewType = function (viewType) {
  6914. return Boolean(this.viewSpecs[viewType]);
  6915. };
  6916. Calendar.prototype.changeView = function (viewType, dateOrRange) {
  6917. var dateMarker = null;
  6918. if (dateOrRange) {
  6919. if (dateOrRange.start && dateOrRange.end) { // a range
  6920. this.optionsManager.mutate({ visibleRange: dateOrRange }, []); // will not rerender
  6921. this.handleOptions(this.optionsManager.computed); // ...but yuck
  6922. }
  6923. else { // a date
  6924. dateMarker = this.dateEnv.createMarker(dateOrRange); // just like gotoDate
  6925. }
  6926. }
  6927. this.unselect();
  6928. this.dispatch({
  6929. type: 'SET_VIEW_TYPE',
  6930. viewType: viewType,
  6931. dateMarker: dateMarker
  6932. });
  6933. };
  6934. // Forces navigation to a view for the given date.
  6935. // `viewType` can be a specific view name or a generic one like "week" or "day".
  6936. // needs to change
  6937. Calendar.prototype.zoomTo = function (dateMarker, viewType) {
  6938. var spec;
  6939. viewType = viewType || 'day'; // day is default zoom
  6940. spec = this.viewSpecs[viewType] ||
  6941. this.getUnitViewSpec(viewType);
  6942. this.unselect();
  6943. if (spec) {
  6944. this.dispatch({
  6945. type: 'SET_VIEW_TYPE',
  6946. viewType: spec.type,
  6947. dateMarker: dateMarker
  6948. });
  6949. }
  6950. else {
  6951. this.dispatch({
  6952. type: 'SET_DATE',
  6953. dateMarker: dateMarker
  6954. });
  6955. }
  6956. };
  6957. // Given a duration singular unit, like "week" or "day", finds a matching view spec.
  6958. // Preference is given to views that have corresponding buttons.
  6959. Calendar.prototype.getUnitViewSpec = function (unit) {
  6960. var component = this.component;
  6961. var viewTypes = [];
  6962. var i;
  6963. var spec;
  6964. // put views that have buttons first. there will be duplicates, but oh
  6965. if (component.header) {
  6966. viewTypes.push.apply(viewTypes, component.header.viewsWithButtons);
  6967. }
  6968. if (component.footer) {
  6969. viewTypes.push.apply(viewTypes, component.footer.viewsWithButtons);
  6970. }
  6971. for (var viewType in this.viewSpecs) {
  6972. viewTypes.push(viewType);
  6973. }
  6974. for (i = 0; i < viewTypes.length; i++) {
  6975. spec = this.viewSpecs[viewTypes[i]];
  6976. if (spec) {
  6977. if (spec.singleUnit === unit) {
  6978. return spec;
  6979. }
  6980. }
  6981. }
  6982. };
  6983. // Current Date
  6984. // -----------------------------------------------------------------------------------------------------------------
  6985. Calendar.prototype.getInitialDate = function () {
  6986. var defaultDateInput = this.opt('defaultDate');
  6987. // compute the initial ambig-timezone date
  6988. if (defaultDateInput != null) {
  6989. return this.dateEnv.createMarker(defaultDateInput);
  6990. }
  6991. else {
  6992. return this.getNow(); // getNow already returns unzoned
  6993. }
  6994. };
  6995. Calendar.prototype.prev = function () {
  6996. this.unselect();
  6997. this.dispatch({ type: 'PREV' });
  6998. };
  6999. Calendar.prototype.next = function () {
  7000. this.unselect();
  7001. this.dispatch({ type: 'NEXT' });
  7002. };
  7003. Calendar.prototype.prevYear = function () {
  7004. this.unselect();
  7005. this.dispatch({
  7006. type: 'SET_DATE',
  7007. dateMarker: this.dateEnv.addYears(this.state.currentDate, -1)
  7008. });
  7009. };
  7010. Calendar.prototype.nextYear = function () {
  7011. this.unselect();
  7012. this.dispatch({
  7013. type: 'SET_DATE',
  7014. dateMarker: this.dateEnv.addYears(this.state.currentDate, 1)
  7015. });
  7016. };
  7017. Calendar.prototype.today = function () {
  7018. this.unselect();
  7019. this.dispatch({
  7020. type: 'SET_DATE',
  7021. dateMarker: this.getNow()
  7022. });
  7023. };
  7024. Calendar.prototype.gotoDate = function (zonedDateInput) {
  7025. this.unselect();
  7026. this.dispatch({
  7027. type: 'SET_DATE',
  7028. dateMarker: this.dateEnv.createMarker(zonedDateInput)
  7029. });
  7030. };
  7031. Calendar.prototype.incrementDate = function (deltaInput) {
  7032. var delta = createDuration(deltaInput);
  7033. if (delta) { // else, warn about invalid input?
  7034. this.unselect();
  7035. this.dispatch({
  7036. type: 'SET_DATE',
  7037. dateMarker: this.dateEnv.add(this.state.currentDate, delta)
  7038. });
  7039. }
  7040. };
  7041. // for external API
  7042. Calendar.prototype.getDate = function () {
  7043. return this.dateEnv.toDate(this.state.currentDate);
  7044. };
  7045. // Date Formatting Utils
  7046. // -----------------------------------------------------------------------------------------------------------------
  7047. Calendar.prototype.formatDate = function (d, formatter) {
  7048. var dateEnv = this.dateEnv;
  7049. return dateEnv.format(dateEnv.createMarker(d), createFormatter(formatter));
  7050. };
  7051. // `settings` is for formatter AND isEndExclusive
  7052. Calendar.prototype.formatRange = function (d0, d1, settings) {
  7053. var dateEnv = this.dateEnv;
  7054. return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings, this.opt('defaultRangeSeparator')), settings);
  7055. };
  7056. Calendar.prototype.formatIso = function (d, omitTime) {
  7057. var dateEnv = this.dateEnv;
  7058. return dateEnv.formatIso(dateEnv.createMarker(d), { omitTime: omitTime });
  7059. };
  7060. // Sizing
  7061. // -----------------------------------------------------------------------------------------------------------------
  7062. Calendar.prototype.windowResize = function (ev) {
  7063. if (!this.isHandlingWindowResize &&
  7064. this.component && // why?
  7065. ev.target === window // not a jqui resize event
  7066. ) {
  7067. this.isHandlingWindowResize = true;
  7068. this.updateSize();
  7069. this.publiclyTrigger('windowResize', [this.view]);
  7070. this.isHandlingWindowResize = false;
  7071. }
  7072. };
  7073. Calendar.prototype.updateSize = function () {
  7074. if (this.component) { // when?
  7075. this.component.updateSize(true);
  7076. }
  7077. };
  7078. // Component Registration
  7079. // -----------------------------------------------------------------------------------------------------------------
  7080. Calendar.prototype.registerInteractiveComponent = function (component, settingsInput) {
  7081. var settings = parseInteractionSettings(component, settingsInput);
  7082. var DEFAULT_INTERACTIONS = [
  7083. EventClicking,
  7084. EventHovering
  7085. ];
  7086. var interactionClasses = DEFAULT_INTERACTIONS.concat(this.pluginSystem.hooks.componentInteractions);
  7087. var interactions = interactionClasses.map(function (interactionClass) {
  7088. return new interactionClass(settings);
  7089. });
  7090. this.interactionsStore[component.uid] = interactions;
  7091. interactionSettingsStore[component.uid] = settings;
  7092. };
  7093. Calendar.prototype.unregisterInteractiveComponent = function (component) {
  7094. for (var _i = 0, _a = this.interactionsStore[component.uid]; _i < _a.length; _i++) {
  7095. var listener = _a[_i];
  7096. listener.destroy();
  7097. }
  7098. delete this.interactionsStore[component.uid];
  7099. delete interactionSettingsStore[component.uid];
  7100. };
  7101. // Date Selection / Event Selection / DayClick
  7102. // -----------------------------------------------------------------------------------------------------------------
  7103. // this public method receives start/end dates in any format, with any timezone
  7104. // NOTE: args were changed from v3
  7105. Calendar.prototype.select = function (dateOrObj, endDate) {
  7106. var selectionInput;
  7107. if (endDate == null) {
  7108. if (dateOrObj.start != null) {
  7109. selectionInput = dateOrObj;
  7110. }
  7111. else {
  7112. selectionInput = {
  7113. start: dateOrObj,
  7114. end: null
  7115. };
  7116. }
  7117. }
  7118. else {
  7119. selectionInput = {
  7120. start: dateOrObj,
  7121. end: endDate
  7122. };
  7123. }
  7124. var selection = parseDateSpan(selectionInput, this.dateEnv, createDuration({ days: 1 }) // TODO: cache this?
  7125. );
  7126. if (selection) { // throw parse error otherwise?
  7127. this.dispatch({ type: 'SELECT_DATES', selection: selection });
  7128. this.triggerDateSelect(selection);
  7129. }
  7130. };
  7131. // public method
  7132. Calendar.prototype.unselect = function (pev) {
  7133. if (this.state.dateSelection) {
  7134. this.dispatch({ type: 'UNSELECT_DATES' });
  7135. this.triggerDateUnselect(pev);
  7136. }
  7137. };
  7138. Calendar.prototype.triggerDateSelect = function (selection, pev) {
  7139. var arg = __assign({}, this.buildDateSpanApi(selection), { jsEvent: pev ? pev.origEvent : null, view: this.view });
  7140. this.publiclyTrigger('select', [arg]);
  7141. };
  7142. Calendar.prototype.triggerDateUnselect = function (pev) {
  7143. this.publiclyTrigger('unselect', [
  7144. {
  7145. jsEvent: pev ? pev.origEvent : null,
  7146. view: this.view
  7147. }
  7148. ]);
  7149. };
  7150. // TODO: receive pev?
  7151. Calendar.prototype.triggerDateClick = function (dateSpan, dayEl, view, ev) {
  7152. var arg = __assign({}, this.buildDatePointApi(dateSpan), { dayEl: dayEl, jsEvent: ev, // Is this always a mouse event? See #4655
  7153. view: view });
  7154. this.publiclyTrigger('dateClick', [arg]);
  7155. };
  7156. Calendar.prototype.buildDatePointApi = function (dateSpan) {
  7157. var props = {};
  7158. for (var _i = 0, _a = this.pluginSystem.hooks.datePointTransforms; _i < _a.length; _i++) {
  7159. var transform = _a[_i];
  7160. __assign(props, transform(dateSpan, this));
  7161. }
  7162. __assign(props, buildDatePointApi(dateSpan, this.dateEnv));
  7163. return props;
  7164. };
  7165. Calendar.prototype.buildDateSpanApi = function (dateSpan) {
  7166. var props = {};
  7167. for (var _i = 0, _a = this.pluginSystem.hooks.dateSpanTransforms; _i < _a.length; _i++) {
  7168. var transform = _a[_i];
  7169. __assign(props, transform(dateSpan, this));
  7170. }
  7171. __assign(props, buildDateSpanApi(dateSpan, this.dateEnv));
  7172. return props;
  7173. };
  7174. // Date Utils
  7175. // -----------------------------------------------------------------------------------------------------------------
  7176. // Returns a DateMarker for the current date, as defined by the client's computer or from the `now` option
  7177. Calendar.prototype.getNow = function () {
  7178. var now = this.opt('now');
  7179. if (typeof now === 'function') {
  7180. now = now();
  7181. }
  7182. if (now == null) {
  7183. return this.dateEnv.createNowMarker();
  7184. }
  7185. return this.dateEnv.createMarker(now);
  7186. };
  7187. // Event-Date Utilities
  7188. // -----------------------------------------------------------------------------------------------------------------
  7189. // Given an event's allDay status and start date, return what its fallback end date should be.
  7190. // TODO: rename to computeDefaultEventEnd
  7191. Calendar.prototype.getDefaultEventEnd = function (allDay, marker) {
  7192. var end = marker;
  7193. if (allDay) {
  7194. end = startOfDay(end);
  7195. end = this.dateEnv.add(end, this.defaultAllDayEventDuration);
  7196. }
  7197. else {
  7198. end = this.dateEnv.add(end, this.defaultTimedEventDuration);
  7199. }
  7200. return end;
  7201. };
  7202. // Public Events API
  7203. // -----------------------------------------------------------------------------------------------------------------
  7204. Calendar.prototype.addEvent = function (eventInput, sourceInput) {
  7205. if (eventInput instanceof EventApi) {
  7206. var def = eventInput._def;
  7207. var instance = eventInput._instance;
  7208. // not already present? don't want to add an old snapshot
  7209. if (!this.state.eventStore.defs[def.defId]) {
  7210. this.dispatch({
  7211. type: 'ADD_EVENTS',
  7212. eventStore: eventTupleToStore({ def: def, instance: instance }) // TODO: better util for two args?
  7213. });
  7214. }
  7215. return eventInput;
  7216. }
  7217. var sourceId;
  7218. if (sourceInput instanceof EventSourceApi) {
  7219. sourceId = sourceInput.internalEventSource.sourceId;
  7220. }
  7221. else if (sourceInput != null) {
  7222. var sourceApi = this.getEventSourceById(sourceInput); // TODO: use an internal function
  7223. if (!sourceApi) {
  7224. console.warn('Could not find an event source with ID "' + sourceInput + '"'); // TODO: test
  7225. return null;
  7226. }
  7227. else {
  7228. sourceId = sourceApi.internalEventSource.sourceId;
  7229. }
  7230. }
  7231. var tuple = parseEvent(eventInput, sourceId, this);
  7232. if (tuple) {
  7233. this.dispatch({
  7234. type: 'ADD_EVENTS',
  7235. eventStore: eventTupleToStore(tuple)
  7236. });
  7237. return new EventApi(this, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
  7238. }
  7239. return null;
  7240. };
  7241. // TODO: optimize
  7242. Calendar.prototype.getEventById = function (id) {
  7243. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7244. id = String(id);
  7245. for (var defId in defs) {
  7246. var def = defs[defId];
  7247. if (def.publicId === id) {
  7248. if (def.recurringDef) {
  7249. return new EventApi(this, def, null);
  7250. }
  7251. else {
  7252. for (var instanceId in instances) {
  7253. var instance = instances[instanceId];
  7254. if (instance.defId === def.defId) {
  7255. return new EventApi(this, def, instance);
  7256. }
  7257. }
  7258. }
  7259. }
  7260. }
  7261. return null;
  7262. };
  7263. Calendar.prototype.getEvents = function () {
  7264. var _a = this.state.eventStore, defs = _a.defs, instances = _a.instances;
  7265. var eventApis = [];
  7266. for (var id in instances) {
  7267. var instance = instances[id];
  7268. var def = defs[instance.defId];
  7269. eventApis.push(new EventApi(this, def, instance));
  7270. }
  7271. return eventApis;
  7272. };
  7273. Calendar.prototype.removeAllEvents = function () {
  7274. this.dispatch({ type: 'REMOVE_ALL_EVENTS' });
  7275. };
  7276. Calendar.prototype.rerenderEvents = function () {
  7277. this.dispatch({ type: 'RESET_EVENTS' });
  7278. };
  7279. // Public Event Sources API
  7280. // -----------------------------------------------------------------------------------------------------------------
  7281. Calendar.prototype.getEventSources = function () {
  7282. var sourceHash = this.state.eventSources;
  7283. var sourceApis = [];
  7284. for (var internalId in sourceHash) {
  7285. sourceApis.push(new EventSourceApi(this, sourceHash[internalId]));
  7286. }
  7287. return sourceApis;
  7288. };
  7289. Calendar.prototype.getEventSourceById = function (id) {
  7290. var sourceHash = this.state.eventSources;
  7291. id = String(id);
  7292. for (var sourceId in sourceHash) {
  7293. if (sourceHash[sourceId].publicId === id) {
  7294. return new EventSourceApi(this, sourceHash[sourceId]);
  7295. }
  7296. }
  7297. return null;
  7298. };
  7299. Calendar.prototype.addEventSource = function (sourceInput) {
  7300. if (sourceInput instanceof EventSourceApi) {
  7301. // not already present? don't want to add an old snapshot
  7302. if (!this.state.eventSources[sourceInput.internalEventSource.sourceId]) {
  7303. this.dispatch({
  7304. type: 'ADD_EVENT_SOURCES',
  7305. sources: [sourceInput.internalEventSource]
  7306. });
  7307. }
  7308. return sourceInput;
  7309. }
  7310. var eventSource = parseEventSource(sourceInput, this);
  7311. if (eventSource) { // TODO: error otherwise?
  7312. this.dispatch({ type: 'ADD_EVENT_SOURCES', sources: [eventSource] });
  7313. return new EventSourceApi(this, eventSource);
  7314. }
  7315. return null;
  7316. };
  7317. Calendar.prototype.removeAllEventSources = function () {
  7318. this.dispatch({ type: 'REMOVE_ALL_EVENT_SOURCES' });
  7319. };
  7320. Calendar.prototype.refetchEvents = function () {
  7321. this.dispatch({ type: 'FETCH_EVENT_SOURCES' });
  7322. };
  7323. // Scroll
  7324. // -----------------------------------------------------------------------------------------------------------------
  7325. Calendar.prototype.scrollToTime = function (timeInput) {
  7326. var duration = createDuration(timeInput);
  7327. if (duration) {
  7328. this.component.view.scrollToDuration(duration);
  7329. }
  7330. };
  7331. return Calendar;
  7332. }());
  7333. EmitterMixin.mixInto(Calendar);
  7334. // for memoizers
  7335. // -----------------------------------------------------------------------------------------------------------------
  7336. function buildDateEnv(locale, timeZone, namedTimeZoneImpl, firstDay, weekNumberCalculation, weekLabel, cmdFormatter) {
  7337. return new DateEnv({
  7338. calendarSystem: 'gregory',
  7339. timeZone: timeZone,
  7340. namedTimeZoneImpl: namedTimeZoneImpl,
  7341. locale: locale,
  7342. weekNumberCalculation: weekNumberCalculation,
  7343. firstDay: firstDay,
  7344. weekLabel: weekLabel,
  7345. cmdFormatter: cmdFormatter
  7346. });
  7347. }
  7348. function buildTheme(calendarOptions) {
  7349. var themeClass = this.pluginSystem.hooks.themeClasses[calendarOptions.themeSystem] || StandardTheme;
  7350. return new themeClass(calendarOptions);
  7351. }
  7352. function buildDelayedRerender(wait) {
  7353. var func = this.tryRerender.bind(this);
  7354. if (wait != null) {
  7355. func = debounce(func, wait);
  7356. }
  7357. return func;
  7358. }
  7359. function buildEventUiBySource(eventSources) {
  7360. return mapHash(eventSources, function (eventSource) {
  7361. return eventSource.ui;
  7362. });
  7363. }
  7364. function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
  7365. var eventUiBases = { '': eventUiSingleBase };
  7366. for (var defId in eventDefs) {
  7367. var def = eventDefs[defId];
  7368. if (def.sourceId && eventUiBySource[def.sourceId]) {
  7369. eventUiBases[defId] = eventUiBySource[def.sourceId];
  7370. }
  7371. }
  7372. return eventUiBases;
  7373. }
  7374. var View = /** @class */ (function (_super) {
  7375. __extends(View, _super);
  7376. function View(context, viewSpec, dateProfileGenerator, parentEl) {
  7377. var _this = _super.call(this, context, createElement('div', { className: 'fc-view fc-' + viewSpec.type + '-view' }), true // isView (HACK)
  7378. ) || this;
  7379. _this.renderDatesMem = memoizeRendering(_this.renderDatesWrap, _this.unrenderDatesWrap);
  7380. _this.renderBusinessHoursMem = memoizeRendering(_this.renderBusinessHours, _this.unrenderBusinessHours, [_this.renderDatesMem]);
  7381. _this.renderDateSelectionMem = memoizeRendering(_this.renderDateSelectionWrap, _this.unrenderDateSelectionWrap, [_this.renderDatesMem]);
  7382. _this.renderEventsMem = memoizeRendering(_this.renderEvents, _this.unrenderEvents, [_this.renderDatesMem]);
  7383. _this.renderEventSelectionMem = memoizeRendering(_this.renderEventSelectionWrap, _this.unrenderEventSelectionWrap, [_this.renderEventsMem]);
  7384. _this.renderEventDragMem = memoizeRendering(_this.renderEventDragWrap, _this.unrenderEventDragWrap, [_this.renderDatesMem]);
  7385. _this.renderEventResizeMem = memoizeRendering(_this.renderEventResizeWrap, _this.unrenderEventResizeWrap, [_this.renderDatesMem]);
  7386. _this.viewSpec = viewSpec;
  7387. _this.dateProfileGenerator = dateProfileGenerator;
  7388. _this.type = viewSpec.type;
  7389. _this.eventOrderSpecs = parseFieldSpecs(_this.opt('eventOrder'));
  7390. _this.nextDayThreshold = createDuration(_this.opt('nextDayThreshold'));
  7391. parentEl.appendChild(_this.el);
  7392. _this.initialize();
  7393. return _this;
  7394. }
  7395. View.prototype.initialize = function () {
  7396. };
  7397. Object.defineProperty(View.prototype, "activeStart", {
  7398. // Date Setting/Unsetting
  7399. // -----------------------------------------------------------------------------------------------------------------
  7400. get: function () {
  7401. return this.dateEnv.toDate(this.props.dateProfile.activeRange.start);
  7402. },
  7403. enumerable: true,
  7404. configurable: true
  7405. });
  7406. Object.defineProperty(View.prototype, "activeEnd", {
  7407. get: function () {
  7408. return this.dateEnv.toDate(this.props.dateProfile.activeRange.end);
  7409. },
  7410. enumerable: true,
  7411. configurable: true
  7412. });
  7413. Object.defineProperty(View.prototype, "currentStart", {
  7414. get: function () {
  7415. return this.dateEnv.toDate(this.props.dateProfile.currentRange.start);
  7416. },
  7417. enumerable: true,
  7418. configurable: true
  7419. });
  7420. Object.defineProperty(View.prototype, "currentEnd", {
  7421. get: function () {
  7422. return this.dateEnv.toDate(this.props.dateProfile.currentRange.end);
  7423. },
  7424. enumerable: true,
  7425. configurable: true
  7426. });
  7427. // General Rendering
  7428. // -----------------------------------------------------------------------------------------------------------------
  7429. View.prototype.render = function (props) {
  7430. this.renderDatesMem(props.dateProfile);
  7431. this.renderBusinessHoursMem(props.businessHours);
  7432. this.renderDateSelectionMem(props.dateSelection);
  7433. this.renderEventsMem(props.eventStore);
  7434. this.renderEventSelectionMem(props.eventSelection);
  7435. this.renderEventDragMem(props.eventDrag);
  7436. this.renderEventResizeMem(props.eventResize);
  7437. };
  7438. View.prototype.destroy = function () {
  7439. _super.prototype.destroy.call(this);
  7440. this.renderDatesMem.unrender(); // should unrender everything else
  7441. };
  7442. // Sizing
  7443. // -----------------------------------------------------------------------------------------------------------------
  7444. View.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  7445. var calendar = this.calendar;
  7446. if (isResize || // HACKS...
  7447. calendar.isViewUpdated ||
  7448. calendar.isDatesUpdated ||
  7449. calendar.isEventsUpdated) {
  7450. // sort of the catch-all sizing
  7451. // anything that might cause dimension changes
  7452. this.updateBaseSize(isResize, viewHeight, isAuto);
  7453. }
  7454. };
  7455. View.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  7456. };
  7457. // Date Rendering
  7458. // -----------------------------------------------------------------------------------------------------------------
  7459. View.prototype.renderDatesWrap = function (dateProfile) {
  7460. this.renderDates(dateProfile);
  7461. this.addScroll({
  7462. duration: createDuration(this.opt('scrollTime'))
  7463. });
  7464. this.startNowIndicator(dateProfile); // shouldn't render yet because updateSize will be called soon
  7465. };
  7466. View.prototype.unrenderDatesWrap = function () {
  7467. this.stopNowIndicator();
  7468. this.unrenderDates();
  7469. };
  7470. View.prototype.renderDates = function (dateProfile) { };
  7471. View.prototype.unrenderDates = function () { };
  7472. // Business Hours
  7473. // -----------------------------------------------------------------------------------------------------------------
  7474. View.prototype.renderBusinessHours = function (businessHours) { };
  7475. View.prototype.unrenderBusinessHours = function () { };
  7476. // Date Selection
  7477. // -----------------------------------------------------------------------------------------------------------------
  7478. View.prototype.renderDateSelectionWrap = function (selection) {
  7479. if (selection) {
  7480. this.renderDateSelection(selection);
  7481. }
  7482. };
  7483. View.prototype.unrenderDateSelectionWrap = function (selection) {
  7484. if (selection) {
  7485. this.unrenderDateSelection(selection);
  7486. }
  7487. };
  7488. View.prototype.renderDateSelection = function (selection) { };
  7489. View.prototype.unrenderDateSelection = function (selection) { };
  7490. // Event Rendering
  7491. // -----------------------------------------------------------------------------------------------------------------
  7492. View.prototype.renderEvents = function (eventStore) { };
  7493. View.prototype.unrenderEvents = function () { };
  7494. // util for subclasses
  7495. View.prototype.sliceEvents = function (eventStore, allDay) {
  7496. var props = this.props;
  7497. return sliceEventStore(eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? this.nextDayThreshold : null).fg;
  7498. };
  7499. View.prototype.computeEventDraggable = function (eventDef, eventUi) {
  7500. var transformers = this.calendar.pluginSystem.hooks.isDraggableTransformers;
  7501. var val = eventUi.startEditable;
  7502. for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
  7503. var transformer = transformers_1[_i];
  7504. val = transformer(val, eventDef, eventUi, this);
  7505. }
  7506. return val;
  7507. };
  7508. View.prototype.computeEventStartResizable = function (eventDef, eventUi) {
  7509. return eventUi.durationEditable && this.opt('eventResizableFromStart');
  7510. };
  7511. View.prototype.computeEventEndResizable = function (eventDef, eventUi) {
  7512. return eventUi.durationEditable;
  7513. };
  7514. // Event Selection
  7515. // -----------------------------------------------------------------------------------------------------------------
  7516. View.prototype.renderEventSelectionWrap = function (instanceId) {
  7517. if (instanceId) {
  7518. this.renderEventSelection(instanceId);
  7519. }
  7520. };
  7521. View.prototype.unrenderEventSelectionWrap = function (instanceId) {
  7522. if (instanceId) {
  7523. this.unrenderEventSelection(instanceId);
  7524. }
  7525. };
  7526. View.prototype.renderEventSelection = function (instanceId) { };
  7527. View.prototype.unrenderEventSelection = function (instanceId) { };
  7528. // Event Drag
  7529. // -----------------------------------------------------------------------------------------------------------------
  7530. View.prototype.renderEventDragWrap = function (state) {
  7531. if (state) {
  7532. this.renderEventDrag(state);
  7533. }
  7534. };
  7535. View.prototype.unrenderEventDragWrap = function (state) {
  7536. if (state) {
  7537. this.unrenderEventDrag(state);
  7538. }
  7539. };
  7540. View.prototype.renderEventDrag = function (state) { };
  7541. View.prototype.unrenderEventDrag = function (state) { };
  7542. // Event Resize
  7543. // -----------------------------------------------------------------------------------------------------------------
  7544. View.prototype.renderEventResizeWrap = function (state) {
  7545. if (state) {
  7546. this.renderEventResize(state);
  7547. }
  7548. };
  7549. View.prototype.unrenderEventResizeWrap = function (state) {
  7550. if (state) {
  7551. this.unrenderEventResize(state);
  7552. }
  7553. };
  7554. View.prototype.renderEventResize = function (state) { };
  7555. View.prototype.unrenderEventResize = function (state) { };
  7556. /* Now Indicator
  7557. ------------------------------------------------------------------------------------------------------------------*/
  7558. // Immediately render the current time indicator and begins re-rendering it at an interval,
  7559. // which is defined by this.getNowIndicatorUnit().
  7560. // TODO: somehow do this for the current whole day's background too
  7561. View.prototype.startNowIndicator = function (dateProfile) {
  7562. var _this = this;
  7563. var dateEnv = this.dateEnv;
  7564. var unit;
  7565. var update;
  7566. var delay; // ms wait value
  7567. if (this.opt('nowIndicator')) {
  7568. unit = this.getNowIndicatorUnit(dateProfile);
  7569. if (unit) {
  7570. update = this.updateNowIndicator.bind(this);
  7571. this.initialNowDate = this.calendar.getNow();
  7572. this.initialNowQueriedMs = new Date().valueOf();
  7573. // wait until the beginning of the next interval
  7574. delay = dateEnv.add(dateEnv.startOf(this.initialNowDate, unit), createDuration(1, unit)).valueOf() - this.initialNowDate.valueOf();
  7575. // TODO: maybe always use setTimeout, waiting until start of next unit
  7576. this.nowIndicatorTimeoutID = setTimeout(function () {
  7577. _this.nowIndicatorTimeoutID = null;
  7578. update();
  7579. if (unit === 'second') {
  7580. delay = 1000; // every second
  7581. }
  7582. else {
  7583. delay = 1000 * 60; // otherwise, every minute
  7584. }
  7585. _this.nowIndicatorIntervalID = setInterval(update, delay); // update every interval
  7586. }, delay);
  7587. }
  7588. // rendering will be initiated in updateSize
  7589. }
  7590. };
  7591. // rerenders the now indicator, computing the new current time from the amount of time that has passed
  7592. // since the initial getNow call.
  7593. View.prototype.updateNowIndicator = function () {
  7594. if (this.props.dateProfile && // a way to determine if dates were rendered yet
  7595. this.initialNowDate // activated before?
  7596. ) {
  7597. this.unrenderNowIndicator(); // won't unrender if unnecessary
  7598. this.renderNowIndicator(addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs));
  7599. this.isNowIndicatorRendered = true;
  7600. }
  7601. };
  7602. // Immediately unrenders the view's current time indicator and stops any re-rendering timers.
  7603. // Won't cause side effects if indicator isn't rendered.
  7604. View.prototype.stopNowIndicator = function () {
  7605. if (this.isNowIndicatorRendered) {
  7606. if (this.nowIndicatorTimeoutID) {
  7607. clearTimeout(this.nowIndicatorTimeoutID);
  7608. this.nowIndicatorTimeoutID = null;
  7609. }
  7610. if (this.nowIndicatorIntervalID) {
  7611. clearInterval(this.nowIndicatorIntervalID);
  7612. this.nowIndicatorIntervalID = null;
  7613. }
  7614. this.unrenderNowIndicator();
  7615. this.isNowIndicatorRendered = false;
  7616. }
  7617. };
  7618. View.prototype.getNowIndicatorUnit = function (dateProfile) {
  7619. // subclasses should implement
  7620. };
  7621. // Renders a current time indicator at the given datetime
  7622. View.prototype.renderNowIndicator = function (date) {
  7623. // SUBCLASSES MUST PASS TO CHILDREN!
  7624. };
  7625. // Undoes the rendering actions from renderNowIndicator
  7626. View.prototype.unrenderNowIndicator = function () {
  7627. // SUBCLASSES MUST PASS TO CHILDREN!
  7628. };
  7629. /* Scroller
  7630. ------------------------------------------------------------------------------------------------------------------*/
  7631. View.prototype.addScroll = function (scroll) {
  7632. var queuedScroll = this.queuedScroll || (this.queuedScroll = {});
  7633. __assign(queuedScroll, scroll);
  7634. };
  7635. View.prototype.popScroll = function (isResize) {
  7636. this.applyQueuedScroll(isResize);
  7637. this.queuedScroll = null;
  7638. };
  7639. View.prototype.applyQueuedScroll = function (isResize) {
  7640. this.applyScroll(this.queuedScroll || {}, isResize);
  7641. };
  7642. View.prototype.queryScroll = function () {
  7643. var scroll = {};
  7644. if (this.props.dateProfile) { // dates rendered yet?
  7645. __assign(scroll, this.queryDateScroll());
  7646. }
  7647. return scroll;
  7648. };
  7649. View.prototype.applyScroll = function (scroll, isResize) {
  7650. var duration = scroll.duration;
  7651. if (duration != null) {
  7652. delete scroll.duration;
  7653. if (this.props.dateProfile) { // dates rendered yet?
  7654. __assign(scroll, this.computeDateScroll(duration));
  7655. }
  7656. }
  7657. if (this.props.dateProfile) { // dates rendered yet?
  7658. this.applyDateScroll(scroll);
  7659. }
  7660. };
  7661. View.prototype.computeDateScroll = function (duration) {
  7662. return {}; // subclasses must implement
  7663. };
  7664. View.prototype.queryDateScroll = function () {
  7665. return {}; // subclasses must implement
  7666. };
  7667. View.prototype.applyDateScroll = function (scroll) {
  7668. // subclasses must implement
  7669. };
  7670. // for API
  7671. View.prototype.scrollToDuration = function (duration) {
  7672. this.applyScroll({ duration: duration }, false);
  7673. };
  7674. return View;
  7675. }(DateComponent));
  7676. EmitterMixin.mixInto(View);
  7677. View.prototype.usesMinMaxTime = false;
  7678. View.prototype.dateProfileGeneratorClass = DateProfileGenerator;
  7679. var FgEventRenderer = /** @class */ (function () {
  7680. function FgEventRenderer(context) {
  7681. this.segs = [];
  7682. this.isSizeDirty = false;
  7683. this.context = context;
  7684. }
  7685. FgEventRenderer.prototype.renderSegs = function (segs, mirrorInfo) {
  7686. this.rangeUpdated(); // called too frequently :(
  7687. // render an `.el` on each seg
  7688. // returns a subset of the segs. segs that were actually rendered
  7689. segs = this.renderSegEls(segs, mirrorInfo);
  7690. this.segs = segs;
  7691. this.attachSegs(segs, mirrorInfo);
  7692. this.isSizeDirty = true;
  7693. this.context.view.triggerRenderedSegs(this.segs, Boolean(mirrorInfo));
  7694. };
  7695. FgEventRenderer.prototype.unrender = function (_segs, mirrorInfo) {
  7696. this.context.view.triggerWillRemoveSegs(this.segs, Boolean(mirrorInfo));
  7697. this.detachSegs(this.segs);
  7698. this.segs = [];
  7699. };
  7700. // Updates values that rely on options and also relate to range
  7701. FgEventRenderer.prototype.rangeUpdated = function () {
  7702. var options = this.context.options;
  7703. var displayEventTime;
  7704. var displayEventEnd;
  7705. this.eventTimeFormat = createFormatter(options.eventTimeFormat || this.computeEventTimeFormat(), options.defaultRangeSeparator);
  7706. displayEventTime = options.displayEventTime;
  7707. if (displayEventTime == null) {
  7708. displayEventTime = this.computeDisplayEventTime(); // might be based off of range
  7709. }
  7710. displayEventEnd = options.displayEventEnd;
  7711. if (displayEventEnd == null) {
  7712. displayEventEnd = this.computeDisplayEventEnd(); // might be based off of range
  7713. }
  7714. this.displayEventTime = displayEventTime;
  7715. this.displayEventEnd = displayEventEnd;
  7716. };
  7717. // Renders and assigns an `el` property for each foreground event segment.
  7718. // Only returns segments that successfully rendered.
  7719. FgEventRenderer.prototype.renderSegEls = function (segs, mirrorInfo) {
  7720. var html = '';
  7721. var i;
  7722. if (segs.length) { // don't cloud an empty html string
  7723. // cloud a large concatenation of event segment HTML
  7724. for (i = 0; i < segs.length; i++) {
  7725. html += this.renderSegHtml(segs[i], mirrorInfo);
  7726. }
  7727. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7728. // Then, compute the 'el' for each segment. An el might be null if the eventRender callback returned false.
  7729. htmlToElements(html).forEach(function (el, i) {
  7730. var seg = segs[i];
  7731. if (el) {
  7732. seg.el = el;
  7733. }
  7734. });
  7735. segs = filterSegsViaEls(this.context.view, segs, Boolean(mirrorInfo));
  7736. }
  7737. return segs;
  7738. };
  7739. // Generic utility for generating the HTML classNames for an event segment's element
  7740. FgEventRenderer.prototype.getSegClasses = function (seg, isDraggable, isResizable, mirrorInfo) {
  7741. var classes = [
  7742. 'fc-event',
  7743. seg.isStart ? 'fc-start' : 'fc-not-start',
  7744. seg.isEnd ? 'fc-end' : 'fc-not-end'
  7745. ].concat(seg.eventRange.ui.classNames);
  7746. if (isDraggable) {
  7747. classes.push('fc-draggable');
  7748. }
  7749. if (isResizable) {
  7750. classes.push('fc-resizable');
  7751. }
  7752. if (mirrorInfo) {
  7753. classes.push('fc-mirror');
  7754. if (mirrorInfo.isDragging) {
  7755. classes.push('fc-dragging');
  7756. }
  7757. if (mirrorInfo.isResizing) {
  7758. classes.push('fc-resizing');
  7759. }
  7760. }
  7761. return classes;
  7762. };
  7763. // Compute the text that should be displayed on an event's element.
  7764. // `range` can be the Event object itself, or something range-like, with at least a `start`.
  7765. // If event times are disabled, or the event has no time, will return a blank string.
  7766. // If not specified, formatter will default to the eventTimeFormat setting,
  7767. // and displayEnd will default to the displayEventEnd setting.
  7768. FgEventRenderer.prototype.getTimeText = function (eventRange, formatter, displayEnd) {
  7769. var def = eventRange.def, instance = eventRange.instance;
  7770. return this._getTimeText(instance.range.start, def.hasEnd ? instance.range.end : null, def.allDay, formatter, displayEnd, instance.forcedStartTzo, instance.forcedEndTzo);
  7771. };
  7772. FgEventRenderer.prototype._getTimeText = function (start, end, allDay, formatter, displayEnd, forcedStartTzo, forcedEndTzo) {
  7773. var dateEnv = this.context.dateEnv;
  7774. if (formatter == null) {
  7775. formatter = this.eventTimeFormat;
  7776. }
  7777. if (displayEnd == null) {
  7778. displayEnd = this.displayEventEnd;
  7779. }
  7780. if (this.displayEventTime && !allDay) {
  7781. if (displayEnd && end) {
  7782. return dateEnv.formatRange(start, end, formatter, {
  7783. forcedStartTzo: forcedStartTzo,
  7784. forcedEndTzo: forcedEndTzo
  7785. });
  7786. }
  7787. else {
  7788. return dateEnv.format(start, formatter, {
  7789. forcedTzo: forcedStartTzo
  7790. });
  7791. }
  7792. }
  7793. return '';
  7794. };
  7795. FgEventRenderer.prototype.computeEventTimeFormat = function () {
  7796. return {
  7797. hour: 'numeric',
  7798. minute: '2-digit',
  7799. omitZeroMinute: true
  7800. };
  7801. };
  7802. FgEventRenderer.prototype.computeDisplayEventTime = function () {
  7803. return true;
  7804. };
  7805. FgEventRenderer.prototype.computeDisplayEventEnd = function () {
  7806. return true;
  7807. };
  7808. // Utility for generating event skin-related CSS properties
  7809. FgEventRenderer.prototype.getSkinCss = function (ui) {
  7810. return {
  7811. 'background-color': ui.backgroundColor,
  7812. 'border-color': ui.borderColor,
  7813. color: ui.textColor
  7814. };
  7815. };
  7816. FgEventRenderer.prototype.sortEventSegs = function (segs) {
  7817. var specs = this.context.view.eventOrderSpecs;
  7818. var objs = segs.map(buildSegCompareObj);
  7819. objs.sort(function (obj0, obj1) {
  7820. return compareByFieldSpecs(obj0, obj1, specs);
  7821. });
  7822. return objs.map(function (c) {
  7823. return c._seg;
  7824. });
  7825. };
  7826. FgEventRenderer.prototype.computeSizes = function (force) {
  7827. if (force || this.isSizeDirty) {
  7828. this.computeSegSizes(this.segs);
  7829. }
  7830. };
  7831. FgEventRenderer.prototype.assignSizes = function (force) {
  7832. if (force || this.isSizeDirty) {
  7833. this.assignSegSizes(this.segs);
  7834. this.isSizeDirty = false;
  7835. }
  7836. };
  7837. FgEventRenderer.prototype.computeSegSizes = function (segs) {
  7838. };
  7839. FgEventRenderer.prototype.assignSegSizes = function (segs) {
  7840. };
  7841. // Manipulation on rendered segs
  7842. FgEventRenderer.prototype.hideByHash = function (hash) {
  7843. if (hash) {
  7844. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7845. var seg = _a[_i];
  7846. if (hash[seg.eventRange.instance.instanceId]) {
  7847. seg.el.style.visibility = 'hidden';
  7848. }
  7849. }
  7850. }
  7851. };
  7852. FgEventRenderer.prototype.showByHash = function (hash) {
  7853. if (hash) {
  7854. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7855. var seg = _a[_i];
  7856. if (hash[seg.eventRange.instance.instanceId]) {
  7857. seg.el.style.visibility = '';
  7858. }
  7859. }
  7860. }
  7861. };
  7862. FgEventRenderer.prototype.selectByInstanceId = function (instanceId) {
  7863. if (instanceId) {
  7864. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7865. var seg = _a[_i];
  7866. var eventInstance = seg.eventRange.instance;
  7867. if (eventInstance && eventInstance.instanceId === instanceId &&
  7868. seg.el // necessary?
  7869. ) {
  7870. seg.el.classList.add('fc-selected');
  7871. }
  7872. }
  7873. }
  7874. };
  7875. FgEventRenderer.prototype.unselectByInstanceId = function (instanceId) {
  7876. if (instanceId) {
  7877. for (var _i = 0, _a = this.segs; _i < _a.length; _i++) {
  7878. var seg = _a[_i];
  7879. if (seg.el) { // necessary?
  7880. seg.el.classList.remove('fc-selected');
  7881. }
  7882. }
  7883. }
  7884. };
  7885. return FgEventRenderer;
  7886. }());
  7887. // returns a object with all primitive props that can be compared
  7888. function buildSegCompareObj(seg) {
  7889. var eventDef = seg.eventRange.def;
  7890. var range = seg.eventRange.instance.range;
  7891. var start = range.start ? range.start.valueOf() : 0; // TODO: better support for open-range events
  7892. var end = range.end ? range.end.valueOf() : 0; // "
  7893. return __assign({}, eventDef.extendedProps, eventDef, { id: eventDef.publicId, start: start,
  7894. end: end, duration: end - start, allDay: Number(eventDef.allDay), _seg: seg // for later retrieval
  7895. });
  7896. }
  7897. var FillRenderer = /** @class */ (function () {
  7898. function FillRenderer(context) {
  7899. this.fillSegTag = 'div';
  7900. this.dirtySizeFlags = {};
  7901. this.context = context;
  7902. this.containerElsByType = {};
  7903. this.segsByType = {};
  7904. }
  7905. FillRenderer.prototype.getSegsByType = function (type) {
  7906. return this.segsByType[type] || [];
  7907. };
  7908. FillRenderer.prototype.renderSegs = function (type, segs) {
  7909. var _a;
  7910. var renderedSegs = this.renderSegEls(type, segs); // assignes `.el` to each seg. returns successfully rendered segs
  7911. var containerEls = this.attachSegs(type, renderedSegs);
  7912. if (containerEls) {
  7913. (_a = (this.containerElsByType[type] || (this.containerElsByType[type] = []))).push.apply(_a, containerEls);
  7914. }
  7915. this.segsByType[type] = renderedSegs;
  7916. if (type === 'bgEvent') {
  7917. this.context.view.triggerRenderedSegs(renderedSegs, false); // isMirror=false
  7918. }
  7919. this.dirtySizeFlags[type] = true;
  7920. };
  7921. // Unrenders a specific type of fill that is currently rendered on the grid
  7922. FillRenderer.prototype.unrender = function (type) {
  7923. var segs = this.segsByType[type];
  7924. if (segs) {
  7925. if (type === 'bgEvent') {
  7926. this.context.view.triggerWillRemoveSegs(segs, false); // isMirror=false
  7927. }
  7928. this.detachSegs(type, segs);
  7929. }
  7930. };
  7931. // Renders and assigns an `el` property for each fill segment. Generic enough to work with different types.
  7932. // Only returns segments that successfully rendered.
  7933. FillRenderer.prototype.renderSegEls = function (type, segs) {
  7934. var _this = this;
  7935. var html = '';
  7936. var i;
  7937. if (segs.length) {
  7938. // cloud a large concatenation of segment HTML
  7939. for (i = 0; i < segs.length; i++) {
  7940. html += this.renderSegHtml(type, segs[i]);
  7941. }
  7942. // Grab individual elements from the combined HTML string. Use each as the default rendering.
  7943. // Then, compute the 'el' for each segment.
  7944. htmlToElements(html).forEach(function (el, i) {
  7945. var seg = segs[i];
  7946. if (el) {
  7947. seg.el = el;
  7948. }
  7949. });
  7950. if (type === 'bgEvent') {
  7951. segs = filterSegsViaEls(this.context.view, segs, false // isMirror. background events can never be mirror elements
  7952. );
  7953. }
  7954. // correct element type? (would be bad if a non-TD were inserted into a table for example)
  7955. segs = segs.filter(function (seg) {
  7956. return elementMatches(seg.el, _this.fillSegTag);
  7957. });
  7958. }
  7959. return segs;
  7960. };
  7961. // Builds the HTML needed for one fill segment. Generic enough to work with different types.
  7962. FillRenderer.prototype.renderSegHtml = function (type, seg) {
  7963. var css = null;
  7964. var classNames = [];
  7965. if (type !== 'highlight' && type !== 'businessHours') {
  7966. css = {
  7967. 'background-color': seg.eventRange.ui.backgroundColor
  7968. };
  7969. }
  7970. if (type !== 'highlight') {
  7971. classNames = classNames.concat(seg.eventRange.ui.classNames);
  7972. }
  7973. if (type === 'businessHours') {
  7974. classNames.push('fc-bgevent');
  7975. }
  7976. else {
  7977. classNames.push('fc-' + type.toLowerCase());
  7978. }
  7979. return '<' + this.fillSegTag +
  7980. (classNames.length ? ' class="' + classNames.join(' ') + '"' : '') +
  7981. (css ? ' style="' + cssToStr(css) + '"' : '') +
  7982. '></' + this.fillSegTag + '>';
  7983. };
  7984. FillRenderer.prototype.detachSegs = function (type, segs) {
  7985. var containerEls = this.containerElsByType[type];
  7986. if (containerEls) {
  7987. containerEls.forEach(removeElement);
  7988. delete this.containerElsByType[type];
  7989. }
  7990. };
  7991. FillRenderer.prototype.computeSizes = function (force) {
  7992. for (var type in this.segsByType) {
  7993. if (force || this.dirtySizeFlags[type]) {
  7994. this.computeSegSizes(this.segsByType[type]);
  7995. }
  7996. }
  7997. };
  7998. FillRenderer.prototype.assignSizes = function (force) {
  7999. for (var type in this.segsByType) {
  8000. if (force || this.dirtySizeFlags[type]) {
  8001. this.assignSegSizes(this.segsByType[type]);
  8002. }
  8003. }
  8004. this.dirtySizeFlags = {};
  8005. };
  8006. FillRenderer.prototype.computeSegSizes = function (segs) {
  8007. };
  8008. FillRenderer.prototype.assignSegSizes = function (segs) {
  8009. };
  8010. return FillRenderer;
  8011. }());
  8012. var NamedTimeZoneImpl = /** @class */ (function () {
  8013. function NamedTimeZoneImpl(timeZoneName) {
  8014. this.timeZoneName = timeZoneName;
  8015. }
  8016. return NamedTimeZoneImpl;
  8017. }());
  8018. /*
  8019. An abstraction for a dragging interaction originating on an event.
  8020. Does higher-level things than PointerDragger, such as possibly:
  8021. - a "mirror" that moves with the pointer
  8022. - a minimum number of pixels or other criteria for a true drag to begin
  8023. subclasses must emit:
  8024. - pointerdown
  8025. - dragstart
  8026. - dragmove
  8027. - pointerup
  8028. - dragend
  8029. */
  8030. var ElementDragging = /** @class */ (function () {
  8031. function ElementDragging(el) {
  8032. this.emitter = new EmitterMixin();
  8033. }
  8034. ElementDragging.prototype.destroy = function () {
  8035. };
  8036. ElementDragging.prototype.setMirrorIsVisible = function (bool) {
  8037. // optional if subclass doesn't want to support a mirror
  8038. };
  8039. ElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  8040. // optional if subclass doesn't want to support a mirror
  8041. };
  8042. ElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  8043. // optional
  8044. };
  8045. return ElementDragging;
  8046. }());
  8047. function formatDate(dateInput, settings) {
  8048. if (settings === void 0) { settings = {}; }
  8049. var dateEnv = buildDateEnv$1(settings);
  8050. var formatter = createFormatter(settings);
  8051. var dateMeta = dateEnv.createMarkerMeta(dateInput);
  8052. if (!dateMeta) { // TODO: warning?
  8053. return '';
  8054. }
  8055. return dateEnv.format(dateMeta.marker, formatter, {
  8056. forcedTzo: dateMeta.forcedTzo
  8057. });
  8058. }
  8059. function formatRange(startInput, endInput, settings // mixture of env and formatter settings
  8060. ) {
  8061. var dateEnv = buildDateEnv$1(typeof settings === 'object' && settings ? settings : {}); // pass in if non-null object
  8062. var formatter = createFormatter(settings, globalDefaults.defaultRangeSeparator);
  8063. var startMeta = dateEnv.createMarkerMeta(startInput);
  8064. var endMeta = dateEnv.createMarkerMeta(endInput);
  8065. if (!startMeta || !endMeta) { // TODO: warning?
  8066. return '';
  8067. }
  8068. return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
  8069. forcedStartTzo: startMeta.forcedTzo,
  8070. forcedEndTzo: endMeta.forcedTzo,
  8071. isEndExclusive: settings.isEndExclusive
  8072. });
  8073. }
  8074. // TODO: more DRY and optimized
  8075. function buildDateEnv$1(settings) {
  8076. var locale = buildLocale(settings.locale || 'en', parseRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
  8077. // ensure required settings
  8078. settings = __assign({ timeZone: globalDefaults.timeZone, calendarSystem: 'gregory' }, settings, { locale: locale });
  8079. return new DateEnv(settings);
  8080. }
  8081. var DRAG_META_PROPS = {
  8082. startTime: createDuration,
  8083. duration: createDuration,
  8084. create: Boolean,
  8085. sourceId: String
  8086. };
  8087. var DRAG_META_DEFAULTS = {
  8088. create: true
  8089. };
  8090. function parseDragMeta(raw) {
  8091. var leftoverProps = {};
  8092. var refined = refineProps(raw, DRAG_META_PROPS, DRAG_META_DEFAULTS, leftoverProps);
  8093. refined.leftoverProps = leftoverProps;
  8094. return refined;
  8095. }
  8096. // Computes a default column header formatting string if `colFormat` is not explicitly defined
  8097. function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
  8098. // if more than one week row, or if there are a lot of columns with not much space,
  8099. // put just the day numbers will be in each cell
  8100. if (!datesRepDistinctDays || dayCnt > 10) {
  8101. return { weekday: 'short' }; // "Sat"
  8102. }
  8103. else if (dayCnt > 1) {
  8104. return { weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }; // "Sat 11/12"
  8105. }
  8106. else {
  8107. return { weekday: 'long' }; // "Saturday"
  8108. }
  8109. }
  8110. function renderDateCell(dateMarker, dateProfile, datesRepDistinctDays, colCnt, colHeadFormat, context, colspan, otherAttrs) {
  8111. var view = context.view, dateEnv = context.dateEnv, theme = context.theme, options = context.options;
  8112. var isDateValid = rangeContainsMarker(dateProfile.activeRange, dateMarker); // TODO: called too frequently. cache somehow.
  8113. var classNames = [
  8114. 'fc-day-header',
  8115. theme.getClass('widgetHeader')
  8116. ];
  8117. var innerHtml;
  8118. if (typeof options.columnHeaderHtml === 'function') {
  8119. innerHtml = options.columnHeaderHtml(dateEnv.toDate(dateMarker));
  8120. }
  8121. else if (typeof options.columnHeaderText === 'function') {
  8122. innerHtml = htmlEscape(options.columnHeaderText(dateEnv.toDate(dateMarker)));
  8123. }
  8124. else {
  8125. innerHtml = htmlEscape(dateEnv.format(dateMarker, colHeadFormat));
  8126. }
  8127. // if only one row of days, the classNames on the header can represent the specific days beneath
  8128. if (datesRepDistinctDays) {
  8129. classNames = classNames.concat(
  8130. // includes the day-of-week class
  8131. // noThemeHighlight=true (don't highlight the header)
  8132. getDayClasses(dateMarker, dateProfile, context, true));
  8133. }
  8134. else {
  8135. classNames.push('fc-' + DAY_IDS[dateMarker.getUTCDay()]); // only add the day-of-week class
  8136. }
  8137. return '' +
  8138. '<th class="' + classNames.join(' ') + '"' +
  8139. ((isDateValid && datesRepDistinctDays) ?
  8140. ' data-date="' + dateEnv.formatIso(dateMarker, { omitTime: true }) + '"' :
  8141. '') +
  8142. (colspan > 1 ?
  8143. ' colspan="' + colspan + '"' :
  8144. '') +
  8145. (otherAttrs ?
  8146. ' ' + otherAttrs :
  8147. '') +
  8148. '>' +
  8149. (isDateValid ?
  8150. // don't make a link if the heading could represent multiple days, or if there's only one day (forceOff)
  8151. buildGotoAnchorHtml(view, { date: dateMarker, forceOff: !datesRepDistinctDays || colCnt === 1 }, innerHtml) :
  8152. // if not valid, display text, but no link
  8153. innerHtml) +
  8154. '</th>';
  8155. }
  8156. var DayHeader = /** @class */ (function (_super) {
  8157. __extends(DayHeader, _super);
  8158. function DayHeader(context, parentEl) {
  8159. var _this = _super.call(this, context) || this;
  8160. parentEl.innerHTML = ''; // because might be nbsp
  8161. parentEl.appendChild(_this.el = htmlToElement('<div class="fc-row ' + _this.theme.getClass('headerRow') + '">' +
  8162. '<table class="' + _this.theme.getClass('tableGrid') + '">' +
  8163. '<thead></thead>' +
  8164. '</table>' +
  8165. '</div>'));
  8166. _this.thead = _this.el.querySelector('thead');
  8167. return _this;
  8168. }
  8169. DayHeader.prototype.destroy = function () {
  8170. removeElement(this.el);
  8171. };
  8172. DayHeader.prototype.render = function (props) {
  8173. var dates = props.dates, datesRepDistinctDays = props.datesRepDistinctDays;
  8174. var parts = [];
  8175. if (props.renderIntroHtml) {
  8176. parts.push(props.renderIntroHtml());
  8177. }
  8178. var colHeadFormat = createFormatter(this.opt('columnHeaderFormat') ||
  8179. computeFallbackHeaderFormat(datesRepDistinctDays, dates.length));
  8180. for (var _i = 0, dates_1 = dates; _i < dates_1.length; _i++) {
  8181. var date = dates_1[_i];
  8182. parts.push(renderDateCell(date, props.dateProfile, datesRepDistinctDays, dates.length, colHeadFormat, this.context));
  8183. }
  8184. if (this.isRtl) {
  8185. parts.reverse();
  8186. }
  8187. this.thead.innerHTML = '<tr>' + parts.join('') + '</tr>';
  8188. };
  8189. return DayHeader;
  8190. }(Component));
  8191. var DaySeries = /** @class */ (function () {
  8192. function DaySeries(range, dateProfileGenerator) {
  8193. var date = range.start;
  8194. var end = range.end;
  8195. var indices = [];
  8196. var dates = [];
  8197. var dayIndex = -1;
  8198. while (date < end) { // loop each day from start to end
  8199. if (dateProfileGenerator.isHiddenDay(date)) {
  8200. indices.push(dayIndex + 0.5); // mark that it's between indices
  8201. }
  8202. else {
  8203. dayIndex++;
  8204. indices.push(dayIndex);
  8205. dates.push(date);
  8206. }
  8207. date = addDays(date, 1);
  8208. }
  8209. this.dates = dates;
  8210. this.indices = indices;
  8211. this.cnt = dates.length;
  8212. }
  8213. DaySeries.prototype.sliceRange = function (range) {
  8214. var firstIndex = this.getDateDayIndex(range.start); // inclusive first index
  8215. var lastIndex = this.getDateDayIndex(addDays(range.end, -1)); // inclusive last index
  8216. var clippedFirstIndex = Math.max(0, firstIndex);
  8217. var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
  8218. // deal with in-between indices
  8219. clippedFirstIndex = Math.ceil(clippedFirstIndex); // in-between starts round to next cell
  8220. clippedLastIndex = Math.floor(clippedLastIndex); // in-between ends round to prev cell
  8221. if (clippedFirstIndex <= clippedLastIndex) {
  8222. return {
  8223. firstIndex: clippedFirstIndex,
  8224. lastIndex: clippedLastIndex,
  8225. isStart: firstIndex === clippedFirstIndex,
  8226. isEnd: lastIndex === clippedLastIndex
  8227. };
  8228. }
  8229. else {
  8230. return null;
  8231. }
  8232. };
  8233. // Given a date, returns its chronolocial cell-index from the first cell of the grid.
  8234. // If the date lies between cells (because of hiddenDays), returns a floating-point value between offsets.
  8235. // If before the first offset, returns a negative number.
  8236. // If after the last offset, returns an offset past the last cell offset.
  8237. // Only works for *start* dates of cells. Will not work for exclusive end dates for cells.
  8238. DaySeries.prototype.getDateDayIndex = function (date) {
  8239. var indices = this.indices;
  8240. var dayOffset = Math.floor(diffDays(this.dates[0], date));
  8241. if (dayOffset < 0) {
  8242. return indices[0] - 1;
  8243. }
  8244. else if (dayOffset >= indices.length) {
  8245. return indices[indices.length - 1] + 1;
  8246. }
  8247. else {
  8248. return indices[dayOffset];
  8249. }
  8250. };
  8251. return DaySeries;
  8252. }());
  8253. var DayTable = /** @class */ (function () {
  8254. function DayTable(daySeries, breakOnWeeks) {
  8255. var dates = daySeries.dates;
  8256. var daysPerRow;
  8257. var firstDay;
  8258. var rowCnt;
  8259. if (breakOnWeeks) {
  8260. // count columns until the day-of-week repeats
  8261. firstDay = dates[0].getUTCDay();
  8262. for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow++) {
  8263. if (dates[daysPerRow].getUTCDay() === firstDay) {
  8264. break;
  8265. }
  8266. }
  8267. rowCnt = Math.ceil(dates.length / daysPerRow);
  8268. }
  8269. else {
  8270. rowCnt = 1;
  8271. daysPerRow = dates.length;
  8272. }
  8273. this.rowCnt = rowCnt;
  8274. this.colCnt = daysPerRow;
  8275. this.daySeries = daySeries;
  8276. this.cells = this.buildCells();
  8277. this.headerDates = this.buildHeaderDates();
  8278. }
  8279. DayTable.prototype.buildCells = function () {
  8280. var rows = [];
  8281. for (var row = 0; row < this.rowCnt; row++) {
  8282. var cells = [];
  8283. for (var col = 0; col < this.colCnt; col++) {
  8284. cells.push(this.buildCell(row, col));
  8285. }
  8286. rows.push(cells);
  8287. }
  8288. return rows;
  8289. };
  8290. DayTable.prototype.buildCell = function (row, col) {
  8291. return {
  8292. date: this.daySeries.dates[row * this.colCnt + col]
  8293. };
  8294. };
  8295. DayTable.prototype.buildHeaderDates = function () {
  8296. var dates = [];
  8297. for (var col = 0; col < this.colCnt; col++) {
  8298. dates.push(this.cells[0][col].date);
  8299. }
  8300. return dates;
  8301. };
  8302. DayTable.prototype.sliceRange = function (range) {
  8303. var colCnt = this.colCnt;
  8304. var seriesSeg = this.daySeries.sliceRange(range);
  8305. var segs = [];
  8306. if (seriesSeg) {
  8307. var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
  8308. var index = firstIndex;
  8309. while (index <= lastIndex) {
  8310. var row = Math.floor(index / colCnt);
  8311. var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
  8312. segs.push({
  8313. row: row,
  8314. firstCol: index % colCnt,
  8315. lastCol: (nextIndex - 1) % colCnt,
  8316. isStart: seriesSeg.isStart && index === firstIndex,
  8317. isEnd: seriesSeg.isEnd && (nextIndex - 1) === lastIndex
  8318. });
  8319. index = nextIndex;
  8320. }
  8321. }
  8322. return segs;
  8323. };
  8324. return DayTable;
  8325. }());
  8326. var Slicer = /** @class */ (function () {
  8327. function Slicer() {
  8328. this.sliceBusinessHours = memoize(this._sliceBusinessHours);
  8329. this.sliceDateSelection = memoize(this._sliceDateSpan);
  8330. this.sliceEventStore = memoize(this._sliceEventStore);
  8331. this.sliceEventDrag = memoize(this._sliceInteraction);
  8332. this.sliceEventResize = memoize(this._sliceInteraction);
  8333. }
  8334. Slicer.prototype.sliceProps = function (props, dateProfile, nextDayThreshold, component) {
  8335. var extraArgs = [];
  8336. for (var _i = 4; _i < arguments.length; _i++) {
  8337. extraArgs[_i - 4] = arguments[_i];
  8338. }
  8339. var eventUiBases = props.eventUiBases;
  8340. var eventSegs = this.sliceEventStore.apply(this, [props.eventStore, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs));
  8341. return {
  8342. dateSelectionSegs: this.sliceDateSelection.apply(this, [props.dateSelection, eventUiBases, component].concat(extraArgs)),
  8343. businessHourSegs: this.sliceBusinessHours.apply(this, [props.businessHours, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8344. fgEventSegs: eventSegs.fg,
  8345. bgEventSegs: eventSegs.bg,
  8346. eventDrag: this.sliceEventDrag.apply(this, [props.eventDrag, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8347. eventResize: this.sliceEventResize.apply(this, [props.eventResize, eventUiBases, dateProfile, nextDayThreshold, component].concat(extraArgs)),
  8348. eventSelection: props.eventSelection
  8349. }; // TODO: give interactionSegs?
  8350. };
  8351. Slicer.prototype.sliceNowDate = function (// does not memoize
  8352. date, component) {
  8353. var extraArgs = [];
  8354. for (var _i = 2; _i < arguments.length; _i++) {
  8355. extraArgs[_i - 2] = arguments[_i];
  8356. }
  8357. return this._sliceDateSpan.apply(this, [{ range: { start: date, end: addMs(date, 1) }, allDay: false },
  8358. {},
  8359. component].concat(extraArgs));
  8360. };
  8361. Slicer.prototype._sliceBusinessHours = function (businessHours, dateProfile, nextDayThreshold, component) {
  8362. var extraArgs = [];
  8363. for (var _i = 4; _i < arguments.length; _i++) {
  8364. extraArgs[_i - 4] = arguments[_i];
  8365. }
  8366. if (!businessHours) {
  8367. return [];
  8368. }
  8369. return this._sliceEventStore.apply(this, [expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), component.calendar),
  8370. {},
  8371. dateProfile,
  8372. nextDayThreshold,
  8373. component].concat(extraArgs)).bg;
  8374. };
  8375. Slicer.prototype._sliceEventStore = function (eventStore, eventUiBases, dateProfile, nextDayThreshold, component) {
  8376. var extraArgs = [];
  8377. for (var _i = 5; _i < arguments.length; _i++) {
  8378. extraArgs[_i - 5] = arguments[_i];
  8379. }
  8380. if (eventStore) {
  8381. var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8382. return {
  8383. bg: this.sliceEventRanges(rangeRes.bg, component, extraArgs),
  8384. fg: this.sliceEventRanges(rangeRes.fg, component, extraArgs)
  8385. };
  8386. }
  8387. else {
  8388. return { bg: [], fg: [] };
  8389. }
  8390. };
  8391. Slicer.prototype._sliceInteraction = function (interaction, eventUiBases, dateProfile, nextDayThreshold, component) {
  8392. var extraArgs = [];
  8393. for (var _i = 5; _i < arguments.length; _i++) {
  8394. extraArgs[_i - 5] = arguments[_i];
  8395. }
  8396. if (!interaction) {
  8397. return null;
  8398. }
  8399. var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
  8400. return {
  8401. segs: this.sliceEventRanges(rangeRes.fg, component, extraArgs),
  8402. affectedInstances: interaction.affectedEvents.instances,
  8403. isEvent: interaction.isEvent,
  8404. sourceSeg: interaction.origSeg
  8405. };
  8406. };
  8407. Slicer.prototype._sliceDateSpan = function (dateSpan, eventUiBases, component) {
  8408. var extraArgs = [];
  8409. for (var _i = 3; _i < arguments.length; _i++) {
  8410. extraArgs[_i - 3] = arguments[_i];
  8411. }
  8412. if (!dateSpan) {
  8413. return [];
  8414. }
  8415. var eventRange = fabricateEventRange(dateSpan, eventUiBases, component.calendar);
  8416. var segs = this.sliceRange.apply(this, [dateSpan.range].concat(extraArgs));
  8417. for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
  8418. var seg = segs_1[_a];
  8419. seg.component = component;
  8420. seg.eventRange = eventRange;
  8421. }
  8422. return segs;
  8423. };
  8424. /*
  8425. "complete" seg means it has component and eventRange
  8426. */
  8427. Slicer.prototype.sliceEventRanges = function (eventRanges, component, // TODO: kill
  8428. extraArgs) {
  8429. var segs = [];
  8430. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  8431. var eventRange = eventRanges_1[_i];
  8432. segs.push.apply(segs, this.sliceEventRange(eventRange, component, extraArgs));
  8433. }
  8434. return segs;
  8435. };
  8436. /*
  8437. "complete" seg means it has component and eventRange
  8438. */
  8439. Slicer.prototype.sliceEventRange = function (eventRange, component, // TODO: kill
  8440. extraArgs) {
  8441. var segs = this.sliceRange.apply(this, [eventRange.range].concat(extraArgs));
  8442. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  8443. var seg = segs_2[_i];
  8444. seg.component = component;
  8445. seg.eventRange = eventRange;
  8446. seg.isStart = eventRange.isStart && seg.isStart;
  8447. seg.isEnd = eventRange.isEnd && seg.isEnd;
  8448. }
  8449. return segs;
  8450. };
  8451. return Slicer;
  8452. }());
  8453. /*
  8454. for incorporating minTime/maxTime if appropriate
  8455. TODO: should be part of DateProfile!
  8456. TimelineDateProfile already does this btw
  8457. */
  8458. function computeActiveRange(dateProfile, isComponentAllDay) {
  8459. var range = dateProfile.activeRange;
  8460. if (isComponentAllDay) {
  8461. return range;
  8462. }
  8463. return {
  8464. start: addMs(range.start, dateProfile.minTime.milliseconds),
  8465. end: addMs(range.end, dateProfile.maxTime.milliseconds - 864e5) // 864e5 = ms in a day
  8466. };
  8467. }
  8468. // exports
  8469. // --------------------------------------------------------------------------------------------------
  8470. var version = '4.3.1';
  8471. exports.Calendar = Calendar;
  8472. exports.Component = Component;
  8473. exports.DateComponent = DateComponent;
  8474. exports.DateEnv = DateEnv;
  8475. exports.DateProfileGenerator = DateProfileGenerator;
  8476. exports.DayHeader = DayHeader;
  8477. exports.DaySeries = DaySeries;
  8478. exports.DayTable = DayTable;
  8479. exports.ElementDragging = ElementDragging;
  8480. exports.ElementScrollController = ElementScrollController;
  8481. exports.EmitterMixin = EmitterMixin;
  8482. exports.EventApi = EventApi;
  8483. exports.FgEventRenderer = FgEventRenderer;
  8484. exports.FillRenderer = FillRenderer;
  8485. exports.Interaction = Interaction;
  8486. exports.Mixin = Mixin;
  8487. exports.NamedTimeZoneImpl = NamedTimeZoneImpl;
  8488. exports.PositionCache = PositionCache;
  8489. exports.ScrollComponent = ScrollComponent;
  8490. exports.ScrollController = ScrollController;
  8491. exports.Slicer = Slicer;
  8492. exports.Splitter = Splitter;
  8493. exports.Theme = Theme;
  8494. exports.View = View;
  8495. exports.WindowScrollController = WindowScrollController;
  8496. exports.addDays = addDays;
  8497. exports.addDurations = addDurations;
  8498. exports.addMs = addMs;
  8499. exports.addWeeks = addWeeks;
  8500. exports.allowContextMenu = allowContextMenu;
  8501. exports.allowSelection = allowSelection;
  8502. exports.appendToElement = appendToElement;
  8503. exports.applyAll = applyAll;
  8504. exports.applyMutationToEventStore = applyMutationToEventStore;
  8505. exports.applyStyle = applyStyle;
  8506. exports.applyStyleProp = applyStyleProp;
  8507. exports.asRoughMinutes = asRoughMinutes;
  8508. exports.asRoughMs = asRoughMs;
  8509. exports.asRoughSeconds = asRoughSeconds;
  8510. exports.buildGotoAnchorHtml = buildGotoAnchorHtml;
  8511. exports.buildSegCompareObj = buildSegCompareObj;
  8512. exports.capitaliseFirstLetter = capitaliseFirstLetter;
  8513. exports.combineEventUis = combineEventUis;
  8514. exports.compareByFieldSpec = compareByFieldSpec;
  8515. exports.compareByFieldSpecs = compareByFieldSpecs;
  8516. exports.compareNumbers = compareNumbers;
  8517. exports.compensateScroll = compensateScroll;
  8518. exports.computeClippingRect = computeClippingRect;
  8519. exports.computeEdges = computeEdges;
  8520. exports.computeFallbackHeaderFormat = computeFallbackHeaderFormat;
  8521. exports.computeHeightAndMargins = computeHeightAndMargins;
  8522. exports.computeInnerRect = computeInnerRect;
  8523. exports.computeRect = computeRect;
  8524. exports.computeVisibleDayRange = computeVisibleDayRange;
  8525. exports.config = config;
  8526. exports.constrainPoint = constrainPoint;
  8527. exports.createDuration = createDuration;
  8528. exports.createElement = createElement;
  8529. exports.createEmptyEventStore = createEmptyEventStore;
  8530. exports.createEventInstance = createEventInstance;
  8531. exports.createFormatter = createFormatter;
  8532. exports.createPlugin = createPlugin;
  8533. exports.cssToStr = cssToStr;
  8534. exports.debounce = debounce;
  8535. exports.diffDates = diffDates;
  8536. exports.diffDayAndTime = diffDayAndTime;
  8537. exports.diffDays = diffDays;
  8538. exports.diffPoints = diffPoints;
  8539. exports.diffWeeks = diffWeeks;
  8540. exports.diffWholeDays = diffWholeDays;
  8541. exports.diffWholeWeeks = diffWholeWeeks;
  8542. exports.disableCursor = disableCursor;
  8543. exports.distributeHeight = distributeHeight;
  8544. exports.elementClosest = elementClosest;
  8545. exports.elementMatches = elementMatches;
  8546. exports.enableCursor = enableCursor;
  8547. exports.eventTupleToStore = eventTupleToStore;
  8548. exports.filterEventStoreDefs = filterEventStoreDefs;
  8549. exports.filterHash = filterHash;
  8550. exports.findChildren = findChildren;
  8551. exports.findElements = findElements;
  8552. exports.flexibleCompare = flexibleCompare;
  8553. exports.forceClassName = forceClassName;
  8554. exports.formatDate = formatDate;
  8555. exports.formatIsoTimeString = formatIsoTimeString;
  8556. exports.formatRange = formatRange;
  8557. exports.getAllDayHtml = getAllDayHtml;
  8558. exports.getClippingParents = getClippingParents;
  8559. exports.getDayClasses = getDayClasses;
  8560. exports.getElSeg = getElSeg;
  8561. exports.getRectCenter = getRectCenter;
  8562. exports.getRelevantEvents = getRelevantEvents;
  8563. exports.globalDefaults = globalDefaults;
  8564. exports.greatestDurationDenominator = greatestDurationDenominator;
  8565. exports.hasBgRendering = hasBgRendering;
  8566. exports.htmlEscape = htmlEscape;
  8567. exports.htmlToElement = htmlToElement;
  8568. exports.insertAfterElement = insertAfterElement;
  8569. exports.interactionSettingsStore = interactionSettingsStore;
  8570. exports.interactionSettingsToStore = interactionSettingsToStore;
  8571. exports.intersectRanges = intersectRanges;
  8572. exports.intersectRects = intersectRects;
  8573. exports.isArraysEqual = isArraysEqual;
  8574. exports.isDateSpansEqual = isDateSpansEqual;
  8575. exports.isInt = isInt;
  8576. exports.isInteractionValid = isInteractionValid;
  8577. exports.isMultiDayRange = isMultiDayRange;
  8578. exports.isPropsEqual = isPropsEqual;
  8579. exports.isPropsValid = isPropsValid;
  8580. exports.isSingleDay = isSingleDay;
  8581. exports.isValidDate = isValidDate;
  8582. exports.listenBySelector = listenBySelector;
  8583. exports.mapHash = mapHash;
  8584. exports.matchCellWidths = matchCellWidths;
  8585. exports.memoize = memoize;
  8586. exports.memoizeOutput = memoizeOutput;
  8587. exports.memoizeRendering = memoizeRendering;
  8588. exports.mergeEventStores = mergeEventStores;
  8589. exports.multiplyDuration = multiplyDuration;
  8590. exports.padStart = padStart;
  8591. exports.parseBusinessHours = parseBusinessHours;
  8592. exports.parseDragMeta = parseDragMeta;
  8593. exports.parseEventDef = parseEventDef;
  8594. exports.parseFieldSpecs = parseFieldSpecs;
  8595. exports.parseMarker = parse;
  8596. exports.pointInsideRect = pointInsideRect;
  8597. exports.prependToElement = prependToElement;
  8598. exports.preventContextMenu = preventContextMenu;
  8599. exports.preventDefault = preventDefault;
  8600. exports.preventSelection = preventSelection;
  8601. exports.processScopedUiProps = processScopedUiProps;
  8602. exports.rangeContainsMarker = rangeContainsMarker;
  8603. exports.rangeContainsRange = rangeContainsRange;
  8604. exports.rangesEqual = rangesEqual;
  8605. exports.rangesIntersect = rangesIntersect;
  8606. exports.refineProps = refineProps;
  8607. exports.removeElement = removeElement;
  8608. exports.removeExact = removeExact;
  8609. exports.renderDateCell = renderDateCell;
  8610. exports.requestJson = requestJson;
  8611. exports.sliceEventStore = sliceEventStore;
  8612. exports.startOfDay = startOfDay;
  8613. exports.subtractInnerElHeight = subtractInnerElHeight;
  8614. exports.translateRect = translateRect;
  8615. exports.uncompensateScroll = uncompensateScroll;
  8616. exports.undistributeHeight = undistributeHeight;
  8617. exports.unpromisify = unpromisify;
  8618. exports.version = version;
  8619. exports.whenTransitionDone = whenTransitionDone;
  8620. exports.wholeDivideDurations = wholeDivideDurations;
  8621. Object.defineProperty(exports, '__esModule', { value: true });
  8622. }));
  8623. /*!
  8624. FullCalendar Day Grid Plugin v4.3.0
  8625. Docs & License: https://fullcalendar.io/
  8626. (c) 2019 Adam Shaw
  8627. */
  8628. (function (global, factory) {
  8629. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  8630. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  8631. (global = global || self, factory(global.FullCalendarDayGrid = {}, global.FullCalendar));
  8632. }(this, function (exports, core) { 'use strict';
  8633. /*! *****************************************************************************
  8634. Copyright (c) Microsoft Corporation. All rights reserved.
  8635. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  8636. this file except in compliance with the License. You may obtain a copy of the
  8637. License at http://www.apache.org/licenses/LICENSE-2.0
  8638. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  8639. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8640. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  8641. MERCHANTABLITY OR NON-INFRINGEMENT.
  8642. See the Apache Version 2.0 License for specific language governing permissions
  8643. and limitations under the License.
  8644. ***************************************************************************** */
  8645. /* global Reflect, Promise */
  8646. var extendStatics = function(d, b) {
  8647. extendStatics = Object.setPrototypeOf ||
  8648. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  8649. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8650. return extendStatics(d, b);
  8651. };
  8652. function __extends(d, b) {
  8653. extendStatics(d, b);
  8654. function __() { this.constructor = d; }
  8655. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8656. }
  8657. var __assign = function() {
  8658. __assign = Object.assign || function __assign(t) {
  8659. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8660. s = arguments[i];
  8661. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8662. }
  8663. return t;
  8664. };
  8665. return __assign.apply(this, arguments);
  8666. };
  8667. var DayGridDateProfileGenerator = /** @class */ (function (_super) {
  8668. __extends(DayGridDateProfileGenerator, _super);
  8669. function DayGridDateProfileGenerator() {
  8670. return _super !== null && _super.apply(this, arguments) || this;
  8671. }
  8672. // Computes the date range that will be rendered.
  8673. DayGridDateProfileGenerator.prototype.buildRenderRange = function (currentRange, currentRangeUnit, isRangeAllDay) {
  8674. var dateEnv = this.dateEnv;
  8675. var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
  8676. var start = renderRange.start;
  8677. var end = renderRange.end;
  8678. var endOfWeek;
  8679. // year and month views should be aligned with weeks. this is already done for week
  8680. if (/^(year|month)$/.test(currentRangeUnit)) {
  8681. start = dateEnv.startOfWeek(start);
  8682. // make end-of-week if not already
  8683. endOfWeek = dateEnv.startOfWeek(end);
  8684. if (endOfWeek.valueOf() !== end.valueOf()) {
  8685. end = core.addWeeks(endOfWeek, 1);
  8686. }
  8687. }
  8688. // ensure 6 weeks
  8689. if (this.options.monthMode &&
  8690. this.options.fixedWeekCount) {
  8691. var rowCnt = Math.ceil(// could be partial weeks due to hiddenDays
  8692. core.diffWeeks(start, end));
  8693. end = core.addWeeks(end, 6 - rowCnt);
  8694. }
  8695. return { start: start, end: end };
  8696. };
  8697. return DayGridDateProfileGenerator;
  8698. }(core.DateProfileGenerator));
  8699. /* A rectangular panel that is absolutely positioned over other content
  8700. ------------------------------------------------------------------------------------------------------------------------
  8701. Options:
  8702. - className (string)
  8703. - content (HTML string, element, or element array)
  8704. - parentEl
  8705. - top
  8706. - left
  8707. - right (the x coord of where the right edge should be. not a "CSS" right)
  8708. - autoHide (boolean)
  8709. - show (callback)
  8710. - hide (callback)
  8711. */
  8712. var Popover = /** @class */ (function () {
  8713. function Popover(options) {
  8714. var _this = this;
  8715. this.isHidden = true;
  8716. this.margin = 10; // the space required between the popover and the edges of the scroll container
  8717. // Triggered when the user clicks *anywhere* in the document, for the autoHide feature
  8718. this.documentMousedown = function (ev) {
  8719. // only hide the popover if the click happened outside the popover
  8720. if (_this.el && !_this.el.contains(ev.target)) {
  8721. _this.hide();
  8722. }
  8723. };
  8724. this.options = options;
  8725. }
  8726. // Shows the popover on the specified position. Renders it if not already
  8727. Popover.prototype.show = function () {
  8728. if (this.isHidden) {
  8729. if (!this.el) {
  8730. this.render();
  8731. }
  8732. this.el.style.display = '';
  8733. this.position();
  8734. this.isHidden = false;
  8735. this.trigger('show');
  8736. }
  8737. };
  8738. // Hides the popover, through CSS, but does not remove it from the DOM
  8739. Popover.prototype.hide = function () {
  8740. if (!this.isHidden) {
  8741. this.el.style.display = 'none';
  8742. this.isHidden = true;
  8743. this.trigger('hide');
  8744. }
  8745. };
  8746. // Creates `this.el` and renders content inside of it
  8747. Popover.prototype.render = function () {
  8748. var _this = this;
  8749. var options = this.options;
  8750. var el = this.el = core.createElement('div', {
  8751. className: 'fc-popover ' + (options.className || ''),
  8752. style: {
  8753. top: '0',
  8754. left: '0'
  8755. }
  8756. });
  8757. if (typeof options.content === 'function') {
  8758. options.content(el);
  8759. }
  8760. options.parentEl.appendChild(el);
  8761. // when a click happens on anything inside with a 'fc-close' className, hide the popover
  8762. core.listenBySelector(el, 'click', '.fc-close', function (ev) {
  8763. _this.hide();
  8764. });
  8765. if (options.autoHide) {
  8766. document.addEventListener('mousedown', this.documentMousedown);
  8767. }
  8768. };
  8769. // Hides and unregisters any handlers
  8770. Popover.prototype.destroy = function () {
  8771. this.hide();
  8772. if (this.el) {
  8773. core.removeElement(this.el);
  8774. this.el = null;
  8775. }
  8776. document.removeEventListener('mousedown', this.documentMousedown);
  8777. };
  8778. // Positions the popover optimally, using the top/left/right options
  8779. Popover.prototype.position = function () {
  8780. var options = this.options;
  8781. var el = this.el;
  8782. var elDims = el.getBoundingClientRect(); // only used for width,height
  8783. var origin = core.computeRect(el.offsetParent);
  8784. var clippingRect = core.computeClippingRect(options.parentEl);
  8785. var top; // the "position" (not "offset") values for the popover
  8786. var left; //
  8787. // compute top and left
  8788. top = options.top || 0;
  8789. if (options.left !== undefined) {
  8790. left = options.left;
  8791. }
  8792. else if (options.right !== undefined) {
  8793. left = options.right - elDims.width; // derive the left value from the right value
  8794. }
  8795. else {
  8796. left = 0;
  8797. }
  8798. // constrain to the view port. if constrained by two edges, give precedence to top/left
  8799. top = Math.min(top, clippingRect.bottom - elDims.height - this.margin);
  8800. top = Math.max(top, clippingRect.top + this.margin);
  8801. left = Math.min(left, clippingRect.right - elDims.width - this.margin);
  8802. left = Math.max(left, clippingRect.left + this.margin);
  8803. core.applyStyle(el, {
  8804. top: top - origin.top,
  8805. left: left - origin.left
  8806. });
  8807. };
  8808. // Triggers a callback. Calls a function in the option hash of the same name.
  8809. // Arguments beyond the first `name` are forwarded on.
  8810. // TODO: better code reuse for this. Repeat code
  8811. // can kill this???
  8812. Popover.prototype.trigger = function (name) {
  8813. if (this.options[name]) {
  8814. this.options[name].apply(this, Array.prototype.slice.call(arguments, 1));
  8815. }
  8816. };
  8817. return Popover;
  8818. }());
  8819. /* Event-rendering methods for the DayGrid class
  8820. ----------------------------------------------------------------------------------------------------------------------*/
  8821. // "Simple" is bad a name. has nothing to do with SimpleDayGrid
  8822. var SimpleDayGridEventRenderer = /** @class */ (function (_super) {
  8823. __extends(SimpleDayGridEventRenderer, _super);
  8824. function SimpleDayGridEventRenderer() {
  8825. return _super !== null && _super.apply(this, arguments) || this;
  8826. }
  8827. // Builds the HTML to be used for the default element for an individual segment
  8828. SimpleDayGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
  8829. var _a = this.context, view = _a.view, options = _a.options;
  8830. var eventRange = seg.eventRange;
  8831. var eventDef = eventRange.def;
  8832. var eventUi = eventRange.ui;
  8833. var allDay = eventDef.allDay;
  8834. var isDraggable = view.computeEventDraggable(eventDef, eventUi);
  8835. var isResizableFromStart = allDay && seg.isStart && view.computeEventStartResizable(eventDef, eventUi);
  8836. var isResizableFromEnd = allDay && seg.isEnd && view.computeEventEndResizable(eventDef, eventUi);
  8837. var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
  8838. var skinCss = core.cssToStr(this.getSkinCss(eventUi));
  8839. var timeHtml = '';
  8840. var timeText;
  8841. var titleHtml;
  8842. classes.unshift('fc-day-grid-event', 'fc-h-event');
  8843. // Only display a timed events time if it is the starting segment
  8844. if (seg.isStart) {
  8845. timeText = this.getTimeText(eventRange);
  8846. if (timeText) {
  8847. timeHtml = '<span class="fc-time">' + core.htmlEscape(timeText) + '</span>';
  8848. }
  8849. }
  8850. titleHtml =
  8851. '<span class="fc-title">' +
  8852. (core.htmlEscape(eventDef.title || '') || '&nbsp;') + // we always want one line of height
  8853. '</span>';
  8854. return '<a class="' + classes.join(' ') + '"' +
  8855. (eventDef.url ?
  8856. ' href="' + core.htmlEscape(eventDef.url) + '"' :
  8857. '') +
  8858. (skinCss ?
  8859. ' style="' + skinCss + '"' :
  8860. '') +
  8861. '>' +
  8862. '<div class="fc-content">' +
  8863. (options.dir === 'rtl' ?
  8864. titleHtml + ' ' + timeHtml : // put a natural space in between
  8865. timeHtml + ' ' + titleHtml //
  8866. ) +
  8867. '</div>' +
  8868. (isResizableFromStart ?
  8869. '<div class="fc-resizer fc-start-resizer"></div>' :
  8870. '') +
  8871. (isResizableFromEnd ?
  8872. '<div class="fc-resizer fc-end-resizer"></div>' :
  8873. '') +
  8874. '</a>';
  8875. };
  8876. // Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
  8877. SimpleDayGridEventRenderer.prototype.computeEventTimeFormat = function () {
  8878. return {
  8879. hour: 'numeric',
  8880. minute: '2-digit',
  8881. omitZeroMinute: true,
  8882. meridiem: 'narrow'
  8883. };
  8884. };
  8885. SimpleDayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  8886. return false; // TODO: somehow consider the originating DayGrid's column count
  8887. };
  8888. return SimpleDayGridEventRenderer;
  8889. }(core.FgEventRenderer));
  8890. /* Event-rendering methods for the DayGrid class
  8891. ----------------------------------------------------------------------------------------------------------------------*/
  8892. var DayGridEventRenderer = /** @class */ (function (_super) {
  8893. __extends(DayGridEventRenderer, _super);
  8894. function DayGridEventRenderer(dayGrid) {
  8895. var _this = _super.call(this, dayGrid.context) || this;
  8896. _this.dayGrid = dayGrid;
  8897. return _this;
  8898. }
  8899. // Renders the given foreground event segments onto the grid
  8900. DayGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  8901. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  8902. // append to each row's content skeleton
  8903. this.dayGrid.rowEls.forEach(function (rowNode, i) {
  8904. rowNode.querySelector('.fc-content-skeleton > table').appendChild(rowStructs[i].tbodyEl);
  8905. });
  8906. // removes the "more.." events popover
  8907. if (!mirrorInfo) {
  8908. this.dayGrid.removeSegPopover();
  8909. }
  8910. };
  8911. // Unrenders all currently rendered foreground event segments
  8912. DayGridEventRenderer.prototype.detachSegs = function () {
  8913. var rowStructs = this.rowStructs || [];
  8914. var rowStruct;
  8915. while ((rowStruct = rowStructs.pop())) {
  8916. core.removeElement(rowStruct.tbodyEl);
  8917. }
  8918. this.rowStructs = null;
  8919. };
  8920. // Uses the given events array to generate <tbody> elements that should be appended to each row's content skeleton.
  8921. // Returns an array of rowStruct objects (see the bottom of `renderSegRow`).
  8922. // PRECONDITION: each segment shoud already have a rendered and assigned `.el`
  8923. DayGridEventRenderer.prototype.renderSegRows = function (segs) {
  8924. var rowStructs = [];
  8925. var segRows;
  8926. var row;
  8927. segRows = this.groupSegRows(segs); // group into nested arrays
  8928. // iterate each row of segment groupings
  8929. for (row = 0; row < segRows.length; row++) {
  8930. rowStructs.push(this.renderSegRow(row, segRows[row]));
  8931. }
  8932. return rowStructs;
  8933. };
  8934. // Given a row # and an array of segments all in the same row, render a <tbody> element, a skeleton that contains
  8935. // the segments. Returns object with a bunch of internal data about how the render was calculated.
  8936. // NOTE: modifies rowSegs
  8937. DayGridEventRenderer.prototype.renderSegRow = function (row, rowSegs) {
  8938. var dayGrid = this.dayGrid;
  8939. var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl;
  8940. var segLevels = this.buildSegLevels(rowSegs); // group into sub-arrays of levels
  8941. var levelCnt = Math.max(1, segLevels.length); // ensure at least one level
  8942. var tbody = document.createElement('tbody');
  8943. var segMatrix = []; // lookup for which segments are rendered into which level+col cells
  8944. var cellMatrix = []; // lookup for all <td> elements of the level+col matrix
  8945. var loneCellMatrix = []; // lookup for <td> elements that only take up a single column
  8946. var i;
  8947. var levelSegs;
  8948. var col;
  8949. var tr;
  8950. var j;
  8951. var seg;
  8952. var td;
  8953. // populates empty cells from the current column (`col`) to `endCol`
  8954. function emptyCellsUntil(endCol) {
  8955. while (col < endCol) {
  8956. // try to grab a cell from the level above and extend its rowspan. otherwise, create a fresh cell
  8957. td = (loneCellMatrix[i - 1] || [])[col];
  8958. if (td) {
  8959. td.rowSpan = (td.rowSpan || 1) + 1;
  8960. }
  8961. else {
  8962. td = document.createElement('td');
  8963. tr.appendChild(td);
  8964. }
  8965. cellMatrix[i][col] = td;
  8966. loneCellMatrix[i][col] = td;
  8967. col++;
  8968. }
  8969. }
  8970. for (i = 0; i < levelCnt; i++) { // iterate through all levels
  8971. levelSegs = segLevels[i];
  8972. col = 0;
  8973. tr = document.createElement('tr');
  8974. segMatrix.push([]);
  8975. cellMatrix.push([]);
  8976. loneCellMatrix.push([]);
  8977. // levelCnt might be 1 even though there are no actual levels. protect against this.
  8978. // this single empty row is useful for styling.
  8979. if (levelSegs) {
  8980. for (j = 0; j < levelSegs.length; j++) { // iterate through segments in level
  8981. seg = levelSegs[j];
  8982. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  8983. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  8984. emptyCellsUntil(leftCol);
  8985. // create a container that occupies or more columns. append the event element.
  8986. td = core.createElement('td', { className: 'fc-event-container' }, seg.el);
  8987. if (leftCol !== rightCol) {
  8988. td.colSpan = rightCol - leftCol + 1;
  8989. }
  8990. else { // a single-column segment
  8991. loneCellMatrix[i][col] = td;
  8992. }
  8993. while (col <= rightCol) {
  8994. cellMatrix[i][col] = td;
  8995. segMatrix[i][col] = seg;
  8996. col++;
  8997. }
  8998. tr.appendChild(td);
  8999. }
  9000. }
  9001. emptyCellsUntil(colCnt); // finish off the row
  9002. var introHtml = dayGrid.renderProps.renderIntroHtml();
  9003. if (introHtml) {
  9004. if (dayGrid.isRtl) {
  9005. core.appendToElement(tr, introHtml);
  9006. }
  9007. else {
  9008. core.prependToElement(tr, introHtml);
  9009. }
  9010. }
  9011. tbody.appendChild(tr);
  9012. }
  9013. return {
  9014. row: row,
  9015. tbodyEl: tbody,
  9016. cellMatrix: cellMatrix,
  9017. segMatrix: segMatrix,
  9018. segLevels: segLevels,
  9019. segs: rowSegs
  9020. };
  9021. };
  9022. // Stacks a flat array of segments, which are all assumed to be in the same row, into subarrays of vertical levels.
  9023. // NOTE: modifies segs
  9024. DayGridEventRenderer.prototype.buildSegLevels = function (segs) {
  9025. var _a = this.dayGrid, isRtl = _a.isRtl, colCnt = _a.colCnt;
  9026. var levels = [];
  9027. var i;
  9028. var seg;
  9029. var j;
  9030. // Give preference to elements with certain criteria, so they have
  9031. // a chance to be closer to the top.
  9032. segs = this.sortEventSegs(segs);
  9033. for (i = 0; i < segs.length; i++) {
  9034. seg = segs[i];
  9035. // loop through levels, starting with the topmost, until the segment doesn't collide with other segments
  9036. for (j = 0; j < levels.length; j++) {
  9037. if (!isDaySegCollision(seg, levels[j])) {
  9038. break;
  9039. }
  9040. }
  9041. // `j` now holds the desired subrow index
  9042. seg.level = j;
  9043. seg.leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol; // for sorting only
  9044. seg.rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol // for sorting only
  9045. ;
  9046. (levels[j] || (levels[j] = [])).push(seg);
  9047. }
  9048. // order segments left-to-right. very important if calendar is RTL
  9049. for (j = 0; j < levels.length; j++) {
  9050. levels[j].sort(compareDaySegCols);
  9051. }
  9052. return levels;
  9053. };
  9054. // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's row
  9055. DayGridEventRenderer.prototype.groupSegRows = function (segs) {
  9056. var segRows = [];
  9057. var i;
  9058. for (i = 0; i < this.dayGrid.rowCnt; i++) {
  9059. segRows.push([]);
  9060. }
  9061. for (i = 0; i < segs.length; i++) {
  9062. segRows[segs[i].row].push(segs[i]);
  9063. }
  9064. return segRows;
  9065. };
  9066. // Computes a default `displayEventEnd` value if one is not expliclty defined
  9067. DayGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  9068. return this.dayGrid.colCnt === 1; // we'll likely have space if there's only one day
  9069. };
  9070. return DayGridEventRenderer;
  9071. }(SimpleDayGridEventRenderer));
  9072. // Computes whether two segments' columns collide. They are assumed to be in the same row.
  9073. function isDaySegCollision(seg, otherSegs) {
  9074. var i;
  9075. var otherSeg;
  9076. for (i = 0; i < otherSegs.length; i++) {
  9077. otherSeg = otherSegs[i];
  9078. if (otherSeg.firstCol <= seg.lastCol &&
  9079. otherSeg.lastCol >= seg.firstCol) {
  9080. return true;
  9081. }
  9082. }
  9083. return false;
  9084. }
  9085. // A cmp function for determining the leftmost event
  9086. function compareDaySegCols(a, b) {
  9087. return a.leftCol - b.leftCol;
  9088. }
  9089. var DayGridMirrorRenderer = /** @class */ (function (_super) {
  9090. __extends(DayGridMirrorRenderer, _super);
  9091. function DayGridMirrorRenderer() {
  9092. return _super !== null && _super.apply(this, arguments) || this;
  9093. }
  9094. DayGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  9095. var sourceSeg = mirrorInfo.sourceSeg;
  9096. var rowStructs = this.rowStructs = this.renderSegRows(segs);
  9097. // inject each new event skeleton into each associated row
  9098. this.dayGrid.rowEls.forEach(function (rowNode, row) {
  9099. var skeletonEl = core.htmlToElement('<div class="fc-mirror-skeleton"><table></table></div>'); // will be absolutely positioned
  9100. var skeletonTopEl;
  9101. var skeletonTop;
  9102. // If there is an original segment, match the top position. Otherwise, put it at the row's top level
  9103. if (sourceSeg && sourceSeg.row === row) {
  9104. skeletonTopEl = sourceSeg.el;
  9105. }
  9106. else {
  9107. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton tbody');
  9108. if (!skeletonTopEl) { // when no events
  9109. skeletonTopEl = rowNode.querySelector('.fc-content-skeleton table');
  9110. }
  9111. }
  9112. skeletonTop = skeletonTopEl.getBoundingClientRect().top -
  9113. rowNode.getBoundingClientRect().top; // the offsetParent origin
  9114. skeletonEl.style.top = skeletonTop + 'px';
  9115. skeletonEl.querySelector('table').appendChild(rowStructs[row].tbodyEl);
  9116. rowNode.appendChild(skeletonEl);
  9117. });
  9118. };
  9119. return DayGridMirrorRenderer;
  9120. }(DayGridEventRenderer));
  9121. var EMPTY_CELL_HTML = '<td style="pointer-events:none"></td>';
  9122. var DayGridFillRenderer = /** @class */ (function (_super) {
  9123. __extends(DayGridFillRenderer, _super);
  9124. function DayGridFillRenderer(dayGrid) {
  9125. var _this = _super.call(this, dayGrid.context) || this;
  9126. _this.fillSegTag = 'td'; // override the default tag name
  9127. _this.dayGrid = dayGrid;
  9128. return _this;
  9129. }
  9130. DayGridFillRenderer.prototype.renderSegs = function (type, segs) {
  9131. // don't render timed background events
  9132. if (type === 'bgEvent') {
  9133. segs = segs.filter(function (seg) {
  9134. return seg.eventRange.def.allDay;
  9135. });
  9136. }
  9137. _super.prototype.renderSegs.call(this, type, segs);
  9138. };
  9139. DayGridFillRenderer.prototype.attachSegs = function (type, segs) {
  9140. var els = [];
  9141. var i;
  9142. var seg;
  9143. var skeletonEl;
  9144. for (i = 0; i < segs.length; i++) {
  9145. seg = segs[i];
  9146. skeletonEl = this.renderFillRow(type, seg);
  9147. this.dayGrid.rowEls[seg.row].appendChild(skeletonEl);
  9148. els.push(skeletonEl);
  9149. }
  9150. return els;
  9151. };
  9152. // Generates the HTML needed for one row of a fill. Requires the seg's el to be rendered.
  9153. DayGridFillRenderer.prototype.renderFillRow = function (type, seg) {
  9154. var dayGrid = this.dayGrid;
  9155. var colCnt = dayGrid.colCnt, isRtl = dayGrid.isRtl;
  9156. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  9157. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  9158. var startCol = leftCol;
  9159. var endCol = rightCol + 1;
  9160. var className;
  9161. var skeletonEl;
  9162. var trEl;
  9163. if (type === 'businessHours') {
  9164. className = 'bgevent';
  9165. }
  9166. else {
  9167. className = type.toLowerCase();
  9168. }
  9169. skeletonEl = core.htmlToElement('<div class="fc-' + className + '-skeleton">' +
  9170. '<table><tr></tr></table>' +
  9171. '</div>');
  9172. trEl = skeletonEl.getElementsByTagName('tr')[0];
  9173. if (startCol > 0) {
  9174. core.appendToElement(trEl,
  9175. // will create (startCol + 1) td's
  9176. new Array(startCol + 1).join(EMPTY_CELL_HTML));
  9177. }
  9178. seg.el.colSpan = endCol - startCol;
  9179. trEl.appendChild(seg.el);
  9180. if (endCol < colCnt) {
  9181. core.appendToElement(trEl,
  9182. // will create (colCnt - endCol) td's
  9183. new Array(colCnt - endCol + 1).join(EMPTY_CELL_HTML));
  9184. }
  9185. var introHtml = dayGrid.renderProps.renderIntroHtml();
  9186. if (introHtml) {
  9187. if (dayGrid.isRtl) {
  9188. core.appendToElement(trEl, introHtml);
  9189. }
  9190. else {
  9191. core.prependToElement(trEl, introHtml);
  9192. }
  9193. }
  9194. return skeletonEl;
  9195. };
  9196. return DayGridFillRenderer;
  9197. }(core.FillRenderer));
  9198. var DayTile = /** @class */ (function (_super) {
  9199. __extends(DayTile, _super);
  9200. function DayTile(context, el) {
  9201. var _this = _super.call(this, context, el) || this;
  9202. var eventRenderer = _this.eventRenderer = new DayTileEventRenderer(_this);
  9203. var renderFrame = _this.renderFrame = core.memoizeRendering(_this._renderFrame);
  9204. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderFrame]);
  9205. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  9206. _this.renderEventDrag = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  9207. _this.renderEventResize = core.memoizeRendering(eventRenderer.hideByHash.bind(eventRenderer), eventRenderer.showByHash.bind(eventRenderer), [renderFrame]);
  9208. context.calendar.registerInteractiveComponent(_this, {
  9209. el: _this.el,
  9210. useEventCenter: false
  9211. });
  9212. return _this;
  9213. }
  9214. DayTile.prototype.render = function (props) {
  9215. this.renderFrame(props.date);
  9216. this.renderFgEvents(props.fgSegs);
  9217. this.renderEventSelection(props.eventSelection);
  9218. this.renderEventDrag(props.eventDragInstances);
  9219. this.renderEventResize(props.eventResizeInstances);
  9220. };
  9221. DayTile.prototype.destroy = function () {
  9222. _super.prototype.destroy.call(this);
  9223. this.renderFrame.unrender(); // should unrender everything else
  9224. this.calendar.unregisterInteractiveComponent(this);
  9225. };
  9226. DayTile.prototype._renderFrame = function (date) {
  9227. var _a = this, theme = _a.theme, dateEnv = _a.dateEnv;
  9228. var title = dateEnv.format(date, core.createFormatter(this.opt('dayPopoverFormat')) // TODO: cache
  9229. );
  9230. this.el.innerHTML =
  9231. '<div class="fc-header ' + theme.getClass('popoverHeader') + '">' +
  9232. '<span class="fc-title">' +
  9233. core.htmlEscape(title) +
  9234. '</span>' +
  9235. '<span class="fc-close ' + theme.getIconClass('close') + '"></span>' +
  9236. '</div>' +
  9237. '<div class="fc-body ' + theme.getClass('popoverContent') + '">' +
  9238. '<div class="fc-event-container"></div>' +
  9239. '</div>';
  9240. this.segContainerEl = this.el.querySelector('.fc-event-container');
  9241. };
  9242. DayTile.prototype.queryHit = function (positionLeft, positionTop, elWidth, elHeight) {
  9243. var date = this.props.date; // HACK
  9244. if (positionLeft < elWidth && positionTop < elHeight) {
  9245. return {
  9246. component: this,
  9247. dateSpan: {
  9248. allDay: true,
  9249. range: { start: date, end: core.addDays(date, 1) }
  9250. },
  9251. dayEl: this.el,
  9252. rect: {
  9253. left: 0,
  9254. top: 0,
  9255. right: elWidth,
  9256. bottom: elHeight
  9257. },
  9258. layer: 1
  9259. };
  9260. }
  9261. };
  9262. return DayTile;
  9263. }(core.DateComponent));
  9264. var DayTileEventRenderer = /** @class */ (function (_super) {
  9265. __extends(DayTileEventRenderer, _super);
  9266. function DayTileEventRenderer(dayTile) {
  9267. var _this = _super.call(this, dayTile.context) || this;
  9268. _this.dayTile = dayTile;
  9269. return _this;
  9270. }
  9271. DayTileEventRenderer.prototype.attachSegs = function (segs) {
  9272. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  9273. var seg = segs_1[_i];
  9274. this.dayTile.segContainerEl.appendChild(seg.el);
  9275. }
  9276. };
  9277. DayTileEventRenderer.prototype.detachSegs = function (segs) {
  9278. for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
  9279. var seg = segs_2[_i];
  9280. core.removeElement(seg.el);
  9281. }
  9282. };
  9283. return DayTileEventRenderer;
  9284. }(SimpleDayGridEventRenderer));
  9285. var DayBgRow = /** @class */ (function () {
  9286. function DayBgRow(context) {
  9287. this.context = context;
  9288. }
  9289. DayBgRow.prototype.renderHtml = function (props) {
  9290. var parts = [];
  9291. if (props.renderIntroHtml) {
  9292. parts.push(props.renderIntroHtml());
  9293. }
  9294. for (var _i = 0, _a = props.cells; _i < _a.length; _i++) {
  9295. var cell = _a[_i];
  9296. parts.push(renderCellHtml(cell.date, props.dateProfile, this.context, cell.htmlAttrs));
  9297. }
  9298. if (!props.cells.length) {
  9299. parts.push('<td class="fc-day ' + this.context.theme.getClass('widgetContent') + '"></td>');
  9300. }
  9301. if (this.context.options.dir === 'rtl') {
  9302. parts.reverse();
  9303. }
  9304. return '<tr>' + parts.join('') + '</tr>';
  9305. };
  9306. return DayBgRow;
  9307. }());
  9308. function renderCellHtml(date, dateProfile, context, otherAttrs) {
  9309. var dateEnv = context.dateEnv, theme = context.theme;
  9310. var isDateValid = core.rangeContainsMarker(dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  9311. var classes = core.getDayClasses(date, dateProfile, context);
  9312. classes.unshift('fc-day', theme.getClass('widgetContent'));
  9313. return '<td class="' + classes.join(' ') + '"' +
  9314. (isDateValid ?
  9315. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  9316. '') +
  9317. (otherAttrs ?
  9318. ' ' + otherAttrs :
  9319. '') +
  9320. '></td>';
  9321. }
  9322. var DAY_NUM_FORMAT = core.createFormatter({ day: 'numeric' });
  9323. var WEEK_NUM_FORMAT = core.createFormatter({ week: 'numeric' });
  9324. var DayGrid = /** @class */ (function (_super) {
  9325. __extends(DayGrid, _super);
  9326. function DayGrid(context, el, renderProps) {
  9327. var _this = _super.call(this, context, el) || this;
  9328. _this.bottomCoordPadding = 0; // hack for extending the hit area for the last row of the coordinate grid
  9329. _this.isCellSizesDirty = false;
  9330. var eventRenderer = _this.eventRenderer = new DayGridEventRenderer(_this);
  9331. var fillRenderer = _this.fillRenderer = new DayGridFillRenderer(_this);
  9332. _this.mirrorRenderer = new DayGridMirrorRenderer(_this);
  9333. var renderCells = _this.renderCells = core.memoizeRendering(_this._renderCells, _this._unrenderCells);
  9334. _this.renderBusinessHours = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderCells]);
  9335. _this.renderDateSelection = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'highlight'), fillRenderer.unrender.bind(fillRenderer, 'highlight'), [renderCells]);
  9336. _this.renderBgEvents = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderCells]);
  9337. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderCells]);
  9338. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  9339. _this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderCells]);
  9340. _this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderCells]);
  9341. _this.renderProps = renderProps;
  9342. return _this;
  9343. }
  9344. DayGrid.prototype.render = function (props) {
  9345. var cells = props.cells;
  9346. this.rowCnt = cells.length;
  9347. this.colCnt = cells[0].length;
  9348. this.renderCells(cells, props.isRigid);
  9349. this.renderBusinessHours(props.businessHourSegs);
  9350. this.renderDateSelection(props.dateSelectionSegs);
  9351. this.renderBgEvents(props.bgEventSegs);
  9352. this.renderFgEvents(props.fgEventSegs);
  9353. this.renderEventSelection(props.eventSelection);
  9354. this.renderEventDrag(props.eventDrag);
  9355. this.renderEventResize(props.eventResize);
  9356. if (this.segPopoverTile) {
  9357. this.updateSegPopoverTile();
  9358. }
  9359. };
  9360. DayGrid.prototype.destroy = function () {
  9361. _super.prototype.destroy.call(this);
  9362. this.renderCells.unrender(); // will unrender everything else
  9363. };
  9364. DayGrid.prototype.getCellRange = function (row, col) {
  9365. var start = this.props.cells[row][col].date;
  9366. var end = core.addDays(start, 1);
  9367. return { start: start, end: end };
  9368. };
  9369. DayGrid.prototype.updateSegPopoverTile = function (date, segs) {
  9370. var ownProps = this.props;
  9371. this.segPopoverTile.receiveProps({
  9372. date: date || this.segPopoverTile.props.date,
  9373. fgSegs: segs || this.segPopoverTile.props.fgSegs,
  9374. eventSelection: ownProps.eventSelection,
  9375. eventDragInstances: ownProps.eventDrag ? ownProps.eventDrag.affectedInstances : null,
  9376. eventResizeInstances: ownProps.eventResize ? ownProps.eventResize.affectedInstances : null
  9377. });
  9378. };
  9379. /* Date Rendering
  9380. ------------------------------------------------------------------------------------------------------------------*/
  9381. DayGrid.prototype._renderCells = function (cells, isRigid) {
  9382. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  9383. var _b = this, rowCnt = _b.rowCnt, colCnt = _b.colCnt;
  9384. var html = '';
  9385. var row;
  9386. var col;
  9387. for (row = 0; row < rowCnt; row++) {
  9388. html += this.renderDayRowHtml(row, isRigid);
  9389. }
  9390. this.el.innerHTML = html;
  9391. this.rowEls = core.findElements(this.el, '.fc-row');
  9392. this.cellEls = core.findElements(this.el, '.fc-day, .fc-disabled-day');
  9393. if (this.isRtl) {
  9394. this.cellEls.reverse();
  9395. }
  9396. this.rowPositions = new core.PositionCache(this.el, this.rowEls, false, true // vertical
  9397. );
  9398. this.colPositions = new core.PositionCache(this.el, this.cellEls.slice(0, colCnt), // only the first row
  9399. true, false // horizontal
  9400. );
  9401. // trigger dayRender with each cell's element
  9402. for (row = 0; row < rowCnt; row++) {
  9403. for (col = 0; col < colCnt; col++) {
  9404. this.publiclyTrigger('dayRender', [
  9405. {
  9406. date: dateEnv.toDate(cells[row][col].date),
  9407. el: this.getCellEl(row, col),
  9408. view: view
  9409. }
  9410. ]);
  9411. }
  9412. }
  9413. this.isCellSizesDirty = true;
  9414. };
  9415. DayGrid.prototype._unrenderCells = function () {
  9416. this.removeSegPopover();
  9417. };
  9418. // Generates the HTML for a single row, which is a div that wraps a table.
  9419. // `row` is the row number.
  9420. DayGrid.prototype.renderDayRowHtml = function (row, isRigid) {
  9421. var theme = this.theme;
  9422. var classes = ['fc-row', 'fc-week', theme.getClass('dayRow')];
  9423. if (isRigid) {
  9424. classes.push('fc-rigid');
  9425. }
  9426. var bgRow = new DayBgRow(this.context);
  9427. return '' +
  9428. '<div class="' + classes.join(' ') + '">' +
  9429. '<div class="fc-bg">' +
  9430. '<table class="' + theme.getClass('tableGrid') + '">' +
  9431. bgRow.renderHtml({
  9432. cells: this.props.cells[row],
  9433. dateProfile: this.props.dateProfile,
  9434. renderIntroHtml: this.renderProps.renderBgIntroHtml
  9435. }) +
  9436. '</table>' +
  9437. '</div>' +
  9438. '<div class="fc-content-skeleton">' +
  9439. '<table>' +
  9440. (this.getIsNumbersVisible() ?
  9441. '<thead>' +
  9442. this.renderNumberTrHtml(row) +
  9443. '</thead>' :
  9444. '') +
  9445. '</table>' +
  9446. '</div>' +
  9447. '</div>';
  9448. };
  9449. DayGrid.prototype.getIsNumbersVisible = function () {
  9450. return this.getIsDayNumbersVisible() ||
  9451. this.renderProps.cellWeekNumbersVisible ||
  9452. this.renderProps.colWeekNumbersVisible;
  9453. };
  9454. DayGrid.prototype.getIsDayNumbersVisible = function () {
  9455. return this.rowCnt > 1;
  9456. };
  9457. /* Grid Number Rendering
  9458. ------------------------------------------------------------------------------------------------------------------*/
  9459. DayGrid.prototype.renderNumberTrHtml = function (row) {
  9460. var intro = this.renderProps.renderNumberIntroHtml(row, this);
  9461. return '' +
  9462. '<tr>' +
  9463. (this.isRtl ? '' : intro) +
  9464. this.renderNumberCellsHtml(row) +
  9465. (this.isRtl ? intro : '') +
  9466. '</tr>';
  9467. };
  9468. DayGrid.prototype.renderNumberCellsHtml = function (row) {
  9469. var htmls = [];
  9470. var col;
  9471. var date;
  9472. for (col = 0; col < this.colCnt; col++) {
  9473. date = this.props.cells[row][col].date;
  9474. htmls.push(this.renderNumberCellHtml(date));
  9475. }
  9476. if (this.isRtl) {
  9477. htmls.reverse();
  9478. }
  9479. return htmls.join('');
  9480. };
  9481. // Generates the HTML for the <td>s of the "number" row in the DayGrid's content skeleton.
  9482. // The number row will only exist if either day numbers or week numbers are turned on.
  9483. DayGrid.prototype.renderNumberCellHtml = function (date) {
  9484. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  9485. var html = '';
  9486. var isDateValid = core.rangeContainsMarker(this.props.dateProfile.activeRange, date); // TODO: called too frequently. cache somehow.
  9487. var isDayNumberVisible = this.getIsDayNumbersVisible() && isDateValid;
  9488. var classes;
  9489. var weekCalcFirstDow;
  9490. if (!isDayNumberVisible && !this.renderProps.cellWeekNumbersVisible) {
  9491. // no numbers in day cell (week number must be along the side)
  9492. return '<td></td>'; // will create an empty space above events :(
  9493. }
  9494. classes = core.getDayClasses(date, this.props.dateProfile, this.context);
  9495. classes.unshift('fc-day-top');
  9496. if (this.renderProps.cellWeekNumbersVisible) {
  9497. weekCalcFirstDow = dateEnv.weekDow;
  9498. }
  9499. html += '<td class="' + classes.join(' ') + '"' +
  9500. (isDateValid ?
  9501. ' data-date="' + dateEnv.formatIso(date, { omitTime: true }) + '"' :
  9502. '') +
  9503. '>';
  9504. if (this.renderProps.cellWeekNumbersVisible && (date.getUTCDay() === weekCalcFirstDow)) {
  9505. html += core.buildGotoAnchorHtml(view, { date: date, type: 'week' }, { 'class': 'fc-week-number' }, dateEnv.format(date, WEEK_NUM_FORMAT) // inner HTML
  9506. );
  9507. }
  9508. if (isDayNumberVisible) {
  9509. html += core.buildGotoAnchorHtml(view, date, { 'class': 'fc-day-number' }, dateEnv.format(date, DAY_NUM_FORMAT) // inner HTML
  9510. );
  9511. }
  9512. html += '</td>';
  9513. return html;
  9514. };
  9515. /* Sizing
  9516. ------------------------------------------------------------------------------------------------------------------*/
  9517. DayGrid.prototype.updateSize = function (isResize) {
  9518. var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
  9519. if (isResize ||
  9520. this.isCellSizesDirty ||
  9521. this.view.calendar.isEventsUpdated // hack
  9522. ) {
  9523. this.buildPositionCaches();
  9524. this.isCellSizesDirty = false;
  9525. }
  9526. fillRenderer.computeSizes(isResize);
  9527. eventRenderer.computeSizes(isResize);
  9528. mirrorRenderer.computeSizes(isResize);
  9529. fillRenderer.assignSizes(isResize);
  9530. eventRenderer.assignSizes(isResize);
  9531. mirrorRenderer.assignSizes(isResize);
  9532. };
  9533. DayGrid.prototype.buildPositionCaches = function () {
  9534. this.buildColPositions();
  9535. this.buildRowPositions();
  9536. };
  9537. DayGrid.prototype.buildColPositions = function () {
  9538. this.colPositions.build();
  9539. };
  9540. DayGrid.prototype.buildRowPositions = function () {
  9541. this.rowPositions.build();
  9542. this.rowPositions.bottoms[this.rowCnt - 1] += this.bottomCoordPadding; // hack
  9543. };
  9544. /* Hit System
  9545. ------------------------------------------------------------------------------------------------------------------*/
  9546. DayGrid.prototype.positionToHit = function (leftPosition, topPosition) {
  9547. var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
  9548. var col = colPositions.leftToIndex(leftPosition);
  9549. var row = rowPositions.topToIndex(topPosition);
  9550. if (row != null && col != null) {
  9551. return {
  9552. row: row,
  9553. col: col,
  9554. dateSpan: {
  9555. range: this.getCellRange(row, col),
  9556. allDay: true
  9557. },
  9558. dayEl: this.getCellEl(row, col),
  9559. relativeRect: {
  9560. left: colPositions.lefts[col],
  9561. right: colPositions.rights[col],
  9562. top: rowPositions.tops[row],
  9563. bottom: rowPositions.bottoms[row]
  9564. }
  9565. };
  9566. }
  9567. };
  9568. /* Cell System
  9569. ------------------------------------------------------------------------------------------------------------------*/
  9570. // FYI: the first column is the leftmost column, regardless of date
  9571. DayGrid.prototype.getCellEl = function (row, col) {
  9572. return this.cellEls[row * this.colCnt + col];
  9573. };
  9574. /* Event Drag Visualization
  9575. ------------------------------------------------------------------------------------------------------------------*/
  9576. DayGrid.prototype._renderEventDrag = function (state) {
  9577. if (state) {
  9578. this.eventRenderer.hideByHash(state.affectedInstances);
  9579. this.fillRenderer.renderSegs('highlight', state.segs);
  9580. }
  9581. };
  9582. DayGrid.prototype._unrenderEventDrag = function (state) {
  9583. if (state) {
  9584. this.eventRenderer.showByHash(state.affectedInstances);
  9585. this.fillRenderer.unrender('highlight');
  9586. }
  9587. };
  9588. /* Event Resize Visualization
  9589. ------------------------------------------------------------------------------------------------------------------*/
  9590. DayGrid.prototype._renderEventResize = function (state) {
  9591. if (state) {
  9592. this.eventRenderer.hideByHash(state.affectedInstances);
  9593. this.fillRenderer.renderSegs('highlight', state.segs);
  9594. this.mirrorRenderer.renderSegs(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  9595. }
  9596. };
  9597. DayGrid.prototype._unrenderEventResize = function (state) {
  9598. if (state) {
  9599. this.eventRenderer.showByHash(state.affectedInstances);
  9600. this.fillRenderer.unrender('highlight');
  9601. this.mirrorRenderer.unrender(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  9602. }
  9603. };
  9604. /* More+ Link Popover
  9605. ------------------------------------------------------------------------------------------------------------------*/
  9606. DayGrid.prototype.removeSegPopover = function () {
  9607. if (this.segPopover) {
  9608. this.segPopover.hide(); // in handler, will call segPopover's removeElement
  9609. }
  9610. };
  9611. // Limits the number of "levels" (vertically stacking layers of events) for each row of the grid.
  9612. // `levelLimit` can be false (don't limit), a number, or true (should be computed).
  9613. DayGrid.prototype.limitRows = function (levelLimit) {
  9614. var rowStructs = this.eventRenderer.rowStructs || [];
  9615. var row; // row #
  9616. var rowLevelLimit;
  9617. for (row = 0; row < rowStructs.length; row++) {
  9618. this.unlimitRow(row);
  9619. if (!levelLimit) {
  9620. rowLevelLimit = false;
  9621. }
  9622. else if (typeof levelLimit === 'number') {
  9623. rowLevelLimit = levelLimit;
  9624. }
  9625. else {
  9626. rowLevelLimit = this.computeRowLevelLimit(row);
  9627. }
  9628. if (rowLevelLimit !== false) {
  9629. this.limitRow(row, rowLevelLimit);
  9630. }
  9631. }
  9632. };
  9633. // Computes the number of levels a row will accomodate without going outside its bounds.
  9634. // Assumes the row is "rigid" (maintains a constant height regardless of what is inside).
  9635. // `row` is the row number.
  9636. DayGrid.prototype.computeRowLevelLimit = function (row) {
  9637. var rowEl = this.rowEls[row]; // the containing "fake" row div
  9638. var rowBottom = rowEl.getBoundingClientRect().bottom; // relative to viewport!
  9639. var trEls = core.findChildren(this.eventRenderer.rowStructs[row].tbodyEl);
  9640. var i;
  9641. var trEl;
  9642. // Reveal one level <tr> at a time and stop when we find one out of bounds
  9643. for (i = 0; i < trEls.length; i++) {
  9644. trEl = trEls[i];
  9645. trEl.classList.remove('fc-limited'); // reset to original state (reveal)
  9646. if (trEl.getBoundingClientRect().bottom > rowBottom) {
  9647. return i;
  9648. }
  9649. }
  9650. return false; // should not limit at all
  9651. };
  9652. // Limits the given grid row to the maximum number of levels and injects "more" links if necessary.
  9653. // `row` is the row number.
  9654. // `levelLimit` is a number for the maximum (inclusive) number of levels allowed.
  9655. DayGrid.prototype.limitRow = function (row, levelLimit) {
  9656. var _this = this;
  9657. var _a = this, colCnt = _a.colCnt, isRtl = _a.isRtl;
  9658. var rowStruct = this.eventRenderer.rowStructs[row];
  9659. var moreNodes = []; // array of "more" <a> links and <td> DOM nodes
  9660. var col = 0; // col #, left-to-right (not chronologically)
  9661. var levelSegs; // array of segment objects in the last allowable level, ordered left-to-right
  9662. var cellMatrix; // a matrix (by level, then column) of all <td> elements in the row
  9663. var limitedNodes; // array of temporarily hidden level <tr> and segment <td> DOM nodes
  9664. var i;
  9665. var seg;
  9666. var segsBelow; // array of segment objects below `seg` in the current `col`
  9667. var totalSegsBelow; // total number of segments below `seg` in any of the columns `seg` occupies
  9668. var colSegsBelow; // array of segment arrays, below seg, one for each column (offset from segs's first column)
  9669. var td;
  9670. var rowSpan;
  9671. var segMoreNodes; // array of "more" <td> cells that will stand-in for the current seg's cell
  9672. var j;
  9673. var moreTd;
  9674. var moreWrap;
  9675. var moreLink;
  9676. // Iterates through empty level cells and places "more" links inside if need be
  9677. var emptyCellsUntil = function (endCol) {
  9678. while (col < endCol) {
  9679. segsBelow = _this.getCellSegs(row, col, levelLimit);
  9680. if (segsBelow.length) {
  9681. td = cellMatrix[levelLimit - 1][col];
  9682. moreLink = _this.renderMoreLink(row, col, segsBelow);
  9683. moreWrap = core.createElement('div', null, moreLink);
  9684. td.appendChild(moreWrap);
  9685. moreNodes.push(moreWrap);
  9686. }
  9687. col++;
  9688. }
  9689. };
  9690. if (levelLimit && levelLimit < rowStruct.segLevels.length) { // is it actually over the limit?
  9691. levelSegs = rowStruct.segLevels[levelLimit - 1];
  9692. cellMatrix = rowStruct.cellMatrix;
  9693. limitedNodes = core.findChildren(rowStruct.tbodyEl).slice(levelLimit); // get level <tr> elements past the limit
  9694. limitedNodes.forEach(function (node) {
  9695. node.classList.add('fc-limited'); // hide elements and get a simple DOM-nodes array
  9696. });
  9697. // iterate though segments in the last allowable level
  9698. for (i = 0; i < levelSegs.length; i++) {
  9699. seg = levelSegs[i];
  9700. var leftCol = isRtl ? (colCnt - 1 - seg.lastCol) : seg.firstCol;
  9701. var rightCol = isRtl ? (colCnt - 1 - seg.firstCol) : seg.lastCol;
  9702. emptyCellsUntil(leftCol); // process empty cells before the segment
  9703. // determine *all* segments below `seg` that occupy the same columns
  9704. colSegsBelow = [];
  9705. totalSegsBelow = 0;
  9706. while (col <= rightCol) {
  9707. segsBelow = this.getCellSegs(row, col, levelLimit);
  9708. colSegsBelow.push(segsBelow);
  9709. totalSegsBelow += segsBelow.length;
  9710. col++;
  9711. }
  9712. if (totalSegsBelow) { // do we need to replace this segment with one or many "more" links?
  9713. td = cellMatrix[levelLimit - 1][leftCol]; // the segment's parent cell
  9714. rowSpan = td.rowSpan || 1;
  9715. segMoreNodes = [];
  9716. // make a replacement <td> for each column the segment occupies. will be one for each colspan
  9717. for (j = 0; j < colSegsBelow.length; j++) {
  9718. moreTd = core.createElement('td', { className: 'fc-more-cell', rowSpan: rowSpan });
  9719. segsBelow = colSegsBelow[j];
  9720. moreLink = this.renderMoreLink(row, leftCol + j, [seg].concat(segsBelow) // count seg as hidden too
  9721. );
  9722. moreWrap = core.createElement('div', null, moreLink);
  9723. moreTd.appendChild(moreWrap);
  9724. segMoreNodes.push(moreTd);
  9725. moreNodes.push(moreTd);
  9726. }
  9727. td.classList.add('fc-limited');
  9728. core.insertAfterElement(td, segMoreNodes);
  9729. limitedNodes.push(td);
  9730. }
  9731. }
  9732. emptyCellsUntil(this.colCnt); // finish off the level
  9733. rowStruct.moreEls = moreNodes; // for easy undoing later
  9734. rowStruct.limitedEls = limitedNodes; // for easy undoing later
  9735. }
  9736. };
  9737. // Reveals all levels and removes all "more"-related elements for a grid's row.
  9738. // `row` is a row number.
  9739. DayGrid.prototype.unlimitRow = function (row) {
  9740. var rowStruct = this.eventRenderer.rowStructs[row];
  9741. if (rowStruct.moreEls) {
  9742. rowStruct.moreEls.forEach(core.removeElement);
  9743. rowStruct.moreEls = null;
  9744. }
  9745. if (rowStruct.limitedEls) {
  9746. rowStruct.limitedEls.forEach(function (limitedEl) {
  9747. limitedEl.classList.remove('fc-limited');
  9748. });
  9749. rowStruct.limitedEls = null;
  9750. }
  9751. };
  9752. // Renders an <a> element that represents hidden event element for a cell.
  9753. // Responsible for attaching click handler as well.
  9754. DayGrid.prototype.renderMoreLink = function (row, col, hiddenSegs) {
  9755. var _this = this;
  9756. var _a = this, view = _a.view, dateEnv = _a.dateEnv;
  9757. var a = core.createElement('a', { className: 'fc-more' });
  9758. a.innerText = this.getMoreLinkText(hiddenSegs.length);
  9759. a.addEventListener('click', function (ev) {
  9760. var clickOption = _this.opt('eventLimitClick');
  9761. var _col = _this.isRtl ? _this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  9762. var date = _this.props.cells[row][_col].date;
  9763. var moreEl = ev.currentTarget;
  9764. var dayEl = _this.getCellEl(row, col);
  9765. var allSegs = _this.getCellSegs(row, col);
  9766. // rescope the segments to be within the cell's date
  9767. var reslicedAllSegs = _this.resliceDaySegs(allSegs, date);
  9768. var reslicedHiddenSegs = _this.resliceDaySegs(hiddenSegs, date);
  9769. if (typeof clickOption === 'function') {
  9770. // the returned value can be an atomic option
  9771. clickOption = _this.publiclyTrigger('eventLimitClick', [
  9772. {
  9773. date: dateEnv.toDate(date),
  9774. allDay: true,
  9775. dayEl: dayEl,
  9776. moreEl: moreEl,
  9777. segs: reslicedAllSegs,
  9778. hiddenSegs: reslicedHiddenSegs,
  9779. jsEvent: ev,
  9780. view: view
  9781. }
  9782. ]);
  9783. }
  9784. if (clickOption === 'popover') {
  9785. _this.showSegPopover(row, col, moreEl, reslicedAllSegs);
  9786. }
  9787. else if (typeof clickOption === 'string') { // a view name
  9788. view.calendar.zoomTo(date, clickOption);
  9789. }
  9790. });
  9791. return a;
  9792. };
  9793. // Reveals the popover that displays all events within a cell
  9794. DayGrid.prototype.showSegPopover = function (row, col, moreLink, segs) {
  9795. var _this = this;
  9796. var _a = this, calendar = _a.calendar, view = _a.view, theme = _a.theme;
  9797. var _col = this.isRtl ? this.colCnt - col - 1 : col; // HACK: props.cells has different dir system?
  9798. var moreWrap = moreLink.parentNode; // the <div> wrapper around the <a>
  9799. var topEl; // the element we want to match the top coordinate of
  9800. var options;
  9801. if (this.rowCnt === 1) {
  9802. topEl = view.el; // will cause the popover to cover any sort of header
  9803. }
  9804. else {
  9805. topEl = this.rowEls[row]; // will align with top of row
  9806. }
  9807. options = {
  9808. className: 'fc-more-popover ' + theme.getClass('popover'),
  9809. parentEl: view.el,
  9810. top: core.computeRect(topEl).top,
  9811. autoHide: true,
  9812. content: function (el) {
  9813. _this.segPopoverTile = new DayTile(_this.context, el);
  9814. _this.updateSegPopoverTile(_this.props.cells[row][_col].date, segs);
  9815. },
  9816. hide: function () {
  9817. _this.segPopoverTile.destroy();
  9818. _this.segPopoverTile = null;
  9819. _this.segPopover.destroy();
  9820. _this.segPopover = null;
  9821. }
  9822. };
  9823. // Determine horizontal coordinate.
  9824. // We use the moreWrap instead of the <td> to avoid border confusion.
  9825. if (this.isRtl) {
  9826. options.right = core.computeRect(moreWrap).right + 1; // +1 to be over cell border
  9827. }
  9828. else {
  9829. options.left = core.computeRect(moreWrap).left - 1; // -1 to be over cell border
  9830. }
  9831. this.segPopover = new Popover(options);
  9832. this.segPopover.show();
  9833. calendar.releaseAfterSizingTriggers(); // hack for eventPositioned
  9834. };
  9835. // Given the events within an array of segment objects, reslice them to be in a single day
  9836. DayGrid.prototype.resliceDaySegs = function (segs, dayDate) {
  9837. var dayStart = dayDate;
  9838. var dayEnd = core.addDays(dayStart, 1);
  9839. var dayRange = { start: dayStart, end: dayEnd };
  9840. var newSegs = [];
  9841. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  9842. var seg = segs_1[_i];
  9843. var eventRange = seg.eventRange;
  9844. var origRange = eventRange.range;
  9845. var slicedRange = core.intersectRanges(origRange, dayRange);
  9846. if (slicedRange) {
  9847. newSegs.push(__assign({}, seg, { eventRange: {
  9848. def: eventRange.def,
  9849. ui: __assign({}, eventRange.ui, { durationEditable: false }),
  9850. instance: eventRange.instance,
  9851. range: slicedRange
  9852. }, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() }));
  9853. }
  9854. }
  9855. return newSegs;
  9856. };
  9857. // Generates the text that should be inside a "more" link, given the number of events it represents
  9858. DayGrid.prototype.getMoreLinkText = function (num) {
  9859. var opt = this.opt('eventLimitText');
  9860. if (typeof opt === 'function') {
  9861. return opt(num);
  9862. }
  9863. else {
  9864. return '+' + num + ' ' + opt;
  9865. }
  9866. };
  9867. // Returns segments within a given cell.
  9868. // If `startLevel` is specified, returns only events including and below that level. Otherwise returns all segs.
  9869. DayGrid.prototype.getCellSegs = function (row, col, startLevel) {
  9870. var segMatrix = this.eventRenderer.rowStructs[row].segMatrix;
  9871. var level = startLevel || 0;
  9872. var segs = [];
  9873. var seg;
  9874. while (level < segMatrix.length) {
  9875. seg = segMatrix[level][col];
  9876. if (seg) {
  9877. segs.push(seg);
  9878. }
  9879. level++;
  9880. }
  9881. return segs;
  9882. };
  9883. return DayGrid;
  9884. }(core.DateComponent));
  9885. var WEEK_NUM_FORMAT$1 = core.createFormatter({ week: 'numeric' });
  9886. /* An abstract class for the daygrid views, as well as month view. Renders one or more rows of day cells.
  9887. ----------------------------------------------------------------------------------------------------------------------*/
  9888. // It is a manager for a DayGrid subcomponent, which does most of the heavy lifting.
  9889. // It is responsible for managing width/height.
  9890. var DayGridView = /** @class */ (function (_super) {
  9891. __extends(DayGridView, _super);
  9892. function DayGridView(context, viewSpec, dateProfileGenerator, parentEl) {
  9893. var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this;
  9894. /* Header Rendering
  9895. ------------------------------------------------------------------------------------------------------------------*/
  9896. // Generates the HTML that will go before the day-of week header cells
  9897. _this.renderHeadIntroHtml = function () {
  9898. var theme = _this.theme;
  9899. if (_this.colWeekNumbersVisible) {
  9900. return '' +
  9901. '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.weekNumberStyleAttr() + '>' +
  9902. '<span>' + // needed for matchCellWidths
  9903. core.htmlEscape(_this.opt('weekLabel')) +
  9904. '</span>' +
  9905. '</th>';
  9906. }
  9907. return '';
  9908. };
  9909. /* Day Grid Rendering
  9910. ------------------------------------------------------------------------------------------------------------------*/
  9911. // Generates the HTML that will go before content-skeleton cells that display the day/week numbers
  9912. _this.renderDayGridNumberIntroHtml = function (row, dayGrid) {
  9913. var dateEnv = _this.dateEnv;
  9914. var weekStart = dayGrid.props.cells[row][0].date;
  9915. if (_this.colWeekNumbersVisible) {
  9916. return '' +
  9917. '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '>' +
  9918. core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths
  9919. _this, { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 }, dateEnv.format(weekStart, WEEK_NUM_FORMAT$1) // inner HTML
  9920. ) +
  9921. '</td>';
  9922. }
  9923. return '';
  9924. };
  9925. // Generates the HTML that goes before the day bg cells for each day-row
  9926. _this.renderDayGridBgIntroHtml = function () {
  9927. var theme = _this.theme;
  9928. if (_this.colWeekNumbersVisible) {
  9929. return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '" ' + _this.weekNumberStyleAttr() + '></td>';
  9930. }
  9931. return '';
  9932. };
  9933. // Generates the HTML that goes before every other type of row generated by DayGrid.
  9934. // Affects mirror-skeleton and highlight-skeleton rows.
  9935. _this.renderDayGridIntroHtml = function () {
  9936. if (_this.colWeekNumbersVisible) {
  9937. return '<td class="fc-week-number" ' + _this.weekNumberStyleAttr() + '></td>';
  9938. }
  9939. return '';
  9940. };
  9941. _this.el.classList.add('fc-dayGrid-view');
  9942. _this.el.innerHTML = _this.renderSkeletonHtml();
  9943. _this.scroller = new core.ScrollComponent('hidden', // overflow x
  9944. 'auto' // overflow y
  9945. );
  9946. var dayGridContainerEl = _this.scroller.el;
  9947. _this.el.querySelector('.fc-body > tr > td').appendChild(dayGridContainerEl);
  9948. dayGridContainerEl.classList.add('fc-day-grid-container');
  9949. var dayGridEl = core.createElement('div', { className: 'fc-day-grid' });
  9950. dayGridContainerEl.appendChild(dayGridEl);
  9951. var cellWeekNumbersVisible;
  9952. if (_this.opt('weekNumbers')) {
  9953. if (_this.opt('weekNumbersWithinDays')) {
  9954. cellWeekNumbersVisible = true;
  9955. _this.colWeekNumbersVisible = false;
  9956. }
  9957. else {
  9958. cellWeekNumbersVisible = false;
  9959. _this.colWeekNumbersVisible = true;
  9960. }
  9961. }
  9962. else {
  9963. _this.colWeekNumbersVisible = false;
  9964. cellWeekNumbersVisible = false;
  9965. }
  9966. _this.dayGrid = new DayGrid(_this.context, dayGridEl, {
  9967. renderNumberIntroHtml: _this.renderDayGridNumberIntroHtml,
  9968. renderBgIntroHtml: _this.renderDayGridBgIntroHtml,
  9969. renderIntroHtml: _this.renderDayGridIntroHtml,
  9970. colWeekNumbersVisible: _this.colWeekNumbersVisible,
  9971. cellWeekNumbersVisible: cellWeekNumbersVisible
  9972. });
  9973. return _this;
  9974. }
  9975. DayGridView.prototype.destroy = function () {
  9976. _super.prototype.destroy.call(this);
  9977. this.dayGrid.destroy();
  9978. this.scroller.destroy();
  9979. };
  9980. // Builds the HTML skeleton for the view.
  9981. // The day-grid component will render inside of a container defined by this HTML.
  9982. DayGridView.prototype.renderSkeletonHtml = function () {
  9983. var theme = this.theme;
  9984. return '' +
  9985. '<table class="' + theme.getClass('tableGrid') + '">' +
  9986. (this.opt('columnHeader') ?
  9987. '<thead class="fc-head">' +
  9988. '<tr>' +
  9989. '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
  9990. '</tr>' +
  9991. '</thead>' :
  9992. '') +
  9993. '<tbody class="fc-body">' +
  9994. '<tr>' +
  9995. '<td class="' + theme.getClass('widgetContent') + '"></td>' +
  9996. '</tr>' +
  9997. '</tbody>' +
  9998. '</table>';
  9999. };
  10000. // Generates an HTML attribute string for setting the width of the week number column, if it is known
  10001. DayGridView.prototype.weekNumberStyleAttr = function () {
  10002. if (this.weekNumberWidth != null) {
  10003. return 'style="width:' + this.weekNumberWidth + 'px"';
  10004. }
  10005. return '';
  10006. };
  10007. // Determines whether each row should have a constant height
  10008. DayGridView.prototype.hasRigidRows = function () {
  10009. var eventLimit = this.opt('eventLimit');
  10010. return eventLimit && typeof eventLimit !== 'number';
  10011. };
  10012. /* Dimensions
  10013. ------------------------------------------------------------------------------------------------------------------*/
  10014. DayGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  10015. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
  10016. this.dayGrid.updateSize(isResize);
  10017. };
  10018. // Refreshes the horizontal dimensions of the view
  10019. DayGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  10020. var dayGrid = this.dayGrid;
  10021. var eventLimit = this.opt('eventLimit');
  10022. var headRowEl = this.header ? this.header.el : null; // HACK
  10023. var scrollerHeight;
  10024. var scrollbarWidths;
  10025. // hack to give the view some height prior to dayGrid's columns being rendered
  10026. // TODO: separate setting height from scroller VS dayGrid.
  10027. if (!dayGrid.rowEls) {
  10028. if (!isAuto) {
  10029. scrollerHeight = this.computeScrollerHeight(viewHeight);
  10030. this.scroller.setHeight(scrollerHeight);
  10031. }
  10032. return;
  10033. }
  10034. if (this.colWeekNumbersVisible) {
  10035. // Make sure all week number cells running down the side have the same width.
  10036. this.weekNumberWidth = core.matchCellWidths(core.findElements(this.el, '.fc-week-number'));
  10037. }
  10038. // reset all heights to be natural
  10039. this.scroller.clear();
  10040. if (headRowEl) {
  10041. core.uncompensateScroll(headRowEl);
  10042. }
  10043. dayGrid.removeSegPopover(); // kill the "more" popover if displayed
  10044. // is the event limit a constant level number?
  10045. if (eventLimit && typeof eventLimit === 'number') {
  10046. dayGrid.limitRows(eventLimit); // limit the levels first so the height can redistribute after
  10047. }
  10048. // distribute the height to the rows
  10049. // (viewHeight is a "recommended" value if isAuto)
  10050. scrollerHeight = this.computeScrollerHeight(viewHeight);
  10051. this.setGridHeight(scrollerHeight, isAuto);
  10052. // is the event limit dynamically calculated?
  10053. if (eventLimit && typeof eventLimit !== 'number') {
  10054. dayGrid.limitRows(eventLimit); // limit the levels after the grid's row heights have been set
  10055. }
  10056. if (!isAuto) { // should we force dimensions of the scroll container?
  10057. this.scroller.setHeight(scrollerHeight);
  10058. scrollbarWidths = this.scroller.getScrollbarWidths();
  10059. if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
  10060. if (headRowEl) {
  10061. core.compensateScroll(headRowEl, scrollbarWidths);
  10062. }
  10063. // doing the scrollbar compensation might have created text overflow which created more height. redo
  10064. scrollerHeight = this.computeScrollerHeight(viewHeight);
  10065. this.scroller.setHeight(scrollerHeight);
  10066. }
  10067. // guarantees the same scrollbar widths
  10068. this.scroller.lockOverflow(scrollbarWidths);
  10069. }
  10070. };
  10071. // given a desired total height of the view, returns what the height of the scroller should be
  10072. DayGridView.prototype.computeScrollerHeight = function (viewHeight) {
  10073. return viewHeight -
  10074. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  10075. };
  10076. // Sets the height of just the DayGrid component in this view
  10077. DayGridView.prototype.setGridHeight = function (height, isAuto) {
  10078. if (this.opt('monthMode')) {
  10079. // if auto, make the height of each row the height that it would be if there were 6 weeks
  10080. if (isAuto) {
  10081. height *= this.dayGrid.rowCnt / 6;
  10082. }
  10083. core.distributeHeight(this.dayGrid.rowEls, height, !isAuto); // if auto, don't compensate for height-hogging rows
  10084. }
  10085. else {
  10086. if (isAuto) {
  10087. core.undistributeHeight(this.dayGrid.rowEls); // let the rows be their natural height with no expanding
  10088. }
  10089. else {
  10090. core.distributeHeight(this.dayGrid.rowEls, height, true); // true = compensate for height-hogging rows
  10091. }
  10092. }
  10093. };
  10094. /* Scroll
  10095. ------------------------------------------------------------------------------------------------------------------*/
  10096. DayGridView.prototype.computeDateScroll = function (duration) {
  10097. return { top: 0 };
  10098. };
  10099. DayGridView.prototype.queryDateScroll = function () {
  10100. return { top: this.scroller.getScrollTop() };
  10101. };
  10102. DayGridView.prototype.applyDateScroll = function (scroll) {
  10103. if (scroll.top !== undefined) {
  10104. this.scroller.setScrollTop(scroll.top);
  10105. }
  10106. };
  10107. return DayGridView;
  10108. }(core.View));
  10109. DayGridView.prototype.dateProfileGeneratorClass = DayGridDateProfileGenerator;
  10110. var SimpleDayGrid = /** @class */ (function (_super) {
  10111. __extends(SimpleDayGrid, _super);
  10112. function SimpleDayGrid(context, dayGrid) {
  10113. var _this = _super.call(this, context, dayGrid.el) || this;
  10114. _this.slicer = new DayGridSlicer();
  10115. _this.dayGrid = dayGrid;
  10116. context.calendar.registerInteractiveComponent(_this, { el: _this.dayGrid.el });
  10117. return _this;
  10118. }
  10119. SimpleDayGrid.prototype.destroy = function () {
  10120. _super.prototype.destroy.call(this);
  10121. this.calendar.unregisterInteractiveComponent(this);
  10122. };
  10123. SimpleDayGrid.prototype.render = function (props) {
  10124. var dayGrid = this.dayGrid;
  10125. var dateProfile = props.dateProfile, dayTable = props.dayTable;
  10126. dayGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, props.nextDayThreshold, dayGrid, dayTable), { dateProfile: dateProfile, cells: dayTable.cells, isRigid: props.isRigid }));
  10127. };
  10128. SimpleDayGrid.prototype.buildPositionCaches = function () {
  10129. this.dayGrid.buildPositionCaches();
  10130. };
  10131. SimpleDayGrid.prototype.queryHit = function (positionLeft, positionTop) {
  10132. var rawHit = this.dayGrid.positionToHit(positionLeft, positionTop);
  10133. if (rawHit) {
  10134. return {
  10135. component: this.dayGrid,
  10136. dateSpan: rawHit.dateSpan,
  10137. dayEl: rawHit.dayEl,
  10138. rect: {
  10139. left: rawHit.relativeRect.left,
  10140. right: rawHit.relativeRect.right,
  10141. top: rawHit.relativeRect.top,
  10142. bottom: rawHit.relativeRect.bottom
  10143. },
  10144. layer: 0
  10145. };
  10146. }
  10147. };
  10148. return SimpleDayGrid;
  10149. }(core.DateComponent));
  10150. var DayGridSlicer = /** @class */ (function (_super) {
  10151. __extends(DayGridSlicer, _super);
  10152. function DayGridSlicer() {
  10153. return _super !== null && _super.apply(this, arguments) || this;
  10154. }
  10155. DayGridSlicer.prototype.sliceRange = function (dateRange, dayTable) {
  10156. return dayTable.sliceRange(dateRange);
  10157. };
  10158. return DayGridSlicer;
  10159. }(core.Slicer));
  10160. var DayGridView$1 = /** @class */ (function (_super) {
  10161. __extends(DayGridView, _super);
  10162. function DayGridView(_context, viewSpec, dateProfileGenerator, parentEl) {
  10163. var _this = _super.call(this, _context, viewSpec, dateProfileGenerator, parentEl) || this;
  10164. _this.buildDayTable = core.memoize(buildDayTable);
  10165. if (_this.opt('columnHeader')) {
  10166. _this.header = new core.DayHeader(_this.context, _this.el.querySelector('.fc-head-container'));
  10167. }
  10168. _this.simpleDayGrid = new SimpleDayGrid(_this.context, _this.dayGrid);
  10169. return _this;
  10170. }
  10171. DayGridView.prototype.destroy = function () {
  10172. _super.prototype.destroy.call(this);
  10173. if (this.header) {
  10174. this.header.destroy();
  10175. }
  10176. this.simpleDayGrid.destroy();
  10177. };
  10178. DayGridView.prototype.render = function (props) {
  10179. _super.prototype.render.call(this, props);
  10180. var dateProfile = this.props.dateProfile;
  10181. var dayTable = this.dayTable =
  10182. this.buildDayTable(dateProfile, this.dateProfileGenerator);
  10183. if (this.header) {
  10184. this.header.receiveProps({
  10185. dateProfile: dateProfile,
  10186. dates: dayTable.headerDates,
  10187. datesRepDistinctDays: dayTable.rowCnt === 1,
  10188. renderIntroHtml: this.renderHeadIntroHtml
  10189. });
  10190. }
  10191. this.simpleDayGrid.receiveProps({
  10192. dateProfile: dateProfile,
  10193. dayTable: dayTable,
  10194. businessHours: props.businessHours,
  10195. dateSelection: props.dateSelection,
  10196. eventStore: props.eventStore,
  10197. eventUiBases: props.eventUiBases,
  10198. eventSelection: props.eventSelection,
  10199. eventDrag: props.eventDrag,
  10200. eventResize: props.eventResize,
  10201. isRigid: this.hasRigidRows(),
  10202. nextDayThreshold: this.nextDayThreshold
  10203. });
  10204. };
  10205. return DayGridView;
  10206. }(DayGridView));
  10207. function buildDayTable(dateProfile, dateProfileGenerator) {
  10208. var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator);
  10209. return new core.DayTable(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
  10210. }
  10211. var main = core.createPlugin({
  10212. defaultView: 'dayGridMonth',
  10213. views: {
  10214. dayGrid: DayGridView$1,
  10215. dayGridDay: {
  10216. type: 'dayGrid',
  10217. duration: { days: 1 }
  10218. },
  10219. dayGridWeek: {
  10220. type: 'dayGrid',
  10221. duration: { weeks: 1 }
  10222. },
  10223. dayGridMonth: {
  10224. type: 'dayGrid',
  10225. duration: { months: 1 },
  10226. monthMode: true,
  10227. fixedWeekCount: true
  10228. }
  10229. }
  10230. });
  10231. exports.AbstractDayGridView = DayGridView;
  10232. exports.DayBgRow = DayBgRow;
  10233. exports.DayGrid = DayGrid;
  10234. exports.DayGridSlicer = DayGridSlicer;
  10235. exports.DayGridView = DayGridView$1;
  10236. exports.SimpleDayGrid = SimpleDayGrid;
  10237. exports.buildBasicDayTable = buildDayTable;
  10238. exports.default = main;
  10239. Object.defineProperty(exports, '__esModule', { value: true });
  10240. }));
  10241. /*!
  10242. FullCalendar List View Plugin v4.3.0
  10243. Docs & License: https://fullcalendar.io/
  10244. (c) 2019 Adam Shaw
  10245. */
  10246. (function (global, factory) {
  10247. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  10248. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  10249. (global = global || self, factory(global.FullCalendarList = {}, global.FullCalendar));
  10250. }(this, function (exports, core) { 'use strict';
  10251. /*! *****************************************************************************
  10252. Copyright (c) Microsoft Corporation. All rights reserved.
  10253. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  10254. this file except in compliance with the License. You may obtain a copy of the
  10255. License at http://www.apache.org/licenses/LICENSE-2.0
  10256. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  10257. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  10258. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10259. MERCHANTABLITY OR NON-INFRINGEMENT.
  10260. See the Apache Version 2.0 License for specific language governing permissions
  10261. and limitations under the License.
  10262. ***************************************************************************** */
  10263. /* global Reflect, Promise */
  10264. var extendStatics = function(d, b) {
  10265. extendStatics = Object.setPrototypeOf ||
  10266. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10267. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10268. return extendStatics(d, b);
  10269. };
  10270. function __extends(d, b) {
  10271. extendStatics(d, b);
  10272. function __() { this.constructor = d; }
  10273. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10274. }
  10275. var ListEventRenderer = /** @class */ (function (_super) {
  10276. __extends(ListEventRenderer, _super);
  10277. function ListEventRenderer(listView) {
  10278. var _this = _super.call(this, listView.context) || this;
  10279. _this.listView = listView;
  10280. return _this;
  10281. }
  10282. ListEventRenderer.prototype.attachSegs = function (segs) {
  10283. if (!segs.length) {
  10284. this.listView.renderEmptyMessage();
  10285. }
  10286. else {
  10287. this.listView.renderSegList(segs);
  10288. }
  10289. };
  10290. ListEventRenderer.prototype.detachSegs = function () {
  10291. };
  10292. // generates the HTML for a single event row
  10293. ListEventRenderer.prototype.renderSegHtml = function (seg) {
  10294. var _a = this.context, view = _a.view, theme = _a.theme;
  10295. var eventRange = seg.eventRange;
  10296. var eventDef = eventRange.def;
  10297. var eventInstance = eventRange.instance;
  10298. var eventUi = eventRange.ui;
  10299. var url = eventDef.url;
  10300. var classes = ['fc-list-item'].concat(eventUi.classNames);
  10301. var bgColor = eventUi.backgroundColor;
  10302. var timeHtml;
  10303. if (eventDef.allDay) {
  10304. timeHtml = core.getAllDayHtml(view);
  10305. }
  10306. else if (core.isMultiDayRange(eventRange.range)) {
  10307. if (seg.isStart) {
  10308. timeHtml = core.htmlEscape(this._getTimeText(eventInstance.range.start, seg.end, false // allDay
  10309. ));
  10310. }
  10311. else if (seg.isEnd) {
  10312. timeHtml = core.htmlEscape(this._getTimeText(seg.start, eventInstance.range.end, false // allDay
  10313. ));
  10314. }
  10315. else { // inner segment that lasts the whole day
  10316. timeHtml = core.getAllDayHtml(view);
  10317. }
  10318. }
  10319. else {
  10320. // Display the normal time text for the *event's* times
  10321. timeHtml = core.htmlEscape(this.getTimeText(eventRange));
  10322. }
  10323. if (url) {
  10324. classes.push('fc-has-url');
  10325. }
  10326. return '<tr class="' + classes.join(' ') + '">' +
  10327. (this.displayEventTime ?
  10328. '<td class="fc-list-item-time ' + theme.getClass('widgetContent') + '">' +
  10329. (timeHtml || '') +
  10330. '</td>' :
  10331. '') +
  10332. '<td class="fc-list-item-marker ' + theme.getClass('widgetContent') + '">' +
  10333. '<span class="fc-event-dot"' +
  10334. (bgColor ?
  10335. ' style="background-color:' + bgColor + '"' :
  10336. '') +
  10337. '></span>' +
  10338. '</td>' +
  10339. '<td class="fc-list-item-title ' + theme.getClass('widgetContent') + '">' +
  10340. '<a' + (url ? ' href="' + core.htmlEscape(url) + '"' : '') + '>' +
  10341. core.htmlEscape(eventDef.title || '') +
  10342. '</a>' +
  10343. '</td>' +
  10344. '</tr>';
  10345. };
  10346. // like "4:00am"
  10347. ListEventRenderer.prototype.computeEventTimeFormat = function () {
  10348. return {
  10349. hour: 'numeric',
  10350. minute: '2-digit',
  10351. meridiem: 'short'
  10352. };
  10353. };
  10354. return ListEventRenderer;
  10355. }(core.FgEventRenderer));
  10356. /*
  10357. Responsible for the scroller, and forwarding event-related actions into the "grid".
  10358. */
  10359. var ListView = /** @class */ (function (_super) {
  10360. __extends(ListView, _super);
  10361. function ListView(context, viewSpec, dateProfileGenerator, parentEl) {
  10362. var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this;
  10363. _this.computeDateVars = core.memoize(computeDateVars);
  10364. _this.eventStoreToSegs = core.memoize(_this._eventStoreToSegs);
  10365. var eventRenderer = _this.eventRenderer = new ListEventRenderer(_this);
  10366. _this.renderContent = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer));
  10367. _this.el.classList.add('fc-list-view');
  10368. var listViewClassNames = (_this.theme.getClass('listView') || '').split(' '); // wish we didn't have to do this
  10369. for (var _i = 0, listViewClassNames_1 = listViewClassNames; _i < listViewClassNames_1.length; _i++) {
  10370. var listViewClassName = listViewClassNames_1[_i];
  10371. if (listViewClassName) { // in case input was empty string
  10372. _this.el.classList.add(listViewClassName);
  10373. }
  10374. }
  10375. _this.scroller = new core.ScrollComponent('hidden', // overflow x
  10376. 'auto' // overflow y
  10377. );
  10378. _this.el.appendChild(_this.scroller.el);
  10379. _this.contentEl = _this.scroller.el; // shortcut
  10380. context.calendar.registerInteractiveComponent(_this, {
  10381. el: _this.el
  10382. // TODO: make aware that it doesn't do Hits
  10383. });
  10384. return _this;
  10385. }
  10386. ListView.prototype.render = function (props) {
  10387. var _a = this.computeDateVars(props.dateProfile), dayDates = _a.dayDates, dayRanges = _a.dayRanges;
  10388. this.dayDates = dayDates;
  10389. this.renderContent(this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges));
  10390. };
  10391. ListView.prototype.destroy = function () {
  10392. _super.prototype.destroy.call(this);
  10393. this.renderContent.unrender();
  10394. this.scroller.destroy(); // will remove the Grid too
  10395. this.calendar.unregisterInteractiveComponent(this);
  10396. };
  10397. ListView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  10398. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto);
  10399. this.eventRenderer.computeSizes(isResize);
  10400. this.eventRenderer.assignSizes(isResize);
  10401. this.scroller.clear(); // sets height to 'auto' and clears overflow
  10402. if (!isAuto) {
  10403. this.scroller.setHeight(this.computeScrollerHeight(viewHeight));
  10404. }
  10405. };
  10406. ListView.prototype.computeScrollerHeight = function (viewHeight) {
  10407. return viewHeight -
  10408. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  10409. };
  10410. ListView.prototype._eventStoreToSegs = function (eventStore, eventUiBases, dayRanges) {
  10411. return this.eventRangesToSegs(core.sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.nextDayThreshold).fg, dayRanges);
  10412. };
  10413. ListView.prototype.eventRangesToSegs = function (eventRanges, dayRanges) {
  10414. var segs = [];
  10415. for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
  10416. var eventRange = eventRanges_1[_i];
  10417. segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
  10418. }
  10419. return segs;
  10420. };
  10421. ListView.prototype.eventRangeToSegs = function (eventRange, dayRanges) {
  10422. var _a = this, dateEnv = _a.dateEnv, nextDayThreshold = _a.nextDayThreshold;
  10423. var range = eventRange.range;
  10424. var allDay = eventRange.def.allDay;
  10425. var dayIndex;
  10426. var segRange;
  10427. var seg;
  10428. var segs = [];
  10429. for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex++) {
  10430. segRange = core.intersectRanges(range, dayRanges[dayIndex]);
  10431. if (segRange) {
  10432. seg = {
  10433. component: this,
  10434. eventRange: eventRange,
  10435. start: segRange.start,
  10436. end: segRange.end,
  10437. isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
  10438. isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
  10439. dayIndex: dayIndex
  10440. };
  10441. segs.push(seg);
  10442. // detect when range won't go fully into the next day,
  10443. // and mutate the latest seg to the be the end.
  10444. if (!seg.isEnd && !allDay &&
  10445. dayIndex + 1 < dayRanges.length &&
  10446. range.end <
  10447. dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
  10448. seg.end = range.end;
  10449. seg.isEnd = true;
  10450. break;
  10451. }
  10452. }
  10453. }
  10454. return segs;
  10455. };
  10456. ListView.prototype.renderEmptyMessage = function () {
  10457. this.contentEl.innerHTML =
  10458. '<div class="fc-list-empty-wrap2">' + // TODO: try less wraps
  10459. '<div class="fc-list-empty-wrap1">' +
  10460. '<div class="fc-list-empty">' +
  10461. core.htmlEscape(this.opt('noEventsMessage')) +
  10462. '</div>' +
  10463. '</div>' +
  10464. '</div>';
  10465. };
  10466. // called by ListEventRenderer
  10467. ListView.prototype.renderSegList = function (allSegs) {
  10468. var segsByDay = this.groupSegsByDay(allSegs); // sparse array
  10469. var dayIndex;
  10470. var daySegs;
  10471. var i;
  10472. var tableEl = core.htmlToElement('<table class="fc-list-table ' + this.calendar.theme.getClass('tableList') + '"><tbody></tbody></table>');
  10473. var tbodyEl = tableEl.querySelector('tbody');
  10474. for (dayIndex = 0; dayIndex < segsByDay.length; dayIndex++) {
  10475. daySegs = segsByDay[dayIndex];
  10476. if (daySegs) { // sparse array, so might be undefined
  10477. // append a day header
  10478. tbodyEl.appendChild(this.buildDayHeaderRow(this.dayDates[dayIndex]));
  10479. daySegs = this.eventRenderer.sortEventSegs(daySegs);
  10480. for (i = 0; i < daySegs.length; i++) {
  10481. tbodyEl.appendChild(daySegs[i].el); // append event row
  10482. }
  10483. }
  10484. }
  10485. this.contentEl.innerHTML = '';
  10486. this.contentEl.appendChild(tableEl);
  10487. };
  10488. // Returns a sparse array of arrays, segs grouped by their dayIndex
  10489. ListView.prototype.groupSegsByDay = function (segs) {
  10490. var segsByDay = []; // sparse array
  10491. var i;
  10492. var seg;
  10493. for (i = 0; i < segs.length; i++) {
  10494. seg = segs[i];
  10495. (segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = []))
  10496. .push(seg);
  10497. }
  10498. return segsByDay;
  10499. };
  10500. // generates the HTML for the day headers that live amongst the event rows
  10501. ListView.prototype.buildDayHeaderRow = function (dayDate) {
  10502. var dateEnv = this.dateEnv;
  10503. var mainFormat = core.createFormatter(this.opt('listDayFormat')); // TODO: cache
  10504. var altFormat = core.createFormatter(this.opt('listDayAltFormat')); // TODO: cache
  10505. return core.createElement('tr', {
  10506. className: 'fc-list-heading',
  10507. 'data-date': dateEnv.formatIso(dayDate, { omitTime: true })
  10508. }, '<td class="' + (this.calendar.theme.getClass('tableListHeading') ||
  10509. this.calendar.theme.getClass('widgetHeader')) + '" colspan="3">' +
  10510. (mainFormat ?
  10511. core.buildGotoAnchorHtml(this, dayDate, { 'class': 'fc-list-heading-main' }, core.htmlEscape(dateEnv.format(dayDate, mainFormat)) // inner HTML
  10512. ) :
  10513. '') +
  10514. (altFormat ?
  10515. core.buildGotoAnchorHtml(this, dayDate, { 'class': 'fc-list-heading-alt' }, core.htmlEscape(dateEnv.format(dayDate, altFormat)) // inner HTML
  10516. ) :
  10517. '') +
  10518. '</td>');
  10519. };
  10520. return ListView;
  10521. }(core.View));
  10522. ListView.prototype.fgSegSelector = '.fc-list-item'; // which elements accept event actions
  10523. function computeDateVars(dateProfile) {
  10524. var dayStart = core.startOfDay(dateProfile.renderRange.start);
  10525. var viewEnd = dateProfile.renderRange.end;
  10526. var dayDates = [];
  10527. var dayRanges = [];
  10528. while (dayStart < viewEnd) {
  10529. dayDates.push(dayStart);
  10530. dayRanges.push({
  10531. start: dayStart,
  10532. end: core.addDays(dayStart, 1)
  10533. });
  10534. dayStart = core.addDays(dayStart, 1);
  10535. }
  10536. return { dayDates: dayDates, dayRanges: dayRanges };
  10537. }
  10538. var main = core.createPlugin({
  10539. views: {
  10540. list: {
  10541. class: ListView,
  10542. buttonTextKey: 'list',
  10543. listDayFormat: { month: 'long', day: 'numeric', year: 'numeric' } // like "January 1, 2016"
  10544. },
  10545. listDay: {
  10546. type: 'list',
  10547. duration: { days: 1 },
  10548. listDayFormat: { weekday: 'long' } // day-of-week is all we need. full date is probably in header
  10549. },
  10550. listWeek: {
  10551. type: 'list',
  10552. duration: { weeks: 1 },
  10553. listDayFormat: { weekday: 'long' },
  10554. listDayAltFormat: { month: 'long', day: 'numeric', year: 'numeric' }
  10555. },
  10556. listMonth: {
  10557. type: 'list',
  10558. duration: { month: 1 },
  10559. listDayAltFormat: { weekday: 'long' } // day-of-week is nice-to-have
  10560. },
  10561. listYear: {
  10562. type: 'list',
  10563. duration: { year: 1 },
  10564. listDayAltFormat: { weekday: 'long' } // day-of-week is nice-to-have
  10565. }
  10566. }
  10567. });
  10568. exports.ListView = ListView;
  10569. exports.default = main;
  10570. Object.defineProperty(exports, '__esModule', { value: true });
  10571. }));
  10572. /*!
  10573. FullCalendar Time Grid Plugin v4.3.0
  10574. Docs & License: https://fullcalendar.io/
  10575. (c) 2019 Adam Shaw
  10576. */
  10577. (function (global, factory) {
  10578. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core'), require('@fullcalendar/daygrid')) :
  10579. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core', '@fullcalendar/daygrid'], factory) :
  10580. (global = global || self, factory(global.FullCalendarTimeGrid = {}, global.FullCalendar, global.FullCalendarDayGrid));
  10581. }(this, function (exports, core, daygrid) { 'use strict';
  10582. /*! *****************************************************************************
  10583. Copyright (c) Microsoft Corporation. All rights reserved.
  10584. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  10585. this file except in compliance with the License. You may obtain a copy of the
  10586. License at http://www.apache.org/licenses/LICENSE-2.0
  10587. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  10588. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  10589. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10590. MERCHANTABLITY OR NON-INFRINGEMENT.
  10591. See the Apache Version 2.0 License for specific language governing permissions
  10592. and limitations under the License.
  10593. ***************************************************************************** */
  10594. /* global Reflect, Promise */
  10595. var extendStatics = function(d, b) {
  10596. extendStatics = Object.setPrototypeOf ||
  10597. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  10598. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10599. return extendStatics(d, b);
  10600. };
  10601. function __extends(d, b) {
  10602. extendStatics(d, b);
  10603. function __() { this.constructor = d; }
  10604. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10605. }
  10606. var __assign = function() {
  10607. __assign = Object.assign || function __assign(t) {
  10608. for (var s, i = 1, n = arguments.length; i < n; i++) {
  10609. s = arguments[i];
  10610. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  10611. }
  10612. return t;
  10613. };
  10614. return __assign.apply(this, arguments);
  10615. };
  10616. /*
  10617. Only handles foreground segs.
  10618. Does not own rendering. Use for low-level util methods by TimeGrid.
  10619. */
  10620. var TimeGridEventRenderer = /** @class */ (function (_super) {
  10621. __extends(TimeGridEventRenderer, _super);
  10622. function TimeGridEventRenderer(timeGrid) {
  10623. var _this = _super.call(this, timeGrid.context) || this;
  10624. _this.timeGrid = timeGrid;
  10625. _this.fullTimeFormat = core.createFormatter({
  10626. hour: 'numeric',
  10627. minute: '2-digit',
  10628. separator: _this.context.options.defaultRangeSeparator
  10629. });
  10630. return _this;
  10631. }
  10632. // Given an array of foreground segments, render a DOM element for each, computes position,
  10633. // and attaches to the column inner-container elements.
  10634. TimeGridEventRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  10635. var segsByCol = this.timeGrid.groupSegsByCol(segs);
  10636. // order the segs within each column
  10637. // TODO: have groupSegsByCol do this?
  10638. for (var col = 0; col < segsByCol.length; col++) {
  10639. segsByCol[col] = this.sortEventSegs(segsByCol[col]);
  10640. }
  10641. this.segsByCol = segsByCol;
  10642. this.timeGrid.attachSegsByCol(segsByCol, this.timeGrid.fgContainerEls);
  10643. };
  10644. TimeGridEventRenderer.prototype.detachSegs = function (segs) {
  10645. segs.forEach(function (seg) {
  10646. core.removeElement(seg.el);
  10647. });
  10648. this.segsByCol = null;
  10649. };
  10650. TimeGridEventRenderer.prototype.computeSegSizes = function (allSegs) {
  10651. var _a = this, timeGrid = _a.timeGrid, segsByCol = _a.segsByCol;
  10652. var colCnt = timeGrid.colCnt;
  10653. timeGrid.computeSegVerticals(allSegs); // horizontals relies on this
  10654. if (segsByCol) {
  10655. for (var col = 0; col < colCnt; col++) {
  10656. this.computeSegHorizontals(segsByCol[col]); // compute horizontal coordinates, z-index's, and reorder the array
  10657. }
  10658. }
  10659. };
  10660. TimeGridEventRenderer.prototype.assignSegSizes = function (allSegs) {
  10661. var _a = this, timeGrid = _a.timeGrid, segsByCol = _a.segsByCol;
  10662. var colCnt = timeGrid.colCnt;
  10663. timeGrid.assignSegVerticals(allSegs); // horizontals relies on this
  10664. if (segsByCol) {
  10665. for (var col = 0; col < colCnt; col++) {
  10666. this.assignSegCss(segsByCol[col]);
  10667. }
  10668. }
  10669. };
  10670. // Computes a default event time formatting string if `eventTimeFormat` is not explicitly defined
  10671. TimeGridEventRenderer.prototype.computeEventTimeFormat = function () {
  10672. return {
  10673. hour: 'numeric',
  10674. minute: '2-digit',
  10675. meridiem: false
  10676. };
  10677. };
  10678. // Computes a default `displayEventEnd` value if one is not expliclty defined
  10679. TimeGridEventRenderer.prototype.computeDisplayEventEnd = function () {
  10680. return true;
  10681. };
  10682. // Renders the HTML for a single event segment's default rendering
  10683. TimeGridEventRenderer.prototype.renderSegHtml = function (seg, mirrorInfo) {
  10684. var view = this.context.view;
  10685. var eventRange = seg.eventRange;
  10686. var eventDef = eventRange.def;
  10687. var eventUi = eventRange.ui;
  10688. var allDay = eventDef.allDay;
  10689. var isDraggable = view.computeEventDraggable(eventDef, eventUi);
  10690. var isResizableFromStart = seg.isStart && view.computeEventStartResizable(eventDef, eventUi);
  10691. var isResizableFromEnd = seg.isEnd && view.computeEventEndResizable(eventDef, eventUi);
  10692. var classes = this.getSegClasses(seg, isDraggable, isResizableFromStart || isResizableFromEnd, mirrorInfo);
  10693. var skinCss = core.cssToStr(this.getSkinCss(eventUi));
  10694. var timeText;
  10695. var fullTimeText; // more verbose time text. for the print stylesheet
  10696. var startTimeText; // just the start time text
  10697. classes.unshift('fc-time-grid-event');
  10698. // if the event appears to span more than one day...
  10699. if (core.isMultiDayRange(eventRange.range)) {
  10700. // Don't display time text on segments that run entirely through a day.
  10701. // That would appear as midnight-midnight and would look dumb.
  10702. // Otherwise, display the time text for the *segment's* times (like 6pm-midnight or midnight-10am)
  10703. if (seg.isStart || seg.isEnd) {
  10704. var unzonedStart = seg.start;
  10705. var unzonedEnd = seg.end;
  10706. timeText = this._getTimeText(unzonedStart, unzonedEnd, allDay); // TODO: give the timezones
  10707. fullTimeText = this._getTimeText(unzonedStart, unzonedEnd, allDay, this.fullTimeFormat);
  10708. startTimeText = this._getTimeText(unzonedStart, unzonedEnd, allDay, null, false); // displayEnd=false
  10709. }
  10710. }
  10711. else {
  10712. // Display the normal time text for the *event's* times
  10713. timeText = this.getTimeText(eventRange);
  10714. fullTimeText = this.getTimeText(eventRange, this.fullTimeFormat);
  10715. startTimeText = this.getTimeText(eventRange, null, false); // displayEnd=false
  10716. }
  10717. return '<a class="' + classes.join(' ') + '"' +
  10718. (eventDef.url ?
  10719. ' href="' + core.htmlEscape(eventDef.url) + '"' :
  10720. '') +
  10721. (skinCss ?
  10722. ' style="' + skinCss + '"' :
  10723. '') +
  10724. '>' +
  10725. '<div class="fc-content">' +
  10726. (timeText ?
  10727. '<div class="fc-time"' +
  10728. ' data-start="' + core.htmlEscape(startTimeText) + '"' +
  10729. ' data-full="' + core.htmlEscape(fullTimeText) + '"' +
  10730. '>' +
  10731. '<span>' + core.htmlEscape(timeText) + '</span>' +
  10732. '</div>' :
  10733. '') +
  10734. (eventDef.title ?
  10735. '<div class="fc-title">' +
  10736. core.htmlEscape(eventDef.title) +
  10737. '</div>' :
  10738. '') +
  10739. '</div>' +
  10740. /* TODO: write CSS for this
  10741. (isResizableFromStart ?
  10742. '<div class="fc-resizer fc-start-resizer"></div>' :
  10743. ''
  10744. ) +
  10745. */
  10746. (isResizableFromEnd ?
  10747. '<div class="fc-resizer fc-end-resizer"></div>' :
  10748. '') +
  10749. '</a>';
  10750. };
  10751. // Given an array of segments that are all in the same column, sets the backwardCoord and forwardCoord on each.
  10752. // Assumed the segs are already ordered.
  10753. // NOTE: Also reorders the given array by date!
  10754. TimeGridEventRenderer.prototype.computeSegHorizontals = function (segs) {
  10755. var levels;
  10756. var level0;
  10757. var i;
  10758. levels = buildSlotSegLevels(segs);
  10759. computeForwardSlotSegs(levels);
  10760. if ((level0 = levels[0])) {
  10761. for (i = 0; i < level0.length; i++) {
  10762. computeSlotSegPressures(level0[i]);
  10763. }
  10764. for (i = 0; i < level0.length; i++) {
  10765. this.computeSegForwardBack(level0[i], 0, 0);
  10766. }
  10767. }
  10768. };
  10769. // Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
  10770. // from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
  10771. // seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
  10772. //
  10773. // The segment might be part of a "series", which means consecutive segments with the same pressure
  10774. // who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
  10775. // segments behind this one in the current series, and `seriesBackwardCoord` is the starting
  10776. // coordinate of the first segment in the series.
  10777. TimeGridEventRenderer.prototype.computeSegForwardBack = function (seg, seriesBackwardPressure, seriesBackwardCoord) {
  10778. var forwardSegs = seg.forwardSegs;
  10779. var i;
  10780. if (seg.forwardCoord === undefined) { // not already computed
  10781. if (!forwardSegs.length) {
  10782. // if there are no forward segments, this segment should butt up against the edge
  10783. seg.forwardCoord = 1;
  10784. }
  10785. else {
  10786. // sort highest pressure first
  10787. this.sortForwardSegs(forwardSegs);
  10788. // this segment's forwardCoord will be calculated from the backwardCoord of the
  10789. // highest-pressure forward segment.
  10790. this.computeSegForwardBack(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
  10791. seg.forwardCoord = forwardSegs[0].backwardCoord;
  10792. }
  10793. // calculate the backwardCoord from the forwardCoord. consider the series
  10794. seg.backwardCoord = seg.forwardCoord -
  10795. (seg.forwardCoord - seriesBackwardCoord) / // available width for series
  10796. (seriesBackwardPressure + 1); // # of segments in the series
  10797. // use this segment's coordinates to computed the coordinates of the less-pressurized
  10798. // forward segments
  10799. for (i = 0; i < forwardSegs.length; i++) {
  10800. this.computeSegForwardBack(forwardSegs[i], 0, seg.forwardCoord);
  10801. }
  10802. }
  10803. };
  10804. TimeGridEventRenderer.prototype.sortForwardSegs = function (forwardSegs) {
  10805. var objs = forwardSegs.map(buildTimeGridSegCompareObj);
  10806. var specs = [
  10807. // put higher-pressure first
  10808. { field: 'forwardPressure', order: -1 },
  10809. // put segments that are closer to initial edge first (and favor ones with no coords yet)
  10810. { field: 'backwardCoord', order: 1 }
  10811. ].concat(this.context.view.eventOrderSpecs);
  10812. objs.sort(function (obj0, obj1) {
  10813. return core.compareByFieldSpecs(obj0, obj1, specs);
  10814. });
  10815. return objs.map(function (c) {
  10816. return c._seg;
  10817. });
  10818. };
  10819. // Given foreground event segments that have already had their position coordinates computed,
  10820. // assigns position-related CSS values to their elements.
  10821. TimeGridEventRenderer.prototype.assignSegCss = function (segs) {
  10822. for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
  10823. var seg = segs_1[_i];
  10824. core.applyStyle(seg.el, this.generateSegCss(seg));
  10825. if (seg.level > 0) {
  10826. seg.el.classList.add('fc-time-grid-event-inset');
  10827. }
  10828. // if the event is short that the title will be cut off,
  10829. // attach a className that condenses the title into the time area.
  10830. if (seg.eventRange.def.title && seg.bottom - seg.top < 30) {
  10831. seg.el.classList.add('fc-short'); // TODO: "condensed" is a better name
  10832. }
  10833. }
  10834. };
  10835. // Generates an object with CSS properties/values that should be applied to an event segment element.
  10836. // Contains important positioning-related properties that should be applied to any event element, customized or not.
  10837. TimeGridEventRenderer.prototype.generateSegCss = function (seg) {
  10838. var shouldOverlap = this.context.options.slotEventOverlap;
  10839. var backwardCoord = seg.backwardCoord; // the left side if LTR. the right side if RTL. floating-point
  10840. var forwardCoord = seg.forwardCoord; // the right side if LTR. the left side if RTL. floating-point
  10841. var props = this.timeGrid.generateSegVerticalCss(seg); // get top/bottom first
  10842. var isRtl = this.timeGrid.isRtl;
  10843. var left; // amount of space from left edge, a fraction of the total width
  10844. var right; // amount of space from right edge, a fraction of the total width
  10845. if (shouldOverlap) {
  10846. // double the width, but don't go beyond the maximum forward coordinate (1.0)
  10847. forwardCoord = Math.min(1, backwardCoord + (forwardCoord - backwardCoord) * 2);
  10848. }
  10849. if (isRtl) {
  10850. left = 1 - forwardCoord;
  10851. right = backwardCoord;
  10852. }
  10853. else {
  10854. left = backwardCoord;
  10855. right = 1 - forwardCoord;
  10856. }
  10857. props.zIndex = seg.level + 1; // convert from 0-base to 1-based
  10858. props.left = left * 100 + '%';
  10859. props.right = right * 100 + '%';
  10860. if (shouldOverlap && seg.forwardPressure) {
  10861. // add padding to the edge so that forward stacked events don't cover the resizer's icon
  10862. props[isRtl ? 'marginLeft' : 'marginRight'] = 10 * 2; // 10 is a guesstimate of the icon's width
  10863. }
  10864. return props;
  10865. };
  10866. return TimeGridEventRenderer;
  10867. }(core.FgEventRenderer));
  10868. // Builds an array of segments "levels". The first level will be the leftmost tier of segments if the calendar is
  10869. // left-to-right, or the rightmost if the calendar is right-to-left. Assumes the segments are already ordered by date.
  10870. function buildSlotSegLevels(segs) {
  10871. var levels = [];
  10872. var i;
  10873. var seg;
  10874. var j;
  10875. for (i = 0; i < segs.length; i++) {
  10876. seg = segs[i];
  10877. // go through all the levels and stop on the first level where there are no collisions
  10878. for (j = 0; j < levels.length; j++) {
  10879. if (!computeSlotSegCollisions(seg, levels[j]).length) {
  10880. break;
  10881. }
  10882. }
  10883. seg.level = j;
  10884. (levels[j] || (levels[j] = [])).push(seg);
  10885. }
  10886. return levels;
  10887. }
  10888. // For every segment, figure out the other segments that are in subsequent
  10889. // levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
  10890. function computeForwardSlotSegs(levels) {
  10891. var i;
  10892. var level;
  10893. var j;
  10894. var seg;
  10895. var k;
  10896. for (i = 0; i < levels.length; i++) {
  10897. level = levels[i];
  10898. for (j = 0; j < level.length; j++) {
  10899. seg = level[j];
  10900. seg.forwardSegs = [];
  10901. for (k = i + 1; k < levels.length; k++) {
  10902. computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
  10903. }
  10904. }
  10905. }
  10906. }
  10907. // Figure out which path forward (via seg.forwardSegs) results in the longest path until
  10908. // the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
  10909. function computeSlotSegPressures(seg) {
  10910. var forwardSegs = seg.forwardSegs;
  10911. var forwardPressure = 0;
  10912. var i;
  10913. var forwardSeg;
  10914. if (seg.forwardPressure === undefined) { // not already computed
  10915. for (i = 0; i < forwardSegs.length; i++) {
  10916. forwardSeg = forwardSegs[i];
  10917. // figure out the child's maximum forward path
  10918. computeSlotSegPressures(forwardSeg);
  10919. // either use the existing maximum, or use the child's forward pressure
  10920. // plus one (for the forwardSeg itself)
  10921. forwardPressure = Math.max(forwardPressure, 1 + forwardSeg.forwardPressure);
  10922. }
  10923. seg.forwardPressure = forwardPressure;
  10924. }
  10925. }
  10926. // Find all the segments in `otherSegs` that vertically collide with `seg`.
  10927. // Append into an optionally-supplied `results` array and return.
  10928. function computeSlotSegCollisions(seg, otherSegs, results) {
  10929. if (results === void 0) { results = []; }
  10930. for (var i = 0; i < otherSegs.length; i++) {
  10931. if (isSlotSegCollision(seg, otherSegs[i])) {
  10932. results.push(otherSegs[i]);
  10933. }
  10934. }
  10935. return results;
  10936. }
  10937. // Do these segments occupy the same vertical space?
  10938. function isSlotSegCollision(seg1, seg2) {
  10939. return seg1.bottom > seg2.top && seg1.top < seg2.bottom;
  10940. }
  10941. function buildTimeGridSegCompareObj(seg) {
  10942. var obj = core.buildSegCompareObj(seg);
  10943. obj.forwardPressure = seg.forwardPressure;
  10944. obj.backwardCoord = seg.backwardCoord;
  10945. return obj;
  10946. }
  10947. var TimeGridMirrorRenderer = /** @class */ (function (_super) {
  10948. __extends(TimeGridMirrorRenderer, _super);
  10949. function TimeGridMirrorRenderer() {
  10950. return _super !== null && _super.apply(this, arguments) || this;
  10951. }
  10952. TimeGridMirrorRenderer.prototype.attachSegs = function (segs, mirrorInfo) {
  10953. this.segsByCol = this.timeGrid.groupSegsByCol(segs);
  10954. this.timeGrid.attachSegsByCol(this.segsByCol, this.timeGrid.mirrorContainerEls);
  10955. this.sourceSeg = mirrorInfo.sourceSeg;
  10956. };
  10957. TimeGridMirrorRenderer.prototype.generateSegCss = function (seg) {
  10958. var props = _super.prototype.generateSegCss.call(this, seg);
  10959. var sourceSeg = this.sourceSeg;
  10960. if (sourceSeg && sourceSeg.col === seg.col) {
  10961. var sourceSegProps = _super.prototype.generateSegCss.call(this, sourceSeg);
  10962. props.left = sourceSegProps.left;
  10963. props.right = sourceSegProps.right;
  10964. props.marginLeft = sourceSegProps.marginLeft;
  10965. props.marginRight = sourceSegProps.marginRight;
  10966. }
  10967. return props;
  10968. };
  10969. return TimeGridMirrorRenderer;
  10970. }(TimeGridEventRenderer));
  10971. var TimeGridFillRenderer = /** @class */ (function (_super) {
  10972. __extends(TimeGridFillRenderer, _super);
  10973. function TimeGridFillRenderer(timeGrid) {
  10974. var _this = _super.call(this, timeGrid.context) || this;
  10975. _this.timeGrid = timeGrid;
  10976. return _this;
  10977. }
  10978. TimeGridFillRenderer.prototype.attachSegs = function (type, segs) {
  10979. var timeGrid = this.timeGrid;
  10980. var containerEls;
  10981. // TODO: more efficient lookup
  10982. if (type === 'bgEvent') {
  10983. containerEls = timeGrid.bgContainerEls;
  10984. }
  10985. else if (type === 'businessHours') {
  10986. containerEls = timeGrid.businessContainerEls;
  10987. }
  10988. else if (type === 'highlight') {
  10989. containerEls = timeGrid.highlightContainerEls;
  10990. }
  10991. timeGrid.attachSegsByCol(timeGrid.groupSegsByCol(segs), containerEls);
  10992. return segs.map(function (seg) {
  10993. return seg.el;
  10994. });
  10995. };
  10996. TimeGridFillRenderer.prototype.computeSegSizes = function (segs) {
  10997. this.timeGrid.computeSegVerticals(segs);
  10998. };
  10999. TimeGridFillRenderer.prototype.assignSegSizes = function (segs) {
  11000. this.timeGrid.assignSegVerticals(segs);
  11001. };
  11002. return TimeGridFillRenderer;
  11003. }(core.FillRenderer));
  11004. /* A component that renders one or more columns of vertical time slots
  11005. ----------------------------------------------------------------------------------------------------------------------*/
  11006. // potential nice values for the slot-duration and interval-duration
  11007. // from largest to smallest
  11008. var AGENDA_STOCK_SUB_DURATIONS = [
  11009. { hours: 1 },
  11010. { minutes: 30 },
  11011. { minutes: 15 },
  11012. { seconds: 30 },
  11013. { seconds: 15 }
  11014. ];
  11015. var TimeGrid = /** @class */ (function (_super) {
  11016. __extends(TimeGrid, _super);
  11017. function TimeGrid(context, el, renderProps) {
  11018. var _this = _super.call(this, context, el) || this;
  11019. _this.isSlatSizesDirty = false;
  11020. _this.isColSizesDirty = false;
  11021. _this.renderSlats = core.memoizeRendering(_this._renderSlats);
  11022. var eventRenderer = _this.eventRenderer = new TimeGridEventRenderer(_this);
  11023. var fillRenderer = _this.fillRenderer = new TimeGridFillRenderer(_this);
  11024. _this.mirrorRenderer = new TimeGridMirrorRenderer(_this);
  11025. var renderColumns = _this.renderColumns = core.memoizeRendering(_this._renderColumns, _this._unrenderColumns);
  11026. _this.renderBusinessHours = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'businessHours'), fillRenderer.unrender.bind(fillRenderer, 'businessHours'), [renderColumns]);
  11027. _this.renderDateSelection = core.memoizeRendering(_this._renderDateSelection, _this._unrenderDateSelection, [renderColumns]);
  11028. _this.renderFgEvents = core.memoizeRendering(eventRenderer.renderSegs.bind(eventRenderer), eventRenderer.unrender.bind(eventRenderer), [renderColumns]);
  11029. _this.renderBgEvents = core.memoizeRendering(fillRenderer.renderSegs.bind(fillRenderer, 'bgEvent'), fillRenderer.unrender.bind(fillRenderer, 'bgEvent'), [renderColumns]);
  11030. _this.renderEventSelection = core.memoizeRendering(eventRenderer.selectByInstanceId.bind(eventRenderer), eventRenderer.unselectByInstanceId.bind(eventRenderer), [_this.renderFgEvents]);
  11031. _this.renderEventDrag = core.memoizeRendering(_this._renderEventDrag, _this._unrenderEventDrag, [renderColumns]);
  11032. _this.renderEventResize = core.memoizeRendering(_this._renderEventResize, _this._unrenderEventResize, [renderColumns]);
  11033. _this.processOptions();
  11034. el.innerHTML =
  11035. '<div class="fc-bg"></div>' +
  11036. '<div class="fc-slats"></div>' +
  11037. '<hr class="fc-divider ' + _this.theme.getClass('widgetHeader') + '" style="display:none" />';
  11038. _this.rootBgContainerEl = el.querySelector('.fc-bg');
  11039. _this.slatContainerEl = el.querySelector('.fc-slats');
  11040. _this.bottomRuleEl = el.querySelector('.fc-divider');
  11041. _this.renderProps = renderProps;
  11042. return _this;
  11043. }
  11044. /* Options
  11045. ------------------------------------------------------------------------------------------------------------------*/
  11046. // Parses various options into properties of this object
  11047. TimeGrid.prototype.processOptions = function () {
  11048. var slotDuration = this.opt('slotDuration');
  11049. var snapDuration = this.opt('snapDuration');
  11050. var snapsPerSlot;
  11051. var input;
  11052. slotDuration = core.createDuration(slotDuration);
  11053. snapDuration = snapDuration ? core.createDuration(snapDuration) : slotDuration;
  11054. snapsPerSlot = core.wholeDivideDurations(slotDuration, snapDuration);
  11055. if (snapsPerSlot === null) {
  11056. snapDuration = slotDuration;
  11057. snapsPerSlot = 1;
  11058. // TODO: say warning?
  11059. }
  11060. this.slotDuration = slotDuration;
  11061. this.snapDuration = snapDuration;
  11062. this.snapsPerSlot = snapsPerSlot;
  11063. // might be an array value (for TimelineView).
  11064. // if so, getting the most granular entry (the last one probably).
  11065. input = this.opt('slotLabelFormat');
  11066. if (Array.isArray(input)) {
  11067. input = input[input.length - 1];
  11068. }
  11069. this.labelFormat = core.createFormatter(input || {
  11070. hour: 'numeric',
  11071. minute: '2-digit',
  11072. omitZeroMinute: true,
  11073. meridiem: 'short'
  11074. });
  11075. input = this.opt('slotLabelInterval');
  11076. this.labelInterval = input ?
  11077. core.createDuration(input) :
  11078. this.computeLabelInterval(slotDuration);
  11079. };
  11080. // Computes an automatic value for slotLabelInterval
  11081. TimeGrid.prototype.computeLabelInterval = function (slotDuration) {
  11082. var i;
  11083. var labelInterval;
  11084. var slotsPerLabel;
  11085. // find the smallest stock label interval that results in more than one slots-per-label
  11086. for (i = AGENDA_STOCK_SUB_DURATIONS.length - 1; i >= 0; i--) {
  11087. labelInterval = core.createDuration(AGENDA_STOCK_SUB_DURATIONS[i]);
  11088. slotsPerLabel = core.wholeDivideDurations(labelInterval, slotDuration);
  11089. if (slotsPerLabel !== null && slotsPerLabel > 1) {
  11090. return labelInterval;
  11091. }
  11092. }
  11093. return slotDuration; // fall back
  11094. };
  11095. /* Rendering
  11096. ------------------------------------------------------------------------------------------------------------------*/
  11097. TimeGrid.prototype.render = function (props) {
  11098. var cells = props.cells;
  11099. this.colCnt = cells.length;
  11100. this.renderSlats(props.dateProfile);
  11101. this.renderColumns(props.cells, props.dateProfile);
  11102. this.renderBusinessHours(props.businessHourSegs);
  11103. this.renderDateSelection(props.dateSelectionSegs);
  11104. this.renderFgEvents(props.fgEventSegs);
  11105. this.renderBgEvents(props.bgEventSegs);
  11106. this.renderEventSelection(props.eventSelection);
  11107. this.renderEventDrag(props.eventDrag);
  11108. this.renderEventResize(props.eventResize);
  11109. };
  11110. TimeGrid.prototype.destroy = function () {
  11111. _super.prototype.destroy.call(this);
  11112. // should unrender everything else too
  11113. this.renderSlats.unrender();
  11114. this.renderColumns.unrender();
  11115. };
  11116. TimeGrid.prototype.updateSize = function (isResize) {
  11117. var _a = this, fillRenderer = _a.fillRenderer, eventRenderer = _a.eventRenderer, mirrorRenderer = _a.mirrorRenderer;
  11118. if (isResize || this.isSlatSizesDirty) {
  11119. this.buildSlatPositions();
  11120. this.isSlatSizesDirty = false;
  11121. }
  11122. if (isResize || this.isColSizesDirty) {
  11123. this.buildColPositions();
  11124. this.isColSizesDirty = false;
  11125. }
  11126. fillRenderer.computeSizes(isResize);
  11127. eventRenderer.computeSizes(isResize);
  11128. mirrorRenderer.computeSizes(isResize);
  11129. fillRenderer.assignSizes(isResize);
  11130. eventRenderer.assignSizes(isResize);
  11131. mirrorRenderer.assignSizes(isResize);
  11132. };
  11133. TimeGrid.prototype._renderSlats = function (dateProfile) {
  11134. var theme = this.theme;
  11135. this.slatContainerEl.innerHTML =
  11136. '<table class="' + theme.getClass('tableGrid') + '">' +
  11137. this.renderSlatRowHtml(dateProfile) +
  11138. '</table>';
  11139. this.slatEls = core.findElements(this.slatContainerEl, 'tr');
  11140. this.slatPositions = new core.PositionCache(this.el, this.slatEls, false, true // vertical
  11141. );
  11142. this.isSlatSizesDirty = true;
  11143. };
  11144. // Generates the HTML for the horizontal "slats" that run width-wise. Has a time axis on a side. Depends on RTL.
  11145. TimeGrid.prototype.renderSlatRowHtml = function (dateProfile) {
  11146. var _a = this, dateEnv = _a.dateEnv, theme = _a.theme, isRtl = _a.isRtl;
  11147. var html = '';
  11148. var dayStart = core.startOfDay(dateProfile.renderRange.start);
  11149. var slotTime = dateProfile.minTime;
  11150. var slotIterator = core.createDuration(0);
  11151. var slotDate; // will be on the view's first day, but we only care about its time
  11152. var isLabeled;
  11153. var axisHtml;
  11154. // Calculate the time for each slot
  11155. while (core.asRoughMs(slotTime) < core.asRoughMs(dateProfile.maxTime)) {
  11156. slotDate = dateEnv.add(dayStart, slotTime);
  11157. isLabeled = core.wholeDivideDurations(slotIterator, this.labelInterval) !== null;
  11158. axisHtml =
  11159. '<td class="fc-axis fc-time ' + theme.getClass('widgetContent') + '">' +
  11160. (isLabeled ?
  11161. '<span>' + // for matchCellWidths
  11162. core.htmlEscape(dateEnv.format(slotDate, this.labelFormat)) +
  11163. '</span>' :
  11164. '') +
  11165. '</td>';
  11166. html +=
  11167. '<tr data-time="' + core.formatIsoTimeString(slotDate) + '"' +
  11168. (isLabeled ? '' : ' class="fc-minor"') +
  11169. '>' +
  11170. (!isRtl ? axisHtml : '') +
  11171. '<td class="' + theme.getClass('widgetContent') + '"></td>' +
  11172. (isRtl ? axisHtml : '') +
  11173. '</tr>';
  11174. slotTime = core.addDurations(slotTime, this.slotDuration);
  11175. slotIterator = core.addDurations(slotIterator, this.slotDuration);
  11176. }
  11177. return html;
  11178. };
  11179. TimeGrid.prototype._renderColumns = function (cells, dateProfile) {
  11180. var _a = this, theme = _a.theme, dateEnv = _a.dateEnv, view = _a.view;
  11181. var bgRow = new daygrid.DayBgRow(this.context);
  11182. this.rootBgContainerEl.innerHTML =
  11183. '<table class="' + theme.getClass('tableGrid') + '">' +
  11184. bgRow.renderHtml({
  11185. cells: cells,
  11186. dateProfile: dateProfile,
  11187. renderIntroHtml: this.renderProps.renderBgIntroHtml
  11188. }) +
  11189. '</table>';
  11190. this.colEls = core.findElements(this.el, '.fc-day, .fc-disabled-day');
  11191. for (var col = 0; col < this.colCnt; col++) {
  11192. this.publiclyTrigger('dayRender', [
  11193. {
  11194. date: dateEnv.toDate(cells[col].date),
  11195. el: this.colEls[col],
  11196. view: view
  11197. }
  11198. ]);
  11199. }
  11200. if (this.isRtl) {
  11201. this.colEls.reverse();
  11202. }
  11203. this.colPositions = new core.PositionCache(this.el, this.colEls, true, // horizontal
  11204. false);
  11205. this.renderContentSkeleton();
  11206. this.isColSizesDirty = true;
  11207. };
  11208. TimeGrid.prototype._unrenderColumns = function () {
  11209. this.unrenderContentSkeleton();
  11210. };
  11211. /* Content Skeleton
  11212. ------------------------------------------------------------------------------------------------------------------*/
  11213. // Renders the DOM that the view's content will live in
  11214. TimeGrid.prototype.renderContentSkeleton = function () {
  11215. var parts = [];
  11216. var skeletonEl;
  11217. parts.push(this.renderProps.renderIntroHtml());
  11218. for (var i = 0; i < this.colCnt; i++) {
  11219. parts.push('<td>' +
  11220. '<div class="fc-content-col">' +
  11221. '<div class="fc-event-container fc-mirror-container"></div>' +
  11222. '<div class="fc-event-container"></div>' +
  11223. '<div class="fc-highlight-container"></div>' +
  11224. '<div class="fc-bgevent-container"></div>' +
  11225. '<div class="fc-business-container"></div>' +
  11226. '</div>' +
  11227. '</td>');
  11228. }
  11229. if (this.isRtl) {
  11230. parts.reverse();
  11231. }
  11232. skeletonEl = this.contentSkeletonEl = core.htmlToElement('<div class="fc-content-skeleton">' +
  11233. '<table>' +
  11234. '<tr>' + parts.join('') + '</tr>' +
  11235. '</table>' +
  11236. '</div>');
  11237. this.colContainerEls = core.findElements(skeletonEl, '.fc-content-col');
  11238. this.mirrorContainerEls = core.findElements(skeletonEl, '.fc-mirror-container');
  11239. this.fgContainerEls = core.findElements(skeletonEl, '.fc-event-container:not(.fc-mirror-container)');
  11240. this.bgContainerEls = core.findElements(skeletonEl, '.fc-bgevent-container');
  11241. this.highlightContainerEls = core.findElements(skeletonEl, '.fc-highlight-container');
  11242. this.businessContainerEls = core.findElements(skeletonEl, '.fc-business-container');
  11243. if (this.isRtl) {
  11244. this.colContainerEls.reverse();
  11245. this.mirrorContainerEls.reverse();
  11246. this.fgContainerEls.reverse();
  11247. this.bgContainerEls.reverse();
  11248. this.highlightContainerEls.reverse();
  11249. this.businessContainerEls.reverse();
  11250. }
  11251. this.el.appendChild(skeletonEl);
  11252. };
  11253. TimeGrid.prototype.unrenderContentSkeleton = function () {
  11254. core.removeElement(this.contentSkeletonEl);
  11255. };
  11256. // Given a flat array of segments, return an array of sub-arrays, grouped by each segment's col
  11257. TimeGrid.prototype.groupSegsByCol = function (segs) {
  11258. var segsByCol = [];
  11259. var i;
  11260. for (i = 0; i < this.colCnt; i++) {
  11261. segsByCol.push([]);
  11262. }
  11263. for (i = 0; i < segs.length; i++) {
  11264. segsByCol[segs[i].col].push(segs[i]);
  11265. }
  11266. return segsByCol;
  11267. };
  11268. // Given segments grouped by column, insert the segments' elements into a parallel array of container
  11269. // elements, each living within a column.
  11270. TimeGrid.prototype.attachSegsByCol = function (segsByCol, containerEls) {
  11271. var col;
  11272. var segs;
  11273. var i;
  11274. for (col = 0; col < this.colCnt; col++) { // iterate each column grouping
  11275. segs = segsByCol[col];
  11276. for (i = 0; i < segs.length; i++) {
  11277. containerEls[col].appendChild(segs[i].el);
  11278. }
  11279. }
  11280. };
  11281. /* Now Indicator
  11282. ------------------------------------------------------------------------------------------------------------------*/
  11283. TimeGrid.prototype.getNowIndicatorUnit = function () {
  11284. return 'minute'; // will refresh on the minute
  11285. };
  11286. TimeGrid.prototype.renderNowIndicator = function (segs, date) {
  11287. // HACK: if date columns not ready for some reason (scheduler)
  11288. if (!this.colContainerEls) {
  11289. return;
  11290. }
  11291. var top = this.computeDateTop(date);
  11292. var nodes = [];
  11293. var i;
  11294. // render lines within the columns
  11295. for (i = 0; i < segs.length; i++) {
  11296. var lineEl = core.createElement('div', { className: 'fc-now-indicator fc-now-indicator-line' });
  11297. lineEl.style.top = top + 'px';
  11298. this.colContainerEls[segs[i].col].appendChild(lineEl);
  11299. nodes.push(lineEl);
  11300. }
  11301. // render an arrow over the axis
  11302. if (segs.length > 0) { // is the current time in view?
  11303. var arrowEl = core.createElement('div', { className: 'fc-now-indicator fc-now-indicator-arrow' });
  11304. arrowEl.style.top = top + 'px';
  11305. this.contentSkeletonEl.appendChild(arrowEl);
  11306. nodes.push(arrowEl);
  11307. }
  11308. this.nowIndicatorEls = nodes;
  11309. };
  11310. TimeGrid.prototype.unrenderNowIndicator = function () {
  11311. if (this.nowIndicatorEls) {
  11312. this.nowIndicatorEls.forEach(core.removeElement);
  11313. this.nowIndicatorEls = null;
  11314. }
  11315. };
  11316. /* Coordinates
  11317. ------------------------------------------------------------------------------------------------------------------*/
  11318. TimeGrid.prototype.getTotalSlatHeight = function () {
  11319. return this.slatContainerEl.getBoundingClientRect().height;
  11320. };
  11321. // Computes the top coordinate, relative to the bounds of the grid, of the given date.
  11322. // A `startOfDayDate` must be given for avoiding ambiguity over how to treat midnight.
  11323. TimeGrid.prototype.computeDateTop = function (when, startOfDayDate) {
  11324. if (!startOfDayDate) {
  11325. startOfDayDate = core.startOfDay(when);
  11326. }
  11327. return this.computeTimeTop(core.createDuration(when.valueOf() - startOfDayDate.valueOf()));
  11328. };
  11329. // Computes the top coordinate, relative to the bounds of the grid, of the given time (a Duration).
  11330. TimeGrid.prototype.computeTimeTop = function (duration) {
  11331. var len = this.slatEls.length;
  11332. var dateProfile = this.props.dateProfile;
  11333. var slatCoverage = (duration.milliseconds - core.asRoughMs(dateProfile.minTime)) / core.asRoughMs(this.slotDuration); // floating-point value of # of slots covered
  11334. var slatIndex;
  11335. var slatRemainder;
  11336. // compute a floating-point number for how many slats should be progressed through.
  11337. // from 0 to number of slats (inclusive)
  11338. // constrained because minTime/maxTime might be customized.
  11339. slatCoverage = Math.max(0, slatCoverage);
  11340. slatCoverage = Math.min(len, slatCoverage);
  11341. // an integer index of the furthest whole slat
  11342. // from 0 to number slats (*exclusive*, so len-1)
  11343. slatIndex = Math.floor(slatCoverage);
  11344. slatIndex = Math.min(slatIndex, len - 1);
  11345. // how much further through the slatIndex slat (from 0.0-1.0) must be covered in addition.
  11346. // could be 1.0 if slatCoverage is covering *all* the slots
  11347. slatRemainder = slatCoverage - slatIndex;
  11348. return this.slatPositions.tops[slatIndex] +
  11349. this.slatPositions.getHeight(slatIndex) * slatRemainder;
  11350. };
  11351. // For each segment in an array, computes and assigns its top and bottom properties
  11352. TimeGrid.prototype.computeSegVerticals = function (segs) {
  11353. var eventMinHeight = this.opt('timeGridEventMinHeight');
  11354. var i;
  11355. var seg;
  11356. var dayDate;
  11357. for (i = 0; i < segs.length; i++) {
  11358. seg = segs[i];
  11359. dayDate = this.props.cells[seg.col].date;
  11360. seg.top = this.computeDateTop(seg.start, dayDate);
  11361. seg.bottom = Math.max(seg.top + eventMinHeight, this.computeDateTop(seg.end, dayDate));
  11362. }
  11363. };
  11364. // Given segments that already have their top/bottom properties computed, applies those values to
  11365. // the segments' elements.
  11366. TimeGrid.prototype.assignSegVerticals = function (segs) {
  11367. var i;
  11368. var seg;
  11369. for (i = 0; i < segs.length; i++) {
  11370. seg = segs[i];
  11371. core.applyStyle(seg.el, this.generateSegVerticalCss(seg));
  11372. }
  11373. };
  11374. // Generates an object with CSS properties for the top/bottom coordinates of a segment element
  11375. TimeGrid.prototype.generateSegVerticalCss = function (seg) {
  11376. return {
  11377. top: seg.top,
  11378. bottom: -seg.bottom // flipped because needs to be space beyond bottom edge of event container
  11379. };
  11380. };
  11381. /* Sizing
  11382. ------------------------------------------------------------------------------------------------------------------*/
  11383. TimeGrid.prototype.buildPositionCaches = function () {
  11384. this.buildColPositions();
  11385. this.buildSlatPositions();
  11386. };
  11387. TimeGrid.prototype.buildColPositions = function () {
  11388. this.colPositions.build();
  11389. };
  11390. TimeGrid.prototype.buildSlatPositions = function () {
  11391. this.slatPositions.build();
  11392. };
  11393. /* Hit System
  11394. ------------------------------------------------------------------------------------------------------------------*/
  11395. TimeGrid.prototype.positionToHit = function (positionLeft, positionTop) {
  11396. var _a = this, dateEnv = _a.dateEnv, snapsPerSlot = _a.snapsPerSlot, slatPositions = _a.slatPositions, colPositions = _a.colPositions;
  11397. var colIndex = colPositions.leftToIndex(positionLeft);
  11398. var slatIndex = slatPositions.topToIndex(positionTop);
  11399. if (colIndex != null && slatIndex != null) {
  11400. var slatTop = slatPositions.tops[slatIndex];
  11401. var slatHeight = slatPositions.getHeight(slatIndex);
  11402. var partial = (positionTop - slatTop) / slatHeight; // floating point number between 0 and 1
  11403. var localSnapIndex = Math.floor(partial * snapsPerSlot); // the snap # relative to start of slat
  11404. var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
  11405. var dayDate = this.props.cells[colIndex].date;
  11406. var time = core.addDurations(this.props.dateProfile.minTime, core.multiplyDuration(this.snapDuration, snapIndex));
  11407. var start = dateEnv.add(dayDate, time);
  11408. var end = dateEnv.add(start, this.snapDuration);
  11409. return {
  11410. col: colIndex,
  11411. dateSpan: {
  11412. range: { start: start, end: end },
  11413. allDay: false
  11414. },
  11415. dayEl: this.colEls[colIndex],
  11416. relativeRect: {
  11417. left: colPositions.lefts[colIndex],
  11418. right: colPositions.rights[colIndex],
  11419. top: slatTop,
  11420. bottom: slatTop + slatHeight
  11421. }
  11422. };
  11423. }
  11424. };
  11425. /* Event Drag Visualization
  11426. ------------------------------------------------------------------------------------------------------------------*/
  11427. TimeGrid.prototype._renderEventDrag = function (state) {
  11428. if (state) {
  11429. this.eventRenderer.hideByHash(state.affectedInstances);
  11430. if (state.isEvent) {
  11431. this.mirrorRenderer.renderSegs(state.segs, { isDragging: true, sourceSeg: state.sourceSeg });
  11432. }
  11433. else {
  11434. this.fillRenderer.renderSegs('highlight', state.segs);
  11435. }
  11436. }
  11437. };
  11438. TimeGrid.prototype._unrenderEventDrag = function (state) {
  11439. if (state) {
  11440. this.eventRenderer.showByHash(state.affectedInstances);
  11441. this.mirrorRenderer.unrender(state.segs, { isDragging: true, sourceSeg: state.sourceSeg });
  11442. this.fillRenderer.unrender('highlight');
  11443. }
  11444. };
  11445. /* Event Resize Visualization
  11446. ------------------------------------------------------------------------------------------------------------------*/
  11447. TimeGrid.prototype._renderEventResize = function (state) {
  11448. if (state) {
  11449. this.eventRenderer.hideByHash(state.affectedInstances);
  11450. this.mirrorRenderer.renderSegs(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  11451. }
  11452. };
  11453. TimeGrid.prototype._unrenderEventResize = function (state) {
  11454. if (state) {
  11455. this.eventRenderer.showByHash(state.affectedInstances);
  11456. this.mirrorRenderer.unrender(state.segs, { isResizing: true, sourceSeg: state.sourceSeg });
  11457. }
  11458. };
  11459. /* Selection
  11460. ------------------------------------------------------------------------------------------------------------------*/
  11461. // Renders a visual indication of a selection. Overrides the default, which was to simply render a highlight.
  11462. TimeGrid.prototype._renderDateSelection = function (segs) {
  11463. if (segs) {
  11464. if (this.opt('selectMirror')) {
  11465. this.mirrorRenderer.renderSegs(segs, { isSelecting: true });
  11466. }
  11467. else {
  11468. this.fillRenderer.renderSegs('highlight', segs);
  11469. }
  11470. }
  11471. };
  11472. TimeGrid.prototype._unrenderDateSelection = function (segs) {
  11473. this.mirrorRenderer.unrender(segs, { isSelecting: true });
  11474. this.fillRenderer.unrender('highlight');
  11475. };
  11476. return TimeGrid;
  11477. }(core.DateComponent));
  11478. var AllDaySplitter = /** @class */ (function (_super) {
  11479. __extends(AllDaySplitter, _super);
  11480. function AllDaySplitter() {
  11481. return _super !== null && _super.apply(this, arguments) || this;
  11482. }
  11483. AllDaySplitter.prototype.getKeyInfo = function () {
  11484. return {
  11485. allDay: {},
  11486. timed: {}
  11487. };
  11488. };
  11489. AllDaySplitter.prototype.getKeysForDateSpan = function (dateSpan) {
  11490. if (dateSpan.allDay) {
  11491. return ['allDay'];
  11492. }
  11493. else {
  11494. return ['timed'];
  11495. }
  11496. };
  11497. AllDaySplitter.prototype.getKeysForEventDef = function (eventDef) {
  11498. if (!eventDef.allDay) {
  11499. return ['timed'];
  11500. }
  11501. else if (core.hasBgRendering(eventDef)) {
  11502. return ['timed', 'allDay'];
  11503. }
  11504. else {
  11505. return ['allDay'];
  11506. }
  11507. };
  11508. return AllDaySplitter;
  11509. }(core.Splitter));
  11510. var TIMEGRID_ALL_DAY_EVENT_LIMIT = 5;
  11511. var WEEK_HEADER_FORMAT = core.createFormatter({ week: 'short' });
  11512. /* An abstract class for all timegrid-related views. Displays one more columns with time slots running vertically.
  11513. ----------------------------------------------------------------------------------------------------------------------*/
  11514. // Is a manager for the TimeGrid subcomponent and possibly the DayGrid subcomponent (if allDaySlot is on).
  11515. // Responsible for managing width/height.
  11516. var TimeGridView = /** @class */ (function (_super) {
  11517. __extends(TimeGridView, _super);
  11518. function TimeGridView(context, viewSpec, dateProfileGenerator, parentEl) {
  11519. var _this = _super.call(this, context, viewSpec, dateProfileGenerator, parentEl) || this;
  11520. _this.splitter = new AllDaySplitter();
  11521. /* Header Render Methods
  11522. ------------------------------------------------------------------------------------------------------------------*/
  11523. // Generates the HTML that will go before the day-of week header cells
  11524. _this.renderHeadIntroHtml = function () {
  11525. var _a = _this, theme = _a.theme, dateEnv = _a.dateEnv;
  11526. var range = _this.props.dateProfile.renderRange;
  11527. var dayCnt = core.diffDays(range.start, range.end);
  11528. var weekText;
  11529. if (_this.opt('weekNumbers')) {
  11530. weekText = dateEnv.format(range.start, WEEK_HEADER_FORMAT);
  11531. return '' +
  11532. '<th class="fc-axis fc-week-number ' + theme.getClass('widgetHeader') + '" ' + _this.axisStyleAttr() + '>' +
  11533. core.buildGotoAnchorHtml(// aside from link, important for matchCellWidths
  11534. _this, { date: range.start, type: 'week', forceOff: dayCnt > 1 }, core.htmlEscape(weekText) // inner HTML
  11535. ) +
  11536. '</th>';
  11537. }
  11538. else {
  11539. return '<th class="fc-axis ' + theme.getClass('widgetHeader') + '" ' + _this.axisStyleAttr() + '></th>';
  11540. }
  11541. };
  11542. /* Time Grid Render Methods
  11543. ------------------------------------------------------------------------------------------------------------------*/
  11544. // Generates the HTML that goes before the bg of the TimeGrid slot area. Long vertical column.
  11545. _this.renderTimeGridBgIntroHtml = function () {
  11546. var theme = _this.theme;
  11547. return '<td class="fc-axis ' + theme.getClass('widgetContent') + '" ' + _this.axisStyleAttr() + '></td>';
  11548. };
  11549. // Generates the HTML that goes before all other types of cells.
  11550. // Affects content-skeleton, mirror-skeleton, highlight-skeleton for both the time-grid and day-grid.
  11551. _this.renderTimeGridIntroHtml = function () {
  11552. return '<td class="fc-axis" ' + _this.axisStyleAttr() + '></td>';
  11553. };
  11554. /* Day Grid Render Methods
  11555. ------------------------------------------------------------------------------------------------------------------*/
  11556. // Generates the HTML that goes before the all-day cells
  11557. _this.renderDayGridBgIntroHtml = function () {
  11558. var theme = _this.theme;
  11559. return '' +
  11560. '<td class="fc-axis ' + theme.getClass('widgetContent') + '" ' + _this.axisStyleAttr() + '>' +
  11561. '<span>' + // needed for matchCellWidths
  11562. core.getAllDayHtml(_this) +
  11563. '</span>' +
  11564. '</td>';
  11565. };
  11566. // Generates the HTML that goes before all other types of cells.
  11567. // Affects content-skeleton, mirror-skeleton, highlight-skeleton for both the time-grid and day-grid.
  11568. _this.renderDayGridIntroHtml = function () {
  11569. return '<td class="fc-axis" ' + _this.axisStyleAttr() + '></td>';
  11570. };
  11571. _this.el.classList.add('fc-timeGrid-view');
  11572. _this.el.innerHTML = _this.renderSkeletonHtml();
  11573. _this.scroller = new core.ScrollComponent('hidden', // overflow x
  11574. 'auto' // overflow y
  11575. );
  11576. var timeGridWrapEl = _this.scroller.el;
  11577. _this.el.querySelector('.fc-body > tr > td').appendChild(timeGridWrapEl);
  11578. timeGridWrapEl.classList.add('fc-time-grid-container');
  11579. var timeGridEl = core.createElement('div', { className: 'fc-time-grid' });
  11580. timeGridWrapEl.appendChild(timeGridEl);
  11581. _this.timeGrid = new TimeGrid(_this.context, timeGridEl, {
  11582. renderBgIntroHtml: _this.renderTimeGridBgIntroHtml,
  11583. renderIntroHtml: _this.renderTimeGridIntroHtml
  11584. });
  11585. if (_this.opt('allDaySlot')) { // should we display the "all-day" area?
  11586. _this.dayGrid = new daygrid.DayGrid(// the all-day subcomponent of this view
  11587. _this.context, _this.el.querySelector('.fc-day-grid'), {
  11588. renderNumberIntroHtml: _this.renderDayGridIntroHtml,
  11589. renderBgIntroHtml: _this.renderDayGridBgIntroHtml,
  11590. renderIntroHtml: _this.renderDayGridIntroHtml,
  11591. colWeekNumbersVisible: false,
  11592. cellWeekNumbersVisible: false
  11593. });
  11594. // have the day-grid extend it's coordinate area over the <hr> dividing the two grids
  11595. var dividerEl = _this.el.querySelector('.fc-divider');
  11596. _this.dayGrid.bottomCoordPadding = dividerEl.getBoundingClientRect().height;
  11597. }
  11598. return _this;
  11599. }
  11600. TimeGridView.prototype.destroy = function () {
  11601. _super.prototype.destroy.call(this);
  11602. this.timeGrid.destroy();
  11603. if (this.dayGrid) {
  11604. this.dayGrid.destroy();
  11605. }
  11606. this.scroller.destroy();
  11607. };
  11608. /* Rendering
  11609. ------------------------------------------------------------------------------------------------------------------*/
  11610. // Builds the HTML skeleton for the view.
  11611. // The day-grid and time-grid components will render inside containers defined by this HTML.
  11612. TimeGridView.prototype.renderSkeletonHtml = function () {
  11613. var theme = this.theme;
  11614. return '' +
  11615. '<table class="' + theme.getClass('tableGrid') + '">' +
  11616. (this.opt('columnHeader') ?
  11617. '<thead class="fc-head">' +
  11618. '<tr>' +
  11619. '<td class="fc-head-container ' + theme.getClass('widgetHeader') + '">&nbsp;</td>' +
  11620. '</tr>' +
  11621. '</thead>' :
  11622. '') +
  11623. '<tbody class="fc-body">' +
  11624. '<tr>' +
  11625. '<td class="' + theme.getClass('widgetContent') + '">' +
  11626. (this.opt('allDaySlot') ?
  11627. '<div class="fc-day-grid"></div>' +
  11628. '<hr class="fc-divider ' + theme.getClass('widgetHeader') + '" />' :
  11629. '') +
  11630. '</td>' +
  11631. '</tr>' +
  11632. '</tbody>' +
  11633. '</table>';
  11634. };
  11635. /* Now Indicator
  11636. ------------------------------------------------------------------------------------------------------------------*/
  11637. TimeGridView.prototype.getNowIndicatorUnit = function () {
  11638. return this.timeGrid.getNowIndicatorUnit();
  11639. };
  11640. // subclasses should implement
  11641. // renderNowIndicator(date: DateMarker) {
  11642. // }
  11643. TimeGridView.prototype.unrenderNowIndicator = function () {
  11644. this.timeGrid.unrenderNowIndicator();
  11645. };
  11646. /* Dimensions
  11647. ------------------------------------------------------------------------------------------------------------------*/
  11648. TimeGridView.prototype.updateSize = function (isResize, viewHeight, isAuto) {
  11649. _super.prototype.updateSize.call(this, isResize, viewHeight, isAuto); // will call updateBaseSize. important that executes first
  11650. this.timeGrid.updateSize(isResize);
  11651. if (this.dayGrid) {
  11652. this.dayGrid.updateSize(isResize);
  11653. }
  11654. };
  11655. // Adjusts the vertical dimensions of the view to the specified values
  11656. TimeGridView.prototype.updateBaseSize = function (isResize, viewHeight, isAuto) {
  11657. var _this = this;
  11658. var eventLimit;
  11659. var scrollerHeight;
  11660. var scrollbarWidths;
  11661. // make all axis cells line up
  11662. this.axisWidth = core.matchCellWidths(core.findElements(this.el, '.fc-axis'));
  11663. // hack to give the view some height prior to timeGrid's columns being rendered
  11664. // TODO: separate setting height from scroller VS timeGrid.
  11665. if (!this.timeGrid.colEls) {
  11666. if (!isAuto) {
  11667. scrollerHeight = this.computeScrollerHeight(viewHeight);
  11668. this.scroller.setHeight(scrollerHeight);
  11669. }
  11670. return;
  11671. }
  11672. // set of fake row elements that must compensate when scroller has scrollbars
  11673. var noScrollRowEls = core.findElements(this.el, '.fc-row').filter(function (node) {
  11674. return !_this.scroller.el.contains(node);
  11675. });
  11676. // reset all dimensions back to the original state
  11677. this.timeGrid.bottomRuleEl.style.display = 'none'; // will be shown later if this <hr> is necessary
  11678. this.scroller.clear(); // sets height to 'auto' and clears overflow
  11679. noScrollRowEls.forEach(core.uncompensateScroll);
  11680. // limit number of events in the all-day area
  11681. if (this.dayGrid) {
  11682. this.dayGrid.removeSegPopover(); // kill the "more" popover if displayed
  11683. eventLimit = this.opt('eventLimit');
  11684. if (eventLimit && typeof eventLimit !== 'number') {
  11685. eventLimit = TIMEGRID_ALL_DAY_EVENT_LIMIT; // make sure "auto" goes to a real number
  11686. }
  11687. if (eventLimit) {
  11688. this.dayGrid.limitRows(eventLimit);
  11689. }
  11690. }
  11691. if (!isAuto) { // should we force dimensions of the scroll container?
  11692. scrollerHeight = this.computeScrollerHeight(viewHeight);
  11693. this.scroller.setHeight(scrollerHeight);
  11694. scrollbarWidths = this.scroller.getScrollbarWidths();
  11695. if (scrollbarWidths.left || scrollbarWidths.right) { // using scrollbars?
  11696. // make the all-day and header rows lines up
  11697. noScrollRowEls.forEach(function (rowEl) {
  11698. core.compensateScroll(rowEl, scrollbarWidths);
  11699. });
  11700. // the scrollbar compensation might have changed text flow, which might affect height, so recalculate
  11701. // and reapply the desired height to the scroller.
  11702. scrollerHeight = this.computeScrollerHeight(viewHeight);
  11703. this.scroller.setHeight(scrollerHeight);
  11704. }
  11705. // guarantees the same scrollbar widths
  11706. this.scroller.lockOverflow(scrollbarWidths);
  11707. // if there's any space below the slats, show the horizontal rule.
  11708. // this won't cause any new overflow, because lockOverflow already called.
  11709. if (this.timeGrid.getTotalSlatHeight() < scrollerHeight) {
  11710. this.timeGrid.bottomRuleEl.style.display = '';
  11711. }
  11712. }
  11713. };
  11714. // given a desired total height of the view, returns what the height of the scroller should be
  11715. TimeGridView.prototype.computeScrollerHeight = function (viewHeight) {
  11716. return viewHeight -
  11717. core.subtractInnerElHeight(this.el, this.scroller.el); // everything that's NOT the scroller
  11718. };
  11719. /* Scroll
  11720. ------------------------------------------------------------------------------------------------------------------*/
  11721. // Computes the initial pre-configured scroll state prior to allowing the user to change it
  11722. TimeGridView.prototype.computeDateScroll = function (duration) {
  11723. var top = this.timeGrid.computeTimeTop(duration);
  11724. // zoom can give weird floating-point values. rather scroll a little bit further
  11725. top = Math.ceil(top);
  11726. if (top) {
  11727. top++; // to overcome top border that slots beyond the first have. looks better
  11728. }
  11729. return { top: top };
  11730. };
  11731. TimeGridView.prototype.queryDateScroll = function () {
  11732. return { top: this.scroller.getScrollTop() };
  11733. };
  11734. TimeGridView.prototype.applyDateScroll = function (scroll) {
  11735. if (scroll.top !== undefined) {
  11736. this.scroller.setScrollTop(scroll.top);
  11737. }
  11738. };
  11739. // Generates an HTML attribute string for setting the width of the axis, if it is known
  11740. TimeGridView.prototype.axisStyleAttr = function () {
  11741. if (this.axisWidth != null) {
  11742. return 'style="width:' + this.axisWidth + 'px"';
  11743. }
  11744. return '';
  11745. };
  11746. return TimeGridView;
  11747. }(core.View));
  11748. TimeGridView.prototype.usesMinMaxTime = true; // indicates that minTime/maxTime affects rendering
  11749. var SimpleTimeGrid = /** @class */ (function (_super) {
  11750. __extends(SimpleTimeGrid, _super);
  11751. function SimpleTimeGrid(context, timeGrid) {
  11752. var _this = _super.call(this, context, timeGrid.el) || this;
  11753. _this.buildDayRanges = core.memoize(buildDayRanges);
  11754. _this.slicer = new TimeGridSlicer();
  11755. _this.timeGrid = timeGrid;
  11756. context.calendar.registerInteractiveComponent(_this, {
  11757. el: _this.timeGrid.el
  11758. });
  11759. return _this;
  11760. }
  11761. SimpleTimeGrid.prototype.destroy = function () {
  11762. _super.prototype.destroy.call(this);
  11763. this.calendar.unregisterInteractiveComponent(this);
  11764. };
  11765. SimpleTimeGrid.prototype.render = function (props) {
  11766. var dateProfile = props.dateProfile, dayTable = props.dayTable;
  11767. var dayRanges = this.dayRanges = this.buildDayRanges(dayTable, dateProfile, this.dateEnv);
  11768. this.timeGrid.receiveProps(__assign({}, this.slicer.sliceProps(props, dateProfile, null, this.timeGrid, dayRanges), { dateProfile: dateProfile, cells: dayTable.cells[0] }));
  11769. };
  11770. SimpleTimeGrid.prototype.renderNowIndicator = function (date) {
  11771. this.timeGrid.renderNowIndicator(this.slicer.sliceNowDate(date, this.timeGrid, this.dayRanges), date);
  11772. };
  11773. SimpleTimeGrid.prototype.buildPositionCaches = function () {
  11774. this.timeGrid.buildPositionCaches();
  11775. };
  11776. SimpleTimeGrid.prototype.queryHit = function (positionLeft, positionTop) {
  11777. var rawHit = this.timeGrid.positionToHit(positionLeft, positionTop);
  11778. if (rawHit) {
  11779. return {
  11780. component: this.timeGrid,
  11781. dateSpan: rawHit.dateSpan,
  11782. dayEl: rawHit.dayEl,
  11783. rect: {
  11784. left: rawHit.relativeRect.left,
  11785. right: rawHit.relativeRect.right,
  11786. top: rawHit.relativeRect.top,
  11787. bottom: rawHit.relativeRect.bottom
  11788. },
  11789. layer: 0
  11790. };
  11791. }
  11792. };
  11793. return SimpleTimeGrid;
  11794. }(core.DateComponent));
  11795. function buildDayRanges(dayTable, dateProfile, dateEnv) {
  11796. var ranges = [];
  11797. for (var _i = 0, _a = dayTable.headerDates; _i < _a.length; _i++) {
  11798. var date = _a[_i];
  11799. ranges.push({
  11800. start: dateEnv.add(date, dateProfile.minTime),
  11801. end: dateEnv.add(date, dateProfile.maxTime)
  11802. });
  11803. }
  11804. return ranges;
  11805. }
  11806. var TimeGridSlicer = /** @class */ (function (_super) {
  11807. __extends(TimeGridSlicer, _super);
  11808. function TimeGridSlicer() {
  11809. return _super !== null && _super.apply(this, arguments) || this;
  11810. }
  11811. TimeGridSlicer.prototype.sliceRange = function (range, dayRanges) {
  11812. var segs = [];
  11813. for (var col = 0; col < dayRanges.length; col++) {
  11814. var segRange = core.intersectRanges(range, dayRanges[col]);
  11815. if (segRange) {
  11816. segs.push({
  11817. start: segRange.start,
  11818. end: segRange.end,
  11819. isStart: segRange.start.valueOf() === range.start.valueOf(),
  11820. isEnd: segRange.end.valueOf() === range.end.valueOf(),
  11821. col: col
  11822. });
  11823. }
  11824. }
  11825. return segs;
  11826. };
  11827. return TimeGridSlicer;
  11828. }(core.Slicer));
  11829. var TimeGridView$1 = /** @class */ (function (_super) {
  11830. __extends(TimeGridView, _super);
  11831. function TimeGridView(_context, viewSpec, dateProfileGenerator, parentEl) {
  11832. var _this = _super.call(this, _context, viewSpec, dateProfileGenerator, parentEl) || this;
  11833. _this.buildDayTable = core.memoize(buildDayTable);
  11834. if (_this.opt('columnHeader')) {
  11835. _this.header = new core.DayHeader(_this.context, _this.el.querySelector('.fc-head-container'));
  11836. }
  11837. _this.simpleTimeGrid = new SimpleTimeGrid(_this.context, _this.timeGrid);
  11838. if (_this.dayGrid) {
  11839. _this.simpleDayGrid = new daygrid.SimpleDayGrid(_this.context, _this.dayGrid);
  11840. }
  11841. return _this;
  11842. }
  11843. TimeGridView.prototype.destroy = function () {
  11844. _super.prototype.destroy.call(this);
  11845. if (this.header) {
  11846. this.header.destroy();
  11847. }
  11848. this.simpleTimeGrid.destroy();
  11849. if (this.simpleDayGrid) {
  11850. this.simpleDayGrid.destroy();
  11851. }
  11852. };
  11853. TimeGridView.prototype.render = function (props) {
  11854. _super.prototype.render.call(this, props); // for flags for updateSize
  11855. var dateProfile = this.props.dateProfile;
  11856. var dayTable = this.buildDayTable(dateProfile, this.dateProfileGenerator);
  11857. var splitProps = this.splitter.splitProps(props);
  11858. if (this.header) {
  11859. this.header.receiveProps({
  11860. dateProfile: dateProfile,
  11861. dates: dayTable.headerDates,
  11862. datesRepDistinctDays: true,
  11863. renderIntroHtml: this.renderHeadIntroHtml
  11864. });
  11865. }
  11866. this.simpleTimeGrid.receiveProps(__assign({}, splitProps['timed'], { dateProfile: dateProfile,
  11867. dayTable: dayTable }));
  11868. if (this.simpleDayGrid) {
  11869. this.simpleDayGrid.receiveProps(__assign({}, splitProps['allDay'], { dateProfile: dateProfile,
  11870. dayTable: dayTable, nextDayThreshold: this.nextDayThreshold, isRigid: false }));
  11871. }
  11872. };
  11873. TimeGridView.prototype.renderNowIndicator = function (date) {
  11874. this.simpleTimeGrid.renderNowIndicator(date);
  11875. };
  11876. return TimeGridView;
  11877. }(TimeGridView));
  11878. function buildDayTable(dateProfile, dateProfileGenerator) {
  11879. var daySeries = new core.DaySeries(dateProfile.renderRange, dateProfileGenerator);
  11880. return new core.DayTable(daySeries, false);
  11881. }
  11882. var main = core.createPlugin({
  11883. defaultView: 'timeGridWeek',
  11884. views: {
  11885. timeGrid: {
  11886. class: TimeGridView$1,
  11887. allDaySlot: true,
  11888. slotDuration: '00:30:00',
  11889. slotEventOverlap: true // a bad name. confused with overlap/constraint system
  11890. },
  11891. timeGridDay: {
  11892. type: 'timeGrid',
  11893. duration: { days: 1 }
  11894. },
  11895. timeGridWeek: {
  11896. type: 'timeGrid',
  11897. duration: { weeks: 1 }
  11898. }
  11899. }
  11900. });
  11901. exports.AbstractTimeGridView = TimeGridView;
  11902. exports.TimeGrid = TimeGrid;
  11903. exports.TimeGridSlicer = TimeGridSlicer;
  11904. exports.TimeGridView = TimeGridView$1;
  11905. exports.buildDayRanges = buildDayRanges;
  11906. exports.buildDayTable = buildDayTable;
  11907. exports.default = main;
  11908. Object.defineProperty(exports, '__esModule', { value: true });
  11909. }));
  11910. /*!
  11911. FullCalendar Interaction Plugin v4.3.0
  11912. Docs & License: https://fullcalendar.io/
  11913. (c) 2019 Adam Shaw
  11914. */
  11915. (function (global, factory) {
  11916. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  11917. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  11918. (global = global || self, factory(global.FullCalendarInteraction = {}, global.FullCalendar));
  11919. }(this, function (exports, core) { 'use strict';
  11920. /*! *****************************************************************************
  11921. Copyright (c) Microsoft Corporation. All rights reserved.
  11922. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  11923. this file except in compliance with the License. You may obtain a copy of the
  11924. License at http://www.apache.org/licenses/LICENSE-2.0
  11925. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  11926. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  11927. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  11928. MERCHANTABLITY OR NON-INFRINGEMENT.
  11929. See the Apache Version 2.0 License for specific language governing permissions
  11930. and limitations under the License.
  11931. ***************************************************************************** */
  11932. /* global Reflect, Promise */
  11933. var extendStatics = function(d, b) {
  11934. extendStatics = Object.setPrototypeOf ||
  11935. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  11936. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  11937. return extendStatics(d, b);
  11938. };
  11939. function __extends(d, b) {
  11940. extendStatics(d, b);
  11941. function __() { this.constructor = d; }
  11942. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11943. }
  11944. var __assign = function() {
  11945. __assign = Object.assign || function __assign(t) {
  11946. for (var s, i = 1, n = arguments.length; i < n; i++) {
  11947. s = arguments[i];
  11948. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  11949. }
  11950. return t;
  11951. };
  11952. return __assign.apply(this, arguments);
  11953. };
  11954. core.config.touchMouseIgnoreWait = 500;
  11955. var ignoreMouseDepth = 0;
  11956. var listenerCnt = 0;
  11957. var isWindowTouchMoveCancelled = false;
  11958. /*
  11959. Uses a "pointer" abstraction, which monitors UI events for both mouse and touch.
  11960. Tracks when the pointer "drags" on a certain element, meaning down+move+up.
  11961. Also, tracks if there was touch-scrolling.
  11962. Also, can prevent touch-scrolling from happening.
  11963. Also, can fire pointermove events when scrolling happens underneath, even when no real pointer movement.
  11964. emits:
  11965. - pointerdown
  11966. - pointermove
  11967. - pointerup
  11968. */
  11969. var PointerDragging = /** @class */ (function () {
  11970. function PointerDragging(containerEl) {
  11971. var _this = this;
  11972. this.subjectEl = null;
  11973. this.downEl = null;
  11974. // options that can be directly assigned by caller
  11975. this.selector = ''; // will cause subjectEl in all emitted events to be this element
  11976. this.handleSelector = '';
  11977. this.shouldIgnoreMove = false;
  11978. this.shouldWatchScroll = true; // for simulating pointermove on scroll
  11979. // internal states
  11980. this.isDragging = false;
  11981. this.isTouchDragging = false;
  11982. this.wasTouchScroll = false;
  11983. // Mouse
  11984. // ----------------------------------------------------------------------------------------------------
  11985. this.handleMouseDown = function (ev) {
  11986. if (!_this.shouldIgnoreMouse() &&
  11987. isPrimaryMouseButton(ev) &&
  11988. _this.tryStart(ev)) {
  11989. var pev = _this.createEventFromMouse(ev, true);
  11990. _this.emitter.trigger('pointerdown', pev);
  11991. _this.initScrollWatch(pev);
  11992. if (!_this.shouldIgnoreMove) {
  11993. document.addEventListener('mousemove', _this.handleMouseMove);
  11994. }
  11995. document.addEventListener('mouseup', _this.handleMouseUp);
  11996. }
  11997. };
  11998. this.handleMouseMove = function (ev) {
  11999. var pev = _this.createEventFromMouse(ev);
  12000. _this.recordCoords(pev);
  12001. _this.emitter.trigger('pointermove', pev);
  12002. };
  12003. this.handleMouseUp = function (ev) {
  12004. document.removeEventListener('mousemove', _this.handleMouseMove);
  12005. document.removeEventListener('mouseup', _this.handleMouseUp);
  12006. _this.emitter.trigger('pointerup', _this.createEventFromMouse(ev));
  12007. _this.cleanup(); // call last so that pointerup has access to props
  12008. };
  12009. // Touch
  12010. // ----------------------------------------------------------------------------------------------------
  12011. this.handleTouchStart = function (ev) {
  12012. if (_this.tryStart(ev)) {
  12013. _this.isTouchDragging = true;
  12014. var pev = _this.createEventFromTouch(ev, true);
  12015. _this.emitter.trigger('pointerdown', pev);
  12016. _this.initScrollWatch(pev);
  12017. // unlike mouse, need to attach to target, not document
  12018. // https://stackoverflow.com/a/45760014
  12019. var target = ev.target;
  12020. if (!_this.shouldIgnoreMove) {
  12021. target.addEventListener('touchmove', _this.handleTouchMove);
  12022. }
  12023. target.addEventListener('touchend', _this.handleTouchEnd);
  12024. target.addEventListener('touchcancel', _this.handleTouchEnd); // treat it as a touch end
  12025. // attach a handler to get called when ANY scroll action happens on the page.
  12026. // this was impossible to do with normal on/off because 'scroll' doesn't bubble.
  12027. // http://stackoverflow.com/a/32954565/96342
  12028. window.addEventListener('scroll', _this.handleTouchScroll, true // useCapture
  12029. );
  12030. }
  12031. };
  12032. this.handleTouchMove = function (ev) {
  12033. var pev = _this.createEventFromTouch(ev);
  12034. _this.recordCoords(pev);
  12035. _this.emitter.trigger('pointermove', pev);
  12036. };
  12037. this.handleTouchEnd = function (ev) {
  12038. if (_this.isDragging) { // done to guard against touchend followed by touchcancel
  12039. var target = ev.target;
  12040. target.removeEventListener('touchmove', _this.handleTouchMove);
  12041. target.removeEventListener('touchend', _this.handleTouchEnd);
  12042. target.removeEventListener('touchcancel', _this.handleTouchEnd);
  12043. window.removeEventListener('scroll', _this.handleTouchScroll, true); // useCaptured=true
  12044. _this.emitter.trigger('pointerup', _this.createEventFromTouch(ev));
  12045. _this.cleanup(); // call last so that pointerup has access to props
  12046. _this.isTouchDragging = false;
  12047. startIgnoringMouse();
  12048. }
  12049. };
  12050. this.handleTouchScroll = function () {
  12051. _this.wasTouchScroll = true;
  12052. };
  12053. this.handleScroll = function (ev) {
  12054. if (!_this.shouldIgnoreMove) {
  12055. var pageX = (window.pageXOffset - _this.prevScrollX) + _this.prevPageX;
  12056. var pageY = (window.pageYOffset - _this.prevScrollY) + _this.prevPageY;
  12057. _this.emitter.trigger('pointermove', {
  12058. origEvent: ev,
  12059. isTouch: _this.isTouchDragging,
  12060. subjectEl: _this.subjectEl,
  12061. pageX: pageX,
  12062. pageY: pageY,
  12063. deltaX: pageX - _this.origPageX,
  12064. deltaY: pageY - _this.origPageY
  12065. });
  12066. }
  12067. };
  12068. this.containerEl = containerEl;
  12069. this.emitter = new core.EmitterMixin();
  12070. containerEl.addEventListener('mousedown', this.handleMouseDown);
  12071. containerEl.addEventListener('touchstart', this.handleTouchStart, { passive: true });
  12072. listenerCreated();
  12073. }
  12074. PointerDragging.prototype.destroy = function () {
  12075. this.containerEl.removeEventListener('mousedown', this.handleMouseDown);
  12076. this.containerEl.removeEventListener('touchstart', this.handleTouchStart, { passive: true });
  12077. listenerDestroyed();
  12078. };
  12079. PointerDragging.prototype.tryStart = function (ev) {
  12080. var subjectEl = this.querySubjectEl(ev);
  12081. var downEl = ev.target;
  12082. if (subjectEl &&
  12083. (!this.handleSelector || core.elementClosest(downEl, this.handleSelector))) {
  12084. this.subjectEl = subjectEl;
  12085. this.downEl = downEl;
  12086. this.isDragging = true; // do this first so cancelTouchScroll will work
  12087. this.wasTouchScroll = false;
  12088. return true;
  12089. }
  12090. return false;
  12091. };
  12092. PointerDragging.prototype.cleanup = function () {
  12093. isWindowTouchMoveCancelled = false;
  12094. this.isDragging = false;
  12095. this.subjectEl = null;
  12096. this.downEl = null;
  12097. // keep wasTouchScroll around for later access
  12098. this.destroyScrollWatch();
  12099. };
  12100. PointerDragging.prototype.querySubjectEl = function (ev) {
  12101. if (this.selector) {
  12102. return core.elementClosest(ev.target, this.selector);
  12103. }
  12104. else {
  12105. return this.containerEl;
  12106. }
  12107. };
  12108. PointerDragging.prototype.shouldIgnoreMouse = function () {
  12109. return ignoreMouseDepth || this.isTouchDragging;
  12110. };
  12111. // can be called by user of this class, to cancel touch-based scrolling for the current drag
  12112. PointerDragging.prototype.cancelTouchScroll = function () {
  12113. if (this.isDragging) {
  12114. isWindowTouchMoveCancelled = true;
  12115. }
  12116. };
  12117. // Scrolling that simulates pointermoves
  12118. // ----------------------------------------------------------------------------------------------------
  12119. PointerDragging.prototype.initScrollWatch = function (ev) {
  12120. if (this.shouldWatchScroll) {
  12121. this.recordCoords(ev);
  12122. window.addEventListener('scroll', this.handleScroll, true); // useCapture=true
  12123. }
  12124. };
  12125. PointerDragging.prototype.recordCoords = function (ev) {
  12126. if (this.shouldWatchScroll) {
  12127. this.prevPageX = ev.pageX;
  12128. this.prevPageY = ev.pageY;
  12129. this.prevScrollX = window.pageXOffset;
  12130. this.prevScrollY = window.pageYOffset;
  12131. }
  12132. };
  12133. PointerDragging.prototype.destroyScrollWatch = function () {
  12134. if (this.shouldWatchScroll) {
  12135. window.removeEventListener('scroll', this.handleScroll, true); // useCaptured=true
  12136. }
  12137. };
  12138. // Event Normalization
  12139. // ----------------------------------------------------------------------------------------------------
  12140. PointerDragging.prototype.createEventFromMouse = function (ev, isFirst) {
  12141. var deltaX = 0;
  12142. var deltaY = 0;
  12143. // TODO: repeat code
  12144. if (isFirst) {
  12145. this.origPageX = ev.pageX;
  12146. this.origPageY = ev.pageY;
  12147. }
  12148. else {
  12149. deltaX = ev.pageX - this.origPageX;
  12150. deltaY = ev.pageY - this.origPageY;
  12151. }
  12152. return {
  12153. origEvent: ev,
  12154. isTouch: false,
  12155. subjectEl: this.subjectEl,
  12156. pageX: ev.pageX,
  12157. pageY: ev.pageY,
  12158. deltaX: deltaX,
  12159. deltaY: deltaY
  12160. };
  12161. };
  12162. PointerDragging.prototype.createEventFromTouch = function (ev, isFirst) {
  12163. var touches = ev.touches;
  12164. var pageX;
  12165. var pageY;
  12166. var deltaX = 0;
  12167. var deltaY = 0;
  12168. // if touch coords available, prefer,
  12169. // because FF would give bad ev.pageX ev.pageY
  12170. if (touches && touches.length) {
  12171. pageX = touches[0].pageX;
  12172. pageY = touches[0].pageY;
  12173. }
  12174. else {
  12175. pageX = ev.pageX;
  12176. pageY = ev.pageY;
  12177. }
  12178. // TODO: repeat code
  12179. if (isFirst) {
  12180. this.origPageX = pageX;
  12181. this.origPageY = pageY;
  12182. }
  12183. else {
  12184. deltaX = pageX - this.origPageX;
  12185. deltaY = pageY - this.origPageY;
  12186. }
  12187. return {
  12188. origEvent: ev,
  12189. isTouch: true,
  12190. subjectEl: this.subjectEl,
  12191. pageX: pageX,
  12192. pageY: pageY,
  12193. deltaX: deltaX,
  12194. deltaY: deltaY
  12195. };
  12196. };
  12197. return PointerDragging;
  12198. }());
  12199. // Returns a boolean whether this was a left mouse click and no ctrl key (which means right click on Mac)
  12200. function isPrimaryMouseButton(ev) {
  12201. return ev.button === 0 && !ev.ctrlKey;
  12202. }
  12203. // Ignoring fake mouse events generated by touch
  12204. // ----------------------------------------------------------------------------------------------------
  12205. function startIgnoringMouse() {
  12206. ignoreMouseDepth++;
  12207. setTimeout(function () {
  12208. ignoreMouseDepth--;
  12209. }, core.config.touchMouseIgnoreWait);
  12210. }
  12211. // We want to attach touchmove as early as possible for Safari
  12212. // ----------------------------------------------------------------------------------------------------
  12213. function listenerCreated() {
  12214. if (!(listenerCnt++)) {
  12215. window.addEventListener('touchmove', onWindowTouchMove, { passive: false });
  12216. }
  12217. }
  12218. function listenerDestroyed() {
  12219. if (!(--listenerCnt)) {
  12220. window.removeEventListener('touchmove', onWindowTouchMove, { passive: false });
  12221. }
  12222. }
  12223. function onWindowTouchMove(ev) {
  12224. if (isWindowTouchMoveCancelled) {
  12225. ev.preventDefault();
  12226. }
  12227. }
  12228. /*
  12229. An effect in which an element follows the movement of a pointer across the screen.
  12230. The moving element is a clone of some other element.
  12231. Must call start + handleMove + stop.
  12232. */
  12233. var ElementMirror = /** @class */ (function () {
  12234. function ElementMirror() {
  12235. this.isVisible = false; // must be explicitly enabled
  12236. this.sourceEl = null;
  12237. this.mirrorEl = null;
  12238. this.sourceElRect = null; // screen coords relative to viewport
  12239. // options that can be set directly by caller
  12240. this.parentNode = document.body;
  12241. this.zIndex = 9999;
  12242. this.revertDuration = 0;
  12243. }
  12244. ElementMirror.prototype.start = function (sourceEl, pageX, pageY) {
  12245. this.sourceEl = sourceEl;
  12246. this.sourceElRect = this.sourceEl.getBoundingClientRect();
  12247. this.origScreenX = pageX - window.pageXOffset;
  12248. this.origScreenY = pageY - window.pageYOffset;
  12249. this.deltaX = 0;
  12250. this.deltaY = 0;
  12251. this.updateElPosition();
  12252. };
  12253. ElementMirror.prototype.handleMove = function (pageX, pageY) {
  12254. this.deltaX = (pageX - window.pageXOffset) - this.origScreenX;
  12255. this.deltaY = (pageY - window.pageYOffset) - this.origScreenY;
  12256. this.updateElPosition();
  12257. };
  12258. // can be called before start
  12259. ElementMirror.prototype.setIsVisible = function (bool) {
  12260. if (bool) {
  12261. if (!this.isVisible) {
  12262. if (this.mirrorEl) {
  12263. this.mirrorEl.style.display = '';
  12264. }
  12265. this.isVisible = bool; // needs to happen before updateElPosition
  12266. this.updateElPosition(); // because was not updating the position while invisible
  12267. }
  12268. }
  12269. else {
  12270. if (this.isVisible) {
  12271. if (this.mirrorEl) {
  12272. this.mirrorEl.style.display = 'none';
  12273. }
  12274. this.isVisible = bool;
  12275. }
  12276. }
  12277. };
  12278. // always async
  12279. ElementMirror.prototype.stop = function (needsRevertAnimation, callback) {
  12280. var _this = this;
  12281. var done = function () {
  12282. _this.cleanup();
  12283. callback();
  12284. };
  12285. if (needsRevertAnimation &&
  12286. this.mirrorEl &&
  12287. this.isVisible &&
  12288. this.revertDuration && // if 0, transition won't work
  12289. (this.deltaX || this.deltaY) // if same coords, transition won't work
  12290. ) {
  12291. this.doRevertAnimation(done, this.revertDuration);
  12292. }
  12293. else {
  12294. setTimeout(done, 0);
  12295. }
  12296. };
  12297. ElementMirror.prototype.doRevertAnimation = function (callback, revertDuration) {
  12298. var mirrorEl = this.mirrorEl;
  12299. var finalSourceElRect = this.sourceEl.getBoundingClientRect(); // because autoscrolling might have happened
  12300. mirrorEl.style.transition =
  12301. 'top ' + revertDuration + 'ms,' +
  12302. 'left ' + revertDuration + 'ms';
  12303. core.applyStyle(mirrorEl, {
  12304. left: finalSourceElRect.left,
  12305. top: finalSourceElRect.top
  12306. });
  12307. core.whenTransitionDone(mirrorEl, function () {
  12308. mirrorEl.style.transition = '';
  12309. callback();
  12310. });
  12311. };
  12312. ElementMirror.prototype.cleanup = function () {
  12313. if (this.mirrorEl) {
  12314. core.removeElement(this.mirrorEl);
  12315. this.mirrorEl = null;
  12316. }
  12317. this.sourceEl = null;
  12318. };
  12319. ElementMirror.prototype.updateElPosition = function () {
  12320. if (this.sourceEl && this.isVisible) {
  12321. core.applyStyle(this.getMirrorEl(), {
  12322. left: this.sourceElRect.left + this.deltaX,
  12323. top: this.sourceElRect.top + this.deltaY
  12324. });
  12325. }
  12326. };
  12327. ElementMirror.prototype.getMirrorEl = function () {
  12328. var sourceElRect = this.sourceElRect;
  12329. var mirrorEl = this.mirrorEl;
  12330. if (!mirrorEl) {
  12331. mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true); // cloneChildren=true
  12332. // we don't want long taps or any mouse interaction causing selection/menus.
  12333. // would use preventSelection(), but that prevents selectstart, causing problems.
  12334. mirrorEl.classList.add('fc-unselectable');
  12335. mirrorEl.classList.add('fc-dragging');
  12336. core.applyStyle(mirrorEl, {
  12337. position: 'fixed',
  12338. zIndex: this.zIndex,
  12339. visibility: '',
  12340. boxSizing: 'border-box',
  12341. width: sourceElRect.right - sourceElRect.left,
  12342. height: sourceElRect.bottom - sourceElRect.top,
  12343. right: 'auto',
  12344. bottom: 'auto',
  12345. margin: 0
  12346. });
  12347. this.parentNode.appendChild(mirrorEl);
  12348. }
  12349. return mirrorEl;
  12350. };
  12351. return ElementMirror;
  12352. }());
  12353. /*
  12354. Is a cache for a given element's scroll information (all the info that ScrollController stores)
  12355. in addition the "client rectangle" of the element.. the area within the scrollbars.
  12356. The cache can be in one of two modes:
  12357. - doesListening:false - ignores when the container is scrolled by someone else
  12358. - doesListening:true - watch for scrolling and update the cache
  12359. */
  12360. var ScrollGeomCache = /** @class */ (function (_super) {
  12361. __extends(ScrollGeomCache, _super);
  12362. function ScrollGeomCache(scrollController, doesListening) {
  12363. var _this = _super.call(this) || this;
  12364. _this.handleScroll = function () {
  12365. _this.scrollTop = _this.scrollController.getScrollTop();
  12366. _this.scrollLeft = _this.scrollController.getScrollLeft();
  12367. _this.handleScrollChange();
  12368. };
  12369. _this.scrollController = scrollController;
  12370. _this.doesListening = doesListening;
  12371. _this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
  12372. _this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
  12373. _this.scrollWidth = scrollController.getScrollWidth();
  12374. _this.scrollHeight = scrollController.getScrollHeight();
  12375. _this.clientWidth = scrollController.getClientWidth();
  12376. _this.clientHeight = scrollController.getClientHeight();
  12377. _this.clientRect = _this.computeClientRect(); // do last in case it needs cached values
  12378. if (_this.doesListening) {
  12379. _this.getEventTarget().addEventListener('scroll', _this.handleScroll);
  12380. }
  12381. return _this;
  12382. }
  12383. ScrollGeomCache.prototype.destroy = function () {
  12384. if (this.doesListening) {
  12385. this.getEventTarget().removeEventListener('scroll', this.handleScroll);
  12386. }
  12387. };
  12388. ScrollGeomCache.prototype.getScrollTop = function () {
  12389. return this.scrollTop;
  12390. };
  12391. ScrollGeomCache.prototype.getScrollLeft = function () {
  12392. return this.scrollLeft;
  12393. };
  12394. ScrollGeomCache.prototype.setScrollTop = function (top) {
  12395. this.scrollController.setScrollTop(top);
  12396. if (!this.doesListening) {
  12397. // we are not relying on the element to normalize out-of-bounds scroll values
  12398. // so we need to sanitize ourselves
  12399. this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
  12400. this.handleScrollChange();
  12401. }
  12402. };
  12403. ScrollGeomCache.prototype.setScrollLeft = function (top) {
  12404. this.scrollController.setScrollLeft(top);
  12405. if (!this.doesListening) {
  12406. // we are not relying on the element to normalize out-of-bounds scroll values
  12407. // so we need to sanitize ourselves
  12408. this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
  12409. this.handleScrollChange();
  12410. }
  12411. };
  12412. ScrollGeomCache.prototype.getClientWidth = function () {
  12413. return this.clientWidth;
  12414. };
  12415. ScrollGeomCache.prototype.getClientHeight = function () {
  12416. return this.clientHeight;
  12417. };
  12418. ScrollGeomCache.prototype.getScrollWidth = function () {
  12419. return this.scrollWidth;
  12420. };
  12421. ScrollGeomCache.prototype.getScrollHeight = function () {
  12422. return this.scrollHeight;
  12423. };
  12424. ScrollGeomCache.prototype.handleScrollChange = function () {
  12425. };
  12426. return ScrollGeomCache;
  12427. }(core.ScrollController));
  12428. var ElementScrollGeomCache = /** @class */ (function (_super) {
  12429. __extends(ElementScrollGeomCache, _super);
  12430. function ElementScrollGeomCache(el, doesListening) {
  12431. return _super.call(this, new core.ElementScrollController(el), doesListening) || this;
  12432. }
  12433. ElementScrollGeomCache.prototype.getEventTarget = function () {
  12434. return this.scrollController.el;
  12435. };
  12436. ElementScrollGeomCache.prototype.computeClientRect = function () {
  12437. return core.computeInnerRect(this.scrollController.el);
  12438. };
  12439. return ElementScrollGeomCache;
  12440. }(ScrollGeomCache));
  12441. var WindowScrollGeomCache = /** @class */ (function (_super) {
  12442. __extends(WindowScrollGeomCache, _super);
  12443. function WindowScrollGeomCache(doesListening) {
  12444. return _super.call(this, new core.WindowScrollController(), doesListening) || this;
  12445. }
  12446. WindowScrollGeomCache.prototype.getEventTarget = function () {
  12447. return window;
  12448. };
  12449. WindowScrollGeomCache.prototype.computeClientRect = function () {
  12450. return {
  12451. left: this.scrollLeft,
  12452. right: this.scrollLeft + this.clientWidth,
  12453. top: this.scrollTop,
  12454. bottom: this.scrollTop + this.clientHeight
  12455. };
  12456. };
  12457. // the window is the only scroll object that changes it's rectangle relative
  12458. // to the document's topleft as it scrolls
  12459. WindowScrollGeomCache.prototype.handleScrollChange = function () {
  12460. this.clientRect = this.computeClientRect();
  12461. };
  12462. return WindowScrollGeomCache;
  12463. }(ScrollGeomCache));
  12464. // If available we are using native "performance" API instead of "Date"
  12465. // Read more about it on MDN:
  12466. // https://developer.mozilla.org/en-US/docs/Web/API/Performance
  12467. var getTime = typeof performance === 'function' ? performance.now : Date.now;
  12468. /*
  12469. For a pointer interaction, automatically scrolls certain scroll containers when the pointer
  12470. approaches the edge.
  12471. The caller must call start + handleMove + stop.
  12472. */
  12473. var AutoScroller = /** @class */ (function () {
  12474. function AutoScroller() {
  12475. var _this = this;
  12476. // options that can be set by caller
  12477. this.isEnabled = true;
  12478. this.scrollQuery = [window, '.fc-scroller'];
  12479. this.edgeThreshold = 50; // pixels
  12480. this.maxVelocity = 300; // pixels per second
  12481. // internal state
  12482. this.pointerScreenX = null;
  12483. this.pointerScreenY = null;
  12484. this.isAnimating = false;
  12485. this.scrollCaches = null;
  12486. // protect against the initial pointerdown being too close to an edge and starting the scroll
  12487. this.everMovedUp = false;
  12488. this.everMovedDown = false;
  12489. this.everMovedLeft = false;
  12490. this.everMovedRight = false;
  12491. this.animate = function () {
  12492. if (_this.isAnimating) { // wasn't cancelled between animation calls
  12493. var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
  12494. if (edge) {
  12495. var now = getTime();
  12496. _this.handleSide(edge, (now - _this.msSinceRequest) / 1000);
  12497. _this.requestAnimation(now);
  12498. }
  12499. else {
  12500. _this.isAnimating = false; // will stop animation
  12501. }
  12502. }
  12503. };
  12504. }
  12505. AutoScroller.prototype.start = function (pageX, pageY) {
  12506. if (this.isEnabled) {
  12507. this.scrollCaches = this.buildCaches();
  12508. this.pointerScreenX = null;
  12509. this.pointerScreenY = null;
  12510. this.everMovedUp = false;
  12511. this.everMovedDown = false;
  12512. this.everMovedLeft = false;
  12513. this.everMovedRight = false;
  12514. this.handleMove(pageX, pageY);
  12515. }
  12516. };
  12517. AutoScroller.prototype.handleMove = function (pageX, pageY) {
  12518. if (this.isEnabled) {
  12519. var pointerScreenX = pageX - window.pageXOffset;
  12520. var pointerScreenY = pageY - window.pageYOffset;
  12521. var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
  12522. var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
  12523. if (yDelta < 0) {
  12524. this.everMovedUp = true;
  12525. }
  12526. else if (yDelta > 0) {
  12527. this.everMovedDown = true;
  12528. }
  12529. if (xDelta < 0) {
  12530. this.everMovedLeft = true;
  12531. }
  12532. else if (xDelta > 0) {
  12533. this.everMovedRight = true;
  12534. }
  12535. this.pointerScreenX = pointerScreenX;
  12536. this.pointerScreenY = pointerScreenY;
  12537. if (!this.isAnimating) {
  12538. this.isAnimating = true;
  12539. this.requestAnimation(getTime());
  12540. }
  12541. }
  12542. };
  12543. AutoScroller.prototype.stop = function () {
  12544. if (this.isEnabled) {
  12545. this.isAnimating = false; // will stop animation
  12546. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12547. var scrollCache = _a[_i];
  12548. scrollCache.destroy();
  12549. }
  12550. this.scrollCaches = null;
  12551. }
  12552. };
  12553. AutoScroller.prototype.requestAnimation = function (now) {
  12554. this.msSinceRequest = now;
  12555. requestAnimationFrame(this.animate);
  12556. };
  12557. AutoScroller.prototype.handleSide = function (edge, seconds) {
  12558. var scrollCache = edge.scrollCache;
  12559. var edgeThreshold = this.edgeThreshold;
  12560. var invDistance = edgeThreshold - edge.distance;
  12561. var velocity = // the closer to the edge, the faster we scroll
  12562. (invDistance * invDistance) / (edgeThreshold * edgeThreshold) * // quadratic
  12563. this.maxVelocity * seconds;
  12564. var sign = 1;
  12565. switch (edge.name) {
  12566. case 'left':
  12567. sign = -1;
  12568. // falls through
  12569. case 'right':
  12570. scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
  12571. break;
  12572. case 'top':
  12573. sign = -1;
  12574. // falls through
  12575. case 'bottom':
  12576. scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
  12577. break;
  12578. }
  12579. };
  12580. // left/top are relative to document topleft
  12581. AutoScroller.prototype.computeBestEdge = function (left, top) {
  12582. var edgeThreshold = this.edgeThreshold;
  12583. var bestSide = null;
  12584. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12585. var scrollCache = _a[_i];
  12586. var rect = scrollCache.clientRect;
  12587. var leftDist = left - rect.left;
  12588. var rightDist = rect.right - left;
  12589. var topDist = top - rect.top;
  12590. var bottomDist = rect.bottom - top;
  12591. // completely within the rect?
  12592. if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
  12593. if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() &&
  12594. (!bestSide || bestSide.distance > topDist)) {
  12595. bestSide = { scrollCache: scrollCache, name: 'top', distance: topDist };
  12596. }
  12597. if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() &&
  12598. (!bestSide || bestSide.distance > bottomDist)) {
  12599. bestSide = { scrollCache: scrollCache, name: 'bottom', distance: bottomDist };
  12600. }
  12601. if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() &&
  12602. (!bestSide || bestSide.distance > leftDist)) {
  12603. bestSide = { scrollCache: scrollCache, name: 'left', distance: leftDist };
  12604. }
  12605. if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() &&
  12606. (!bestSide || bestSide.distance > rightDist)) {
  12607. bestSide = { scrollCache: scrollCache, name: 'right', distance: rightDist };
  12608. }
  12609. }
  12610. }
  12611. return bestSide;
  12612. };
  12613. AutoScroller.prototype.buildCaches = function () {
  12614. return this.queryScrollEls().map(function (el) {
  12615. if (el === window) {
  12616. return new WindowScrollGeomCache(false); // false = don't listen to user-generated scrolls
  12617. }
  12618. else {
  12619. return new ElementScrollGeomCache(el, false); // false = don't listen to user-generated scrolls
  12620. }
  12621. });
  12622. };
  12623. AutoScroller.prototype.queryScrollEls = function () {
  12624. var els = [];
  12625. for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
  12626. var query = _a[_i];
  12627. if (typeof query === 'object') {
  12628. els.push(query);
  12629. }
  12630. else {
  12631. els.push.apply(els, Array.prototype.slice.call(document.querySelectorAll(query)));
  12632. }
  12633. }
  12634. return els;
  12635. };
  12636. return AutoScroller;
  12637. }());
  12638. /*
  12639. Monitors dragging on an element. Has a number of high-level features:
  12640. - minimum distance required before dragging
  12641. - minimum wait time ("delay") before dragging
  12642. - a mirror element that follows the pointer
  12643. */
  12644. var FeaturefulElementDragging = /** @class */ (function (_super) {
  12645. __extends(FeaturefulElementDragging, _super);
  12646. function FeaturefulElementDragging(containerEl) {
  12647. var _this = _super.call(this, containerEl) || this;
  12648. // options that can be directly set by caller
  12649. // the caller can also set the PointerDragging's options as well
  12650. _this.delay = null;
  12651. _this.minDistance = 0;
  12652. _this.touchScrollAllowed = true; // prevents drag from starting and blocks scrolling during drag
  12653. _this.mirrorNeedsRevert = false;
  12654. _this.isInteracting = false; // is the user validly moving the pointer? lasts until pointerup
  12655. _this.isDragging = false; // is it INTENTFULLY dragging? lasts until after revert animation
  12656. _this.isDelayEnded = false;
  12657. _this.isDistanceSurpassed = false;
  12658. _this.delayTimeoutId = null;
  12659. _this.onPointerDown = function (ev) {
  12660. if (!_this.isDragging) { // so new drag doesn't happen while revert animation is going
  12661. _this.isInteracting = true;
  12662. _this.isDelayEnded = false;
  12663. _this.isDistanceSurpassed = false;
  12664. core.preventSelection(document.body);
  12665. core.preventContextMenu(document.body);
  12666. // prevent links from being visited if there's an eventual drag.
  12667. // also prevents selection in older browsers (maybe?).
  12668. // not necessary for touch, besides, browser would complain about passiveness.
  12669. if (!ev.isTouch) {
  12670. ev.origEvent.preventDefault();
  12671. }
  12672. _this.emitter.trigger('pointerdown', ev);
  12673. if (!_this.pointer.shouldIgnoreMove) {
  12674. // actions related to initiating dragstart+dragmove+dragend...
  12675. _this.mirror.setIsVisible(false); // reset. caller must set-visible
  12676. _this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY); // must happen on first pointer down
  12677. _this.startDelay(ev);
  12678. if (!_this.minDistance) {
  12679. _this.handleDistanceSurpassed(ev);
  12680. }
  12681. }
  12682. }
  12683. };
  12684. _this.onPointerMove = function (ev) {
  12685. if (_this.isInteracting) { // if false, still waiting for previous drag's revert
  12686. _this.emitter.trigger('pointermove', ev);
  12687. if (!_this.isDistanceSurpassed) {
  12688. var minDistance = _this.minDistance;
  12689. var distanceSq = void 0; // current distance from the origin, squared
  12690. var deltaX = ev.deltaX, deltaY = ev.deltaY;
  12691. distanceSq = deltaX * deltaX + deltaY * deltaY;
  12692. if (distanceSq >= minDistance * minDistance) { // use pythagorean theorem
  12693. _this.handleDistanceSurpassed(ev);
  12694. }
  12695. }
  12696. if (_this.isDragging) {
  12697. // a real pointer move? (not one simulated by scrolling)
  12698. if (ev.origEvent.type !== 'scroll') {
  12699. _this.mirror.handleMove(ev.pageX, ev.pageY);
  12700. _this.autoScroller.handleMove(ev.pageX, ev.pageY);
  12701. }
  12702. _this.emitter.trigger('dragmove', ev);
  12703. }
  12704. }
  12705. };
  12706. _this.onPointerUp = function (ev) {
  12707. if (_this.isInteracting) { // if false, still waiting for previous drag's revert
  12708. _this.isInteracting = false;
  12709. core.allowSelection(document.body);
  12710. core.allowContextMenu(document.body);
  12711. _this.emitter.trigger('pointerup', ev); // can potentially set mirrorNeedsRevert
  12712. if (_this.isDragging) {
  12713. _this.autoScroller.stop();
  12714. _this.tryStopDrag(ev); // which will stop the mirror
  12715. }
  12716. if (_this.delayTimeoutId) {
  12717. clearTimeout(_this.delayTimeoutId);
  12718. _this.delayTimeoutId = null;
  12719. }
  12720. }
  12721. };
  12722. var pointer = _this.pointer = new PointerDragging(containerEl);
  12723. pointer.emitter.on('pointerdown', _this.onPointerDown);
  12724. pointer.emitter.on('pointermove', _this.onPointerMove);
  12725. pointer.emitter.on('pointerup', _this.onPointerUp);
  12726. _this.mirror = new ElementMirror();
  12727. _this.autoScroller = new AutoScroller();
  12728. return _this;
  12729. }
  12730. FeaturefulElementDragging.prototype.destroy = function () {
  12731. this.pointer.destroy();
  12732. };
  12733. FeaturefulElementDragging.prototype.startDelay = function (ev) {
  12734. var _this = this;
  12735. if (typeof this.delay === 'number') {
  12736. this.delayTimeoutId = setTimeout(function () {
  12737. _this.delayTimeoutId = null;
  12738. _this.handleDelayEnd(ev);
  12739. }, this.delay); // not assignable to number!
  12740. }
  12741. else {
  12742. this.handleDelayEnd(ev);
  12743. }
  12744. };
  12745. FeaturefulElementDragging.prototype.handleDelayEnd = function (ev) {
  12746. this.isDelayEnded = true;
  12747. this.tryStartDrag(ev);
  12748. };
  12749. FeaturefulElementDragging.prototype.handleDistanceSurpassed = function (ev) {
  12750. this.isDistanceSurpassed = true;
  12751. this.tryStartDrag(ev);
  12752. };
  12753. FeaturefulElementDragging.prototype.tryStartDrag = function (ev) {
  12754. if (this.isDelayEnded && this.isDistanceSurpassed) {
  12755. if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
  12756. this.isDragging = true;
  12757. this.mirrorNeedsRevert = false;
  12758. this.autoScroller.start(ev.pageX, ev.pageY);
  12759. this.emitter.trigger('dragstart', ev);
  12760. if (this.touchScrollAllowed === false) {
  12761. this.pointer.cancelTouchScroll();
  12762. }
  12763. }
  12764. }
  12765. };
  12766. FeaturefulElementDragging.prototype.tryStopDrag = function (ev) {
  12767. // .stop() is ALWAYS asynchronous, which we NEED because we want all pointerup events
  12768. // that come from the document to fire beforehand. much more convenient this way.
  12769. this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev) // bound with args
  12770. );
  12771. };
  12772. FeaturefulElementDragging.prototype.stopDrag = function (ev) {
  12773. this.isDragging = false;
  12774. this.emitter.trigger('dragend', ev);
  12775. };
  12776. // fill in the implementations...
  12777. FeaturefulElementDragging.prototype.setIgnoreMove = function (bool) {
  12778. this.pointer.shouldIgnoreMove = bool;
  12779. };
  12780. FeaturefulElementDragging.prototype.setMirrorIsVisible = function (bool) {
  12781. this.mirror.setIsVisible(bool);
  12782. };
  12783. FeaturefulElementDragging.prototype.setMirrorNeedsRevert = function (bool) {
  12784. this.mirrorNeedsRevert = bool;
  12785. };
  12786. FeaturefulElementDragging.prototype.setAutoScrollEnabled = function (bool) {
  12787. this.autoScroller.isEnabled = bool;
  12788. };
  12789. return FeaturefulElementDragging;
  12790. }(core.ElementDragging));
  12791. /*
  12792. When this class is instantiated, it records the offset of an element (relative to the document topleft),
  12793. and continues to monitor scrolling, updating the cached coordinates if it needs to.
  12794. Does not access the DOM after instantiation, so highly performant.
  12795. Also keeps track of all scrolling/overflow:hidden containers that are parents of the given element
  12796. and an determine if a given point is inside the combined clipping rectangle.
  12797. */
  12798. var OffsetTracker = /** @class */ (function () {
  12799. function OffsetTracker(el) {
  12800. this.origRect = core.computeRect(el);
  12801. // will work fine for divs that have overflow:hidden
  12802. this.scrollCaches = core.getClippingParents(el).map(function (el) {
  12803. return new ElementScrollGeomCache(el, true); // listen=true
  12804. });
  12805. }
  12806. OffsetTracker.prototype.destroy = function () {
  12807. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12808. var scrollCache = _a[_i];
  12809. scrollCache.destroy();
  12810. }
  12811. };
  12812. OffsetTracker.prototype.computeLeft = function () {
  12813. var left = this.origRect.left;
  12814. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12815. var scrollCache = _a[_i];
  12816. left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
  12817. }
  12818. return left;
  12819. };
  12820. OffsetTracker.prototype.computeTop = function () {
  12821. var top = this.origRect.top;
  12822. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12823. var scrollCache = _a[_i];
  12824. top += scrollCache.origScrollTop - scrollCache.getScrollTop();
  12825. }
  12826. return top;
  12827. };
  12828. OffsetTracker.prototype.isWithinClipping = function (pageX, pageY) {
  12829. var point = { left: pageX, top: pageY };
  12830. for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
  12831. var scrollCache = _a[_i];
  12832. if (!isIgnoredClipping(scrollCache.getEventTarget()) &&
  12833. !core.pointInsideRect(point, scrollCache.clientRect)) {
  12834. return false;
  12835. }
  12836. }
  12837. return true;
  12838. };
  12839. return OffsetTracker;
  12840. }());
  12841. // certain clipping containers should never constrain interactions, like <html> and <body>
  12842. // https://github.com/fullcalendar/fullcalendar/issues/3615
  12843. function isIgnoredClipping(node) {
  12844. var tagName = node.tagName;
  12845. return tagName === 'HTML' || tagName === 'BODY';
  12846. }
  12847. /*
  12848. Tracks movement over multiple droppable areas (aka "hits")
  12849. that exist in one or more DateComponents.
  12850. Relies on an existing draggable.
  12851. emits:
  12852. - pointerdown
  12853. - dragstart
  12854. - hitchange - fires initially, even if not over a hit
  12855. - pointerup
  12856. - (hitchange - again, to null, if ended over a hit)
  12857. - dragend
  12858. */
  12859. var HitDragging = /** @class */ (function () {
  12860. function HitDragging(dragging, droppableStore) {
  12861. var _this = this;
  12862. // options that can be set by caller
  12863. this.useSubjectCenter = false;
  12864. this.requireInitial = true; // if doesn't start out on a hit, won't emit any events
  12865. this.initialHit = null;
  12866. this.movingHit = null;
  12867. this.finalHit = null; // won't ever be populated if shouldIgnoreMove
  12868. this.handlePointerDown = function (ev) {
  12869. var dragging = _this.dragging;
  12870. _this.initialHit = null;
  12871. _this.movingHit = null;
  12872. _this.finalHit = null;
  12873. _this.prepareHits();
  12874. _this.processFirstCoord(ev);
  12875. if (_this.initialHit || !_this.requireInitial) {
  12876. dragging.setIgnoreMove(false);
  12877. _this.emitter.trigger('pointerdown', ev); // TODO: fire this before computing processFirstCoord, so listeners can cancel. this gets fired by almost every handler :(
  12878. }
  12879. else {
  12880. dragging.setIgnoreMove(true);
  12881. }
  12882. };
  12883. this.handleDragStart = function (ev) {
  12884. _this.emitter.trigger('dragstart', ev);
  12885. _this.handleMove(ev, true); // force = fire even if initially null
  12886. };
  12887. this.handleDragMove = function (ev) {
  12888. _this.emitter.trigger('dragmove', ev);
  12889. _this.handleMove(ev);
  12890. };
  12891. this.handlePointerUp = function (ev) {
  12892. _this.releaseHits();
  12893. _this.emitter.trigger('pointerup', ev);
  12894. };
  12895. this.handleDragEnd = function (ev) {
  12896. if (_this.movingHit) {
  12897. _this.emitter.trigger('hitupdate', null, true, ev);
  12898. }
  12899. _this.finalHit = _this.movingHit;
  12900. _this.movingHit = null;
  12901. _this.emitter.trigger('dragend', ev);
  12902. };
  12903. this.droppableStore = droppableStore;
  12904. dragging.emitter.on('pointerdown', this.handlePointerDown);
  12905. dragging.emitter.on('dragstart', this.handleDragStart);
  12906. dragging.emitter.on('dragmove', this.handleDragMove);
  12907. dragging.emitter.on('pointerup', this.handlePointerUp);
  12908. dragging.emitter.on('dragend', this.handleDragEnd);
  12909. this.dragging = dragging;
  12910. this.emitter = new core.EmitterMixin();
  12911. }
  12912. // sets initialHit
  12913. // sets coordAdjust
  12914. HitDragging.prototype.processFirstCoord = function (ev) {
  12915. var origPoint = { left: ev.pageX, top: ev.pageY };
  12916. var adjustedPoint = origPoint;
  12917. var subjectEl = ev.subjectEl;
  12918. var subjectRect;
  12919. if (subjectEl !== document) {
  12920. subjectRect = core.computeRect(subjectEl);
  12921. adjustedPoint = core.constrainPoint(adjustedPoint, subjectRect);
  12922. }
  12923. var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
  12924. if (initialHit) {
  12925. if (this.useSubjectCenter && subjectRect) {
  12926. var slicedSubjectRect = core.intersectRects(subjectRect, initialHit.rect);
  12927. if (slicedSubjectRect) {
  12928. adjustedPoint = core.getRectCenter(slicedSubjectRect);
  12929. }
  12930. }
  12931. this.coordAdjust = core.diffPoints(adjustedPoint, origPoint);
  12932. }
  12933. else {
  12934. this.coordAdjust = { left: 0, top: 0 };
  12935. }
  12936. };
  12937. HitDragging.prototype.handleMove = function (ev, forceHandle) {
  12938. var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
  12939. if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
  12940. this.movingHit = hit;
  12941. this.emitter.trigger('hitupdate', hit, false, ev);
  12942. }
  12943. };
  12944. HitDragging.prototype.prepareHits = function () {
  12945. this.offsetTrackers = core.mapHash(this.droppableStore, function (interactionSettings) {
  12946. interactionSettings.component.buildPositionCaches();
  12947. return new OffsetTracker(interactionSettings.el);
  12948. });
  12949. };
  12950. HitDragging.prototype.releaseHits = function () {
  12951. var offsetTrackers = this.offsetTrackers;
  12952. for (var id in offsetTrackers) {
  12953. offsetTrackers[id].destroy();
  12954. }
  12955. this.offsetTrackers = {};
  12956. };
  12957. HitDragging.prototype.queryHitForOffset = function (offsetLeft, offsetTop) {
  12958. var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
  12959. var bestHit = null;
  12960. for (var id in droppableStore) {
  12961. var component = droppableStore[id].component;
  12962. var offsetTracker = offsetTrackers[id];
  12963. if (offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
  12964. var originLeft = offsetTracker.computeLeft();
  12965. var originTop = offsetTracker.computeTop();
  12966. var positionLeft = offsetLeft - originLeft;
  12967. var positionTop = offsetTop - originTop;
  12968. var origRect = offsetTracker.origRect;
  12969. var width = origRect.right - origRect.left;
  12970. var height = origRect.bottom - origRect.top;
  12971. if (
  12972. // must be within the element's bounds
  12973. positionLeft >= 0 && positionLeft < width &&
  12974. positionTop >= 0 && positionTop < height) {
  12975. var hit = component.queryHit(positionLeft, positionTop, width, height);
  12976. if (hit &&
  12977. (
  12978. // make sure the hit is within activeRange, meaning it's not a deal cell
  12979. !component.props.dateProfile || // hack for DayTile
  12980. core.rangeContainsRange(component.props.dateProfile.activeRange, hit.dateSpan.range)) &&
  12981. (!bestHit || hit.layer > bestHit.layer)) {
  12982. // TODO: better way to re-orient rectangle
  12983. hit.rect.left += originLeft;
  12984. hit.rect.right += originLeft;
  12985. hit.rect.top += originTop;
  12986. hit.rect.bottom += originTop;
  12987. bestHit = hit;
  12988. }
  12989. }
  12990. }
  12991. }
  12992. return bestHit;
  12993. };
  12994. return HitDragging;
  12995. }());
  12996. function isHitsEqual(hit0, hit1) {
  12997. if (!hit0 && !hit1) {
  12998. return true;
  12999. }
  13000. if (Boolean(hit0) !== Boolean(hit1)) {
  13001. return false;
  13002. }
  13003. return core.isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
  13004. }
  13005. /*
  13006. Monitors when the user clicks on a specific date/time of a component.
  13007. A pointerdown+pointerup on the same "hit" constitutes a click.
  13008. */
  13009. var DateClicking = /** @class */ (function (_super) {
  13010. __extends(DateClicking, _super);
  13011. function DateClicking(settings) {
  13012. var _this = _super.call(this, settings) || this;
  13013. _this.handlePointerDown = function (ev) {
  13014. var dragging = _this.dragging;
  13015. // do this in pointerdown (not dragend) because DOM might be mutated by the time dragend is fired
  13016. dragging.setIgnoreMove(!_this.component.isValidDateDownEl(dragging.pointer.downEl));
  13017. };
  13018. // won't even fire if moving was ignored
  13019. _this.handleDragEnd = function (ev) {
  13020. var component = _this.component;
  13021. var pointer = _this.dragging.pointer;
  13022. if (!pointer.wasTouchScroll) {
  13023. var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
  13024. if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
  13025. component.calendar.triggerDateClick(initialHit.dateSpan, initialHit.dayEl, component.view, ev.origEvent);
  13026. }
  13027. }
  13028. };
  13029. var component = settings.component;
  13030. // we DO want to watch pointer moves because otherwise finalHit won't get populated
  13031. _this.dragging = new FeaturefulElementDragging(component.el);
  13032. _this.dragging.autoScroller.isEnabled = false;
  13033. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
  13034. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13035. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  13036. return _this;
  13037. }
  13038. DateClicking.prototype.destroy = function () {
  13039. this.dragging.destroy();
  13040. };
  13041. return DateClicking;
  13042. }(core.Interaction));
  13043. /*
  13044. Tracks when the user selects a portion of time of a component,
  13045. constituted by a drag over date cells, with a possible delay at the beginning of the drag.
  13046. */
  13047. var DateSelecting = /** @class */ (function (_super) {
  13048. __extends(DateSelecting, _super);
  13049. function DateSelecting(settings) {
  13050. var _this = _super.call(this, settings) || this;
  13051. _this.dragSelection = null;
  13052. _this.handlePointerDown = function (ev) {
  13053. var _a = _this, component = _a.component, dragging = _a.dragging;
  13054. var canSelect = component.opt('selectable') &&
  13055. component.isValidDateDownEl(ev.origEvent.target);
  13056. // don't bother to watch expensive moves if component won't do selection
  13057. dragging.setIgnoreMove(!canSelect);
  13058. // if touch, require user to hold down
  13059. dragging.delay = ev.isTouch ? getComponentTouchDelay(component) : null;
  13060. };
  13061. _this.handleDragStart = function (ev) {
  13062. _this.component.calendar.unselect(ev); // unselect previous selections
  13063. };
  13064. _this.handleHitUpdate = function (hit, isFinal) {
  13065. var calendar = _this.component.calendar;
  13066. var dragSelection = null;
  13067. var isInvalid = false;
  13068. if (hit) {
  13069. dragSelection = joinHitsIntoSelection(_this.hitDragging.initialHit, hit, calendar.pluginSystem.hooks.dateSelectionTransformers);
  13070. if (!dragSelection || !_this.component.isDateSelectionValid(dragSelection)) {
  13071. isInvalid = true;
  13072. dragSelection = null;
  13073. }
  13074. }
  13075. if (dragSelection) {
  13076. calendar.dispatch({ type: 'SELECT_DATES', selection: dragSelection });
  13077. }
  13078. else if (!isFinal) { // only unselect if moved away while dragging
  13079. calendar.dispatch({ type: 'UNSELECT_DATES' });
  13080. }
  13081. if (!isInvalid) {
  13082. core.enableCursor();
  13083. }
  13084. else {
  13085. core.disableCursor();
  13086. }
  13087. if (!isFinal) {
  13088. _this.dragSelection = dragSelection; // only clear if moved away from all hits while dragging
  13089. }
  13090. };
  13091. _this.handlePointerUp = function (pev) {
  13092. if (_this.dragSelection) {
  13093. // selection is already rendered, so just need to report selection
  13094. _this.component.calendar.triggerDateSelect(_this.dragSelection, pev);
  13095. _this.dragSelection = null;
  13096. }
  13097. };
  13098. var component = settings.component;
  13099. var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
  13100. dragging.touchScrollAllowed = false;
  13101. dragging.minDistance = component.opt('selectMinDistance') || 0;
  13102. dragging.autoScroller.isEnabled = component.opt('dragScroll');
  13103. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
  13104. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13105. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  13106. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  13107. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  13108. return _this;
  13109. }
  13110. DateSelecting.prototype.destroy = function () {
  13111. this.dragging.destroy();
  13112. };
  13113. return DateSelecting;
  13114. }(core.Interaction));
  13115. function getComponentTouchDelay(component) {
  13116. var delay = component.opt('selectLongPressDelay');
  13117. if (delay == null) {
  13118. delay = component.opt('longPressDelay');
  13119. }
  13120. return delay;
  13121. }
  13122. function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
  13123. var dateSpan0 = hit0.dateSpan;
  13124. var dateSpan1 = hit1.dateSpan;
  13125. var ms = [
  13126. dateSpan0.range.start,
  13127. dateSpan0.range.end,
  13128. dateSpan1.range.start,
  13129. dateSpan1.range.end
  13130. ];
  13131. ms.sort(core.compareNumbers);
  13132. var props = {};
  13133. for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
  13134. var transformer = dateSelectionTransformers_1[_i];
  13135. var res = transformer(hit0, hit1);
  13136. if (res === false) {
  13137. return null;
  13138. }
  13139. else if (res) {
  13140. __assign(props, res);
  13141. }
  13142. }
  13143. props.range = { start: ms[0], end: ms[3] };
  13144. props.allDay = dateSpan0.allDay;
  13145. return props;
  13146. }
  13147. var EventDragging = /** @class */ (function (_super) {
  13148. __extends(EventDragging, _super);
  13149. function EventDragging(settings) {
  13150. var _this = _super.call(this, settings) || this;
  13151. // internal state
  13152. _this.subjectSeg = null; // the seg being selected/dragged
  13153. _this.isDragging = false;
  13154. _this.eventRange = null;
  13155. _this.relevantEvents = null; // the events being dragged
  13156. _this.receivingCalendar = null;
  13157. _this.validMutation = null;
  13158. _this.mutatedRelevantEvents = null;
  13159. _this.handlePointerDown = function (ev) {
  13160. var origTarget = ev.origEvent.target;
  13161. var _a = _this, component = _a.component, dragging = _a.dragging;
  13162. var mirror = dragging.mirror;
  13163. var initialCalendar = component.calendar;
  13164. var subjectSeg = _this.subjectSeg = core.getElSeg(ev.subjectEl);
  13165. var eventRange = _this.eventRange = subjectSeg.eventRange;
  13166. var eventInstanceId = eventRange.instance.instanceId;
  13167. _this.relevantEvents = core.getRelevantEvents(initialCalendar.state.eventStore, eventInstanceId);
  13168. dragging.minDistance = ev.isTouch ? 0 : component.opt('eventDragMinDistance');
  13169. dragging.delay =
  13170. // only do a touch delay if touch and this event hasn't been selected yet
  13171. (ev.isTouch && eventInstanceId !== component.props.eventSelection) ?
  13172. getComponentTouchDelay$1(component) :
  13173. null;
  13174. mirror.parentNode = initialCalendar.el;
  13175. mirror.revertDuration = component.opt('dragRevertDuration');
  13176. var isValid = component.isValidSegDownEl(origTarget) &&
  13177. !core.elementClosest(origTarget, '.fc-resizer'); // NOT on a resizer
  13178. dragging.setIgnoreMove(!isValid);
  13179. // disable dragging for elements that are resizable (ie, selectable)
  13180. // but are not draggable
  13181. _this.isDragging = isValid &&
  13182. ev.subjectEl.classList.contains('fc-draggable');
  13183. };
  13184. _this.handleDragStart = function (ev) {
  13185. var initialCalendar = _this.component.calendar;
  13186. var eventRange = _this.eventRange;
  13187. var eventInstanceId = eventRange.instance.instanceId;
  13188. if (ev.isTouch) {
  13189. // need to select a different event?
  13190. if (eventInstanceId !== _this.component.props.eventSelection) {
  13191. initialCalendar.dispatch({ type: 'SELECT_EVENT', eventInstanceId: eventInstanceId });
  13192. }
  13193. }
  13194. else {
  13195. // if now using mouse, but was previous touch interaction, clear selected event
  13196. initialCalendar.dispatch({ type: 'UNSELECT_EVENT' });
  13197. }
  13198. if (_this.isDragging) {
  13199. initialCalendar.unselect(ev); // unselect *date* selection
  13200. initialCalendar.publiclyTrigger('eventDragStart', [
  13201. {
  13202. el: _this.subjectSeg.el,
  13203. event: new core.EventApi(initialCalendar, eventRange.def, eventRange.instance),
  13204. jsEvent: ev.origEvent,
  13205. view: _this.component.view
  13206. }
  13207. ]);
  13208. }
  13209. };
  13210. _this.handleHitUpdate = function (hit, isFinal) {
  13211. if (!_this.isDragging) {
  13212. return;
  13213. }
  13214. var relevantEvents = _this.relevantEvents;
  13215. var initialHit = _this.hitDragging.initialHit;
  13216. var initialCalendar = _this.component.calendar;
  13217. // states based on new hit
  13218. var receivingCalendar = null;
  13219. var mutation = null;
  13220. var mutatedRelevantEvents = null;
  13221. var isInvalid = false;
  13222. var interaction = {
  13223. affectedEvents: relevantEvents,
  13224. mutatedEvents: core.createEmptyEventStore(),
  13225. isEvent: true,
  13226. origSeg: _this.subjectSeg
  13227. };
  13228. if (hit) {
  13229. var receivingComponent = hit.component;
  13230. receivingCalendar = receivingComponent.calendar;
  13231. if (initialCalendar === receivingCalendar ||
  13232. receivingComponent.opt('editable') && receivingComponent.opt('droppable')) {
  13233. mutation = computeEventMutation(initialHit, hit, receivingCalendar.pluginSystem.hooks.eventDragMutationMassagers);
  13234. if (mutation) {
  13235. mutatedRelevantEvents = core.applyMutationToEventStore(relevantEvents, receivingCalendar.eventUiBases, mutation, receivingCalendar);
  13236. interaction.mutatedEvents = mutatedRelevantEvents;
  13237. if (!receivingComponent.isInteractionValid(interaction)) {
  13238. isInvalid = true;
  13239. mutation = null;
  13240. mutatedRelevantEvents = null;
  13241. interaction.mutatedEvents = core.createEmptyEventStore();
  13242. }
  13243. }
  13244. }
  13245. else {
  13246. receivingCalendar = null;
  13247. }
  13248. }
  13249. _this.displayDrag(receivingCalendar, interaction);
  13250. if (!isInvalid) {
  13251. core.enableCursor();
  13252. }
  13253. else {
  13254. core.disableCursor();
  13255. }
  13256. if (!isFinal) {
  13257. if (initialCalendar === receivingCalendar && // TODO: write test for this
  13258. isHitsEqual(initialHit, hit)) {
  13259. mutation = null;
  13260. }
  13261. _this.dragging.setMirrorNeedsRevert(!mutation);
  13262. // render the mirror if no already-rendered mirror
  13263. // TODO: wish we could somehow wait for dispatch to guarantee render
  13264. _this.dragging.setMirrorIsVisible(!hit || !document.querySelector('.fc-mirror'));
  13265. // assign states based on new hit
  13266. _this.receivingCalendar = receivingCalendar;
  13267. _this.validMutation = mutation;
  13268. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  13269. }
  13270. };
  13271. _this.handlePointerUp = function () {
  13272. if (!_this.isDragging) {
  13273. _this.cleanup(); // because handleDragEnd won't fire
  13274. }
  13275. };
  13276. _this.handleDragEnd = function (ev) {
  13277. if (_this.isDragging) {
  13278. var initialCalendar_1 = _this.component.calendar;
  13279. var initialView = _this.component.view;
  13280. var _a = _this, receivingCalendar = _a.receivingCalendar, validMutation = _a.validMutation;
  13281. var eventDef = _this.eventRange.def;
  13282. var eventInstance = _this.eventRange.instance;
  13283. var eventApi = new core.EventApi(initialCalendar_1, eventDef, eventInstance);
  13284. var relevantEvents_1 = _this.relevantEvents;
  13285. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  13286. var finalHit = _this.hitDragging.finalHit;
  13287. _this.clearDrag(); // must happen after revert animation
  13288. initialCalendar_1.publiclyTrigger('eventDragStop', [
  13289. {
  13290. el: _this.subjectSeg.el,
  13291. event: eventApi,
  13292. jsEvent: ev.origEvent,
  13293. view: initialView
  13294. }
  13295. ]);
  13296. if (validMutation) {
  13297. // dropped within same calendar
  13298. if (receivingCalendar === initialCalendar_1) {
  13299. initialCalendar_1.dispatch({
  13300. type: 'MERGE_EVENTS',
  13301. eventStore: mutatedRelevantEvents
  13302. });
  13303. var transformed = {};
  13304. for (var _i = 0, _b = initialCalendar_1.pluginSystem.hooks.eventDropTransformers; _i < _b.length; _i++) {
  13305. var transformer = _b[_i];
  13306. __assign(transformed, transformer(validMutation, initialCalendar_1));
  13307. }
  13308. var eventDropArg = __assign({}, transformed, { el: ev.subjectEl, delta: validMutation.datesDelta, oldEvent: eventApi, event: new core.EventApi(// the data AFTER the mutation
  13309. initialCalendar_1, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null), revert: function () {
  13310. initialCalendar_1.dispatch({
  13311. type: 'MERGE_EVENTS',
  13312. eventStore: relevantEvents_1
  13313. });
  13314. }, jsEvent: ev.origEvent, view: initialView });
  13315. initialCalendar_1.publiclyTrigger('eventDrop', [eventDropArg]);
  13316. // dropped in different calendar
  13317. }
  13318. else if (receivingCalendar) {
  13319. initialCalendar_1.publiclyTrigger('eventLeave', [
  13320. {
  13321. draggedEl: ev.subjectEl,
  13322. event: eventApi,
  13323. view: initialView
  13324. }
  13325. ]);
  13326. initialCalendar_1.dispatch({
  13327. type: 'REMOVE_EVENT_INSTANCES',
  13328. instances: _this.mutatedRelevantEvents.instances
  13329. });
  13330. receivingCalendar.dispatch({
  13331. type: 'MERGE_EVENTS',
  13332. eventStore: _this.mutatedRelevantEvents
  13333. });
  13334. if (ev.isTouch) {
  13335. receivingCalendar.dispatch({
  13336. type: 'SELECT_EVENT',
  13337. eventInstanceId: eventInstance.instanceId
  13338. });
  13339. }
  13340. var dropArg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.component // should this be finalHit.component.view? See #4644
  13341. });
  13342. receivingCalendar.publiclyTrigger('drop', [dropArg]);
  13343. receivingCalendar.publiclyTrigger('eventReceive', [
  13344. {
  13345. draggedEl: ev.subjectEl,
  13346. event: new core.EventApi(// the data AFTER the mutation
  13347. receivingCalendar, mutatedRelevantEvents.defs[eventDef.defId], mutatedRelevantEvents.instances[eventInstance.instanceId]),
  13348. view: finalHit.component // should this be finalHit.component.view? See #4644
  13349. }
  13350. ]);
  13351. }
  13352. }
  13353. else {
  13354. initialCalendar_1.publiclyTrigger('_noEventDrop');
  13355. }
  13356. }
  13357. _this.cleanup();
  13358. };
  13359. var component = _this.component;
  13360. var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
  13361. dragging.pointer.selector = EventDragging.SELECTOR;
  13362. dragging.touchScrollAllowed = false;
  13363. dragging.autoScroller.isEnabled = component.opt('dragScroll');
  13364. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsStore);
  13365. hitDragging.useSubjectCenter = settings.useEventCenter;
  13366. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13367. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  13368. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  13369. hitDragging.emitter.on('pointerup', _this.handlePointerUp);
  13370. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  13371. return _this;
  13372. }
  13373. EventDragging.prototype.destroy = function () {
  13374. this.dragging.destroy();
  13375. };
  13376. // render a drag state on the next receivingCalendar
  13377. EventDragging.prototype.displayDrag = function (nextCalendar, state) {
  13378. var initialCalendar = this.component.calendar;
  13379. var prevCalendar = this.receivingCalendar;
  13380. // does the previous calendar need to be cleared?
  13381. if (prevCalendar && prevCalendar !== nextCalendar) {
  13382. // does the initial calendar need to be cleared?
  13383. // if so, don't clear all the way. we still need to to hide the affectedEvents
  13384. if (prevCalendar === initialCalendar) {
  13385. prevCalendar.dispatch({
  13386. type: 'SET_EVENT_DRAG',
  13387. state: {
  13388. affectedEvents: state.affectedEvents,
  13389. mutatedEvents: core.createEmptyEventStore(),
  13390. isEvent: true,
  13391. origSeg: state.origSeg
  13392. }
  13393. });
  13394. // completely clear the old calendar if it wasn't the initial
  13395. }
  13396. else {
  13397. prevCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13398. }
  13399. }
  13400. if (nextCalendar) {
  13401. nextCalendar.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  13402. }
  13403. };
  13404. EventDragging.prototype.clearDrag = function () {
  13405. var initialCalendar = this.component.calendar;
  13406. var receivingCalendar = this.receivingCalendar;
  13407. if (receivingCalendar) {
  13408. receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13409. }
  13410. // the initial calendar might have an dummy drag state from displayDrag
  13411. if (initialCalendar !== receivingCalendar) {
  13412. initialCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13413. }
  13414. };
  13415. EventDragging.prototype.cleanup = function () {
  13416. this.subjectSeg = null;
  13417. this.isDragging = false;
  13418. this.eventRange = null;
  13419. this.relevantEvents = null;
  13420. this.receivingCalendar = null;
  13421. this.validMutation = null;
  13422. this.mutatedRelevantEvents = null;
  13423. };
  13424. EventDragging.SELECTOR = '.fc-draggable, .fc-resizable'; // TODO: test this in IE11
  13425. return EventDragging;
  13426. }(core.Interaction));
  13427. function computeEventMutation(hit0, hit1, massagers) {
  13428. var dateSpan0 = hit0.dateSpan;
  13429. var dateSpan1 = hit1.dateSpan;
  13430. var date0 = dateSpan0.range.start;
  13431. var date1 = dateSpan1.range.start;
  13432. var standardProps = {};
  13433. if (dateSpan0.allDay !== dateSpan1.allDay) {
  13434. standardProps.allDay = dateSpan1.allDay;
  13435. standardProps.hasEnd = hit1.component.opt('allDayMaintainDuration');
  13436. if (dateSpan1.allDay) {
  13437. // means date1 is already start-of-day,
  13438. // but date0 needs to be converted
  13439. date0 = core.startOfDay(date0);
  13440. }
  13441. }
  13442. var delta = core.diffDates(date0, date1, hit0.component.dateEnv, hit0.component === hit1.component ?
  13443. hit0.component.largeUnit :
  13444. null);
  13445. if (delta.milliseconds) { // has hours/minutes/seconds
  13446. standardProps.allDay = false;
  13447. }
  13448. var mutation = {
  13449. datesDelta: delta,
  13450. standardProps: standardProps
  13451. };
  13452. for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
  13453. var massager = massagers_1[_i];
  13454. massager(mutation, hit0, hit1);
  13455. }
  13456. return mutation;
  13457. }
  13458. function getComponentTouchDelay$1(component) {
  13459. var delay = component.opt('eventLongPressDelay');
  13460. if (delay == null) {
  13461. delay = component.opt('longPressDelay');
  13462. }
  13463. return delay;
  13464. }
  13465. var EventDragging$1 = /** @class */ (function (_super) {
  13466. __extends(EventDragging, _super);
  13467. function EventDragging(settings) {
  13468. var _this = _super.call(this, settings) || this;
  13469. // internal state
  13470. _this.draggingSeg = null; // TODO: rename to resizingSeg? subjectSeg?
  13471. _this.eventRange = null;
  13472. _this.relevantEvents = null;
  13473. _this.validMutation = null;
  13474. _this.mutatedRelevantEvents = null;
  13475. _this.handlePointerDown = function (ev) {
  13476. var component = _this.component;
  13477. var seg = _this.querySeg(ev);
  13478. var eventRange = _this.eventRange = seg.eventRange;
  13479. _this.dragging.minDistance = component.opt('eventDragMinDistance');
  13480. // if touch, need to be working with a selected event
  13481. _this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) ||
  13482. (ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId));
  13483. };
  13484. _this.handleDragStart = function (ev) {
  13485. var calendar = _this.component.calendar;
  13486. var eventRange = _this.eventRange;
  13487. _this.relevantEvents = core.getRelevantEvents(calendar.state.eventStore, _this.eventRange.instance.instanceId);
  13488. _this.draggingSeg = _this.querySeg(ev);
  13489. calendar.unselect();
  13490. calendar.publiclyTrigger('eventResizeStart', [
  13491. {
  13492. el: _this.draggingSeg.el,
  13493. event: new core.EventApi(calendar, eventRange.def, eventRange.instance),
  13494. jsEvent: ev.origEvent,
  13495. view: _this.component.view
  13496. }
  13497. ]);
  13498. };
  13499. _this.handleHitUpdate = function (hit, isFinal, ev) {
  13500. var calendar = _this.component.calendar;
  13501. var relevantEvents = _this.relevantEvents;
  13502. var initialHit = _this.hitDragging.initialHit;
  13503. var eventInstance = _this.eventRange.instance;
  13504. var mutation = null;
  13505. var mutatedRelevantEvents = null;
  13506. var isInvalid = false;
  13507. var interaction = {
  13508. affectedEvents: relevantEvents,
  13509. mutatedEvents: core.createEmptyEventStore(),
  13510. isEvent: true,
  13511. origSeg: _this.draggingSeg
  13512. };
  13513. if (hit) {
  13514. mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains('fc-start-resizer'), eventInstance.range, calendar.pluginSystem.hooks.eventResizeJoinTransforms);
  13515. }
  13516. if (mutation) {
  13517. mutatedRelevantEvents = core.applyMutationToEventStore(relevantEvents, calendar.eventUiBases, mutation, calendar);
  13518. interaction.mutatedEvents = mutatedRelevantEvents;
  13519. if (!_this.component.isInteractionValid(interaction)) {
  13520. isInvalid = true;
  13521. mutation = null;
  13522. mutatedRelevantEvents = null;
  13523. interaction.mutatedEvents = null;
  13524. }
  13525. }
  13526. if (mutatedRelevantEvents) {
  13527. calendar.dispatch({
  13528. type: 'SET_EVENT_RESIZE',
  13529. state: interaction
  13530. });
  13531. }
  13532. else {
  13533. calendar.dispatch({ type: 'UNSET_EVENT_RESIZE' });
  13534. }
  13535. if (!isInvalid) {
  13536. core.enableCursor();
  13537. }
  13538. else {
  13539. core.disableCursor();
  13540. }
  13541. if (!isFinal) {
  13542. if (mutation && isHitsEqual(initialHit, hit)) {
  13543. mutation = null;
  13544. }
  13545. _this.validMutation = mutation;
  13546. _this.mutatedRelevantEvents = mutatedRelevantEvents;
  13547. }
  13548. };
  13549. _this.handleDragEnd = function (ev) {
  13550. var calendar = _this.component.calendar;
  13551. var view = _this.component.view;
  13552. var eventDef = _this.eventRange.def;
  13553. var eventInstance = _this.eventRange.instance;
  13554. var eventApi = new core.EventApi(calendar, eventDef, eventInstance);
  13555. var relevantEvents = _this.relevantEvents;
  13556. var mutatedRelevantEvents = _this.mutatedRelevantEvents;
  13557. calendar.publiclyTrigger('eventResizeStop', [
  13558. {
  13559. el: _this.draggingSeg.el,
  13560. event: eventApi,
  13561. jsEvent: ev.origEvent,
  13562. view: view
  13563. }
  13564. ]);
  13565. if (_this.validMutation) {
  13566. calendar.dispatch({
  13567. type: 'MERGE_EVENTS',
  13568. eventStore: mutatedRelevantEvents
  13569. });
  13570. calendar.publiclyTrigger('eventResize', [
  13571. {
  13572. el: _this.draggingSeg.el,
  13573. startDelta: _this.validMutation.startDelta || core.createDuration(0),
  13574. endDelta: _this.validMutation.endDelta || core.createDuration(0),
  13575. prevEvent: eventApi,
  13576. event: new core.EventApi(// the data AFTER the mutation
  13577. calendar, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null),
  13578. revert: function () {
  13579. calendar.dispatch({
  13580. type: 'MERGE_EVENTS',
  13581. eventStore: relevantEvents
  13582. });
  13583. },
  13584. jsEvent: ev.origEvent,
  13585. view: view
  13586. }
  13587. ]);
  13588. }
  13589. else {
  13590. calendar.publiclyTrigger('_noEventResize');
  13591. }
  13592. // reset all internal state
  13593. _this.draggingSeg = null;
  13594. _this.relevantEvents = null;
  13595. _this.validMutation = null;
  13596. // okay to keep eventInstance around. useful to set it in handlePointerDown
  13597. };
  13598. var component = settings.component;
  13599. var dragging = _this.dragging = new FeaturefulElementDragging(component.el);
  13600. dragging.pointer.selector = '.fc-resizer';
  13601. dragging.touchScrollAllowed = false;
  13602. dragging.autoScroller.isEnabled = component.opt('dragScroll');
  13603. var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, core.interactionSettingsToStore(settings));
  13604. hitDragging.emitter.on('pointerdown', _this.handlePointerDown);
  13605. hitDragging.emitter.on('dragstart', _this.handleDragStart);
  13606. hitDragging.emitter.on('hitupdate', _this.handleHitUpdate);
  13607. hitDragging.emitter.on('dragend', _this.handleDragEnd);
  13608. return _this;
  13609. }
  13610. EventDragging.prototype.destroy = function () {
  13611. this.dragging.destroy();
  13612. };
  13613. EventDragging.prototype.querySeg = function (ev) {
  13614. return core.getElSeg(core.elementClosest(ev.subjectEl, this.component.fgSegSelector));
  13615. };
  13616. return EventDragging;
  13617. }(core.Interaction));
  13618. function computeMutation(hit0, hit1, isFromStart, instanceRange, transforms) {
  13619. var dateEnv = hit0.component.dateEnv;
  13620. var date0 = hit0.dateSpan.range.start;
  13621. var date1 = hit1.dateSpan.range.start;
  13622. var delta = core.diffDates(date0, date1, dateEnv, hit0.component.largeUnit);
  13623. var props = {};
  13624. for (var _i = 0, transforms_1 = transforms; _i < transforms_1.length; _i++) {
  13625. var transform = transforms_1[_i];
  13626. var res = transform(hit0, hit1);
  13627. if (res === false) {
  13628. return null;
  13629. }
  13630. else if (res) {
  13631. __assign(props, res);
  13632. }
  13633. }
  13634. if (isFromStart) {
  13635. if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
  13636. props.startDelta = delta;
  13637. return props;
  13638. }
  13639. }
  13640. else {
  13641. if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
  13642. props.endDelta = delta;
  13643. return props;
  13644. }
  13645. }
  13646. return null;
  13647. }
  13648. var UnselectAuto = /** @class */ (function () {
  13649. function UnselectAuto(calendar) {
  13650. var _this = this;
  13651. this.isRecentPointerDateSelect = false; // wish we could use a selector to detect date selection, but uses hit system
  13652. this.onSelect = function (selectInfo) {
  13653. if (selectInfo.jsEvent) {
  13654. _this.isRecentPointerDateSelect = true;
  13655. }
  13656. };
  13657. this.onDocumentPointerUp = function (pev) {
  13658. var _a = _this, calendar = _a.calendar, documentPointer = _a.documentPointer;
  13659. var state = calendar.state;
  13660. // touch-scrolling should never unfocus any type of selection
  13661. if (!documentPointer.wasTouchScroll) {
  13662. if (state.dateSelection && // an existing date selection?
  13663. !_this.isRecentPointerDateSelect // a new pointer-initiated date selection since last onDocumentPointerUp?
  13664. ) {
  13665. var unselectAuto = calendar.viewOpt('unselectAuto');
  13666. var unselectCancel = calendar.viewOpt('unselectCancel');
  13667. if (unselectAuto && (!unselectAuto || !core.elementClosest(documentPointer.downEl, unselectCancel))) {
  13668. calendar.unselect(pev);
  13669. }
  13670. }
  13671. if (state.eventSelection && // an existing event selected?
  13672. !core.elementClosest(documentPointer.downEl, EventDragging.SELECTOR) // interaction DIDN'T start on an event
  13673. ) {
  13674. calendar.dispatch({ type: 'UNSELECT_EVENT' });
  13675. }
  13676. }
  13677. _this.isRecentPointerDateSelect = false;
  13678. };
  13679. this.calendar = calendar;
  13680. var documentPointer = this.documentPointer = new PointerDragging(document);
  13681. documentPointer.shouldIgnoreMove = true;
  13682. documentPointer.shouldWatchScroll = false;
  13683. documentPointer.emitter.on('pointerup', this.onDocumentPointerUp);
  13684. /*
  13685. TODO: better way to know about whether there was a selection with the pointer
  13686. */
  13687. calendar.on('select', this.onSelect);
  13688. }
  13689. UnselectAuto.prototype.destroy = function () {
  13690. this.calendar.off('select', this.onSelect);
  13691. this.documentPointer.destroy();
  13692. };
  13693. return UnselectAuto;
  13694. }());
  13695. /*
  13696. Given an already instantiated draggable object for one-or-more elements,
  13697. Interprets any dragging as an attempt to drag an events that lives outside
  13698. of a calendar onto a calendar.
  13699. */
  13700. var ExternalElementDragging = /** @class */ (function () {
  13701. function ExternalElementDragging(dragging, suppliedDragMeta) {
  13702. var _this = this;
  13703. this.receivingCalendar = null;
  13704. this.droppableEvent = null; // will exist for all drags, even if create:false
  13705. this.suppliedDragMeta = null;
  13706. this.dragMeta = null;
  13707. this.handleDragStart = function (ev) {
  13708. _this.dragMeta = _this.buildDragMeta(ev.subjectEl);
  13709. };
  13710. this.handleHitUpdate = function (hit, isFinal, ev) {
  13711. var dragging = _this.hitDragging.dragging;
  13712. var receivingCalendar = null;
  13713. var droppableEvent = null;
  13714. var isInvalid = false;
  13715. var interaction = {
  13716. affectedEvents: core.createEmptyEventStore(),
  13717. mutatedEvents: core.createEmptyEventStore(),
  13718. isEvent: _this.dragMeta.create,
  13719. origSeg: null
  13720. };
  13721. if (hit) {
  13722. receivingCalendar = hit.component.calendar;
  13723. if (_this.canDropElOnCalendar(ev.subjectEl, receivingCalendar)) {
  13724. droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingCalendar);
  13725. interaction.mutatedEvents = core.eventTupleToStore(droppableEvent);
  13726. isInvalid = !core.isInteractionValid(interaction, receivingCalendar);
  13727. if (isInvalid) {
  13728. interaction.mutatedEvents = core.createEmptyEventStore();
  13729. droppableEvent = null;
  13730. }
  13731. }
  13732. }
  13733. _this.displayDrag(receivingCalendar, interaction);
  13734. // show mirror if no already-rendered mirror element OR if we are shutting down the mirror (?)
  13735. // TODO: wish we could somehow wait for dispatch to guarantee render
  13736. dragging.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector('.fc-mirror'));
  13737. if (!isInvalid) {
  13738. core.enableCursor();
  13739. }
  13740. else {
  13741. core.disableCursor();
  13742. }
  13743. if (!isFinal) {
  13744. dragging.setMirrorNeedsRevert(!droppableEvent);
  13745. _this.receivingCalendar = receivingCalendar;
  13746. _this.droppableEvent = droppableEvent;
  13747. }
  13748. };
  13749. this.handleDragEnd = function (pev) {
  13750. var _a = _this, receivingCalendar = _a.receivingCalendar, droppableEvent = _a.droppableEvent;
  13751. _this.clearDrag();
  13752. if (receivingCalendar && droppableEvent) {
  13753. var finalHit = _this.hitDragging.finalHit;
  13754. var finalView = finalHit.component.view;
  13755. var dragMeta = _this.dragMeta;
  13756. var arg = __assign({}, receivingCalendar.buildDatePointApi(finalHit.dateSpan), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView });
  13757. receivingCalendar.publiclyTrigger('drop', [arg]);
  13758. if (dragMeta.create) {
  13759. receivingCalendar.dispatch({
  13760. type: 'MERGE_EVENTS',
  13761. eventStore: core.eventTupleToStore(droppableEvent)
  13762. });
  13763. if (pev.isTouch) {
  13764. receivingCalendar.dispatch({
  13765. type: 'SELECT_EVENT',
  13766. eventInstanceId: droppableEvent.instance.instanceId
  13767. });
  13768. }
  13769. // signal that an external event landed
  13770. receivingCalendar.publiclyTrigger('eventReceive', [
  13771. {
  13772. draggedEl: pev.subjectEl,
  13773. event: new core.EventApi(receivingCalendar, droppableEvent.def, droppableEvent.instance),
  13774. view: finalView
  13775. }
  13776. ]);
  13777. }
  13778. }
  13779. _this.receivingCalendar = null;
  13780. _this.droppableEvent = null;
  13781. };
  13782. var hitDragging = this.hitDragging = new HitDragging(dragging, core.interactionSettingsStore);
  13783. hitDragging.requireInitial = false; // will start outside of a component
  13784. hitDragging.emitter.on('dragstart', this.handleDragStart);
  13785. hitDragging.emitter.on('hitupdate', this.handleHitUpdate);
  13786. hitDragging.emitter.on('dragend', this.handleDragEnd);
  13787. this.suppliedDragMeta = suppliedDragMeta;
  13788. }
  13789. ExternalElementDragging.prototype.buildDragMeta = function (subjectEl) {
  13790. if (typeof this.suppliedDragMeta === 'object') {
  13791. return core.parseDragMeta(this.suppliedDragMeta);
  13792. }
  13793. else if (typeof this.suppliedDragMeta === 'function') {
  13794. return core.parseDragMeta(this.suppliedDragMeta(subjectEl));
  13795. }
  13796. else {
  13797. return getDragMetaFromEl(subjectEl);
  13798. }
  13799. };
  13800. ExternalElementDragging.prototype.displayDrag = function (nextCalendar, state) {
  13801. var prevCalendar = this.receivingCalendar;
  13802. if (prevCalendar && prevCalendar !== nextCalendar) {
  13803. prevCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13804. }
  13805. if (nextCalendar) {
  13806. nextCalendar.dispatch({ type: 'SET_EVENT_DRAG', state: state });
  13807. }
  13808. };
  13809. ExternalElementDragging.prototype.clearDrag = function () {
  13810. if (this.receivingCalendar) {
  13811. this.receivingCalendar.dispatch({ type: 'UNSET_EVENT_DRAG' });
  13812. }
  13813. };
  13814. ExternalElementDragging.prototype.canDropElOnCalendar = function (el, receivingCalendar) {
  13815. var dropAccept = receivingCalendar.opt('dropAccept');
  13816. if (typeof dropAccept === 'function') {
  13817. return dropAccept(el);
  13818. }
  13819. else if (typeof dropAccept === 'string' && dropAccept) {
  13820. return Boolean(core.elementMatches(el, dropAccept));
  13821. }
  13822. return true;
  13823. };
  13824. return ExternalElementDragging;
  13825. }());
  13826. // Utils for computing event store from the DragMeta
  13827. // ----------------------------------------------------------------------------------------------------
  13828. function computeEventForDateSpan(dateSpan, dragMeta, calendar) {
  13829. var defProps = __assign({}, dragMeta.leftoverProps);
  13830. for (var _i = 0, _a = calendar.pluginSystem.hooks.externalDefTransforms; _i < _a.length; _i++) {
  13831. var transform = _a[_i];
  13832. __assign(defProps, transform(dateSpan, dragMeta));
  13833. }
  13834. var def = core.parseEventDef(defProps, dragMeta.sourceId, dateSpan.allDay, calendar.opt('forceEventDuration') || Boolean(dragMeta.duration), // hasEnd
  13835. calendar);
  13836. var start = dateSpan.range.start;
  13837. // only rely on time info if drop zone is all-day,
  13838. // otherwise, we already know the time
  13839. if (dateSpan.allDay && dragMeta.startTime) {
  13840. start = calendar.dateEnv.add(start, dragMeta.startTime);
  13841. }
  13842. var end = dragMeta.duration ?
  13843. calendar.dateEnv.add(start, dragMeta.duration) :
  13844. calendar.getDefaultEventEnd(dateSpan.allDay, start);
  13845. var instance = core.createEventInstance(def.defId, { start: start, end: end });
  13846. return { def: def, instance: instance };
  13847. }
  13848. // Utils for extracting data from element
  13849. // ----------------------------------------------------------------------------------------------------
  13850. function getDragMetaFromEl(el) {
  13851. var str = getEmbeddedElData(el, 'event');
  13852. var obj = str ?
  13853. JSON.parse(str) :
  13854. { create: false }; // if no embedded data, assume no event creation
  13855. return core.parseDragMeta(obj);
  13856. }
  13857. core.config.dataAttrPrefix = '';
  13858. function getEmbeddedElData(el, name) {
  13859. var prefix = core.config.dataAttrPrefix;
  13860. var prefixedName = (prefix ? prefix + '-' : '') + name;
  13861. return el.getAttribute('data-' + prefixedName) || '';
  13862. }
  13863. /*
  13864. Makes an element (that is *external* to any calendar) draggable.
  13865. Can pass in data that determines how an event will be created when dropped onto a calendar.
  13866. Leverages FullCalendar's internal drag-n-drop functionality WITHOUT a third-party drag system.
  13867. */
  13868. var ExternalDraggable = /** @class */ (function () {
  13869. function ExternalDraggable(el, settings) {
  13870. var _this = this;
  13871. if (settings === void 0) { settings = {}; }
  13872. this.handlePointerDown = function (ev) {
  13873. var dragging = _this.dragging;
  13874. var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
  13875. dragging.minDistance =
  13876. minDistance != null ?
  13877. minDistance :
  13878. (ev.isTouch ? 0 : core.globalDefaults.eventDragMinDistance);
  13879. dragging.delay =
  13880. ev.isTouch ? // TODO: eventually read eventLongPressDelay instead vvv
  13881. (longPressDelay != null ? longPressDelay : core.globalDefaults.longPressDelay) :
  13882. 0;
  13883. };
  13884. this.handleDragStart = function (ev) {
  13885. if (ev.isTouch &&
  13886. _this.dragging.delay &&
  13887. ev.subjectEl.classList.contains('fc-event')) {
  13888. _this.dragging.mirror.getMirrorEl().classList.add('fc-selected');
  13889. }
  13890. };
  13891. this.settings = settings;
  13892. var dragging = this.dragging = new FeaturefulElementDragging(el);
  13893. dragging.touchScrollAllowed = false;
  13894. if (settings.itemSelector != null) {
  13895. dragging.pointer.selector = settings.itemSelector;
  13896. }
  13897. if (settings.appendTo != null) {
  13898. dragging.mirror.parentNode = settings.appendTo; // TODO: write tests
  13899. }
  13900. dragging.emitter.on('pointerdown', this.handlePointerDown);
  13901. dragging.emitter.on('dragstart', this.handleDragStart);
  13902. new ExternalElementDragging(dragging, settings.eventData);
  13903. }
  13904. ExternalDraggable.prototype.destroy = function () {
  13905. this.dragging.destroy();
  13906. };
  13907. return ExternalDraggable;
  13908. }());
  13909. /*
  13910. Detects when a *THIRD-PARTY* drag-n-drop system interacts with elements.
  13911. The third-party system is responsible for drawing the visuals effects of the drag.
  13912. This class simply monitors for pointer movements and fires events.
  13913. It also has the ability to hide the moving element (the "mirror") during the drag.
  13914. */
  13915. var InferredElementDragging = /** @class */ (function (_super) {
  13916. __extends(InferredElementDragging, _super);
  13917. function InferredElementDragging(containerEl) {
  13918. var _this = _super.call(this, containerEl) || this;
  13919. _this.shouldIgnoreMove = false;
  13920. _this.mirrorSelector = '';
  13921. _this.currentMirrorEl = null;
  13922. _this.handlePointerDown = function (ev) {
  13923. _this.emitter.trigger('pointerdown', ev);
  13924. if (!_this.shouldIgnoreMove) {
  13925. // fire dragstart right away. does not support delay or min-distance
  13926. _this.emitter.trigger('dragstart', ev);
  13927. }
  13928. };
  13929. _this.handlePointerMove = function (ev) {
  13930. if (!_this.shouldIgnoreMove) {
  13931. _this.emitter.trigger('dragmove', ev);
  13932. }
  13933. };
  13934. _this.handlePointerUp = function (ev) {
  13935. _this.emitter.trigger('pointerup', ev);
  13936. if (!_this.shouldIgnoreMove) {
  13937. // fire dragend right away. does not support a revert animation
  13938. _this.emitter.trigger('dragend', ev);
  13939. }
  13940. };
  13941. var pointer = _this.pointer = new PointerDragging(containerEl);
  13942. pointer.emitter.on('pointerdown', _this.handlePointerDown);
  13943. pointer.emitter.on('pointermove', _this.handlePointerMove);
  13944. pointer.emitter.on('pointerup', _this.handlePointerUp);
  13945. return _this;
  13946. }
  13947. InferredElementDragging.prototype.destroy = function () {
  13948. this.pointer.destroy();
  13949. };
  13950. InferredElementDragging.prototype.setIgnoreMove = function (bool) {
  13951. this.shouldIgnoreMove = bool;
  13952. };
  13953. InferredElementDragging.prototype.setMirrorIsVisible = function (bool) {
  13954. if (bool) {
  13955. // restore a previously hidden element.
  13956. // use the reference in case the selector class has already been removed.
  13957. if (this.currentMirrorEl) {
  13958. this.currentMirrorEl.style.visibility = '';
  13959. this.currentMirrorEl = null;
  13960. }
  13961. }
  13962. else {
  13963. var mirrorEl = this.mirrorSelector ?
  13964. document.querySelector(this.mirrorSelector) :
  13965. null;
  13966. if (mirrorEl) {
  13967. this.currentMirrorEl = mirrorEl;
  13968. mirrorEl.style.visibility = 'hidden';
  13969. }
  13970. }
  13971. };
  13972. return InferredElementDragging;
  13973. }(core.ElementDragging));
  13974. /*
  13975. Bridges third-party drag-n-drop systems with FullCalendar.
  13976. Must be instantiated and destroyed by caller.
  13977. */
  13978. var ThirdPartyDraggable = /** @class */ (function () {
  13979. function ThirdPartyDraggable(containerOrSettings, settings) {
  13980. var containerEl = document;
  13981. if (
  13982. // wish we could just test instanceof EventTarget, but doesn't work in IE11
  13983. containerOrSettings === document ||
  13984. containerOrSettings instanceof Element) {
  13985. containerEl = containerOrSettings;
  13986. settings = settings || {};
  13987. }
  13988. else {
  13989. settings = (containerOrSettings || {});
  13990. }
  13991. var dragging = this.dragging = new InferredElementDragging(containerEl);
  13992. if (typeof settings.itemSelector === 'string') {
  13993. dragging.pointer.selector = settings.itemSelector;
  13994. }
  13995. else if (containerEl === document) {
  13996. dragging.pointer.selector = '[data-event]';
  13997. }
  13998. if (typeof settings.mirrorSelector === 'string') {
  13999. dragging.mirrorSelector = settings.mirrorSelector;
  14000. }
  14001. new ExternalElementDragging(dragging, settings.eventData);
  14002. }
  14003. ThirdPartyDraggable.prototype.destroy = function () {
  14004. this.dragging.destroy();
  14005. };
  14006. return ThirdPartyDraggable;
  14007. }());
  14008. var main = core.createPlugin({
  14009. componentInteractions: [DateClicking, DateSelecting, EventDragging, EventDragging$1],
  14010. calendarInteractions: [UnselectAuto],
  14011. elementDraggingImpl: FeaturefulElementDragging
  14012. });
  14013. exports.Draggable = ExternalDraggable;
  14014. exports.FeaturefulElementDragging = FeaturefulElementDragging;
  14015. exports.PointerDragging = PointerDragging;
  14016. exports.ThirdPartyDraggable = ThirdPartyDraggable;
  14017. exports.default = main;
  14018. Object.defineProperty(exports, '__esModule', { value: true });
  14019. }));
  14020. /*!
  14021. FullCalendar Bootstrap Plugin v4.1.0
  14022. Docs & License: https://fullcalendar.io/
  14023. (c) 2019 Adam Shaw
  14024. */
  14025. (function (global, factory) {
  14026. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fullcalendar/core')) :
  14027. typeof define === 'function' && define.amd ? define(['exports', '@fullcalendar/core'], factory) :
  14028. (global = global || self, factory(global.FullCalendarBootstrap = {}, global.FullCalendar));
  14029. }(this, function (exports, core) { 'use strict';
  14030. /*! *****************************************************************************
  14031. Copyright (c) Microsoft Corporation. All rights reserved.
  14032. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14033. this file except in compliance with the License. You may obtain a copy of the
  14034. License at http://www.apache.org/licenses/LICENSE-2.0
  14035. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14036. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  14037. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  14038. MERCHANTABLITY OR NON-INFRINGEMENT.
  14039. See the Apache Version 2.0 License for specific language governing permissions
  14040. and limitations under the License.
  14041. ***************************************************************************** */
  14042. /* global Reflect, Promise */
  14043. var extendStatics = function(d, b) {
  14044. extendStatics = Object.setPrototypeOf ||
  14045. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  14046. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14047. return extendStatics(d, b);
  14048. };
  14049. function __extends(d, b) {
  14050. extendStatics(d, b);
  14051. function __() { this.constructor = d; }
  14052. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14053. }
  14054. var BootstrapTheme = /** @class */ (function (_super) {
  14055. __extends(BootstrapTheme, _super);
  14056. function BootstrapTheme() {
  14057. return _super !== null && _super.apply(this, arguments) || this;
  14058. }
  14059. return BootstrapTheme;
  14060. }(core.Theme));
  14061. BootstrapTheme.prototype.classes = {
  14062. widget: 'fc-bootstrap',
  14063. tableGrid: 'table-bordered',
  14064. tableList: 'table',
  14065. tableListHeading: 'table-active',
  14066. buttonGroup: 'btn-group',
  14067. button: 'btn btn-default',
  14068. buttonActive: 'active',
  14069. today: 'alert alert-info',
  14070. popover: 'card card-primary',
  14071. popoverHeader: 'card-header',
  14072. popoverContent: 'card-body',
  14073. // day grid
  14074. // for left/right border color when border is inset from edges (all-day in timeGrid view)
  14075. // avoid `table` class b/c don't want margins/padding/structure. only border color.
  14076. headerRow: 'table-bordered',
  14077. dayRow: 'table-bordered',
  14078. // list view
  14079. listView: 'card card-primary'
  14080. };
  14081. BootstrapTheme.prototype.baseIconClass = 'fal';
  14082. BootstrapTheme.prototype.iconClasses = {
  14083. close: 'fa-times',
  14084. prev: 'fa-chevron-left',
  14085. next: 'fa-chevron-right',
  14086. prevYear: 'fa-angle-double-left',
  14087. nextYear: 'fa-angle-double-right'
  14088. };
  14089. BootstrapTheme.prototype.iconOverrideOption = 'bootstrapFontAwesome';
  14090. BootstrapTheme.prototype.iconOverrideCustomButtonOption = 'bootstrapFontAwesome';
  14091. BootstrapTheme.prototype.iconOverridePrefix = 'fa-';
  14092. var main = core.createPlugin({
  14093. themeClasses: {
  14094. bootstrap: BootstrapTheme
  14095. }
  14096. });
  14097. exports.BootstrapTheme = BootstrapTheme;
  14098. exports.default = main;
  14099. Object.defineProperty(exports, '__esModule', { value: true });
  14100. }));